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

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

Issue 2254093002: Return buffers from StreamParsers in a single unified map (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restored calling GetBuffers after each Parse in WebM test Created 4 years, 4 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/common/stream_parser_test_base.h » ('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/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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 kMaxMissingTrackInSegmentLogs) 769 kMaxMissingTrackInSegmentLogs)
770 << "Media segment did not contain any " 770 << "Media segment did not contain any "
771 << (missing_audio && missing_video ? "audio or video" 771 << (missing_audio && missing_video ? "audio or video"
772 : missing_audio ? "audio" : "video") 772 : missing_audio ? "audio" : "video")
773 << " coded frames, mismatching initialization segment. Therefore, MSE " 773 << " coded frames, mismatching initialization segment. Therefore, MSE "
774 "coded frame processing may not interoperably detect discontinuities " 774 "coded frame processing may not interoperably detect discontinuities "
775 "in appended media."; 775 "in appended media.";
776 } 776 }
777 777
778 bool MediaSourceState::OnNewBuffers( 778 bool MediaSourceState::OnNewBuffers(
779 const StreamParser::BufferQueue& audio_buffers, 779 const StreamParser::BufferQueueMap& buffer_queue_map) {
780 const StreamParser::BufferQueue& video_buffers,
781 const StreamParser::TextBufferQueueMap& text_map) {
782 DVLOG(2) << "OnNewBuffers()"; 780 DVLOG(2) << "OnNewBuffers()";
783 DCHECK_EQ(state_, PARSER_INITIALIZED); 781 DCHECK_EQ(state_, PARSER_INITIALIZED);
784 DCHECK(timestamp_offset_during_append_); 782 DCHECK(timestamp_offset_during_append_);
785 DCHECK(parsing_media_segment_); 783 DCHECK(parsing_media_segment_);
786 784
787 media_segment_contained_audio_frame_ |= !audio_buffers.empty(); 785 for (const auto& it : buffer_queue_map) {
788 media_segment_contained_video_frame_ |= !video_buffers.empty(); 786 const StreamParser::BufferQueue& bufq = it.second;
787 DCHECK(!bufq.empty());
788 if (bufq[0]->type() == DemuxerStream::AUDIO) {
789 media_segment_contained_audio_frame_ = true;
790 } else if (bufq[0]->type() == DemuxerStream::VIDEO) {
791 media_segment_contained_video_frame_ = true;
792 }
793 }
789 794
790 const TimeDelta timestamp_offset_before_processing = 795 const TimeDelta timestamp_offset_before_processing =
791 *timestamp_offset_during_append_; 796 *timestamp_offset_during_append_;
792 797
793 // Calculate the new timestamp offset for audio/video tracks if the stream 798 // Calculate the new timestamp offset for audio/video tracks if the stream
794 // parser has requested automatic updates. 799 // parser has requested automatic updates.
795 TimeDelta new_timestamp_offset = timestamp_offset_before_processing; 800 TimeDelta new_timestamp_offset = timestamp_offset_before_processing;
796 if (auto_update_timestamp_offset_) { 801 if (auto_update_timestamp_offset_) {
797 const bool have_audio_buffers = !audio_buffers.empty(); 802 TimeDelta min_end_timestamp = kNoTimestamp;
798 const bool have_video_buffers = !video_buffers.empty(); 803 for (const auto& it : buffer_queue_map) {
799 if (have_audio_buffers && have_video_buffers) { 804 const StreamParser::BufferQueue& bufq = it.second;
800 new_timestamp_offset += 805 DCHECK(!bufq.empty());
801 std::min(EndTimestamp(audio_buffers), EndTimestamp(video_buffers)); 806 if (min_end_timestamp == kNoTimestamp ||
802 } else if (have_audio_buffers) { 807 EndTimestamp(bufq) < min_end_timestamp) {
803 new_timestamp_offset += EndTimestamp(audio_buffers); 808 min_end_timestamp = EndTimestamp(bufq);
804 } else if (have_video_buffers) { 809 DCHECK_NE(kNoTimestamp, min_end_timestamp);
805 new_timestamp_offset += EndTimestamp(video_buffers); 810 }
806 } 811 }
812 if (min_end_timestamp != kNoTimestamp)
813 new_timestamp_offset += min_end_timestamp;
807 } 814 }
808 815
809 if (!frame_processor_->ProcessFrames(audio_buffers, video_buffers, text_map, 816 if (!frame_processor_->ProcessFrames(
810 append_window_start_during_append_, 817 buffer_queue_map, append_window_start_during_append_,
811 append_window_end_during_append_, 818 append_window_end_during_append_, timestamp_offset_during_append_)) {
812 timestamp_offset_during_append_)) {
813 return false; 819 return false;
814 } 820 }
815 821
816 // Only update the timestamp offset if the frame processor hasn't already. 822 // Only update the timestamp offset if the frame processor hasn't already.
817 if (auto_update_timestamp_offset_ && 823 if (auto_update_timestamp_offset_ &&
818 timestamp_offset_before_processing == *timestamp_offset_during_append_) { 824 timestamp_offset_before_processing == *timestamp_offset_during_append_) {
819 *timestamp_offset_during_append_ = new_timestamp_offset; 825 *timestamp_offset_during_append_ = new_timestamp_offset;
820 } 826 }
821 827
822 return true; 828 return true;
823 } 829 }
824 830
825 void MediaSourceState::OnSourceInitDone( 831 void MediaSourceState::OnSourceInitDone(
826 const StreamParser::InitParameters& params) { 832 const StreamParser::InitParameters& params) {
827 DCHECK_EQ(state_, PENDING_PARSER_INIT); 833 DCHECK_EQ(state_, PENDING_PARSER_INIT);
828 state_ = PARSER_INITIALIZED; 834 state_ = PARSER_INITIALIZED;
829 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; 835 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset;
830 base::ResetAndReturn(&init_cb_).Run(params); 836 base::ResetAndReturn(&init_cb_).Run(params);
831 } 837 }
832 838
833 } // namespace media 839 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/media_source_state.h ('k') | media/formats/common/stream_parser_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698