content/media/encoder/VorbisTrackEncoder.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.

     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/. */
     6 #ifndef VorbisTrackEncoder_h_
     7 #define VorbisTrackEncoder_h_
     9 #include "TrackEncoder.h"
    10 #include "nsCOMPtr.h"
    11 #include <vorbis/codec.h>
    13 namespace mozilla {
    15 class VorbisTrackEncoder : public AudioTrackEncoder
    16 {
    17 public:
    18   VorbisTrackEncoder();
    19   virtual ~VorbisTrackEncoder();
    21   already_AddRefed<TrackMetadataBase> GetMetadata() MOZ_FINAL MOZ_OVERRIDE;
    23   nsresult GetEncodedTrack(EncodedFrameContainer& aData) MOZ_FINAL MOZ_OVERRIDE;
    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   }
    35   nsresult Init(int aChannels, int aSamplingRate) MOZ_FINAL MOZ_OVERRIDE;
    37 private:
    38   // Write Xiph-style lacing to aOutput.
    39   void WriteLacing(nsTArray<uint8_t> *aOutput, int32_t aLacing);
    41   // Get the encoded data from vorbis encoder and append into aData.
    42   void GetEncodedFrames(EncodedFrameContainer& aData);
    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 };
    53 }
    54 #endif

mercurial