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

Side by Side Diff: media/mp2t/mp2t_stream_parser.cc

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix compile errors 11/21 #6 Created 7 years 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
« no previous file with comments | « media/mp2t/mp2t_stream_parser.h ('k') | media/mp2t/mp2t_stream_parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/mp2t/mp2t_stream_parser.h" 5 #include "media/mp2t/mp2t_stream_parser.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "media/base/audio_decoder_config.h" 10 #include "media/base/audio_decoder_config.h"
11 #include "media/base/buffers.h" 11 #include "media/base/buffers.h"
12 #include "media/base/stream_parser_buffer.h" 12 #include "media/base/stream_parser_buffer.h"
13 #include "media/base/text_track_config.h"
13 #include "media/base/video_decoder_config.h" 14 #include "media/base/video_decoder_config.h"
14 #include "media/mp2t/es_parser.h" 15 #include "media/mp2t/es_parser.h"
15 #include "media/mp2t/es_parser_adts.h" 16 #include "media/mp2t/es_parser_adts.h"
16 #include "media/mp2t/es_parser_h264.h" 17 #include "media/mp2t/es_parser_h264.h"
17 #include "media/mp2t/mp2t_common.h" 18 #include "media/mp2t/mp2t_common.h"
18 #include "media/mp2t/ts_packet.h" 19 #include "media/mp2t/ts_packet.h"
19 #include "media/mp2t/ts_section.h" 20 #include "media/mp2t/ts_section.h"
20 #include "media/mp2t/ts_section_pat.h" 21 #include "media/mp2t/ts_section_pat.h"
21 #include "media/mp2t/ts_section_pes.h" 22 #include "media/mp2t/ts_section_pes.h"
22 #include "media/mp2t/ts_section_pmt.h" 23 #include "media/mp2t/ts_section_pmt.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 160 }
160 161
161 Mp2tStreamParser::~Mp2tStreamParser() { 162 Mp2tStreamParser::~Mp2tStreamParser() {
162 STLDeleteValues(&pids_); 163 STLDeleteValues(&pids_);
163 } 164 }
164 165
165 void Mp2tStreamParser::Init( 166 void Mp2tStreamParser::Init(
166 const InitCB& init_cb, 167 const InitCB& init_cb,
167 const NewConfigCB& config_cb, 168 const NewConfigCB& config_cb,
168 const NewBuffersCB& new_buffers_cb, 169 const NewBuffersCB& new_buffers_cb,
169 const NewTextBuffersCB& text_cb, 170 const NewTextBuffersCB& /* text_cb */ ,
170 const NeedKeyCB& need_key_cb, 171 const NeedKeyCB& need_key_cb,
171 const AddTextTrackCB& add_text_track_cb,
172 const NewMediaSegmentCB& new_segment_cb, 172 const NewMediaSegmentCB& new_segment_cb,
173 const base::Closure& end_of_segment_cb, 173 const base::Closure& end_of_segment_cb,
174 const LogCB& log_cb) { 174 const LogCB& log_cb) {
175 DCHECK(!is_initialized_); 175 DCHECK(!is_initialized_);
176 DCHECK(init_cb_.is_null()); 176 DCHECK(init_cb_.is_null());
177 DCHECK(!init_cb.is_null()); 177 DCHECK(!init_cb.is_null());
178 DCHECK(!config_cb.is_null()); 178 DCHECK(!config_cb.is_null());
179 DCHECK(!new_buffers_cb.is_null()); 179 DCHECK(!new_buffers_cb.is_null());
180 DCHECK(!need_key_cb.is_null()); 180 DCHECK(!need_key_cb.is_null());
181 DCHECK(!end_of_segment_cb.is_null()); 181 DCHECK(!end_of_segment_cb.is_null());
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 BufferQueueWithConfig& queue_with_config = buffer_queue_chain_.front(); 469 BufferQueueWithConfig& queue_with_config = buffer_queue_chain_.front();
470 if (selected_audio_pid_ > 0 && 470 if (selected_audio_pid_ > 0 &&
471 !queue_with_config.audio_config.IsValidConfig()) 471 !queue_with_config.audio_config.IsValidConfig())
472 return true; 472 return true;
473 if (selected_video_pid_ > 0 && 473 if (selected_video_pid_ > 0 &&
474 !queue_with_config.video_config.IsValidConfig()) 474 !queue_with_config.video_config.IsValidConfig())
475 return true; 475 return true;
476 476
477 // Pass the config before invoking the initialization callback. 477 // Pass the config before invoking the initialization callback.
478 RCHECK(config_cb_.Run(queue_with_config.audio_config, 478 RCHECK(config_cb_.Run(queue_with_config.audio_config,
479 queue_with_config.video_config)); 479 queue_with_config.video_config,
480 TextTrackConfigMap()));
480 queue_with_config.is_config_sent = true; 481 queue_with_config.is_config_sent = true;
481 482
482 // For Mpeg2 TS, the duration is not known. 483 // For Mpeg2 TS, the duration is not known.
483 DVLOG(1) << "Mpeg2TS stream parser initialization done"; 484 DVLOG(1) << "Mpeg2TS stream parser initialization done";
484 init_cb_.Run(true, kInfiniteDuration()); 485 init_cb_.Run(true, kInfiniteDuration());
485 is_initialized_ = true; 486 is_initialized_ = true;
486 487
487 return true; 488 return true;
488 } 489 }
489 490
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 if (!segment_started_) { 579 if (!segment_started_) {
579 DVLOG(1) << "Starting a new segment"; 580 DVLOG(1) << "Starting a new segment";
580 segment_started_ = true; 581 segment_started_ = true;
581 new_segment_cb_.Run(); 582 new_segment_cb_.Run();
582 } 583 }
583 584
584 // Update the audio and video config if needed. 585 // Update the audio and video config if needed.
585 BufferQueueWithConfig& queue_with_config = buffer_queue_chain_.front(); 586 BufferQueueWithConfig& queue_with_config = buffer_queue_chain_.front();
586 if (!queue_with_config.is_config_sent) { 587 if (!queue_with_config.is_config_sent) {
587 if (!config_cb_.Run(queue_with_config.audio_config, 588 if (!config_cb_.Run(queue_with_config.audio_config,
588 queue_with_config.video_config)) 589 queue_with_config.video_config,
590 TextTrackConfigMap()))
589 return false; 591 return false;
590 queue_with_config.is_config_sent = true; 592 queue_with_config.is_config_sent = true;
591 } 593 }
592 594
593 // Add buffers. 595 // Add buffers.
594 if (!queue_with_config.audio_queue.empty() || 596 if (!queue_with_config.audio_queue.empty() ||
595 !queue_with_config.video_queue.empty()) { 597 !queue_with_config.video_queue.empty()) {
596 if (!new_buffers_cb_.Run(queue_with_config.audio_queue, 598 if (!new_buffers_cb_.Run(queue_with_config.audio_queue,
597 queue_with_config.video_queue)) { 599 queue_with_config.video_queue)) {
598 return false; 600 return false;
599 } 601 }
600 } 602 }
601 603
602 buffer_queue_chain_.pop_front(); 604 buffer_queue_chain_.pop_front();
603 } 605 }
604 606
605 // Push an empty queue with the last audio/video config 607 // Push an empty queue with the last audio/video config
606 // so that buffers with the same config can be added later on. 608 // so that buffers with the same config can be added later on.
607 BufferQueueWithConfig queue_with_config( 609 BufferQueueWithConfig queue_with_config(
608 true, last_audio_config, last_video_config); 610 true, last_audio_config, last_video_config);
609 buffer_queue_chain_.push_back(queue_with_config); 611 buffer_queue_chain_.push_back(queue_with_config);
610 612
611 return true; 613 return true;
612 } 614 }
613 615
614 } // namespace mp2t 616 } // namespace mp2t
615 } // namespace media 617 } // namespace media
616 618
OLDNEW
« no previous file with comments | « media/mp2t/mp2t_stream_parser.h ('k') | media/mp2t/mp2t_stream_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698