LibreOffice Module avmedia (master) 1
soundhandler.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/lang/XTypeProvider.hpp>
23#include <com/sun/star/frame/XNotifyingDispatch.hpp>
24#include <com/sun/star/frame/XStatusListener.hpp>
25#include <com/sun/star/document/XExtendedFilterDetection.hpp>
26#include <com/sun/star/media/XPlayer.hpp>
27#include <com/sun/star/beans/PropertyValue.hpp>
28#include <com/sun/star/util/URL.hpp>
29
30#include <com/sun/star/lang/XServiceInfo.hpp>
31
33#include <cppuhelper/weak.hxx>
34
35#include <vcl/timer.hxx>
36#include <vcl/idle.hxx>
37#include <tools/link.hxx>
38
39namespace avmedia{
40
41/*-************************************************************************************************************
42 @short handler to detect and play sounds ("wav" and "au" only!)
43 @descr Register this implementation as a content handler to detect and/or play wav- and au-sounds.
44 It doesn't depend from the target platform. But one instance of this class
45 can play one sound at the same time only. Means every new dispatch request will stop the
46 might still running one. So we support one operation/one URL/one listener at the same time
47 only.
48
49 @devstatus ready
50 @threadsafe yes
51*//*-*************************************************************************************************************/
52class SoundHandler : // interfaces
53 public css::lang::XTypeProvider
54 , public css::lang::XServiceInfo
55 , public css::frame::XNotifyingDispatch // => XDispatch
56 , public css::document::XExtendedFilterDetection
57 // baseclasses
58 // Order is necessary for right initialization!
59 , private cppu::BaseMutex
60 , public ::cppu::OWeakObject
61{
62 // public methods
63 public:
64
65 // constructor / destructor
67 virtual ~SoundHandler( ) override;
68
69 // XInterface, XTypeProvider, XServiceInfo
70 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
71 virtual void SAL_CALL acquire() noexcept override;
72 virtual void SAL_CALL release() noexcept override;
73 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes () override;
74 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
75
76 /* interface XServiceInfo */
77 virtual OUString SAL_CALL getImplementationName ( ) override;
78 virtual sal_Bool SAL_CALL supportsService ( const OUString& sServiceName ) override;
79 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames ( ) override;
80
81 // XNotifyingDispatch
82 virtual void SAL_CALL dispatchWithNotification(const css::util::URL& aURL ,
83 const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
84 const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override;
85
86 // XDispatch
87 virtual void SAL_CALL dispatch ( const css::util::URL& aURL ,
88 const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override;
89 // not supported !
90 virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ ,
91 const css::util::URL& /*aURL*/ ) override {};
92 virtual void SAL_CALL removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ ,
93 const css::util::URL& /*aURL*/ ) override {};
94
95 // XExtendedFilterDetection
96 virtual OUString SAL_CALL detect ( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) override;
97
98 // protected methods
99 protected:
100
101 // private methods
102 private:
103 DECL_LINK( implts_PlayerNotify, Timer*, void );
104
105 // variables
106 // (should be private everyway!)
107 private:
108
110 css::uno::Reference< css::uno::XInterface > m_xSelfHold ; // we must protect us against dying during async(!) dispatch() call!
111 css::uno::Reference< css::media::XPlayer > m_xPlayer ; // uses avmedia player to play sounds...
112
113 css::uno::Reference< css::frame::XDispatchResultListener > m_xListener ;
115
116}; // class SoundHandler
117
118} // namespace avmedia
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sServiceName
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::uno::XInterface > m_xSelfHold
virtual ~SoundHandler() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL dispatchWithNotification(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &lArguments, const css::uno::Reference< css::frame::XDispatchResultListener > &xListener) override
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
css::uno::Reference< css::media::XPlayer > m_xPlayer
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &, const css::util::URL &) override
virtual void SAL_CALL release() noexcept override
css::uno::Reference< css::frame::XDispatchResultListener > m_xListener
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
DECL_LINK(implts_PlayerNotify, Timer *, void)
virtual OUString SAL_CALL detect(css::uno::Sequence< css::beans::PropertyValue > &lDescriptor) override
virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > &, const css::util::URL &) override
virtual void SAL_CALL dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &lArguments) override
URL aURL
unsigned char sal_Bool