LCOV - code coverage report
Current view: top level - dom/media/mediasource - SourceBufferTask.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 29 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 32 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 MOZILLA_SOURCEBUFFERTASK_H_
       8             : #define MOZILLA_SOURCEBUFFERTASK_H_
       9             : 
      10             : #include "mozilla/MozPromise.h"
      11             : #include "mozilla/Pair.h"
      12             : #include "mozilla/RefPtr.h"
      13             : #include "SourceBufferAttributes.h"
      14             : #include "TimeUnits.h"
      15             : #include "MediaResult.h"
      16             : 
      17             : namespace mozilla {
      18             : 
      19           0 : class SourceBufferTask {
      20             : public:
      21           0 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SourceBufferTask);
      22             :   enum class Type  {
      23             :     AppendBuffer,
      24             :     Abort,
      25             :     Reset,
      26             :     RangeRemoval,
      27             :     EvictData,
      28             :     Detach
      29             :   };
      30             : 
      31             :   typedef Pair<bool, SourceBufferAttributes> AppendBufferResult;
      32             :   typedef MozPromise<AppendBufferResult, MediaResult, /* IsExclusive = */ true> AppendPromise;
      33             :   typedef MozPromise<bool, nsresult, /* IsExclusive = */ true> RangeRemovalPromise;
      34             : 
      35             :   virtual Type GetType() const = 0;
      36             : 
      37             :   template<typename ReturnType>
      38           0 :   ReturnType* As()
      39             :   {
      40           0 :     MOZ_ASSERT(this->GetType() == ReturnType::sType);
      41           0 :     return static_cast<ReturnType*>(this);
      42             :   }
      43             : 
      44             : protected:
      45           0 :   virtual ~SourceBufferTask() {}
      46             : };
      47             : 
      48           0 : class AppendBufferTask : public SourceBufferTask {
      49             : public:
      50           0 :   AppendBufferTask(already_AddRefed<MediaByteBuffer> aData,
      51             :                    const SourceBufferAttributes& aAttributes)
      52           0 :   : mBuffer(aData)
      53           0 :   , mAttributes(aAttributes)
      54           0 :   {}
      55             : 
      56             :   static const Type sType = Type::AppendBuffer;
      57           0 :   Type GetType() const override { return Type::AppendBuffer; }
      58             : 
      59             :   RefPtr<MediaByteBuffer> mBuffer;
      60             :   SourceBufferAttributes mAttributes;
      61             :   MozPromiseHolder<AppendPromise> mPromise;
      62             : };
      63             : 
      64           0 : class AbortTask : public SourceBufferTask {
      65             : public:
      66             :   static const Type sType = Type::Abort;
      67           0 :   Type GetType() const override { return Type::Abort; }
      68             : };
      69             : 
      70           0 : class ResetTask : public SourceBufferTask {
      71             : public:
      72             :   static const Type sType = Type::Reset;
      73           0 :   Type GetType() const override { return Type::Reset; }
      74             : };
      75             : 
      76           0 : class RangeRemovalTask : public SourceBufferTask {
      77             : public:
      78           0 :   explicit RangeRemovalTask(const media::TimeInterval& aRange)
      79           0 :   : mRange(aRange)
      80           0 :   {}
      81             : 
      82             :   static const Type sType = Type::RangeRemoval;
      83           0 :   Type GetType() const override { return Type::RangeRemoval; }
      84             : 
      85             :   media::TimeInterval mRange;
      86             :   MozPromiseHolder<RangeRemovalPromise> mPromise;
      87             : };
      88             : 
      89           0 : class EvictDataTask : public SourceBufferTask {
      90             : public:
      91           0 :   EvictDataTask(const media::TimeUnit& aPlaybackTime, int64_t aSizetoEvict)
      92           0 :   : mPlaybackTime(aPlaybackTime)
      93           0 :   , mSizeToEvict(aSizetoEvict)
      94           0 :   {}
      95             : 
      96             :   static const Type sType = Type::EvictData;
      97           0 :   Type GetType() const override { return Type::EvictData; }
      98             : 
      99             :   media::TimeUnit mPlaybackTime;
     100             :   int64_t mSizeToEvict;
     101             : };
     102             : 
     103           0 : class DetachTask : public SourceBufferTask {
     104             : public:
     105             :   static const Type sType = Type::Detach;
     106           0 :   Type GetType() const override { return Type::Detach; }
     107             : };
     108             : 
     109             : } // end mozilla namespace
     110             : 
     111             : #endif

Generated by: LCOV version 1.13