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 #include "media/formats/mp2t/es_parser_adts.h" | 5 #include "media/formats/mp2t/es_parser_adts.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "media/base/audio_timestamp_helper.h" | 13 #include "media/base/audio_timestamp_helper.h" |
14 #include "media/base/bit_reader.h" | 14 #include "media/base/bit_reader.h" |
15 #include "media/base/channel_layout.h" | 15 #include "media/base/channel_layout.h" |
| 16 #include "media/base/encryption_scheme.h" |
16 #include "media/base/stream_parser_buffer.h" | 17 #include "media/base/stream_parser_buffer.h" |
17 #include "media/base/timestamp_constants.h" | 18 #include "media/base/timestamp_constants.h" |
18 #include "media/formats/common/offset_byte_queue.h" | 19 #include "media/formats/common/offset_byte_queue.h" |
19 #include "media/formats/mp2t/mp2t_common.h" | 20 #include "media/formats/mp2t/mp2t_common.h" |
20 #include "media/formats/mpeg/adts_constants.h" | 21 #include "media/formats/mpeg/adts_constants.h" |
21 | 22 |
22 namespace media { | 23 namespace media { |
23 | 24 |
24 static int ExtractAdtsFrameSize(const uint8_t* adts_header) { | 25 static int ExtractAdtsFrameSize(const uint8_t* adts_header) { |
25 return ((static_cast<int>(adts_header[5]) >> 5) | | 26 return ((static_cast<int>(adts_header[5]) >> 5) | |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // allows two bits for its value. | 220 // allows two bits for its value. |
220 ((adts_profile + 1) << 11) + | 221 ((adts_profile + 1) << 11) + |
221 // frequency_index is [0..13], per early out above. | 222 // frequency_index is [0..13], per early out above. |
222 (frequency_index << 7) + | 223 (frequency_index << 7) + |
223 // channel_configuration is [0..7], per early out above. | 224 // channel_configuration is [0..7], per early out above. |
224 (channel_configuration << 3)); | 225 (channel_configuration << 3)); |
225 std::vector<uint8_t> extra_data; | 226 std::vector<uint8_t> extra_data; |
226 extra_data.push_back(static_cast<uint8_t>(extra_data_int >> 8)); | 227 extra_data.push_back(static_cast<uint8_t>(extra_data_int >> 8)); |
227 extra_data.push_back(static_cast<uint8_t>(extra_data_int & 0xff)); | 228 extra_data.push_back(static_cast<uint8_t>(extra_data_int & 0xff)); |
228 | 229 |
| 230 EncryptionScheme scheme(false); |
| 231 |
229 AudioDecoderConfig audio_decoder_config( | 232 AudioDecoderConfig audio_decoder_config( |
230 kCodecAAC, | 233 kCodecAAC, kSampleFormatS16, |
231 kSampleFormatS16, | |
232 kADTSChannelLayoutTable[channel_configuration], | 234 kADTSChannelLayoutTable[channel_configuration], |
233 extended_samples_per_second, | 235 extended_samples_per_second, extra_data, scheme); |
234 extra_data, | |
235 false); | |
236 | 236 |
237 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { | 237 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { |
238 DVLOG(1) << "Sampling frequency: " << samples_per_second; | 238 DVLOG(1) << "Sampling frequency: " << samples_per_second; |
239 DVLOG(1) << "Extended sampling frequency: " << extended_samples_per_second; | 239 DVLOG(1) << "Extended sampling frequency: " << extended_samples_per_second; |
240 DVLOG(1) << "Channel config: " << channel_configuration; | 240 DVLOG(1) << "Channel config: " << channel_configuration; |
241 DVLOG(1) << "Adts profile: " << adts_profile; | 241 DVLOG(1) << "Adts profile: " << adts_profile; |
242 // Reset the timestamp helper to use a new time scale. | 242 // Reset the timestamp helper to use a new time scale. |
243 if (audio_timestamp_helper_ && | 243 if (audio_timestamp_helper_ && |
244 audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) { | 244 audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) { |
245 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); | 245 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); |
246 audio_timestamp_helper_.reset( | 246 audio_timestamp_helper_.reset( |
247 new AudioTimestampHelper(samples_per_second)); | 247 new AudioTimestampHelper(samples_per_second)); |
248 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); | 248 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); |
249 } else { | 249 } else { |
250 audio_timestamp_helper_.reset( | 250 audio_timestamp_helper_.reset( |
251 new AudioTimestampHelper(samples_per_second)); | 251 new AudioTimestampHelper(samples_per_second)); |
252 } | 252 } |
253 // Audio config notification. | 253 // Audio config notification. |
254 last_audio_decoder_config_ = audio_decoder_config; | 254 last_audio_decoder_config_ = audio_decoder_config; |
255 new_audio_config_cb_.Run(audio_decoder_config); | 255 new_audio_config_cb_.Run(audio_decoder_config); |
256 } | 256 } |
257 | 257 |
258 return true; | 258 return true; |
259 } | 259 } |
260 | 260 |
261 } // namespace mp2t | 261 } // namespace mp2t |
262 } // namespace media | 262 } // namespace media |
OLD | NEW |