|
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 WebMWriter_h_ |
|
7 #define WebMWriter_h_ |
|
8 |
|
9 #include "ContainerWriter.h" |
|
10 |
|
11 namespace mozilla { |
|
12 |
|
13 class EbmlComposer; |
|
14 |
|
15 // Vorbis meta data structure |
|
16 class VorbisMetadata : public TrackMetadataBase |
|
17 { |
|
18 public: |
|
19 nsTArray<uint8_t> mData; |
|
20 int32_t mChannels; |
|
21 int32_t mBitDepth; |
|
22 float mSamplingFrequency; |
|
23 MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_VORBIS; } |
|
24 }; |
|
25 |
|
26 // VP8 meta data structure |
|
27 class VP8Metadata : public TrackMetadataBase |
|
28 { |
|
29 public: |
|
30 int32_t mWidth; |
|
31 int32_t mHeight; |
|
32 int32_t mDisplayWidth; |
|
33 int32_t mDisplayHeight; |
|
34 int32_t mEncodedFrameRate; |
|
35 MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_VP8; } |
|
36 }; |
|
37 |
|
38 /** |
|
39 * WebM writer helper |
|
40 * This class accepts encoder to set audio or video meta data or |
|
41 * encoded data to ebml Composer, and get muxing data through GetContainerData. |
|
42 * The ctor/dtor run in the MediaRecorder thread, others run in MediaEncoder thread. |
|
43 */ |
|
44 class WebMWriter : public ContainerWriter |
|
45 { |
|
46 public: |
|
47 // aTrackTypes indicate this muxer should multiplex into Video only or A/V foramt. |
|
48 // Run in MediaRecorder thread |
|
49 WebMWriter(uint32_t aTrackTypes); |
|
50 // WriteEncodedTrack inserts raw packets into WebM stream. |
|
51 nsresult WriteEncodedTrack(const EncodedFrameContainer &aData, |
|
52 uint32_t aFlags = 0) MOZ_OVERRIDE; |
|
53 |
|
54 // GetContainerData outputs multiplexing data. |
|
55 // aFlags indicates the muxer should enter into finished stage and flush out |
|
56 // queue data. |
|
57 nsresult GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs, |
|
58 uint32_t aFlags = 0) MOZ_OVERRIDE; |
|
59 |
|
60 // Assign metadata into muxer |
|
61 nsresult SetMetadata(TrackMetadataBase* aMetadata) MOZ_OVERRIDE; |
|
62 |
|
63 private: |
|
64 nsAutoPtr<EbmlComposer> mEbmlComposer; |
|
65 |
|
66 // Indicate what kind of meta data needed in the writer. |
|
67 // If this value become 0, it means writer can start to generate header. |
|
68 uint8_t mMetadataRequiredFlag; |
|
69 }; |
|
70 |
|
71 } |
|
72 #endif |