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

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

Issue 2460763002: Fixed track id remapping in MSE FrameProcessor (Closed)
Patch Set: Created 4 years, 1 month 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/frame_processor.cc ('k') | media/filters/source_buffer_state_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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/source_buffer_state.h" 5 #include "media/filters/source_buffer_state.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // during Flush or parser reset operations. 538 // during Flush or parser reset operations.
539 CHECK(append_in_progress_); 539 CHECK(append_in_progress_);
540 540
541 bool success = true; 541 bool success = true;
542 542
543 // TODO(wolenetz): Update codec string strictness, if necessary, once spec 543 // TODO(wolenetz): Update codec string strictness, if necessary, once spec
544 // issue https://github.com/w3c/media-source/issues/161 is resolved. 544 // issue https://github.com/w3c/media-source/issues/161 is resolved.
545 std::vector<AudioCodec> expected_acodecs = expected_audio_codecs_; 545 std::vector<AudioCodec> expected_acodecs = expected_audio_codecs_;
546 std::vector<VideoCodec> expected_vcodecs = expected_video_codecs_; 546 std::vector<VideoCodec> expected_vcodecs = expected_video_codecs_;
547 547
548 FrameProcessor::TrackIdChanges track_id_changes;
548 for (const auto& track : tracks->tracks()) { 549 for (const auto& track : tracks->tracks()) {
549 const auto& track_id = track->bytestream_track_id(); 550 const auto& track_id = track->bytestream_track_id();
550 551
551 if (track->type() == MediaTrack::Audio) { 552 if (track->type() == MediaTrack::Audio) {
552 AudioDecoderConfig audio_config = tracks->getAudioConfig(track_id); 553 AudioDecoderConfig audio_config = tracks->getAudioConfig(track_id);
553 DVLOG(1) << "Audio track_id=" << track_id 554 DVLOG(1) << "Audio track_id=" << track_id
554 << " config: " << audio_config.AsHumanReadableString(); 555 << " config: " << audio_config.AsHumanReadableString();
555 DCHECK(audio_config.IsValidConfig()); 556 DCHECK(audio_config.IsValidConfig());
556 557
557 const auto& it = std::find(expected_acodecs.begin(), 558 const auto& it = std::find(expected_acodecs.begin(),
(...skipping 23 matching lines...) Expand all
581 auto it = audio_streams_.find(track_id); 582 auto it = audio_streams_.find(track_id);
582 if (it != audio_streams_.end()) 583 if (it != audio_streams_.end())
583 stream = it->second; 584 stream = it->second;
584 } else { 585 } else {
585 // If there is only one audio track then bytestream id might change in 586 // If there is only one audio track then bytestream id might change in
586 // a new init segment. So update our state and notify frame processor. 587 // a new init segment. So update our state and notify frame processor.
587 const auto& it = audio_streams_.begin(); 588 const auto& it = audio_streams_.begin();
588 if (it != audio_streams_.end()) { 589 if (it != audio_streams_.end()) {
589 stream = it->second; 590 stream = it->second;
590 if (it->first != track_id) { 591 if (it->first != track_id) {
591 frame_processor_->UpdateTrack(it->first, track_id); 592 track_id_changes[it->first] = track_id;
592 audio_streams_[track_id] = stream; 593 audio_streams_[track_id] = stream;
593 audio_streams_.erase(it->first); 594 audio_streams_.erase(it->first);
594 } 595 }
595 } 596 }
596 } 597 }
597 if (!stream) { 598 if (!stream) {
598 MEDIA_LOG(ERROR, media_log_) << "Got unexpected audio track" 599 MEDIA_LOG(ERROR, media_log_) << "Got unexpected audio track"
599 << " track_id=" << track_id; 600 << " track_id=" << track_id;
600 return false; 601 return false;
601 } 602 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 auto it = video_streams_.find(track_id); 638 auto it = video_streams_.find(track_id);
638 if (it != video_streams_.end()) 639 if (it != video_streams_.end())
639 stream = it->second; 640 stream = it->second;
640 } else { 641 } else {
641 // If there is only one video track then bytestream id might change in 642 // If there is only one video track then bytestream id might change in
642 // a new init segment. So update our state and notify frame processor. 643 // a new init segment. So update our state and notify frame processor.
643 const auto& it = video_streams_.begin(); 644 const auto& it = video_streams_.begin();
644 if (it != video_streams_.end()) { 645 if (it != video_streams_.end()) {
645 stream = it->second; 646 stream = it->second;
646 if (it->first != track_id) { 647 if (it->first != track_id) {
647 frame_processor_->UpdateTrack(it->first, track_id); 648 track_id_changes[it->first] = track_id;
648 video_streams_[track_id] = stream; 649 video_streams_[track_id] = stream;
649 video_streams_.erase(it->first); 650 video_streams_.erase(it->first);
650 } 651 }
651 } 652 }
652 } 653 }
653 if (!stream) { 654 if (!stream) {
654 MEDIA_LOG(ERROR, media_log_) << "Got unexpected video track" 655 MEDIA_LOG(ERROR, media_log_) << "Got unexpected video track"
655 << " track_id=" << track_id; 656 << " track_id=" << track_id;
656 return false; 657 return false;
657 } 658 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 config_itr->second.kind(), config_itr->second.label(), 708 config_itr->second.kind(), config_itr->second.label(),
708 config_itr->second.language(), old_config.id()); 709 config_itr->second.language(), old_config.id());
709 if (!new_config.Matches(old_config)) { 710 if (!new_config.Matches(old_config)) {
710 success &= false; 711 success &= false;
711 MEDIA_LOG(ERROR, media_log_) 712 MEDIA_LOG(ERROR, media_log_)
712 << "New text track config does not match old one."; 713 << "New text track config does not match old one.";
713 } else { 714 } else {
714 StreamParser::TrackId old_id = stream_itr->first; 715 StreamParser::TrackId old_id = stream_itr->first;
715 StreamParser::TrackId new_id = config_itr->first; 716 StreamParser::TrackId new_id = config_itr->first;
716 if (new_id != old_id) { 717 if (new_id != old_id) {
717 if (frame_processor_->UpdateTrack(old_id, new_id)) { 718 track_id_changes[old_id] = new_id;
718 text_streams_.clear(); 719 text_streams_.erase(old_id);
719 text_streams_[config_itr->first] = text_stream; 720 text_streams_[new_id] = text_stream;
720 } else {
721 success &= false;
722 MEDIA_LOG(ERROR, media_log_)
723 << "Error remapping single text track number";
724 }
725 } 721 }
726 } 722 }
727 } else { 723 } else {
728 for (auto config_itr = text_configs.begin(); 724 for (auto config_itr = text_configs.begin();
729 config_itr != text_configs.end(); ++config_itr) { 725 config_itr != text_configs.end(); ++config_itr) {
730 auto stream_itr = text_streams_.find(config_itr->first); 726 auto stream_itr = text_streams_.find(config_itr->first);
731 if (stream_itr == text_streams_.end()) { 727 if (stream_itr == text_streams_.end()) {
732 success &= false; 728 success &= false;
733 MEDIA_LOG(ERROR, media_log_) 729 MEDIA_LOG(ERROR, media_log_)
734 << "Unexpected text track configuration for track ID " 730 << "Unexpected text track configuration for track ID "
(...skipping 13 matching lines...) Expand all
748 } 744 }
749 } 745 }
750 } 746 }
751 } 747 }
752 748
753 if (audio_streams_.empty() && video_streams_.empty()) { 749 if (audio_streams_.empty() && video_streams_.empty()) {
754 DVLOG(1) << __func__ << ": couldn't find a valid audio or video stream"; 750 DVLOG(1) << __func__ << ": couldn't find a valid audio or video stream";
755 return false; 751 return false;
756 } 752 }
757 753
754 if (!frame_processor_->UpdateTrackIds(track_id_changes)) {
755 DVLOG(1) << __func__ << ": failed to remap track ids in frame processor";
756 return false;
757 }
758
758 frame_processor_->SetAllTrackBuffersNeedRandomAccessPoint(); 759 frame_processor_->SetAllTrackBuffersNeedRandomAccessPoint();
759 760
760 if (!first_init_segment_received_) { 761 if (!first_init_segment_received_) {
761 first_init_segment_received_ = true; 762 first_init_segment_received_ = true;
762 SetStreamMemoryLimits(); 763 SetStreamMemoryLimits();
763 } 764 }
764 765
765 DVLOG(1) << "OnNewConfigs() : " << (success ? "success" : "failed"); 766 DVLOG(1) << "OnNewConfigs() : " << (success ? "success" : "failed");
766 if (success) { 767 if (success) {
767 if (state_ == PENDING_PARSER_CONFIG) 768 if (state_ == PENDING_PARSER_CONFIG)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 } 888 }
888 void SourceBufferState::OnSourceInitDone( 889 void SourceBufferState::OnSourceInitDone(
889 const StreamParser::InitParameters& params) { 890 const StreamParser::InitParameters& params) {
890 DCHECK_EQ(state_, PENDING_PARSER_INIT); 891 DCHECK_EQ(state_, PENDING_PARSER_INIT);
891 state_ = PARSER_INITIALIZED; 892 state_ = PARSER_INITIALIZED;
892 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; 893 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset;
893 base::ResetAndReturn(&init_cb_).Run(params); 894 base::ResetAndReturn(&init_cb_).Run(params);
894 } 895 }
895 896
896 } // namespace media 897 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/frame_processor.cc ('k') | media/filters/source_buffer_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698