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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 CompleteConfigChange(); | 1229 CompleteConfigChange(); |
1209 return audio_configs_[current_config_index_]; | 1230 return audio_configs_[current_config_index_]; |
1210 } | 1231 } |
1211 | 1232 |
1212 const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() { | 1233 const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() { |
1213 if (config_change_pending_) | 1234 if (config_change_pending_) |
1214 CompleteConfigChange(); | 1235 CompleteConfigChange(); |
1215 return video_configs_[current_config_index_]; | 1236 return video_configs_[current_config_index_]; |
1216 } | 1237 } |
1217 | 1238 |
| 1239 const TextTrackConfig& SourceBufferStream::GetCurrentTextTrackConfig() { |
| 1240 return text_track_config_; |
| 1241 } |
| 1242 |
1218 base::TimeDelta SourceBufferStream::GetMaxInterbufferDistance() const { | 1243 base::TimeDelta SourceBufferStream::GetMaxInterbufferDistance() const { |
1219 if (max_interbuffer_distance_ == kNoTimestamp()) | 1244 if (max_interbuffer_distance_ == kNoTimestamp()) |
1220 return base::TimeDelta::FromMilliseconds(kDefaultBufferDurationInMs); | 1245 return base::TimeDelta::FromMilliseconds(kDefaultBufferDurationInMs); |
1221 return max_interbuffer_distance_; | 1246 return max_interbuffer_distance_; |
1222 } | 1247 } |
1223 | 1248 |
1224 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { | 1249 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { |
1225 DCHECK(!audio_configs_.empty()); | 1250 DCHECK(!audio_configs_.empty()); |
1226 DCHECK(video_configs_.empty()); | 1251 DCHECK(video_configs_.empty()); |
1227 DVLOG(3) << "UpdateAudioConfig."; | 1252 DVLOG(3) << "UpdateAudioConfig."; |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 return ComputeFudgeRoom(GetApproximateDuration()); | 1977 return ComputeFudgeRoom(GetApproximateDuration()); |
1953 } | 1978 } |
1954 | 1979 |
1955 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { | 1980 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { |
1956 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); | 1981 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); |
1957 DCHECK(max_interbuffer_distance != kNoTimestamp()); | 1982 DCHECK(max_interbuffer_distance != kNoTimestamp()); |
1958 return max_interbuffer_distance; | 1983 return max_interbuffer_distance; |
1959 } | 1984 } |
1960 | 1985 |
1961 } // namespace media | 1986 } // namespace media |
OLD | NEW |