| OLD | NEW |
| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 deleted_buffers.front()->GetDecodeTimestamp(); | 330 deleted_buffers.front()->GetDecodeTimestamp(); |
| 331 | 331 |
| 332 DCHECK(track_buffer_.empty() || | 332 DCHECK(track_buffer_.empty() || |
| 333 track_buffer_.back()->GetDecodeTimestamp() < start_of_deleted) | 333 track_buffer_.back()->GetDecodeTimestamp() < start_of_deleted) |
| 334 << "decode timestamp " | 334 << "decode timestamp " |
| 335 << track_buffer_.back()->GetDecodeTimestamp().InSecondsF() << " sec" | 335 << track_buffer_.back()->GetDecodeTimestamp().InSecondsF() << " sec" |
| 336 << ", start_of_deleted " << start_of_deleted.InSecondsF()<< " sec"; | 336 << ", start_of_deleted " << start_of_deleted.InSecondsF()<< " sec"; |
| 337 | 337 |
| 338 track_buffer_.insert(track_buffer_.end(), deleted_buffers.begin(), | 338 track_buffer_.insert(track_buffer_.end(), deleted_buffers.begin(), |
| 339 deleted_buffers.end()); | 339 deleted_buffers.end()); |
| 340 DVLOG(3) << __FUNCTION__ << " Added " << deleted_buffers.size() |
| 341 << " deleted buffers to track buffer. TB size is now " |
| 342 << track_buffer_.size(); |
| 343 } else { |
| 344 DVLOG(3) << __FUNCTION__ << " No deleted buffers for track buffer"; |
| 340 } | 345 } |
| 341 | 346 |
| 342 // Prune any extra buffers in |track_buffer_| if new keyframes | 347 // Prune any extra buffers in |track_buffer_| if new keyframes |
| 343 // are appended to the range covered by |track_buffer_|. | 348 // are appended to the range covered by |track_buffer_|. |
| 344 if (!track_buffer_.empty()) { | 349 if (!track_buffer_.empty()) { |
| 345 DecodeTimestamp keyframe_timestamp = | 350 DecodeTimestamp keyframe_timestamp = |
| 346 FindKeyframeAfterTimestamp(track_buffer_.front()->GetDecodeTimestamp()); | 351 FindKeyframeAfterTimestamp(track_buffer_.front()->GetDecodeTimestamp()); |
| 347 if (keyframe_timestamp != kNoDecodeTimestamp()) | 352 if (keyframe_timestamp != kNoDecodeTimestamp()) |
| 348 PruneTrackBuffer(keyframe_timestamp); | 353 PruneTrackBuffer(keyframe_timestamp); |
| 349 } | 354 } |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 const bool exclude_start = | 822 const bool exclude_start = |
| 818 new_buffers.front()->splice_buffers().empty() && | 823 new_buffers.front()->splice_buffers().empty() && |
| 819 prev_timestamp == next_timestamp && | 824 prev_timestamp == next_timestamp && |
| 820 SourceBufferRange::AllowSameTimestamp(prev_is_keyframe, next_is_keyframe); | 825 SourceBufferRange::AllowSameTimestamp(prev_is_keyframe, next_is_keyframe); |
| 821 | 826 |
| 822 // Delete the buffers that |new_buffers| overlaps. | 827 // Delete the buffers that |new_buffers| overlaps. |
| 823 DecodeTimestamp start = new_buffers.front()->GetDecodeTimestamp(); | 828 DecodeTimestamp start = new_buffers.front()->GetDecodeTimestamp(); |
| 824 DecodeTimestamp end = new_buffers.back()->GetDecodeTimestamp(); | 829 DecodeTimestamp end = new_buffers.back()->GetDecodeTimestamp(); |
| 825 base::TimeDelta duration = new_buffers.back()->duration(); | 830 base::TimeDelta duration = new_buffers.back()->duration(); |
| 826 | 831 |
| 827 if (duration != kNoTimestamp() && duration > base::TimeDelta()) { | 832 // Set end time for remove to include the duration of last buffer. If the |
| 833 // duration is estimated, use 1 microsecond instead to ensure frames are not |
| 834 // accidentally removed due to over-estimation. |
| 835 if (duration != kNoTimestamp() && duration > base::TimeDelta() && |
| 836 !new_buffers.back()->is_duration_estimated()) { |
| 828 end += duration; | 837 end += duration; |
| 829 } else { | 838 } else { |
| 830 // TODO(acolwell): Ensure all buffers actually have proper | 839 // TODO(chcunningham): Emit warning when 0ms durations are not expected. |
| 831 // duration info so that this hack isn't needed. | |
| 832 // http://crbug.com/312836 | 840 // http://crbug.com/312836 |
| 833 end += base::TimeDelta::FromInternalValue(1); | 841 end += base::TimeDelta::FromInternalValue(1); |
| 834 } | 842 } |
| 835 | 843 |
| 836 RemoveInternal(start, end, exclude_start, deleted_buffers); | 844 RemoveInternal(start, end, exclude_start, deleted_buffers); |
| 837 | 845 |
| 838 // Restore the range seek state if necessary. | 846 // Restore the range seek state if necessary. |
| 839 if (temporarily_select_range) | 847 if (temporarily_select_range) |
| 840 SetSelectedRange(NULL); | 848 SetSelectedRange(NULL); |
| 841 } | 849 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 scoped_refptr<StreamParserBuffer>& next_buffer = track_buffer_.front(); | 1078 scoped_refptr<StreamParserBuffer>& next_buffer = track_buffer_.front(); |
| 1071 | 1079 |
| 1072 // If the next buffer is an audio splice frame, the next effective config id | 1080 // If the next buffer is an audio splice frame, the next effective config id |
| 1073 // comes from the first splice buffer. | 1081 // comes from the first splice buffer. |
| 1074 if (next_buffer->GetSpliceBufferConfigId(0) != current_config_index_) { | 1082 if (next_buffer->GetSpliceBufferConfigId(0) != current_config_index_) { |
| 1075 config_change_pending_ = true; | 1083 config_change_pending_ = true; |
| 1076 DVLOG(1) << "Config change (track buffer config ID does not match)."; | 1084 DVLOG(1) << "Config change (track buffer config ID does not match)."; |
| 1077 return kConfigChange; | 1085 return kConfigChange; |
| 1078 } | 1086 } |
| 1079 | 1087 |
| 1088 DVLOG(3) << __FUNCTION__ << " Next buffer coming from track_buffer_"; |
| 1080 *out_buffer = next_buffer; | 1089 *out_buffer = next_buffer; |
| 1081 track_buffer_.pop_front(); | 1090 track_buffer_.pop_front(); |
| 1082 last_output_buffer_timestamp_ = (*out_buffer)->GetDecodeTimestamp(); | 1091 last_output_buffer_timestamp_ = (*out_buffer)->GetDecodeTimestamp(); |
| 1083 | 1092 |
| 1084 // If the track buffer becomes empty, then try to set the selected range | 1093 // If the track buffer becomes empty, then try to set the selected range |
| 1085 // based on the timestamp of this buffer being returned. | 1094 // based on the timestamp of this buffer being returned. |
| 1086 if (track_buffer_.empty()) | 1095 if (track_buffer_.empty()) |
| 1087 SetSelectedRangeIfNeeded(last_output_buffer_timestamp_); | 1096 SetSelectedRangeIfNeeded(last_output_buffer_timestamp_); |
| 1088 | 1097 |
| 1089 return kSuccess; | 1098 return kSuccess; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 return false; | 1575 return false; |
| 1567 | 1576 |
| 1568 DCHECK_NE(have_splice_buffers, have_preroll_buffer); | 1577 DCHECK_NE(have_splice_buffers, have_preroll_buffer); |
| 1569 splice_buffers_index_ = 0; | 1578 splice_buffers_index_ = 0; |
| 1570 pending_buffer_.swap(*out_buffer); | 1579 pending_buffer_.swap(*out_buffer); |
| 1571 pending_buffers_complete_ = false; | 1580 pending_buffers_complete_ = false; |
| 1572 return true; | 1581 return true; |
| 1573 } | 1582 } |
| 1574 | 1583 |
| 1575 } // namespace media | 1584 } // namespace media |
| OLD | NEW |