content/media/encoder/VorbisTrackEncoder.h

branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
equal deleted inserted replaced
-1:000000000000 0:e710f68da66f
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 VorbisTrackEncoder_h_
7 #define VorbisTrackEncoder_h_
8
9 #include "TrackEncoder.h"
10 #include "nsCOMPtr.h"
11 #include <vorbis/codec.h>
12
13 namespace mozilla {
14
15 class VorbisTrackEncoder : public AudioTrackEncoder
16 {
17 public:
18 VorbisTrackEncoder();
19 virtual ~VorbisTrackEncoder();
20
21 already_AddRefed<TrackMetadataBase> GetMetadata() MOZ_FINAL MOZ_OVERRIDE;
22
23 nsresult GetEncodedTrack(EncodedFrameContainer& aData) MOZ_FINAL MOZ_OVERRIDE;
24
25 protected:
26 /**
27 * http://xiph.org/vorbis/doc/libvorbis/vorbis_analysis_buffer.html
28 * We use 1024 samples for the write buffer; libvorbis will construct packets
29 * with the appropriate duration for the encoding mode internally.
30 */
31 int GetPacketDuration() MOZ_FINAL MOZ_OVERRIDE {
32 return 1024;
33 }
34
35 nsresult Init(int aChannels, int aSamplingRate) MOZ_FINAL MOZ_OVERRIDE;
36
37 private:
38 // Write Xiph-style lacing to aOutput.
39 void WriteLacing(nsTArray<uint8_t> *aOutput, int32_t aLacing);
40
41 // Get the encoded data from vorbis encoder and append into aData.
42 void GetEncodedFrames(EncodedFrameContainer& aData);
43
44 // vorbis codec members
45 // Struct that stores all the static vorbis bitstream settings.
46 vorbis_info mVorbisInfo;
47 // Central working state for the PCM->packet encoder.
48 vorbis_dsp_state mVorbisDsp;
49 // Local working space for PCM->packet encode.
50 vorbis_block mVorbisBlock;
51 };
52
53 }
54 #endif

mercurial