Chromium Code Reviews| 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_FORMATS_MP2T_ES_PARSER_ADTS_H_ | 5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ |
| 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ | 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "media/base/audio_decoder_config.h" | 18 #include "media/base/audio_decoder_config.h" |
| 19 #include "media/base/decrypt_config.h" | |
| 19 #include "media/base/media_export.h" | 20 #include "media/base/media_export.h" |
| 20 #include "media/formats/mp2t/es_parser.h" | 21 #include "media/formats/mp2t/es_parser.h" |
| 22 #include "media/media_features.h" | |
| 21 | 23 |
| 22 namespace media { | 24 namespace media { |
| 23 class AudioTimestampHelper; | 25 class AudioTimestampHelper; |
| 24 class BitReader; | 26 class BitReader; |
| 25 class OffsetByteQueue; | 27 class OffsetByteQueue; |
| 26 class StreamParserBuffer; | 28 class StreamParserBuffer; |
| 27 } | 29 } |
| 28 | 30 |
| 29 namespace media { | 31 namespace media { |
| 30 namespace mp2t { | 32 namespace mp2t { |
| 31 | 33 |
| 32 class MEDIA_EXPORT EsParserAdts : public EsParser { | 34 class MEDIA_EXPORT EsParserAdts : public EsParser { |
| 33 public: | 35 public: |
| 34 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; | 36 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; |
| 35 | 37 |
| 36 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb, | 38 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb, |
| 37 const EmitBufferCB& emit_buffer_cb, | 39 const EmitBufferCB& emit_buffer_cb, |
| 38 bool sbr_in_mimetype); | 40 bool sbr_in_mimetype); |
| 41 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) | |
| 42 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb, | |
| 43 const EmitBufferCB& emit_buffer_cb, | |
| 44 const GetDecryptConfigCB& get_decrypt_config_cb, | |
| 45 bool use_hls_sample_aes, | |
|
ddorwin
2016/04/12 00:40:47
nit: suggest putting this first since it controls
dougsteed
2016/05/08 23:18:44
Done.
| |
| 46 bool sbr_in_mimetype); | |
|
ddorwin
2016/04/12 00:40:47
I think the order should be consistent between the
dougsteed
2016/05/08 23:18:44
Done.
| |
| 47 #endif | |
| 48 | |
| 39 ~EsParserAdts() override; | 49 ~EsParserAdts() override; |
| 40 | 50 |
| 41 // EsParser implementation. | 51 // EsParser implementation. |
| 42 void Flush() override; | 52 void Flush() override; |
| 43 | 53 |
| 44 private: | 54 private: |
| 45 struct AdtsFrame; | 55 struct AdtsFrame; |
| 46 | 56 |
| 47 // EsParser implementation. | 57 // EsParser implementation. |
| 48 bool ParseFromEsQueue() override; | 58 bool ParseFromEsQueue() override; |
| 49 void ResetInternal() override; | 59 void ResetInternal() override; |
| 50 | 60 |
| 51 // Synchronize the stream on an ADTS syncword (consuming bytes from | 61 // Synchronize the stream on an ADTS syncword (consuming bytes from |
| 52 // |es_queue_| if needed). | 62 // |es_queue_| if needed). |
| 53 // Returns true when a full ADTS frame has been found: in that case | 63 // Returns true when a full ADTS frame has been found: in that case |
| 54 // |adts_frame| structure is filled up accordingly. | 64 // |adts_frame| structure is filled up accordingly. |
| 55 // Returns false otherwise (no ADTS syncword found or partial ADTS frame). | 65 // Returns false otherwise (no ADTS syncword found or partial ADTS frame). |
| 56 bool LookForAdtsFrame(AdtsFrame* adts_frame); | 66 bool LookForAdtsFrame(AdtsFrame* adts_frame); |
| 57 | 67 |
| 58 // Skip an ADTS frame in the ES queue. | 68 // Skip an ADTS frame in the ES queue. |
| 59 void SkipAdtsFrame(const AdtsFrame& adts_frame); | 69 void SkipAdtsFrame(const AdtsFrame& adts_frame); |
| 60 | 70 |
| 61 // Signal any audio configuration change (if any). | 71 // Signal any audio configuration change (if any). |
| 62 // Return false if the current audio config is not | 72 // Return false if the current audio config is not |
| 63 // a supported ADTS audio config. | 73 // a supported ADTS audio config. |
| 64 bool UpdateAudioConfiguration(const uint8_t* adts_header); | 74 bool UpdateAudioConfiguration(const uint8_t* adts_header); |
| 65 | 75 |
| 76 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) | |
| 77 void CalculateSubsamplesForAdtsFrame(const AdtsFrame& adts_frame, | |
| 78 std::vector<SubsampleEntry>* subsamples); | |
| 79 #endif | |
| 80 | |
| 66 // Callbacks: | 81 // Callbacks: |
| 67 // - to signal a new audio configuration, | 82 // - to signal a new audio configuration, |
| 68 // - to send ES buffers. | 83 // - to send ES buffers. |
| 69 NewAudioConfigCB new_audio_config_cb_; | 84 NewAudioConfigCB new_audio_config_cb_; |
| 70 EmitBufferCB emit_buffer_cb_; | 85 EmitBufferCB emit_buffer_cb_; |
| 86 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) | |
| 87 // - to obtain the current decrypt_config. Only called if use_hls_sample_aes_. | |
| 88 GetDecryptConfigCB get_decrypt_config_cb_; | |
| 89 bool use_hls_sample_aes_; | |
|
ddorwin
2016/04/12 00:40:47
ditto on ordering
dougsteed
2016/05/08 23:18:44
Done.
| |
| 90 #endif | |
| 71 | 91 |
| 72 // True when AAC SBR extension is signalled in the mimetype | 92 // True when AAC SBR extension is signalled in the mimetype |
| 73 // (mp4a.40.5 in the codecs parameter). | 93 // (mp4a.40.5 in the codecs parameter). |
| 74 bool sbr_in_mimetype_; | 94 bool sbr_in_mimetype_; |
| 75 | 95 |
| 76 // Interpolated PTS for frames that don't have one. | 96 // Interpolated PTS for frames that don't have one. |
| 77 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; | 97 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; |
| 78 | 98 |
| 79 // Last audio config. | 99 // Last audio config. |
| 80 AudioDecoderConfig last_audio_decoder_config_; | 100 AudioDecoderConfig last_audio_decoder_config_; |
| 81 | 101 |
| 82 DISALLOW_COPY_AND_ASSIGN(EsParserAdts); | 102 DISALLOW_COPY_AND_ASSIGN(EsParserAdts); |
| 83 }; | 103 }; |
| 84 | 104 |
| 85 } // namespace mp2t | 105 } // namespace mp2t |
| 86 } // namespace media | 106 } // namespace media |
| 87 | 107 |
| 88 #endif | 108 #endif |
| OLD | NEW |