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

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

Issue 791723003: Use of the playback time in the MSE garbage collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/filters/source_buffer_stream.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_stream.h" 5 #include "media/filters/source_buffer_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config, 96 SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config,
97 const LogCB& log_cb, 97 const LogCB& log_cb,
98 bool splice_frames_enabled) 98 bool splice_frames_enabled)
99 : log_cb_(log_cb), 99 : log_cb_(log_cb),
100 current_config_index_(0), 100 current_config_index_(0),
101 append_config_index_(0), 101 append_config_index_(0),
102 seek_pending_(false), 102 seek_pending_(false),
103 end_of_stream_(false), 103 end_of_stream_(false),
104 seek_buffer_timestamp_(kNoTimestamp()), 104 seek_buffer_timestamp_(kNoTimestamp()),
105 selected_range_(NULL), 105 selected_range_(NULL),
106 current_media_time_(kNoDecodeTimestamp()),
106 media_segment_start_time_(kNoDecodeTimestamp()), 107 media_segment_start_time_(kNoDecodeTimestamp()),
107 range_for_next_append_(ranges_.end()), 108 range_for_next_append_(ranges_.end()),
108 new_media_segment_(false), 109 new_media_segment_(false),
109 last_appended_buffer_timestamp_(kNoDecodeTimestamp()), 110 last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
110 last_appended_buffer_is_keyframe_(false), 111 last_appended_buffer_is_keyframe_(false),
111 last_output_buffer_timestamp_(kNoDecodeTimestamp()), 112 last_output_buffer_timestamp_(kNoDecodeTimestamp()),
112 max_interbuffer_distance_(kNoTimestamp()), 113 max_interbuffer_distance_(kNoTimestamp()),
113 memory_limit_(kSourceBufferAudioMemoryLimit), 114 memory_limit_(kSourceBufferAudioMemoryLimit),
114 config_change_pending_(false), 115 config_change_pending_(false),
115 splice_buffers_index_(0), 116 splice_buffers_index_(0),
116 pending_buffers_complete_(false), 117 pending_buffers_complete_(false),
117 splice_frames_enabled_(splice_frames_enabled) { 118 splice_frames_enabled_(splice_frames_enabled) {
118 DCHECK(audio_config.IsValidConfig()); 119 DCHECK(audio_config.IsValidConfig());
119 audio_configs_.push_back(audio_config); 120 audio_configs_.push_back(audio_config);
120 } 121 }
121 122
122 SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config, 123 SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config,
123 const LogCB& log_cb, 124 const LogCB& log_cb,
124 bool splice_frames_enabled) 125 bool splice_frames_enabled)
125 : log_cb_(log_cb), 126 : log_cb_(log_cb),
126 current_config_index_(0), 127 current_config_index_(0),
127 append_config_index_(0), 128 append_config_index_(0),
128 seek_pending_(false), 129 seek_pending_(false),
129 end_of_stream_(false), 130 end_of_stream_(false),
130 seek_buffer_timestamp_(kNoTimestamp()), 131 seek_buffer_timestamp_(kNoTimestamp()),
131 selected_range_(NULL), 132 selected_range_(NULL),
133 current_media_time_(kNoDecodeTimestamp()),
132 media_segment_start_time_(kNoDecodeTimestamp()), 134 media_segment_start_time_(kNoDecodeTimestamp()),
133 range_for_next_append_(ranges_.end()), 135 range_for_next_append_(ranges_.end()),
134 new_media_segment_(false), 136 new_media_segment_(false),
135 last_appended_buffer_timestamp_(kNoDecodeTimestamp()), 137 last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
136 last_appended_buffer_is_keyframe_(false), 138 last_appended_buffer_is_keyframe_(false),
137 last_output_buffer_timestamp_(kNoDecodeTimestamp()), 139 last_output_buffer_timestamp_(kNoDecodeTimestamp()),
138 max_interbuffer_distance_(kNoTimestamp()), 140 max_interbuffer_distance_(kNoTimestamp()),
139 memory_limit_(kSourceBufferVideoMemoryLimit), 141 memory_limit_(kSourceBufferVideoMemoryLimit),
140 config_change_pending_(false), 142 config_change_pending_(false),
141 splice_buffers_index_(0), 143 splice_buffers_index_(0),
142 pending_buffers_complete_(false), 144 pending_buffers_complete_(false),
143 splice_frames_enabled_(splice_frames_enabled) { 145 splice_frames_enabled_(splice_frames_enabled) {
144 DCHECK(video_config.IsValidConfig()); 146 DCHECK(video_config.IsValidConfig());
145 video_configs_.push_back(video_config); 147 video_configs_.push_back(video_config);
146 } 148 }
147 149
148 SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config, 150 SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config,
149 const LogCB& log_cb, 151 const LogCB& log_cb,
150 bool splice_frames_enabled) 152 bool splice_frames_enabled)
151 : log_cb_(log_cb), 153 : log_cb_(log_cb),
152 current_config_index_(0), 154 current_config_index_(0),
153 append_config_index_(0), 155 append_config_index_(0),
154 text_track_config_(text_config), 156 text_track_config_(text_config),
155 seek_pending_(false), 157 seek_pending_(false),
156 end_of_stream_(false), 158 end_of_stream_(false),
157 seek_buffer_timestamp_(kNoTimestamp()), 159 seek_buffer_timestamp_(kNoTimestamp()),
158 selected_range_(NULL), 160 selected_range_(NULL),
161 current_media_time_(kNoDecodeTimestamp()),
159 media_segment_start_time_(kNoDecodeTimestamp()), 162 media_segment_start_time_(kNoDecodeTimestamp()),
160 range_for_next_append_(ranges_.end()), 163 range_for_next_append_(ranges_.end()),
161 new_media_segment_(false), 164 new_media_segment_(false),
162 last_appended_buffer_timestamp_(kNoDecodeTimestamp()), 165 last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
163 last_appended_buffer_is_keyframe_(false), 166 last_appended_buffer_is_keyframe_(false),
164 last_output_buffer_timestamp_(kNoDecodeTimestamp()), 167 last_output_buffer_timestamp_(kNoDecodeTimestamp()),
165 max_interbuffer_distance_(kNoTimestamp()), 168 max_interbuffer_distance_(kNoTimestamp()),
166 memory_limit_(kSourceBufferAudioMemoryLimit), 169 memory_limit_(kSourceBufferAudioMemoryLimit),
167 config_change_pending_(false), 170 config_change_pending_(false),
168 splice_buffers_index_(0), 171 splice_buffers_index_(0),
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 DCHECK_EQ(current_range, selected_range_); 703 DCHECK_EQ(current_range, selected_range_);
701 break; 704 break;
702 } 705 }
703 bytes_deleted = current_range->DeleteGOPFromBack(&buffers); 706 bytes_deleted = current_range->DeleteGOPFromBack(&buffers);
704 } else { 707 } else {
705 current_range = ranges_.front(); 708 current_range = ranges_.front();
706 if (current_range->FirstGOPContainsNextBufferPosition()) { 709 if (current_range->FirstGOPContainsNextBufferPosition()) {
707 DCHECK_EQ(current_range, selected_range_); 710 DCHECK_EQ(current_range, selected_range_);
708 break; 711 break;
709 } 712 }
713 if (current_media_time_ != kNoDecodeTimestamp() &&
714 !current_range->FirstGOPEarlierThanMediaTime(current_media_time_)) {
715 break;
716 }
710 bytes_deleted = current_range->DeleteGOPFromFront(&buffers); 717 bytes_deleted = current_range->DeleteGOPFromFront(&buffers);
711 } 718 }
712 719
713 // Check to see if we've just deleted the GOP that was last appended. 720 // Check to see if we've just deleted the GOP that was last appended.
714 DecodeTimestamp end_timestamp = buffers.back()->GetDecodeTimestamp(); 721 DecodeTimestamp end_timestamp = buffers.back()->GetDecodeTimestamp();
715 if (end_timestamp == last_appended_buffer_timestamp_) { 722 if (end_timestamp == last_appended_buffer_timestamp_) {
716 DCHECK(last_appended_buffer_timestamp_ != kNoDecodeTimestamp()); 723 DCHECK(last_appended_buffer_timestamp_ != kNoDecodeTimestamp());
717 DCHECK(!new_range_for_append); 724 DCHECK(!new_range_for_append);
718 // Create a new range containing these buffers. 725 // Create a new range containing these buffers.
719 new_range_for_append = new SourceBufferRange( 726 new_range_for_append = new SourceBufferRange(
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 // merges. 884 // merges.
878 if (transfer_current_position) 885 if (transfer_current_position)
879 SetSelectedRange(range_with_new_buffers); 886 SetSelectedRange(range_with_new_buffers);
880 887
881 if (next_range_itr == range_for_next_append_) 888 if (next_range_itr == range_for_next_append_)
882 range_for_next_append_ = range_with_new_buffers_itr; 889 range_for_next_append_ = range_with_new_buffers_itr;
883 890
884 DeleteAndRemoveRange(&next_range_itr); 891 DeleteAndRemoveRange(&next_range_itr);
885 } 892 }
886 893
894 void SourceBufferStream::NotifyMediaTimeUpdate(DecodeTimestamp media_time) {
895 if (current_media_time_ != kNoDecodeTimestamp() &&
896 media_time < current_media_time_) {
897 DLOG(WARNING) << "Time should be monotonically increasing: "
898 << media_time.InMilliseconds()
899 << " " << current_media_time_.InMilliseconds();
900 return;
901 }
902 current_media_time_ = media_time;
903 }
904
887 void SourceBufferStream::Seek(base::TimeDelta timestamp) { 905 void SourceBufferStream::Seek(base::TimeDelta timestamp) {
888 DCHECK(timestamp >= base::TimeDelta()); 906 DCHECK(timestamp >= base::TimeDelta());
889 DVLOG(1) << __FUNCTION__ << " " << GetStreamTypeName() 907 DVLOG(1) << __FUNCTION__ << " " << GetStreamTypeName()
890 << " (" << timestamp.InSecondsF() << ")"; 908 << " (" << timestamp.InSecondsF() << ")";
891 ResetSeekState(); 909 ResetSeekState();
910 current_media_time_ = kNoDecodeTimestamp();
892 911
893 if (ShouldSeekToStartOfBuffered(timestamp)) { 912 if (ShouldSeekToStartOfBuffered(timestamp)) {
894 ranges_.front()->SeekToStart(); 913 ranges_.front()->SeekToStart();
895 SetSelectedRange(ranges_.front()); 914 SetSelectedRange(ranges_.front());
896 seek_pending_ = false; 915 seek_pending_ = false;
897 return; 916 return;
898 } 917 }
899 918
900 seek_buffer_timestamp_ = timestamp; 919 seek_buffer_timestamp_ = timestamp;
901 seek_pending_ = true; 920 seek_pending_ = true;
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 return false; 1581 return false;
1563 1582
1564 DCHECK_NE(have_splice_buffers, have_preroll_buffer); 1583 DCHECK_NE(have_splice_buffers, have_preroll_buffer);
1565 splice_buffers_index_ = 0; 1584 splice_buffers_index_ = 0;
1566 pending_buffer_.swap(*out_buffer); 1585 pending_buffer_.swap(*out_buffer);
1567 pending_buffers_complete_ = false; 1586 pending_buffers_complete_ = false;
1568 return true; 1587 return true;
1569 } 1588 }
1570 1589
1571 } // namespace media 1590 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/source_buffer_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698