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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       4             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef EncodedFrameContainer_H_
       7             : #define EncodedFrameContainer_H_
       8             : 
       9             : #include "nsTArray.h"
      10             : 
      11             : namespace mozilla {
      12             : 
      13             : class EncodedFrame;
      14             : 
      15             : /*
      16             :  * This container is used to carry video or audio encoded data from encoder to muxer.
      17             :  * The media data object is created by encoder and recycle by the destructor.
      18             :  * Only allow to store audio or video encoded data in EncodedData.
      19             :  */
      20           0 : class EncodedFrameContainer
      21             : {
      22             : public:
      23             :   // Append encoded frame data
      24           0 :   void AppendEncodedFrame(EncodedFrame* aEncodedFrame)
      25             :   {
      26           0 :     mEncodedFrames.AppendElement(aEncodedFrame);
      27           0 :   }
      28             :   // Retrieve all of the encoded frames
      29           0 :   const nsTArray<RefPtr<EncodedFrame> >& GetEncodedFrames() const
      30             :   {
      31           0 :     return mEncodedFrames;
      32             :   }
      33             : private:
      34             :   // This container is used to store the video or audio encoded packets.
      35             :   // Muxer should check mFrameType and get the encoded data type from mEncodedFrames.
      36             :   nsTArray<RefPtr<EncodedFrame> > mEncodedFrames;
      37             : };
      38             : 
      39             : // Represent one encoded frame
      40             : class EncodedFrame final
      41             : {
      42           0 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(EncodedFrame)
      43             : public:
      44           0 :   EncodedFrame() :
      45             :     mTimeStamp(0),
      46             :     mDuration(0),
      47           0 :     mFrameType(UNKNOWN)
      48           0 :   {}
      49             :   enum FrameType {
      50             :     VP8_I_FRAME,      // VP8 intraframe
      51             :     VP8_P_FRAME,      // VP8 predicted frame
      52             :     OPUS_AUDIO_FRAME, // Opus audio frame
      53             :     VORBIS_AUDIO_FRAME,
      54             :     AVC_I_FRAME,
      55             :     AVC_P_FRAME,
      56             :     AVC_B_FRAME,
      57             :     AVC_CSD,          // AVC codec specific data
      58             :     AAC_AUDIO_FRAME,
      59             :     AAC_CSD,          // AAC codec specific data
      60             :     AMR_AUDIO_CSD,
      61             :     AMR_AUDIO_FRAME,
      62             :     EVRC_AUDIO_CSD,
      63             :     EVRC_AUDIO_FRAME,
      64             :     UNKNOWN           // FrameType not set
      65             :   };
      66           0 :   void SwapInFrameData(nsTArray<uint8_t>& aData)
      67             :   {
      68           0 :     mFrameData.SwapElements(aData);
      69           0 :   }
      70             :   nsresult SwapOutFrameData(nsTArray<uint8_t>& aData)
      71             :   {
      72             :     if (mFrameType != UNKNOWN) {
      73             :       // Reset this frame type to UNKNOWN once the data is swapped out.
      74             :       mFrameData.SwapElements(aData);
      75             :       mFrameType = UNKNOWN;
      76             :       return NS_OK;
      77             :     }
      78             :     return NS_ERROR_FAILURE;
      79             :   }
      80           0 :   const nsTArray<uint8_t>& GetFrameData() const
      81             :   {
      82           0 :     return mFrameData;
      83             :   }
      84           0 :   uint64_t GetTimeStamp() const { return mTimeStamp; }
      85           0 :   void SetTimeStamp(uint64_t aTimeStamp) { mTimeStamp = aTimeStamp; }
      86             : 
      87           0 :   uint64_t GetDuration() const { return mDuration; }
      88           0 :   void SetDuration(uint64_t aDuration) { mDuration = aDuration; }
      89             : 
      90           0 :   FrameType GetFrameType() const { return mFrameType; }
      91           0 :   void SetFrameType(FrameType aFrameType) { mFrameType = aFrameType; }
      92             : private:
      93             :   // Private destructor, to discourage deletion outside of Release():
      94           0 :   ~EncodedFrame()
      95           0 :   {
      96           0 :   }
      97             : 
      98             :   // Encoded data
      99             :   nsTArray<uint8_t> mFrameData;
     100             :   uint64_t mTimeStamp;
     101             :   // The playback duration of this packet in number of samples
     102             :   uint64_t mDuration;
     103             :   // Represent what is in the FrameData
     104             :   FrameType mFrameType;
     105             : };
     106             : 
     107             : } // namespace mozilla
     108             : 
     109             : #endif

Generated by: LCOV version 1.13