content/media/encoder/VorbisTrackEncoder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/encoder/VorbisTrackEncoder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef VorbisTrackEncoder_h_
    1.10 +#define VorbisTrackEncoder_h_
    1.11 +
    1.12 +#include "TrackEncoder.h"
    1.13 +#include "nsCOMPtr.h"
    1.14 +#include <vorbis/codec.h>
    1.15 +
    1.16 +namespace mozilla {
    1.17 +
    1.18 +class VorbisTrackEncoder : public AudioTrackEncoder
    1.19 +{
    1.20 +public:
    1.21 +  VorbisTrackEncoder();
    1.22 +  virtual ~VorbisTrackEncoder();
    1.23 +
    1.24 +  already_AddRefed<TrackMetadataBase> GetMetadata() MOZ_FINAL MOZ_OVERRIDE;
    1.25 +
    1.26 +  nsresult GetEncodedTrack(EncodedFrameContainer& aData) MOZ_FINAL MOZ_OVERRIDE;
    1.27 +
    1.28 +protected:
    1.29 +  /**
    1.30 +   * http://xiph.org/vorbis/doc/libvorbis/vorbis_analysis_buffer.html
    1.31 +   * We use 1024 samples for the write buffer; libvorbis will construct packets
    1.32 +   * with the appropriate duration for the encoding mode internally.
    1.33 +   */
    1.34 +  int GetPacketDuration() MOZ_FINAL MOZ_OVERRIDE {
    1.35 +    return 1024;
    1.36 +  }
    1.37 +
    1.38 +  nsresult Init(int aChannels, int aSamplingRate) MOZ_FINAL MOZ_OVERRIDE;
    1.39 +
    1.40 +private:
    1.41 +  // Write Xiph-style lacing to aOutput.
    1.42 +  void WriteLacing(nsTArray<uint8_t> *aOutput, int32_t aLacing);
    1.43 +
    1.44 +  // Get the encoded data from vorbis encoder and append into aData.
    1.45 +  void GetEncodedFrames(EncodedFrameContainer& aData);
    1.46 +
    1.47 +  // vorbis codec members
    1.48 +  // Struct that stores all the static vorbis bitstream settings.
    1.49 +  vorbis_info mVorbisInfo;
    1.50 +  // Central working state for the PCM->packet encoder.
    1.51 +  vorbis_dsp_state mVorbisDsp;
    1.52 +  // Local working space for PCM->packet encode.
    1.53 +  vorbis_block mVorbisBlock;
    1.54 +};
    1.55 +
    1.56 +}
    1.57 +#endif

mercurial