xref: /trunk/main/avmedia/source/framework/soundhandler.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
19ea84ac5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39ea84ac5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49ea84ac5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59ea84ac5SAndrew Rist  * distributed with this work for additional information
69ea84ac5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79ea84ac5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89ea84ac5SAndrew Rist  * "License"); you may not use this file except in compliance
99ea84ac5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
119ea84ac5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
139ea84ac5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149ea84ac5SAndrew Rist  * software distributed under the License is distributed on an
159ea84ac5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169ea84ac5SAndrew Rist  * KIND, either express or implied.  See the License for the
179ea84ac5SAndrew Rist  * specific language governing permissions and limitations
189ea84ac5SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
209ea84ac5SAndrew Rist  *************************************************************/
219ea84ac5SAndrew Rist 
229ea84ac5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //  interface includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
32cdf0e10cSrcweir #include <com/sun/star/frame/XNotifyingDispatch.hpp>
33cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp>
34cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
35cdf0e10cSrcweir #include <com/sun/star/document/XExtendedFilterDetection.hpp>
36cdf0e10cSrcweir #include <com/sun/star/media/XPlayer.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
38cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
39*46880872SDamjan Jovanovic #include <com/sun/star/uno/XComponentContext.hpp>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
42cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir //_________________________________________________________________________________________________________________
45cdf0e10cSrcweir //  other includes
46cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <vcl/timer.hxx>
50cdf0e10cSrcweir #include <tools/link.hxx>
51cdf0e10cSrcweir #include <avmedia/mediawindow.hxx>
52cdf0e10cSrcweir #include <vos/mutex.hxx>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir namespace css = ::com::sun::star;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //_________________________________________________________________________________________________________________
57cdf0e10cSrcweir //  namespace
58cdf0e10cSrcweir //_________________________________________________________________________________________________________________
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace avmedia{
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63cdf0e10cSrcweir //  exported const
64cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //_________________________________________________________________________________________________________________
67cdf0e10cSrcweir //  exported definitions
68cdf0e10cSrcweir //_________________________________________________________________________________________________________________
69cdf0e10cSrcweir 
70cdf0e10cSrcweir struct ThreadHelpBase
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     public:
73cdf0e10cSrcweir         mutable ::vos::OMutex m_aLock;
74cdf0e10cSrcweir };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir /*-************************************************************************************************************//**
77cdf0e10cSrcweir     @short          handler to detect and play sounds ("wav" and "au" only!)
78cdf0e10cSrcweir     @descr          Register this implementation as a content handler to detect and/or play wav- and au-sounds.
79cdf0e10cSrcweir                     It doesn't depend from the target platform. But one instance of this class
80cdf0e10cSrcweir                     can play one sound at the same time only. Means every new dispatch request will stop the
81cdf0e10cSrcweir                     might still running one. So we support one operation/one URL/one listener at the same time
82cdf0e10cSrcweir                     only.
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     @devstatus      ready
85cdf0e10cSrcweir     @threadsafe     yes
86cdf0e10cSrcweir *//*-*************************************************************************************************************/
87cdf0e10cSrcweir class SoundHandler  :   // interfaces
88cdf0e10cSrcweir                         public  css::lang::XTypeProvider
89cdf0e10cSrcweir                     ,   public  css::lang::XServiceInfo
90cdf0e10cSrcweir                     ,   public  css::frame::XNotifyingDispatch // => XDispatch
91cdf0e10cSrcweir                     ,   public  css::document::XExtendedFilterDetection
92cdf0e10cSrcweir                         // baseclasses
9307a3d7f1SPedro Giffuni                         // Order is necessary for right initialization!
94cdf0e10cSrcweir                     ,   private ThreadHelpBase
95cdf0e10cSrcweir                     ,   public  ::cppu::OWeakObject
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
98cdf0e10cSrcweir     //  public methods
99cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
100cdf0e10cSrcweir     public:
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
103cdf0e10cSrcweir         //  constructor / destructor
104cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
105*46880872SDamjan Jovanovic                  SoundHandler( const css::uno::Reference< css::uno::XComponentContext >& xContext );
106cdf0e10cSrcweir         virtual ~SoundHandler(                                                                    );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
109cdf0e10cSrcweir         //  XInterface, XTypeProvider, XServiceInfo
110cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
111cdf0e10cSrcweir         virtual css::uno::Any  SAL_CALL queryInterface( const css::uno::Type& aType   ) throw( css::uno::RuntimeException );
112cdf0e10cSrcweir         virtual void SAL_CALL acquire() throw();
113cdf0e10cSrcweir         virtual void SAL_CALL release() throw();
114cdf0e10cSrcweir         virtual css::uno::Sequence< css::uno::Type >  SAL_CALL getTypes () throw( css::uno::RuntimeException );
115cdf0e10cSrcweir         virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw( css::uno::RuntimeException );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     /* interface XServiceInfo */
119cdf0e10cSrcweir        virtual ::rtl::OUString                                        SAL_CALL getImplementationName              (                                                                               ) throw( css::uno::RuntimeException );
120cdf0e10cSrcweir        virtual sal_Bool                                               SAL_CALL supportsService                    ( const ::rtl::OUString&                                        sServiceName    ) throw( css::uno::RuntimeException );
121cdf0e10cSrcweir        virtual css::uno::Sequence< ::rtl::OUString >                  SAL_CALL getSupportedServiceNames           (                                                                               ) throw( css::uno::RuntimeException );
122cdf0e10cSrcweir     /* Helper for XServiceInfo */
123cdf0e10cSrcweir        static css::uno::Sequence< ::rtl::OUString >                   SAL_CALL impl_getStaticSupportedServiceNames(                                                                               );
124cdf0e10cSrcweir        static ::rtl::OUString                                         SAL_CALL impl_getStaticImplementationName   (                                                                               );
125cdf0e10cSrcweir     /* Helper for registry */
126*46880872SDamjan Jovanovic        static css::uno::Reference< css::uno::XInterface >             SAL_CALL impl_createInstance                ( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw( css::uno::Exception );
127cdf0e10cSrcweir     /* Helper for initialization of service by using own reference! */
128cdf0e10cSrcweir        virtual void                                                   SAL_CALL impl_initService                   (                                                                               );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
131cdf0e10cSrcweir         //  XNotifyingDispatch
132cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
133cdf0e10cSrcweir         virtual void SAL_CALL dispatchWithNotification(const css::util::URL&                                             aURL      ,
134cdf0e10cSrcweir                                                        const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
135cdf0e10cSrcweir                                                        const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
138cdf0e10cSrcweir         //  XDispatch
139cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
140cdf0e10cSrcweir         virtual void SAL_CALL dispatch              (   const   css::util::URL&                                     aURL        ,
141cdf0e10cSrcweir                                                         const   css::uno::Sequence< css::beans::PropertyValue >&    lArguments  ) throw( css::uno::RuntimeException );
142cdf0e10cSrcweir         // not supported !
addStatusListener(const css::uno::Reference<css::frame::XStatusListener> &,const css::util::URL &)143cdf0e10cSrcweir         virtual void SAL_CALL addStatusListener     (   const   css::uno::Reference< css::frame::XStatusListener >& /*xListener*/   ,
144cdf0e10cSrcweir                                                         const   css::util::URL&                                     /*aURL*/        ) throw( css::uno::RuntimeException ) {};
removeStatusListener(const css::uno::Reference<css::frame::XStatusListener> &,const css::util::URL &)145cdf0e10cSrcweir         virtual void SAL_CALL removeStatusListener  (   const   css::uno::Reference< css::frame::XStatusListener >& /*xListener*/   ,
146cdf0e10cSrcweir                                                         const   css::util::URL&                                     /*aURL*/        ) throw( css::uno::RuntimeException ) {};
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
149cdf0e10cSrcweir         //  XExtendedFilterDetection
150cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
151cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL detect     (           css::uno::Sequence< css::beans::PropertyValue >&    lDescriptor ) throw( css::uno::RuntimeException );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
154cdf0e10cSrcweir     //  protected methods
155cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
156cdf0e10cSrcweir     protected:
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
159cdf0e10cSrcweir     //  private methods
160cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
161cdf0e10cSrcweir     private:
162cdf0e10cSrcweir         DECL_LINK( implts_PlayerNotify, void* );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
165cdf0e10cSrcweir     //  variables
166cdf0e10cSrcweir     //  (should be private everyway!)
167cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
168cdf0e10cSrcweir     private:
169cdf0e10cSrcweir 
170cdf0e10cSrcweir         bool m_bError;
171*46880872SDamjan Jovanovic         css::uno::Reference< css::uno::XComponentContext >         m_xContext          ;   /// component context to create new services
17230acf5e8Spfg         css::uno::Reference< css::uno::XInterface >                m_xSelfHold         ;   /// we must protect against dying during async(!) dispatch() call!
173cdf0e10cSrcweir         css::uno::Reference< css::media::XPlayer >                 m_xPlayer           ;   /// uses avmedia player to play sounds ...
174cdf0e10cSrcweir 
175cdf0e10cSrcweir         css::uno::Reference< css::frame::XDispatchResultListener > m_xListener         ;
176cdf0e10cSrcweir         Timer m_aUpdateTimer;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir };      //  class SoundHandler
179cdf0e10cSrcweir 
180cdf0e10cSrcweir }       //  namespace avmedia
181cdf0e10cSrcweir 
182cdf0e10cSrcweir #endif  //  #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
183