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