LCOV - code coverage report
Current view: top level - dom/media/encoder - ContainerWriter.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 6 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 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 ContainerWriter_h_
       7             : #define ContainerWriter_h_
       8             : 
       9             : #include "nsTArray.h"
      10             : #include "EncodedFrameContainer.h"
      11             : #include "TrackMetadataBase.h"
      12             : 
      13             : namespace mozilla {
      14             : /**
      15             :  * ContainerWriter packs encoded track data into a specific media container.
      16             :  */
      17             : class ContainerWriter {
      18             : public:
      19           0 :   ContainerWriter()
      20           0 :     : mInitialized(false)
      21           0 :     , mIsWritingComplete(false)
      22           0 :   {}
      23           0 :   virtual ~ContainerWriter() {}
      24             :   // Mapping to DOMLocalMediaStream::TrackTypeHints
      25             :   enum {
      26             :     CREATE_AUDIO_TRACK = 1 << 0,
      27             :     CREATE_VIDEO_TRACK = 1 << 1,
      28             :   };
      29             :   enum {
      30             :     END_OF_STREAM = 1 << 0
      31             :   };
      32             : 
      33             :   /**
      34             :    * Writes encoded track data from aBuffer to a packet, and insert this packet
      35             :    * into the internal stream of container writer. aDuration is the playback
      36             :    * duration of this packet in number of samples. aFlags is true with
      37             :    * END_OF_STREAM if this is the last packet of track.
      38             :    * Currently, WriteEncodedTrack doesn't support multiple tracks.
      39             :    */
      40             :   virtual nsresult WriteEncodedTrack(const EncodedFrameContainer& aData,
      41             :                                      uint32_t aFlags = 0) = 0;
      42             : 
      43             :   /**
      44             :    * Set the meta data pointer into muxer
      45             :    * This function will check the integrity of aMetadata.
      46             :    * If the meta data isn't well format, this function will return NS_ERROR_FAILURE to caller,
      47             :    * else save the pointer to mMetadata and return NS_OK.
      48             :    */
      49             :   virtual nsresult SetMetadata(TrackMetadataBase* aMetadata) = 0;
      50             : 
      51             :   /**
      52             :    * Indicate if the writer has finished to output data
      53             :    */
      54           0 :   virtual bool IsWritingComplete() { return mIsWritingComplete; }
      55             : 
      56             :   enum {
      57             :     FLUSH_NEEDED = 1 << 0,
      58             :     GET_HEADER = 1 << 1
      59             :   };
      60             : 
      61             :   /**
      62             :    * Copies the final container data to a buffer if it has accumulated enough
      63             :    * packets from WriteEncodedTrack. This buffer of data is appended to
      64             :    * aOutputBufs, and existing elements of aOutputBufs should not be modified.
      65             :    * aFlags is true with FLUSH_NEEDED will force OggWriter to flush an ogg page
      66             :    * even it is not full, and copy these container data to a buffer for
      67             :    * aOutputBufs to append.
      68             :    */
      69             :   virtual nsresult GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
      70             :                                     uint32_t aFlags = 0) = 0;
      71             : protected:
      72             :   bool mInitialized;
      73             :   bool mIsWritingComplete;
      74             : };
      75             : 
      76             : } // namespace mozilla
      77             : 
      78             : #endif

Generated by: LCOV version 1.13