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