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/mp2t_stream_parser.h" | 5 #include "media/formats/mp2t/mp2t_stream_parser.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 163 } |
164 | 164 |
165 void Mp2tStreamParser::Init( | 165 void Mp2tStreamParser::Init( |
166 const InitCB& init_cb, | 166 const InitCB& init_cb, |
167 const NewConfigCB& config_cb, | 167 const NewConfigCB& config_cb, |
168 const NewBuffersCB& new_buffers_cb, | 168 const NewBuffersCB& new_buffers_cb, |
169 bool /* ignore_text_tracks */, | 169 bool /* ignore_text_tracks */, |
170 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 170 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
171 const NewMediaSegmentCB& new_segment_cb, | 171 const NewMediaSegmentCB& new_segment_cb, |
172 const base::Closure& end_of_segment_cb, | 172 const base::Closure& end_of_segment_cb, |
173 const LogCB& log_cb) { | 173 const scoped_refptr<MediaLog>& media_log) { |
174 DCHECK(!is_initialized_); | 174 DCHECK(!is_initialized_); |
175 DCHECK(init_cb_.is_null()); | 175 DCHECK(init_cb_.is_null()); |
176 DCHECK(!init_cb.is_null()); | 176 DCHECK(!init_cb.is_null()); |
177 DCHECK(!config_cb.is_null()); | 177 DCHECK(!config_cb.is_null()); |
178 DCHECK(!new_buffers_cb.is_null()); | 178 DCHECK(!new_buffers_cb.is_null()); |
179 DCHECK(!encrypted_media_init_data_cb.is_null()); | 179 DCHECK(!encrypted_media_init_data_cb.is_null()); |
180 DCHECK(!end_of_segment_cb.is_null()); | 180 DCHECK(!end_of_segment_cb.is_null()); |
181 | 181 |
182 init_cb_ = init_cb; | 182 init_cb_ = init_cb; |
183 config_cb_ = config_cb; | 183 config_cb_ = config_cb; |
184 new_buffers_cb_ = new_buffers_cb; | 184 new_buffers_cb_ = new_buffers_cb; |
185 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; | 185 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; |
186 new_segment_cb_ = new_segment_cb; | 186 new_segment_cb_ = new_segment_cb; |
187 end_of_segment_cb_ = end_of_segment_cb; | 187 end_of_segment_cb_ = end_of_segment_cb; |
188 log_cb_ = log_cb; | 188 media_log_ = media_log; |
189 } | 189 } |
190 | 190 |
191 void Mp2tStreamParser::Flush() { | 191 void Mp2tStreamParser::Flush() { |
192 DVLOG(1) << "Mp2tStreamParser::Flush"; | 192 DVLOG(1) << "Mp2tStreamParser::Flush"; |
193 | 193 |
194 // Flush the buffers and reset the pids. | 194 // Flush the buffers and reset the pids. |
195 for (std::map<int, PidState*>::iterator it = pids_.begin(); | 195 for (std::map<int, PidState*>::iterator it = pids_.begin(); |
196 it != pids_.end(); ++it) { | 196 it != pids_.end(); ++it) { |
197 DVLOG(1) << "Flushing PID: " << it->first; | 197 DVLOG(1) << "Flushing PID: " << it->first; |
198 PidState* pid_state = it->second; | 198 PidState* pid_state = it->second; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 new EsParserAdts( | 344 new EsParserAdts( |
345 base::Bind(&Mp2tStreamParser::OnAudioConfigChanged, | 345 base::Bind(&Mp2tStreamParser::OnAudioConfigChanged, |
346 base::Unretained(this), | 346 base::Unretained(this), |
347 pes_pid), | 347 pes_pid), |
348 base::Bind(&Mp2tStreamParser::OnEmitAudioBuffer, | 348 base::Bind(&Mp2tStreamParser::OnEmitAudioBuffer, |
349 base::Unretained(this), | 349 base::Unretained(this), |
350 pes_pid), | 350 pes_pid), |
351 sbr_in_mimetype_)); | 351 sbr_in_mimetype_)); |
352 is_audio = true; | 352 is_audio = true; |
353 } else if (stream_type == kStreamTypeMpeg1Audio) { | 353 } else if (stream_type == kStreamTypeMpeg1Audio) { |
354 es_parser.reset( | 354 es_parser.reset(new EsParserMpeg1Audio( |
355 new EsParserMpeg1Audio( | 355 base::Bind(&Mp2tStreamParser::OnAudioConfigChanged, |
356 base::Bind(&Mp2tStreamParser::OnAudioConfigChanged, | 356 base::Unretained(this), pes_pid), |
357 base::Unretained(this), | 357 base::Bind(&Mp2tStreamParser::OnEmitAudioBuffer, base::Unretained(this), |
358 pes_pid), | 358 pes_pid), |
359 base::Bind(&Mp2tStreamParser::OnEmitAudioBuffer, | 359 media_log_)); |
360 base::Unretained(this), | |
361 pes_pid), | |
362 log_cb_)); | |
363 is_audio = true; | 360 is_audio = true; |
364 } else { | 361 } else { |
365 return; | 362 return; |
366 } | 363 } |
367 | 364 |
368 // Create the PES state here. | 365 // Create the PES state here. |
369 DVLOG(1) << "Create a new PES state"; | 366 DVLOG(1) << "Create a new PES state"; |
370 scoped_ptr<TsSection> pes_section_parser( | 367 scoped_ptr<TsSection> pes_section_parser( |
371 new TsSectionPes(es_parser.Pass(), ×tamp_unroller_)); | 368 new TsSectionPes(es_parser.Pass(), ×tamp_unroller_)); |
372 PidState::PidType pid_type = | 369 PidState::PidType pid_type = |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 // so that buffers with the same config can be added later on. | 623 // so that buffers with the same config can be added later on. |
627 BufferQueueWithConfig queue_with_config( | 624 BufferQueueWithConfig queue_with_config( |
628 true, last_audio_config, last_video_config); | 625 true, last_audio_config, last_video_config); |
629 buffer_queue_chain_.push_back(queue_with_config); | 626 buffer_queue_chain_.push_back(queue_with_config); |
630 | 627 |
631 return true; | 628 return true; |
632 } | 629 } |
633 | 630 |
634 } // namespace mp2t | 631 } // namespace mp2t |
635 } // namespace media | 632 } // namespace media |
OLD | NEW |