| 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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 last_appended_buffer_timestamp_(kNoTimestamp()), | 361 last_appended_buffer_timestamp_(kNoTimestamp()), |
| 362 last_appended_buffer_is_keyframe_(false), | 362 last_appended_buffer_is_keyframe_(false), |
| 363 last_output_buffer_timestamp_(kNoTimestamp()), | 363 last_output_buffer_timestamp_(kNoTimestamp()), |
| 364 max_interbuffer_distance_(kNoTimestamp()), | 364 max_interbuffer_distance_(kNoTimestamp()), |
| 365 memory_limit_(kDefaultVideoMemoryLimit), | 365 memory_limit_(kDefaultVideoMemoryLimit), |
| 366 config_change_pending_(false) { | 366 config_change_pending_(false) { |
| 367 DCHECK(video_config.IsValidConfig()); | 367 DCHECK(video_config.IsValidConfig()); |
| 368 video_configs_.push_back(video_config); | 368 video_configs_.push_back(video_config); |
| 369 } | 369 } |
| 370 | 370 |
| 371 SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config, |
| 372 const LogCB& log_cb) |
| 373 : log_cb_(log_cb), |
| 374 current_config_index_(0), |
| 375 append_config_index_(0), |
| 376 text_track_config_(text_config), |
| 377 seek_pending_(false), |
| 378 end_of_stream_(false), |
| 379 seek_buffer_timestamp_(kNoTimestamp()), |
| 380 selected_range_(NULL), |
| 381 media_segment_start_time_(kNoTimestamp()), |
| 382 range_for_next_append_(ranges_.end()), |
| 383 new_media_segment_(false), |
| 384 last_appended_buffer_timestamp_(kNoTimestamp()), |
| 385 last_appended_buffer_is_keyframe_(false), |
| 386 last_output_buffer_timestamp_(kNoTimestamp()), |
| 387 max_interbuffer_distance_(kNoTimestamp()), |
| 388 memory_limit_(kDefaultAudioMemoryLimit), |
| 389 config_change_pending_(false) { |
| 390 } |
| 391 |
| 371 SourceBufferStream::~SourceBufferStream() { | 392 SourceBufferStream::~SourceBufferStream() { |
| 372 while (!ranges_.empty()) { | 393 while (!ranges_.empty()) { |
| 373 delete ranges_.front(); | 394 delete ranges_.front(); |
| 374 ranges_.pop_front(); | 395 ranges_.pop_front(); |
| 375 } | 396 } |
| 376 } | 397 } |
| 377 | 398 |
| 378 void SourceBufferStream::OnNewMediaSegment( | 399 void SourceBufferStream::OnNewMediaSegment( |
| 379 base::TimeDelta media_segment_start_time) { | 400 base::TimeDelta media_segment_start_time) { |
| 380 DCHECK(!end_of_stream_); | 401 DCHECK(!end_of_stream_); |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 CompleteConfigChange(); | 1227 CompleteConfigChange(); |
| 1207 return audio_configs_[current_config_index_]; | 1228 return audio_configs_[current_config_index_]; |
| 1208 } | 1229 } |
| 1209 | 1230 |
| 1210 const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() { | 1231 const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() { |
| 1211 if (config_change_pending_) | 1232 if (config_change_pending_) |
| 1212 CompleteConfigChange(); | 1233 CompleteConfigChange(); |
| 1213 return video_configs_[current_config_index_]; | 1234 return video_configs_[current_config_index_]; |
| 1214 } | 1235 } |
| 1215 | 1236 |
| 1237 const TextTrackConfig& SourceBufferStream::GetCurrentTextTrackConfig() { |
| 1238 return text_track_config_; |
| 1239 } |
| 1240 |
| 1216 base::TimeDelta SourceBufferStream::GetMaxInterbufferDistance() const { | 1241 base::TimeDelta SourceBufferStream::GetMaxInterbufferDistance() const { |
| 1217 if (max_interbuffer_distance_ == kNoTimestamp()) | 1242 if (max_interbuffer_distance_ == kNoTimestamp()) |
| 1218 return base::TimeDelta::FromMilliseconds(kDefaultBufferDurationInMs); | 1243 return base::TimeDelta::FromMilliseconds(kDefaultBufferDurationInMs); |
| 1219 return max_interbuffer_distance_; | 1244 return max_interbuffer_distance_; |
| 1220 } | 1245 } |
| 1221 | 1246 |
| 1222 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { | 1247 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { |
| 1223 DCHECK(!audio_configs_.empty()); | 1248 DCHECK(!audio_configs_.empty()); |
| 1224 DCHECK(video_configs_.empty()); | 1249 DCHECK(video_configs_.empty()); |
| 1225 DVLOG(3) << "UpdateAudioConfig."; | 1250 DVLOG(3) << "UpdateAudioConfig."; |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 return ComputeFudgeRoom(GetApproximateDuration()); | 1975 return ComputeFudgeRoom(GetApproximateDuration()); |
| 1951 } | 1976 } |
| 1952 | 1977 |
| 1953 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { | 1978 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { |
| 1954 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); | 1979 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); |
| 1955 DCHECK(max_interbuffer_distance != kNoTimestamp()); | 1980 DCHECK(max_interbuffer_distance != kNoTimestamp()); |
| 1956 return max_interbuffer_distance; | 1981 return max_interbuffer_distance; |
| 1957 } | 1982 } |
| 1958 | 1983 |
| 1959 } // namespace media | 1984 } // namespace media |
| OLD | NEW |