gecko/content/media/webm/EbmlComposer.h
Randy Lin c99b2ced4f Bug 891705 - [MediaEncoder] Implement WebM 1.0 container writer. r=giles, r=gps, r=rillian
This is an integrated patch which includes:
1. Bug 891705: [MediaEncoder] Implement WebM 1.0 container writer. r=giles, r=gps
2. Bug 950567: [MediaEncoder] Phase-in libmkv library. r=giles
3. bug 883749: Implement Vorbis encoding. r=rillian
4. bug 881840: Implement VP8 track encoder. r=rillian
2014-01-15 14:21:14 +08:00

76 lines
2.1 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef EbmlComposer_h_
#define EbmlComposer_h_
#include "nsTArray.h"
#include "ContainerWriter.h"
namespace mozilla {
/*
* A WebM muxer helper for package the valid WebM format.
*/
class EbmlComposer {
public:
EbmlComposer();
/*
* Assign the parameter which header required.
*/
void SetVideoConfig(uint32_t aWidth, uint32_t aHeight, float aFrameRate);
void SetAudioConfig(uint32_t aSampleFreq, uint32_t aChannels,
uint32_t bitDepth);
/*
* Set the CodecPrivateData for writing in header.
*/
void SetAudioCodecPrivateData(nsTArray<uint8_t>& aBufs)
{
mCodecPrivateData.AppendElements(aBufs);
}
/*
* Generate the whole WebM header and output to mBuff.
*/
void GenerateHeader();
/*
* Insert media encoded buffer into muxer and it would be package
* into SimpleBlock. If no cluster is opened, new cluster will start for writing.
*/
void WriteSimpleBlock(EncodedFrame* aFrame);
/*
* Get valid cluster data.
*/
void ExtractBuffer(nsTArray<nsTArray<uint8_t> >* aDestBufs,
uint32_t aFlag = 0);
private:
// Close current cluster and move data to mClusterCanFlushBuffs.
void FinishCluster();
// The temporary storage for cluster data.
nsTArray<nsTArray<uint8_t> > mClusterBuffs;
// The storage which contain valid cluster data.
nsTArray<nsTArray<uint8_t> > mClusterCanFlushBuffs;
// Indicate the header index in mClusterBuffs.
uint32_t mClusterHeaderIndex;
// The cluster length position.
uint64_t mClusterLengthLoc;
// Audio codec specific header data.
nsTArray<uint8_t> mCodecPrivateData;
// The timecode of the cluster.
uint64_t mClusterTimecode;
// Video configuration
int mWidth;
int mHeight;
float mFrameRate;
// Audio configuration
float mSampleFreq;
int mBitDepth;
int mChannels;
};
}
#endif