Return linux_android_rel_ng to the CQ.
[chromium-blink-merge.git] / media / filters / ffmpeg_aac_bitstream_converter.h
blobc7328e69ab21c10fe4a6f5c752801fd2a8e889a0
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_FILTERS_FFMPEG_AAC_BITSTREAM_CONVERTER_H_
6 #define MEDIA_FILTERS_FFMPEG_AAC_BITSTREAM_CONVERTER_H_
8 #include "base/basictypes.h"
9 #include "media/base/media_export.h"
10 #include "media/filters/ffmpeg_bitstream_converter.h"
12 // Forward declarations for FFmpeg datatypes used.
13 struct AVCodecContext;
14 struct AVPacket;
16 namespace media {
18 // Bitstream converter that adds ADTS headers to AAC frames.
19 class MEDIA_EXPORT FFmpegAACBitstreamConverter
20 : public FFmpegBitstreamConverter {
21 public:
22 enum { kAdtsHeaderSize = 7 };
24 // The |stream_codec_context| will be used during conversion and should be the
25 // AVCodecContext for the stream sourcing these packets. A reference to
26 // |stream_codec_context| is retained, so it must outlive this class.
27 explicit FFmpegAACBitstreamConverter(AVCodecContext* stream_codec_context);
28 ~FFmpegAACBitstreamConverter() override;
30 // FFmpegBitstreamConverter implementation.
31 // Uses FFmpeg allocation methods for buffer allocation to ensure
32 // compatibility with FFmpeg's memory management.
33 bool ConvertPacket(AVPacket* packet) override;
35 private:
36 // Variable to hold a pointer to memory where we can access the global
37 // data from the FFmpeg file format's global headers.
38 AVCodecContext* stream_codec_context_;
40 bool header_generated_;
41 uint8_t hdr_[kAdtsHeaderSize];
42 int codec_;
43 int audio_profile_;
44 int sample_rate_index_;
45 int channel_configuration_;
46 int frame_length_;
48 DISALLOW_COPY_AND_ASSIGN(FFmpegAACBitstreamConverter);
51 } // namespace media
53 #endif // MEDIA_FILTERS_FFMPEG_AAC_BITSTREAM_CONVERTER_H_