content/media/encoder/VorbisTrackEncoder.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     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