LCOV - code coverage report
Current view: top level - avmedia/source/framework - soundhandler.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 5 20.0 %
Date: 2014-04-11 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
      21             : #define __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
      22             : 
      23             : #include <com/sun/star/lang/XTypeProvider.hpp>
      24             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      25             : #include <com/sun/star/frame/XNotifyingDispatch.hpp>
      26             : #include <com/sun/star/frame/XStatusListener.hpp>
      27             : #include <com/sun/star/frame/XFrame.hpp>
      28             : #include <com/sun/star/document/XExtendedFilterDetection.hpp>
      29             : #include <com/sun/star/media/XPlayer.hpp>
      30             : #include <com/sun/star/beans/PropertyValue.hpp>
      31             : #include <com/sun/star/util/URL.hpp>
      32             : 
      33             : #include <com/sun/star/lang/XServiceInfo.hpp>
      34             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      35             : 
      36             : #include <cppuhelper/weak.hxx>
      37             : 
      38             : #include <vcl/timer.hxx>
      39             : #include <tools/link.hxx>
      40             : #include <avmedia/mediawindow.hxx>
      41             : #include <osl/mutex.hxx>
      42             : 
      43             : namespace avmedia{
      44             : 
      45           2 : struct ThreadHelpBase
      46             : {
      47             :     public:
      48             :         mutable ::osl::Mutex m_aLock;
      49             : };
      50             : 
      51             : /*-************************************************************************************************************
      52             :     @short          handler to detect and play sounds ("wav" and "au" only!)
      53             :     @descr          Register this implementation as a content handler to detect and/or play wav- and au-sounds.
      54             :                     It doesn't depend from the target platform. But one instance of this class
      55             :                     can play one sound at the same time only. Means every new dispatch request will stop the
      56             :                     might still running one. So we support one operation/one URL/one listener at the same time
      57             :                     only.
      58             : 
      59             :     @devstatus      ready
      60             :     @threadsafe     yes
      61             : *//*-*************************************************************************************************************/
      62             : class SoundHandler  :   // interfaces
      63             :                         public  css::lang::XTypeProvider
      64             :                     ,   public  css::lang::XServiceInfo
      65             :                     ,   public  css::frame::XNotifyingDispatch // => XDispatch
      66             :                     ,   public  css::document::XExtendedFilterDetection
      67             :                         // baseclasses
      68             :                         // Order is necessary for right initialization!
      69             :                     ,   private ThreadHelpBase
      70             :                     ,   public  ::cppu::OWeakObject
      71             : {
      72             :     // public methods
      73             :     public:
      74             : 
      75             :         // constructor / destructor
      76             :                  SoundHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
      77             :         virtual ~SoundHandler(                                                                        );
      78             : 
      79             :         //  XInterface, XTypeProvider, XServiceInfo
      80             :         virtual css::uno::Any  SAL_CALL queryInterface( const css::uno::Type& aType   ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      81             :         virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
      82             :         virtual void SAL_CALL release() throw() SAL_OVERRIDE;
      83             :         virtual css::uno::Sequence< css::uno::Type >  SAL_CALL getTypes () throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      84             :         virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      85             : 
      86             :     /* interface XServiceInfo */
      87             :        virtual OUString                                               SAL_CALL getImplementationName              (                                                                               ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      88             :        virtual sal_Bool                                               SAL_CALL supportsService                    ( const OUString&                                               sServiceName    ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      89             :        virtual css::uno::Sequence< OUString >                         SAL_CALL getSupportedServiceNames           (                                                                               ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      90             :     /* Helper for XServiceInfo */
      91             :        static css::uno::Sequence< OUString >                          SAL_CALL impl_getStaticSupportedServiceNames(                                                                               );
      92             :        static OUString                                                SAL_CALL impl_getStaticImplementationName   (                                                                               );
      93             :     /* Helper for registry */
      94             :        static css::uno::Reference< css::uno::XInterface >             SAL_CALL impl_createInstance                ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception );
      95             :        static css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL impl_createFactory                 ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
      96             :     /* Helper for initialization of service by using own reference! */
      97             :        virtual void                                                   SAL_CALL impl_initService                   (                                                                               );
      98             : 
      99             :         //  XNotifyingDispatch
     100             :         virtual void SAL_CALL dispatchWithNotification(const css::util::URL&                                             aURL      ,
     101             :                                                        const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
     102             :                                                        const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     103             : 
     104             :         //  XDispatch
     105             :         virtual void SAL_CALL dispatch              (   const   css::util::URL&                                     aURL        ,
     106             :                                                         const   css::uno::Sequence< css::beans::PropertyValue >&    lArguments  ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     107             :         // not supported !
     108           0 :         virtual void SAL_CALL addStatusListener     (   const   css::uno::Reference< css::frame::XStatusListener >& /*xListener*/   ,
     109           0 :                                                         const   css::util::URL&                                     /*aURL*/        ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE {};
     110           0 :         virtual void SAL_CALL removeStatusListener  (   const   css::uno::Reference< css::frame::XStatusListener >& /*xListener*/   ,
     111           0 :                                                         const   css::util::URL&                                     /*aURL*/        ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE {};
     112             : 
     113             :         //  XExtendedFilterDetection
     114             :         virtual OUString SAL_CALL detect           (           css::uno::Sequence< css::beans::PropertyValue >&    lDescriptor ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     115             : 
     116             :     //  protected methods
     117             :     protected:
     118             : 
     119             :     //  private methods
     120             :     private:
     121             :         DECL_LINK( implts_PlayerNotify, void* );
     122             : 
     123             :     //  variables
     124             :     //  (should be private everyway!)
     125             :     private:
     126             : 
     127             :         bool m_bError;
     128             :         css::uno::Reference< css::lang::XMultiServiceFactory >     m_xFactory          ;   // global uno service factory to create new services
     129             :         css::uno::Reference< css::uno::XInterface >                m_xSelfHold         ;   // we must protect us against dieing during async(!) dispatch() call!
     130             :         css::uno::Reference< css::media::XPlayer >                 m_xPlayer           ;   // uses avmedia player to play sounds...
     131             : 
     132             :         css::uno::Reference< css::frame::XDispatchResultListener > m_xListener         ;
     133             :         Timer m_aUpdateTimer;
     134             : 
     135             : };      //  class SoundHandler
     136             : 
     137             : }       //  namespace avmedia
     138             : 
     139             : #endif  //  #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10