1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_AVMEDIA_SOURCE_FRAMEWORK_SOUNDHANDLER_HXX
21 #define INCLUDED_AVMEDIA_SOURCE_FRAMEWORK_SOUNDHANDLER_HXX
23 #include <com/sun/star/lang/XTypeProvider.hpp>
24 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
25 #include <com/sun/star/frame/XStatusListener.hpp>
26 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
27 #include <com/sun/star/media/XPlayer.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <com/sun/star/util/URL.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34 #include <cppuhelper/weak.hxx>
36 #include <vcl/timer.hxx>
37 #include <vcl/idle.hxx>
38 #include <tools/link.hxx>
39 #include <avmedia/mediawindow.hxx>
40 #include <osl/mutex.hxx>
47 mutable ::osl::Mutex m_aLock
;
50 /*-************************************************************************************************************
51 @short handler to detect and play sounds ("wav" and "au" only!)
52 @descr Register this implementation as a content handler to detect and/or play wav- and au-sounds.
53 It doesn't depend from the target platform. But one instance of this class
54 can play one sound at the same time only. Means every new dispatch request will stop the
55 might still running one. So we support one operation/one URL/one listener at the same time
60 *//*-*************************************************************************************************************/
61 class SoundHandler
: // interfaces
62 public css::lang::XTypeProvider
63 , public css::lang::XServiceInfo
64 , public css::frame::XNotifyingDispatch
// => XDispatch
65 , public css::document::XExtendedFilterDetection
67 // Order is necessary for right initialization!
68 , private ThreadHelpBase
69 , public ::cppu::OWeakObject
74 // constructor / destructor
76 virtual ~SoundHandler( ) override
;
78 // XInterface, XTypeProvider, XServiceInfo
79 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
80 virtual void SAL_CALL
acquire() throw() override
;
81 virtual void SAL_CALL
release() throw() override
;
82 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes () override
;
83 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
85 /* interface XServiceInfo */
86 virtual OUString SAL_CALL
getImplementationName ( ) override
;
87 virtual sal_Bool SAL_CALL
supportsService ( const OUString
& sServiceName
) override
;
88 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames ( ) override
;
91 virtual void SAL_CALL
dispatchWithNotification(const css::util::URL
& aURL
,
92 const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
,
93 const css::uno::Reference
< css::frame::XDispatchResultListener
>& xListener
) override
;
96 virtual void SAL_CALL
dispatch ( const css::util::URL
& aURL
,
97 const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
) override
;
99 virtual void SAL_CALL
addStatusListener ( const css::uno::Reference
< css::frame::XStatusListener
>& /*xListener*/ ,
100 const css::util::URL
& /*aURL*/ ) override
{};
101 virtual void SAL_CALL
removeStatusListener ( const css::uno::Reference
< css::frame::XStatusListener
>& /*xListener*/ ,
102 const css::util::URL
& /*aURL*/ ) override
{};
104 // XExtendedFilterDetection
105 virtual OUString SAL_CALL
detect ( css::uno::Sequence
< css::beans::PropertyValue
>& lDescriptor
) override
;
112 DECL_LINK( implts_PlayerNotify
, Timer
*, void );
115 // (should be private everyway!)
119 css::uno::Reference
< css::uno::XInterface
> m_xSelfHold
; // we must protect us against dying during async(!) dispatch() call!
120 css::uno::Reference
< css::media::XPlayer
> m_xPlayer
; // uses avmedia player to play sounds...
122 css::uno::Reference
< css::frame::XDispatchResultListener
> m_xListener
;
125 }; // class SoundHandler
127 } // namespace avmedia
129 #endif // INCLUDED_AVMEDIA_SOURCE_FRAMEWORK_SOUNDHANDLER_HXX
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */