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 109ea84ac5SAndrew Rist * 119ea84ac5SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 129ea84ac5SAndrew Rist * 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. 199ea84ac5SAndrew Rist * 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/lang/XMultiServiceFactory.hpp> 33cdf0e10cSrcweir #include <com/sun/star/frame/XNotifyingDispatch.hpp> 34cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp> 35cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 36cdf0e10cSrcweir #include <com/sun/star/document/XExtendedFilterDetection.hpp> 37cdf0e10cSrcweir #include <com/sun/star/media/XPlayer.hpp> 38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 39cdf0e10cSrcweir #include <com/sun/star/util/URL.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 93*07a3d7f1SPedro 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 //--------------------------------------------------------------------------------------------------------- 105cdf0e10cSrcweir SoundHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); 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 */ 126cdf0e10cSrcweir static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception ); 127cdf0e10cSrcweir static css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); 128cdf0e10cSrcweir /* Helper for initialization of service by using own reference! */ 129cdf0e10cSrcweir virtual void SAL_CALL impl_initService ( ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 132cdf0e10cSrcweir // XNotifyingDispatch 133cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 134cdf0e10cSrcweir virtual void SAL_CALL dispatchWithNotification(const css::util::URL& aURL , 135cdf0e10cSrcweir const css::uno::Sequence< css::beans::PropertyValue >& lArguments, 136cdf0e10cSrcweir const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException); 137cdf0e10cSrcweir 138cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 139cdf0e10cSrcweir // XDispatch 140cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 141cdf0e10cSrcweir virtual void SAL_CALL dispatch ( const css::util::URL& aURL , 142cdf0e10cSrcweir const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); 143cdf0e10cSrcweir // not supported ! 144cdf0e10cSrcweir virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ , 145cdf0e10cSrcweir const css::util::URL& /*aURL*/ ) throw( css::uno::RuntimeException ) {}; 146cdf0e10cSrcweir virtual void SAL_CALL removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ , 147cdf0e10cSrcweir const css::util::URL& /*aURL*/ ) throw( css::uno::RuntimeException ) {}; 148cdf0e10cSrcweir 149cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 150cdf0e10cSrcweir // XExtendedFilterDetection 151cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 152cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL detect ( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) throw( css::uno::RuntimeException ); 153cdf0e10cSrcweir 154cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 155cdf0e10cSrcweir // protected methods 156cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 157cdf0e10cSrcweir protected: 158cdf0e10cSrcweir 159cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 160cdf0e10cSrcweir // private methods 161cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 162cdf0e10cSrcweir private: 163cdf0e10cSrcweir DECL_LINK( implts_PlayerNotify, void* ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 166cdf0e10cSrcweir // variables 167cdf0e10cSrcweir // (should be private everyway!) 168cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 169cdf0e10cSrcweir private: 170cdf0e10cSrcweir 171cdf0e10cSrcweir bool m_bError; 172cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// global uno service factory to create new services 173cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > m_xSelfHold ; /// we must protect us against dieing during async(!) dispatch() call! 174cdf0e10cSrcweir css::uno::Reference< css::media::XPlayer > m_xPlayer ; /// uses avmedia player to play sounds ... 175cdf0e10cSrcweir 176cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchResultListener > m_xListener ; 177cdf0e10cSrcweir Timer m_aUpdateTimer; 178cdf0e10cSrcweir 179cdf0e10cSrcweir }; // class SoundHandler 180cdf0e10cSrcweir 181cdf0e10cSrcweir } // namespace avmedia 182cdf0e10cSrcweir 183cdf0e10cSrcweir #endif // #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_ 184