content/media/webm/EbmlComposer.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef EbmlComposer_h_
michael@0 7 #define EbmlComposer_h_
michael@0 8 #include "nsTArray.h"
michael@0 9 #include "ContainerWriter.h"
michael@0 10
michael@0 11 namespace mozilla {
michael@0 12
michael@0 13 /*
michael@0 14 * A WebM muxer helper for package the valid WebM format.
michael@0 15 */
michael@0 16 class EbmlComposer {
michael@0 17 public:
michael@0 18 EbmlComposer();
michael@0 19 /*
michael@0 20 * Assign the parameter which header required.
michael@0 21 */
michael@0 22 void SetVideoConfig(uint32_t aWidth, uint32_t aHeight, uint32_t aDisplayWidth,
michael@0 23 uint32_t aDisplayHeight, float aFrameRate);
michael@0 24
michael@0 25 void SetAudioConfig(uint32_t aSampleFreq, uint32_t aChannels,
michael@0 26 uint32_t bitDepth);
michael@0 27 /*
michael@0 28 * Set the CodecPrivateData for writing in header.
michael@0 29 */
michael@0 30 void SetAudioCodecPrivateData(nsTArray<uint8_t>& aBufs)
michael@0 31 {
michael@0 32 mCodecPrivateData.AppendElements(aBufs);
michael@0 33 }
michael@0 34 /*
michael@0 35 * Generate the whole WebM header and output to mBuff.
michael@0 36 */
michael@0 37 void GenerateHeader();
michael@0 38 /*
michael@0 39 * Insert media encoded buffer into muxer and it would be package
michael@0 40 * into SimpleBlock. If no cluster is opened, new cluster will start for writing.
michael@0 41 */
michael@0 42 void WriteSimpleBlock(EncodedFrame* aFrame);
michael@0 43 /*
michael@0 44 * Get valid cluster data.
michael@0 45 */
michael@0 46 void ExtractBuffer(nsTArray<nsTArray<uint8_t> >* aDestBufs,
michael@0 47 uint32_t aFlag = 0);
michael@0 48 private:
michael@0 49 // Move the metadata data to mClusterCanFlushBuffs.
michael@0 50 void FinishMetadata();
michael@0 51 // Close current cluster and move data to mClusterCanFlushBuffs.
michael@0 52 void FinishCluster();
michael@0 53 // The temporary storage for cluster data.
michael@0 54 nsTArray<nsTArray<uint8_t> > mClusterBuffs;
michael@0 55 // The storage which contain valid cluster data.
michael@0 56 nsTArray<nsTArray<uint8_t> > mClusterCanFlushBuffs;
michael@0 57
michael@0 58 // Indicate the data types in mClusterBuffs.
michael@0 59 enum {
michael@0 60 FLUSH_NONE = 0,
michael@0 61 FLUSH_METADATA = 1 << 0,
michael@0 62 FLUSH_CLUSTER = 1 << 1
michael@0 63 };
michael@0 64 uint32_t mFlushState;
michael@0 65 // Indicate the cluster header index in mClusterBuffs.
michael@0 66 uint32_t mClusterHeaderIndex;
michael@0 67 // The cluster length position.
michael@0 68 uint64_t mClusterLengthLoc;
michael@0 69 // Audio codec specific header data.
michael@0 70 nsTArray<uint8_t> mCodecPrivateData;
michael@0 71
michael@0 72 // The timecode of the cluster.
michael@0 73 uint64_t mClusterTimecode;
michael@0 74
michael@0 75 // Video configuration
michael@0 76 int mWidth;
michael@0 77 int mHeight;
michael@0 78 int mDisplayWidth;
michael@0 79 int mDisplayHeight;
michael@0 80 float mFrameRate;
michael@0 81 // Audio configuration
michael@0 82 float mSampleFreq;
michael@0 83 int mBitDepth;
michael@0 84 int mChannels;
michael@0 85 };
michael@0 86
michael@0 87 }
michael@0 88 #endif

mercurial