Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: media/formats/mp2t/es_parser_mpeg1audio.cc

Issue 1235793005: Deprecate LogCB in favor of using MediaLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and attempt to fix Android compilation Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 20 matching lines...) Expand all
31 // Number of samples in the frame. 31 // Number of samples in the frame.
32 int sample_count; 32 int sample_count;
33 33
34 // Frame offset in the ES queue. 34 // Frame offset in the ES queue.
35 int64 queue_offset; 35 int64 queue_offset;
36 }; 36 };
37 37
38 EsParserMpeg1Audio::EsParserMpeg1Audio( 38 EsParserMpeg1Audio::EsParserMpeg1Audio(
39 const NewAudioConfigCB& new_audio_config_cb, 39 const NewAudioConfigCB& new_audio_config_cb,
40 const EmitBufferCB& emit_buffer_cb, 40 const EmitBufferCB& emit_buffer_cb,
41 const LogCB& log_cb) 41 const scoped_refptr<MediaLog>& media_log)
42 : log_cb_(log_cb), 42 : media_log_(media_log),
43 new_audio_config_cb_(new_audio_config_cb), 43 new_audio_config_cb_(new_audio_config_cb),
44 emit_buffer_cb_(emit_buffer_cb) { 44 emit_buffer_cb_(emit_buffer_cb) {
45 } 45 }
46 46
47 EsParserMpeg1Audio::~EsParserMpeg1Audio() { 47 EsParserMpeg1Audio::~EsParserMpeg1Audio() {
48 } 48 }
49 49
50 bool EsParserMpeg1Audio::ParseFromEsQueue() { 50 bool EsParserMpeg1Audio::ParseFromEsQueue() {
51 // Look for every MPEG1 audio frame in the ES buffer. 51 // Look for every MPEG1 audio frame in the ES buffer.
52 Mpeg1AudioFrame mpeg1audio_frame; 52 Mpeg1AudioFrame mpeg1audio_frame;
53 while (LookForMpeg1AudioFrame(&mpeg1audio_frame)) { 53 while (LookForMpeg1AudioFrame(&mpeg1audio_frame)) {
54 // Update the audio configuration if needed. 54 // Update the audio configuration if needed.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return false; 115 return false;
116 116
117 for (int offset = 0; offset < max_offset; offset++) { 117 for (int offset = 0; offset < max_offset; offset++) {
118 const uint8* cur_buf = &es[offset]; 118 const uint8* cur_buf = &es[offset];
119 if (cur_buf[0] != 0xff) 119 if (cur_buf[0] != 0xff)
120 continue; 120 continue;
121 121
122 int remaining_size = es_size - offset; 122 int remaining_size = es_size - offset;
123 DCHECK_GE(remaining_size, MPEG1AudioStreamParser::kHeaderSize); 123 DCHECK_GE(remaining_size, MPEG1AudioStreamParser::kHeaderSize);
124 MPEG1AudioStreamParser::Header header; 124 MPEG1AudioStreamParser::Header header;
125 if (!MPEG1AudioStreamParser::ParseHeader(log_cb_, cur_buf, &header)) 125 if (!MPEG1AudioStreamParser::ParseHeader(media_log_, cur_buf, &header))
126 continue; 126 continue;
127 127
128 if (remaining_size < header.frame_size) { 128 if (remaining_size < header.frame_size) {
129 // Not a full frame: will resume when we have more data. 129 // Not a full frame: will resume when we have more data.
130 // Remove all the bytes located before the frame header, 130 // Remove all the bytes located before the frame header,
131 // these bytes will not be used anymore. 131 // these bytes will not be used anymore.
132 es_queue_->Pop(offset); 132 es_queue_->Pop(offset);
133 return false; 133 return false;
134 } 134 }
135 135
(...skipping 19 matching lines...) Expand all
155 return true; 155 return true;
156 } 156 }
157 157
158 es_queue_->Pop(max_offset); 158 es_queue_->Pop(max_offset);
159 return false; 159 return false;
160 } 160 }
161 161
162 bool EsParserMpeg1Audio::UpdateAudioConfiguration( 162 bool EsParserMpeg1Audio::UpdateAudioConfiguration(
163 const uint8* mpeg1audio_header) { 163 const uint8* mpeg1audio_header) {
164 MPEG1AudioStreamParser::Header header; 164 MPEG1AudioStreamParser::Header header;
165 if (!MPEG1AudioStreamParser::ParseHeader(log_cb_, 165 if (!MPEG1AudioStreamParser::ParseHeader(media_log_, mpeg1audio_header,
166 mpeg1audio_header,
167 &header)) { 166 &header)) {
168 return false; 167 return false;
169 } 168 }
170 169
171 // TODO(damienv): Verify whether Android playback requires the extra data 170 // TODO(damienv): Verify whether Android playback requires the extra data
172 // field for Mpeg1 audio. If yes, we should generate this field. 171 // field for Mpeg1 audio. If yes, we should generate this field.
173 AudioDecoderConfig audio_decoder_config( 172 AudioDecoderConfig audio_decoder_config(
174 kCodecMP3, 173 kCodecMP3,
175 kSampleFormatS16, 174 kSampleFormatS16,
176 header.channel_layout, 175 header.channel_layout,
(...skipping 24 matching lines...) Expand all
201 } 200 }
202 201
203 void EsParserMpeg1Audio::SkipMpeg1AudioFrame( 202 void EsParserMpeg1Audio::SkipMpeg1AudioFrame(
204 const Mpeg1AudioFrame& mpeg1audio_frame) { 203 const Mpeg1AudioFrame& mpeg1audio_frame) {
205 DCHECK_EQ(mpeg1audio_frame.queue_offset, es_queue_->head()); 204 DCHECK_EQ(mpeg1audio_frame.queue_offset, es_queue_->head());
206 es_queue_->Pop(mpeg1audio_frame.size); 205 es_queue_->Pop(mpeg1audio_frame.size);
207 } 206 }
208 207
209 } // namespace mp2t 208 } // namespace mp2t
210 } // namespace media 209 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser_mpeg1audio.h ('k') | media/formats/mp2t/es_parser_mpeg1audio_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698