1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
media / filters / ffmpeg_aac_bitstream_converter.h [blame]
// Copyright 2014 The Chromium Authors
// 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 <stdint.h>
#include "base/memory/raw_ptr.h"
#include "media/base/media_export.h"
#include "media/filters/ffmpeg_bitstream_converter.h"
// Forward declarations for FFmpeg datatypes used.
struct AVCodecParameters;
struct AVPacket;
namespace media {
// Bitstream converter that adds ADTS headers to AAC frames.
class MEDIA_EXPORT FFmpegAACBitstreamConverter
: public FFmpegBitstreamConverter {
public:
enum { kAdtsHeaderSize = 7 };
// The |stream_codec_parameters| will be used during conversion and should be
// the AVCodecParameters for the stream sourcing these packets. A reference to
// |stream_codec_parameters| is retained, so it must outlive this class.
explicit FFmpegAACBitstreamConverter(
AVCodecParameters* stream_codec_parameters);
FFmpegAACBitstreamConverter(const FFmpegAACBitstreamConverter&) = delete;
FFmpegAACBitstreamConverter& operator=(const FFmpegAACBitstreamConverter&) =
delete;
~FFmpegAACBitstreamConverter() override;
// FFmpegBitstreamConverter implementation.
// Uses FFmpeg allocation methods for buffer allocation to ensure
// compatibility with FFmpeg's memory management.
bool ConvertPacket(AVPacket* packet) override;
private:
// Variable to hold a pointer to memory where we can access the global
// data from the FFmpeg file format's global headers.
raw_ptr<AVCodecParameters> stream_codec_parameters_;
bool header_generated_;
uint8_t hdr_[kAdtsHeaderSize];
int codec_;
int audio_profile_;
int sample_rate_index_;
int channel_configuration_;
int frame_length_;
};
} // namespace media
#endif // MEDIA_FILTERS_FFMPEG_AAC_BITSTREAM_CONVERTER_H_