| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_state.h" | 5 #include "media/filters/source_buffer_state.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 uint64_t estimated_new_size = newDataSize * curr_size / total_buffered_size; | 299 uint64_t estimated_new_size = newDataSize * curr_size / total_buffered_size; |
| 300 DCHECK_LE(estimated_new_size, SIZE_MAX); | 300 DCHECK_LE(estimated_new_size, SIZE_MAX); |
| 301 success &= it.second->EvictCodedFrames( | 301 success &= it.second->EvictCodedFrames( |
| 302 media_time, static_cast<size_t>(estimated_new_size)); | 302 media_time, static_cast<size_t>(estimated_new_size)); |
| 303 } | 303 } |
| 304 | 304 |
| 305 DVLOG(3) << __func__ << " success=" << success; | 305 DVLOG(3) << __func__ << " success=" << success; |
| 306 return success; | 306 return success; |
| 307 } | 307 } |
| 308 | 308 |
| 309 void SourceBufferState::OnMemoryPressure( |
| 310 DecodeTimestamp media_time, |
| 311 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, |
| 312 bool force_instant_gc) { |
| 313 // Notify video streams about memory pressure first, since video typically |
| 314 // takes up the most memory and that's where we can expect most savings. |
| 315 for (const auto& it : video_streams_) { |
| 316 it.second->OnMemoryPressure(media_time, memory_pressure_level, |
| 317 force_instant_gc); |
| 318 } |
| 319 for (const auto& it : audio_streams_) { |
| 320 it.second->OnMemoryPressure(media_time, memory_pressure_level, |
| 321 force_instant_gc); |
| 322 } |
| 323 for (const auto& it : text_streams_) { |
| 324 it.second->OnMemoryPressure(media_time, memory_pressure_level, |
| 325 force_instant_gc); |
| 326 } |
| 327 } |
| 328 |
| 309 Ranges<TimeDelta> SourceBufferState::GetBufferedRanges(TimeDelta duration, | 329 Ranges<TimeDelta> SourceBufferState::GetBufferedRanges(TimeDelta duration, |
| 310 bool ended) const { | 330 bool ended) const { |
| 311 RangesList ranges_list; | 331 RangesList ranges_list; |
| 312 for (const auto& it : audio_streams_) | 332 for (const auto& it : audio_streams_) |
| 313 ranges_list.push_back(it.second->GetBufferedRanges(duration)); | 333 ranges_list.push_back(it.second->GetBufferedRanges(duration)); |
| 314 | 334 |
| 315 for (const auto& it : video_streams_) | 335 for (const auto& it : video_streams_) |
| 316 ranges_list.push_back(it.second->GetBufferedRanges(duration)); | 336 ranges_list.push_back(it.second->GetBufferedRanges(duration)); |
| 317 | 337 |
| 318 for (const auto& it : text_streams_) | 338 for (const auto& it : text_streams_) |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 } | 908 } |
| 889 void SourceBufferState::OnSourceInitDone( | 909 void SourceBufferState::OnSourceInitDone( |
| 890 const StreamParser::InitParameters& params) { | 910 const StreamParser::InitParameters& params) { |
| 891 DCHECK_EQ(state_, PENDING_PARSER_INIT); | 911 DCHECK_EQ(state_, PENDING_PARSER_INIT); |
| 892 state_ = PARSER_INITIALIZED; | 912 state_ = PARSER_INITIALIZED; |
| 893 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; | 913 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; |
| 894 base::ResetAndReturn(&init_cb_).Run(params); | 914 base::ResetAndReturn(&init_cb_).Run(params); |
| 895 } | 915 } |
| 896 | 916 |
| 897 } // namespace media | 917 } // namespace media |
| OLD | NEW |