LCOV - code coverage report
Current view: top level - dom/media/mediasink - AudioSinkWrapper.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 12 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef AudioSinkWrapper_h_
       8             : #define AudioSinkWrapper_h_
       9             : 
      10             : #include "mozilla/AbstractThread.h"
      11             : #include "mozilla/dom/AudioChannelBinding.h"
      12             : #include "mozilla/RefPtr.h"
      13             : #include "mozilla/TimeStamp.h"
      14             : #include "mozilla/UniquePtr.h"
      15             : 
      16             : #include "MediaSink.h"
      17             : 
      18             : namespace mozilla {
      19             : 
      20             : class MediaData;
      21             : template <class T> class MediaQueue;
      22             : 
      23             : namespace media {
      24             : 
      25             : class AudioSink;
      26             : 
      27             : /**
      28             :  * A wrapper around AudioSink to provide the interface of MediaSink.
      29             :  */
      30             : class AudioSinkWrapper : public MediaSink {
      31             :   // An AudioSink factory.
      32           0 :   class Creator {
      33             :   public:
      34           0 :     virtual ~Creator() {}
      35             :     virtual AudioSink* Create() = 0;
      36             :   };
      37             : 
      38             :   // Wrap around a function object which creates AudioSinks.
      39             :   template <typename Function>
      40           0 :   class CreatorImpl : public Creator {
      41             :   public:
      42           0 :     explicit CreatorImpl(const Function& aFunc) : mFunction(aFunc) {}
      43           0 :     AudioSink* Create() override { return mFunction(); }
      44             :   private:
      45             :     Function mFunction;
      46             :   };
      47             : 
      48             : public:
      49             :   template <typename Function>
      50           0 :   AudioSinkWrapper(AbstractThread* aOwnerThread, const Function& aFunc)
      51             :     : mOwnerThread(aOwnerThread)
      52           0 :     , mCreator(new CreatorImpl<Function>(aFunc))
      53             :     , mIsStarted(false)
      54             :     // Give an invalid value to facilitate debug if used before playback starts.
      55             :     , mPlayDuration(TimeUnit::Invalid())
      56           0 :     , mAudioEnded(true)
      57           0 :   {}
      58             : 
      59             :   const PlaybackParams& GetPlaybackParams() const override;
      60             :   void SetPlaybackParams(const PlaybackParams& aParams) override;
      61             : 
      62             :   RefPtr<GenericPromise> OnEnded(TrackType aType) override;
      63             :   TimeUnit GetEndTime(TrackType aType) const override;
      64             :   TimeUnit GetPosition(TimeStamp* aTimeStamp = nullptr) const override;
      65             :   bool HasUnplayedFrames(TrackType aType) const override;
      66             : 
      67             :   void SetVolume(double aVolume) override;
      68             :   void SetPlaybackRate(double aPlaybackRate) override;
      69             :   void SetPreservesPitch(bool aPreservesPitch) override;
      70             :   void SetPlaying(bool aPlaying) override;
      71             : 
      72             :   void Start(const TimeUnit& aStartTime, const MediaInfo& aInfo) override;
      73             :   void Stop() override;
      74             :   bool IsStarted() const override;
      75             :   bool IsPlaying() const override;
      76             : 
      77             :   void Shutdown() override;
      78             : 
      79             : private:
      80             :   virtual ~AudioSinkWrapper();
      81             : 
      82           0 :   void AssertOwnerThread() const {
      83           0 :     MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
      84           0 :   }
      85             : 
      86             :   TimeUnit GetVideoPosition(TimeStamp aNow) const;
      87             : 
      88             :   void OnAudioEnded();
      89             : 
      90             :   const RefPtr<AbstractThread> mOwnerThread;
      91             :   UniquePtr<Creator> mCreator;
      92             :   UniquePtr<AudioSink> mAudioSink;
      93             :   RefPtr<GenericPromise> mEndPromise;
      94             : 
      95             :   bool mIsStarted;
      96             :   PlaybackParams mParams;
      97             : 
      98             :   TimeStamp mPlayStartTime;
      99             :   TimeUnit mPlayDuration;
     100             : 
     101             :   bool mAudioEnded;
     102             :   MozPromiseRequestHolder<GenericPromise> mAudioSinkPromise;
     103             : };
     104             : 
     105             : } // namespace media
     106             : } // namespace mozilla
     107             : 
     108             : #endif //AudioSinkWrapper_h_

Generated by: LCOV version 1.13