| 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_mpeg1audio.h" | 5 #include "media/formats/mp2t/es_parser_mpeg1audio.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 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/mpeg1_audio_stream_parser.h" | 21 #include "media/formats/mpeg/mpeg1_audio_stream_parser.h" |
| 21 | 22 |
| 22 namespace media { | 23 namespace media { |
| 23 namespace mp2t { | 24 namespace mp2t { |
| 24 | 25 |
| 25 struct EsParserMpeg1Audio::Mpeg1AudioFrame { | 26 struct EsParserMpeg1Audio::Mpeg1AudioFrame { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const uint8* mpeg1audio_header) { | 165 const uint8* mpeg1audio_header) { |
| 165 MPEG1AudioStreamParser::Header header; | 166 MPEG1AudioStreamParser::Header header; |
| 166 if (!MPEG1AudioStreamParser::ParseHeader(media_log_, mpeg1audio_header, | 167 if (!MPEG1AudioStreamParser::ParseHeader(media_log_, mpeg1audio_header, |
| 167 &header)) { | 168 &header)) { |
| 168 return false; | 169 return false; |
| 169 } | 170 } |
| 170 | 171 |
| 171 // TODO(damienv): Verify whether Android playback requires the extra data | 172 // TODO(damienv): Verify whether Android playback requires the extra data |
| 172 // field for Mpeg1 audio. If yes, we should generate this field. | 173 // field for Mpeg1 audio. If yes, we should generate this field. |
| 173 AudioDecoderConfig audio_decoder_config( | 174 AudioDecoderConfig audio_decoder_config( |
| 174 kCodecMP3, | 175 kCodecMP3, kSampleFormatS16, header.channel_layout, header.sample_rate, |
| 175 kSampleFormatS16, | 176 std::vector<uint8_t>(), EncryptionScheme(false)); |
| 176 header.channel_layout, | |
| 177 header.sample_rate, | |
| 178 std::vector<uint8_t>(), | |
| 179 false); | |
| 180 | 177 |
| 181 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { | 178 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { |
| 182 DVLOG(1) << "Sampling frequency: " << header.sample_rate; | 179 DVLOG(1) << "Sampling frequency: " << header.sample_rate; |
| 183 DVLOG(1) << "Channel layout: " << header.channel_layout; | 180 DVLOG(1) << "Channel layout: " << header.channel_layout; |
| 184 // Reset the timestamp helper to use a new time scale. | 181 // Reset the timestamp helper to use a new time scale. |
| 185 if (audio_timestamp_helper_ && | 182 if (audio_timestamp_helper_ && |
| 186 audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) { | 183 audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) { |
| 187 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); | 184 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); |
| 188 audio_timestamp_helper_.reset( | 185 audio_timestamp_helper_.reset( |
| 189 new AudioTimestampHelper(header.sample_rate)); | 186 new AudioTimestampHelper(header.sample_rate)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 201 } | 198 } |
| 202 | 199 |
| 203 void EsParserMpeg1Audio::SkipMpeg1AudioFrame( | 200 void EsParserMpeg1Audio::SkipMpeg1AudioFrame( |
| 204 const Mpeg1AudioFrame& mpeg1audio_frame) { | 201 const Mpeg1AudioFrame& mpeg1audio_frame) { |
| 205 DCHECK_EQ(mpeg1audio_frame.queue_offset, es_queue_->head()); | 202 DCHECK_EQ(mpeg1audio_frame.queue_offset, es_queue_->head()); |
| 206 es_queue_->Pop(mpeg1audio_frame.size); | 203 es_queue_->Pop(mpeg1audio_frame.size); |
| 207 } | 204 } |
| 208 | 205 |
| 209 } // namespace mp2t | 206 } // namespace mp2t |
| 210 } // namespace media | 207 } // namespace media |
| OLD | NEW |