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

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

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