Chromium Code Reviews| Index: media/filters/ffmpeg_aac_bitstream_converter.h |
| diff --git a/media/filters/ffmpeg_aac_bitstream_converter.h b/media/filters/ffmpeg_aac_bitstream_converter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..154bd1889286a23d0e16689e6e03de9577c3914f |
| --- /dev/null |
| +++ b/media/filters/ffmpeg_aac_bitstream_converter.h |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_FILTERS_FFMPEG_AAC_BITSTREAM_CONVERTER_H_ |
| +#define MEDIA_FILTERS_FFMPEG_AAC_BITSTREAM_CONVERTER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "media/filters/ffmpeg_bitstream_converter.h" |
| + |
| +// Forward declarations for FFmpeg datatypes used. |
| +struct AVCodecContext; |
| +struct AVPacket; |
| + |
| +namespace media { |
| + |
| +// Adds ADTS headers to AAC frames. |
|
DaleCurtis
2014/10/31 21:50:15
Can you reflow this comment to avoid the odd line
kjoswiak
2014/11/01 00:44:27
Done.
|
| +// |
| +// Uses FFmpeg allocation methods for buffer |
| +// allocation to ensure compatibility with FFmpeg's memory management. |
| +class FFmpegAACBitstreamConverter : public FFmpegBitstreamConverter { |
| + public: |
| + // The |stream_codec_context| will be used during conversion and should be the |
| + // AVCodecContext for the stream sourcing these packets. A reference to |
| + // |stream_codec_context| is retained, so it must outlive this class. |
| + explicit FFmpegAACBitstreamConverter(AVCodecContext* stream_codec_context); |
| + ~FFmpegAACBitstreamConverter() override; |
| + |
| + bool ConvertPacket(AVPacket* packet) override; |
| + |
| + private: |
| + enum { kAdtsHeaderSize = 7 }; |
| + |
| + // Variable to hold a pointer to memory where we can access the global |
| + // data from the FFmpeg file format's global headers. |
| + AVCodecContext* stream_codec_context_; |
| + |
| + bool header_generated_; |
| + uint8_t hdr_[kAdtsHeaderSize]; |
| + |
| + bool GenerateAdtsHeader(int codec, int layer, int audio_profile, |
| + int sample_rate, int private_stream, |
| + int channel_configuration, int originality, int home, |
| + int copyrighted_stream, int copyright_start, |
| + int frame_length, int buffer_fullness, |
| + int number_of_frames_minus_one); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FFmpegAACBitstreamConverter); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_FILTERS_FFMPEG_AAC_BITSTREAM_CONVERTER_H_ |