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

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

Issue 251903008: Fix incorrect config id being associated with post splice buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ChunkDemuxer test. Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/source_buffer_stream.h ('k') | media/filters/source_buffer_stream_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 (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 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 media_segment_start_time_(kNoTimestamp()), 352 media_segment_start_time_(kNoTimestamp()),
353 range_for_next_append_(ranges_.end()), 353 range_for_next_append_(ranges_.end()),
354 new_media_segment_(false), 354 new_media_segment_(false),
355 last_appended_buffer_timestamp_(kNoTimestamp()), 355 last_appended_buffer_timestamp_(kNoTimestamp()),
356 last_appended_buffer_is_keyframe_(false), 356 last_appended_buffer_is_keyframe_(false),
357 last_output_buffer_timestamp_(kNoTimestamp()), 357 last_output_buffer_timestamp_(kNoTimestamp()),
358 max_interbuffer_distance_(kNoTimestamp()), 358 max_interbuffer_distance_(kNoTimestamp()),
359 memory_limit_(kDefaultAudioMemoryLimit), 359 memory_limit_(kDefaultAudioMemoryLimit),
360 config_change_pending_(false), 360 config_change_pending_(false),
361 splice_buffers_index_(0), 361 splice_buffers_index_(0),
362 pre_splice_complete_(false),
362 splice_frames_enabled_(splice_frames_enabled) { 363 splice_frames_enabled_(splice_frames_enabled) {
363 DCHECK(audio_config.IsValidConfig()); 364 DCHECK(audio_config.IsValidConfig());
364 audio_configs_.push_back(audio_config); 365 audio_configs_.push_back(audio_config);
365 } 366 }
366 367
367 SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config, 368 SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config,
368 const LogCB& log_cb, 369 const LogCB& log_cb,
369 bool splice_frames_enabled) 370 bool splice_frames_enabled)
370 : log_cb_(log_cb), 371 : log_cb_(log_cb),
371 current_config_index_(0), 372 current_config_index_(0),
372 append_config_index_(0), 373 append_config_index_(0),
373 seek_pending_(false), 374 seek_pending_(false),
374 end_of_stream_(false), 375 end_of_stream_(false),
375 seek_buffer_timestamp_(kNoTimestamp()), 376 seek_buffer_timestamp_(kNoTimestamp()),
376 selected_range_(NULL), 377 selected_range_(NULL),
377 media_segment_start_time_(kNoTimestamp()), 378 media_segment_start_time_(kNoTimestamp()),
378 range_for_next_append_(ranges_.end()), 379 range_for_next_append_(ranges_.end()),
379 new_media_segment_(false), 380 new_media_segment_(false),
380 last_appended_buffer_timestamp_(kNoTimestamp()), 381 last_appended_buffer_timestamp_(kNoTimestamp()),
381 last_appended_buffer_is_keyframe_(false), 382 last_appended_buffer_is_keyframe_(false),
382 last_output_buffer_timestamp_(kNoTimestamp()), 383 last_output_buffer_timestamp_(kNoTimestamp()),
383 max_interbuffer_distance_(kNoTimestamp()), 384 max_interbuffer_distance_(kNoTimestamp()),
384 memory_limit_(kDefaultVideoMemoryLimit), 385 memory_limit_(kDefaultVideoMemoryLimit),
385 config_change_pending_(false), 386 config_change_pending_(false),
386 splice_buffers_index_(0), 387 splice_buffers_index_(0),
388 pre_splice_complete_(false),
387 splice_frames_enabled_(splice_frames_enabled) { 389 splice_frames_enabled_(splice_frames_enabled) {
388 DCHECK(video_config.IsValidConfig()); 390 DCHECK(video_config.IsValidConfig());
389 video_configs_.push_back(video_config); 391 video_configs_.push_back(video_config);
390 } 392 }
391 393
392 SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config, 394 SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config,
393 const LogCB& log_cb, 395 const LogCB& log_cb,
394 bool splice_frames_enabled) 396 bool splice_frames_enabled)
395 : log_cb_(log_cb), 397 : log_cb_(log_cb),
396 current_config_index_(0), 398 current_config_index_(0),
397 append_config_index_(0), 399 append_config_index_(0),
398 text_track_config_(text_config), 400 text_track_config_(text_config),
399 seek_pending_(false), 401 seek_pending_(false),
400 end_of_stream_(false), 402 end_of_stream_(false),
401 seek_buffer_timestamp_(kNoTimestamp()), 403 seek_buffer_timestamp_(kNoTimestamp()),
402 selected_range_(NULL), 404 selected_range_(NULL),
403 media_segment_start_time_(kNoTimestamp()), 405 media_segment_start_time_(kNoTimestamp()),
404 range_for_next_append_(ranges_.end()), 406 range_for_next_append_(ranges_.end()),
405 new_media_segment_(false), 407 new_media_segment_(false),
406 last_appended_buffer_timestamp_(kNoTimestamp()), 408 last_appended_buffer_timestamp_(kNoTimestamp()),
407 last_appended_buffer_is_keyframe_(false), 409 last_appended_buffer_is_keyframe_(false),
408 last_output_buffer_timestamp_(kNoTimestamp()), 410 last_output_buffer_timestamp_(kNoTimestamp()),
409 max_interbuffer_distance_(kNoTimestamp()), 411 max_interbuffer_distance_(kNoTimestamp()),
410 memory_limit_(kDefaultAudioMemoryLimit), 412 memory_limit_(kDefaultAudioMemoryLimit),
411 config_change_pending_(false), 413 config_change_pending_(false),
412 splice_buffers_index_(0), 414 splice_buffers_index_(0),
415 pre_splice_complete_(false),
413 splice_frames_enabled_(splice_frames_enabled) {} 416 splice_frames_enabled_(splice_frames_enabled) {}
414 417
415 SourceBufferStream::~SourceBufferStream() { 418 SourceBufferStream::~SourceBufferStream() {
416 while (!ranges_.empty()) { 419 while (!ranges_.empty()) {
417 delete ranges_.front(); 420 delete ranges_.front();
418 ranges_.pop_front(); 421 ranges_.pop_front();
419 } 422 }
420 } 423 }
421 424
422 void SourceBufferStream::OnNewMediaSegment( 425 void SourceBufferStream::OnNewMediaSegment(
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 DVLOG(1) << __FUNCTION__ << " : done"; 687 DVLOG(1) << __FUNCTION__ << " : done";
685 } 688 }
686 689
687 void SourceBufferStream::ResetSeekState() { 690 void SourceBufferStream::ResetSeekState() {
688 SetSelectedRange(NULL); 691 SetSelectedRange(NULL);
689 track_buffer_.clear(); 692 track_buffer_.clear();
690 config_change_pending_ = false; 693 config_change_pending_ = false;
691 last_output_buffer_timestamp_ = kNoTimestamp(); 694 last_output_buffer_timestamp_ = kNoTimestamp();
692 splice_buffers_index_ = 0; 695 splice_buffers_index_ = 0;
693 splice_buffer_ = NULL; 696 splice_buffer_ = NULL;
697 pre_splice_complete_ = false;
694 } 698 }
695 699
696 bool SourceBufferStream::ShouldSeekToStartOfBuffered( 700 bool SourceBufferStream::ShouldSeekToStartOfBuffered(
697 base::TimeDelta seek_timestamp) const { 701 base::TimeDelta seek_timestamp) const {
698 if (ranges_.empty()) 702 if (ranges_.empty())
699 return false; 703 return false;
700 base::TimeDelta beginning_of_buffered = 704 base::TimeDelta beginning_of_buffered =
701 ranges_.front()->GetStartTimestamp(); 705 ranges_.front()->GetStartTimestamp();
702 return (seek_timestamp <= beginning_of_buffered && 706 return (seek_timestamp <= beginning_of_buffered &&
703 beginning_of_buffered < kSeekToStartFudgeRoom()); 707 beginning_of_buffered < kSeekToStartFudgeRoom());
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 1167
1164 // Every pre splice buffer must have the same splice_timestamp(). 1168 // Every pre splice buffer must have the same splice_timestamp().
1165 DCHECK(splice_buffer_->splice_timestamp() == 1169 DCHECK(splice_buffer_->splice_timestamp() ==
1166 splice_buffers[splice_buffers_index_]->splice_timestamp()); 1170 splice_buffers[splice_buffers_index_]->splice_timestamp());
1167 1171
1168 *out_buffer = splice_buffers[splice_buffers_index_++]; 1172 *out_buffer = splice_buffers[splice_buffers_index_++];
1169 return SourceBufferStream::kSuccess; 1173 return SourceBufferStream::kSuccess;
1170 } 1174 }
1171 1175
1172 // Did we hand out the last pre-splice buffer on the previous call? 1176 // Did we hand out the last pre-splice buffer on the previous call?
1173 if (splice_buffers_index_ == last_splice_buffer_index) { 1177 if (!pre_splice_complete_) {
1174 splice_buffers_index_++; 1178 DCHECK_EQ(splice_buffers_index_, last_splice_buffer_index);
1179 pre_splice_complete_ = true;
1175 config_change_pending_ = true; 1180 config_change_pending_ = true;
1176 DVLOG(1) << "Config change (forced for fade in of splice frame)."; 1181 DVLOG(1) << "Config change (forced for fade in of splice frame).";
1177 return SourceBufferStream::kConfigChange; 1182 return SourceBufferStream::kConfigChange;
1178 } 1183 }
1179 1184
1180 // All pre-splice buffers have been handed out and a config change completed, 1185 // All pre-splice buffers have been handed out and a config change completed,
1181 // so hand out the final buffer for fade in. Because a config change is 1186 // so hand out the final buffer for fade in. Because a config change is
1182 // always issued prior to handing out this buffer, any changes in config id 1187 // always issued prior to handing out this buffer, any changes in config id
1183 // have been inherently handled. 1188 // have been inherently handled.
1184 DCHECK_GE(splice_buffers_index_, splice_buffers.size()); 1189 DCHECK(pre_splice_complete_);
1190 DCHECK_EQ(splice_buffers_index_, splice_buffers.size() - 1);
1185 DCHECK(splice_buffers.back()->splice_timestamp() == kNoTimestamp()); 1191 DCHECK(splice_buffers.back()->splice_timestamp() == kNoTimestamp());
1186 *out_buffer = splice_buffers.back(); 1192 *out_buffer = splice_buffers.back();
1187 splice_buffer_ = NULL; 1193 splice_buffer_ = NULL;
1188 splice_buffers_index_ = 0; 1194 splice_buffers_index_ = 0;
1195 pre_splice_complete_ = false;
1189 return SourceBufferStream::kSuccess; 1196 return SourceBufferStream::kSuccess;
1190 } 1197 }
1191 1198
1192 SourceBufferStream::Status SourceBufferStream::GetNextBufferInternal( 1199 SourceBufferStream::Status SourceBufferStream::GetNextBufferInternal(
1193 scoped_refptr<StreamParserBuffer>* out_buffer) { 1200 scoped_refptr<StreamParserBuffer>* out_buffer) {
1194 CHECK(!config_change_pending_); 1201 CHECK(!config_change_pending_);
1195 1202
1196 if (!track_buffer_.empty()) { 1203 if (!track_buffer_.empty()) {
1197 DCHECK(!selected_range_); 1204 DCHECK(!selected_range_);
1198 scoped_refptr<StreamParserBuffer>& next_buffer = track_buffer_.front(); 1205 scoped_refptr<StreamParserBuffer>& next_buffer = track_buffer_.front();
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 if (buffer->end_of_stream() || buffer->timestamp() >= end) 2200 if (buffer->end_of_stream() || buffer->timestamp() >= end)
2194 break; 2201 break;
2195 if (buffer->timestamp() + buffer->duration() <= start) 2202 if (buffer->timestamp() + buffer->duration() <= start)
2196 continue; 2203 continue;
2197 buffers->push_back(buffer); 2204 buffers->push_back(buffer);
2198 } 2205 }
2199 return previous_size < buffers->size(); 2206 return previous_size < buffers->size();
2200 } 2207 }
2201 2208
2202 } // namespace media 2209 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/source_buffer_stream.h ('k') | media/filters/source_buffer_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698