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

Side by Side Diff: media/filters/media_source_state.cc

Issue 2050043002: Generate and assign media track ids in demuxers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-streamparser-trackid
Patch Set: rebase to ToT Created 4 years, 6 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
« no previous file with comments | « media/filters/media_source_state.h ('k') | media/formats/mp4/mp4_stream_parser.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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/filters/media_source_state.h" 5 #include "media/filters/media_source_state.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "media/base/media_track.h" 9 #include "media/base/media_track.h"
10 #include "media/base/media_tracks.h" 10 #include "media/base/media_tracks.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void MediaSourceState::SetGroupStartTimestampIfInSequenceMode( 144 void MediaSourceState::SetGroupStartTimestampIfInSequenceMode(
145 base::TimeDelta timestamp_offset) { 145 base::TimeDelta timestamp_offset) {
146 DCHECK(!parsing_media_segment_); 146 DCHECK(!parsing_media_segment_);
147 147
148 frame_processor_->SetGroupStartTimestampIfInSequenceMode(timestamp_offset); 148 frame_processor_->SetGroupStartTimestampIfInSequenceMode(timestamp_offset);
149 } 149 }
150 150
151 void MediaSourceState::SetTracksWatcher( 151 void MediaSourceState::SetTracksWatcher(
152 const Demuxer::MediaTracksUpdatedCB& tracks_updated_cb) { 152 const Demuxer::MediaTracksUpdatedCB& tracks_updated_cb) {
153 DCHECK(init_segment_received_cb_.is_null()); 153 DCHECK(init_segment_received_cb_.is_null());
154 DCHECK(!tracks_updated_cb.is_null());
154 init_segment_received_cb_ = tracks_updated_cb; 155 init_segment_received_cb_ = tracks_updated_cb;
155 DCHECK(!init_segment_received_cb_.is_null());
156 } 156 }
157 157
158 bool MediaSourceState::Append(const uint8_t* data, 158 bool MediaSourceState::Append(const uint8_t* data,
159 size_t length, 159 size_t length,
160 TimeDelta append_window_start, 160 TimeDelta append_window_start,
161 TimeDelta append_window_end, 161 TimeDelta append_window_end,
162 TimeDelta* timestamp_offset) { 162 TimeDelta* timestamp_offset) {
163 append_in_progress_ = true; 163 append_in_progress_ = true;
164 DCHECK(timestamp_offset); 164 DCHECK(timestamp_offset);
165 DCHECK(!timestamp_offset_during_append_); 165 DCHECK(!timestamp_offset_during_append_);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 474 }
475 475
476 bool MediaSourceState::OnNewConfigs( 476 bool MediaSourceState::OnNewConfigs(
477 bool allow_audio, 477 bool allow_audio,
478 bool allow_video, 478 bool allow_video,
479 std::unique_ptr<MediaTracks> tracks, 479 std::unique_ptr<MediaTracks> tracks,
480 const StreamParser::TextTrackConfigMap& text_configs) { 480 const StreamParser::TextTrackConfigMap& text_configs) {
481 DCHECK_GE(state_, PENDING_PARSER_CONFIG); 481 DCHECK_GE(state_, PENDING_PARSER_CONFIG);
482 DCHECK(tracks.get()); 482 DCHECK(tracks.get());
483 483
484 media_tracks_ = std::move(tracks); 484 MediaTrack* audio_track = nullptr;
485 const AudioDecoderConfig& audio_config = media_tracks_->getFirstAudioConfig(); 485 MediaTrack* video_track = nullptr;
486 const VideoDecoderConfig& video_config = media_tracks_->getFirstVideoConfig(); 486 AudioDecoderConfig audio_config;
487 VideoDecoderConfig video_config;
488 for (const auto& track : tracks->tracks()) {
489 const auto& track_id = track->bytestream_track_id();
490
491 if (track->type() == MediaTrack::Audio) {
492 if (audio_track) {
493 MEDIA_LOG(ERROR, media_log_)
494 << "Error: more than one audio track is currently not supported.";
495 return false;
496 }
497 audio_track = track.get();
498 audio_config = tracks->getAudioConfig(track_id);
499 DCHECK(audio_config.IsValidConfig());
500 } else if (track->type() == MediaTrack::Video) {
501 if (video_track) {
502 MEDIA_LOG(ERROR, media_log_)
503 << "Error: more than one video track is currently not supported.";
504 return false;
505 }
506 video_track = track.get();
507 video_config = tracks->getVideoConfig(track_id);
508 DCHECK(video_config.IsValidConfig());
509 } else {
510 MEDIA_LOG(ERROR, media_log_) << "Error: unsupported media track type "
511 << track->type();
512 return false;
513 }
514 }
487 515
488 DVLOG(1) << "OnNewConfigs(" << allow_audio << ", " << allow_video << ", " 516 DVLOG(1) << "OnNewConfigs(" << allow_audio << ", " << allow_video << ", "
489 << audio_config.IsValidConfig() << ", " 517 << audio_config.IsValidConfig() << ", "
490 << video_config.IsValidConfig() << ")"; 518 << video_config.IsValidConfig() << ")";
491 // MSE spec allows new configs to be emitted only during Append, but not 519 // MSE spec allows new configs to be emitted only during Append, but not
492 // during Flush or parser reset operations. 520 // during Flush or parser reset operations.
493 CHECK(append_in_progress_); 521 CHECK(append_in_progress_);
494 522
495 if (!audio_config.IsValidConfig() && !video_config.IsValidConfig()) { 523 if (!audio_config.IsValidConfig() && !video_config.IsValidConfig()) {
496 DVLOG(1) << "OnNewConfigs() : Audio & video config are not valid!"; 524 DVLOG(1) << "OnNewConfigs() : Audio & video config are not valid!";
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 << config_itr->first 673 << config_itr->first
646 << " does not match old one."; 674 << " does not match old one.";
647 break; 675 break;
648 } 676 }
649 } 677 }
650 } 678 }
651 } 679 }
652 680
653 frame_processor_->SetAllTrackBuffersNeedRandomAccessPoint(); 681 frame_processor_->SetAllTrackBuffersNeedRandomAccessPoint();
654 682
683 if (audio_track) {
684 DCHECK(audio_);
685 audio_track->set_id(audio_->media_track_id());
686 }
687 if (video_track) {
688 DCHECK(video_);
689 video_track->set_id(video_->media_track_id());
690 }
691
655 DVLOG(1) << "OnNewConfigs() : " << (success ? "success" : "failed"); 692 DVLOG(1) << "OnNewConfigs() : " << (success ? "success" : "failed");
656 if (success) { 693 if (success) {
657 if (state_ == PENDING_PARSER_CONFIG) 694 if (state_ == PENDING_PARSER_CONFIG)
658 state_ = PENDING_PARSER_INIT; 695 state_ = PENDING_PARSER_INIT;
659 DCHECK(!init_segment_received_cb_.is_null()); 696 DCHECK(!init_segment_received_cb_.is_null());
660 init_segment_received_cb_.Run(std::move(media_tracks_)); 697 init_segment_received_cb_.Run(std::move(tracks));
661 } 698 }
662 699
663 return success; 700 return success;
664 } 701 }
665 702
666 void MediaSourceState::OnNewMediaSegment() { 703 void MediaSourceState::OnNewMediaSegment() {
667 DVLOG(2) << "OnNewMediaSegment()"; 704 DVLOG(2) << "OnNewMediaSegment()";
668 DCHECK_EQ(state_, PARSER_INITIALIZED); 705 DCHECK_EQ(state_, PARSER_INITIALIZED);
669 parsing_media_segment_ = true; 706 parsing_media_segment_ = true;
670 media_segment_contained_audio_frame_ = false; 707 media_segment_contained_audio_frame_ = false;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 777
741 void MediaSourceState::OnSourceInitDone( 778 void MediaSourceState::OnSourceInitDone(
742 const StreamParser::InitParameters& params) { 779 const StreamParser::InitParameters& params) {
743 DCHECK_EQ(state_, PENDING_PARSER_INIT); 780 DCHECK_EQ(state_, PENDING_PARSER_INIT);
744 state_ = PARSER_INITIALIZED; 781 state_ = PARSER_INITIALIZED;
745 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; 782 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset;
746 base::ResetAndReturn(&init_cb_).Run(params); 783 base::ResetAndReturn(&init_cb_).Run(params);
747 } 784 }
748 785
749 } // namespace media 786 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/media_source_state.h ('k') | media/formats/mp4/mp4_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698