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/media_source_state.h" | 5 #include "media/filters/media_source_state.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "media/base/media_track.h" | 9 #include "media/base/media_track.h" |
10 #include "media/base/media_tracks.h" | 10 #include "media/base/media_tracks.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DCHECK(!timestamp_offset_during_append_); | 163 DCHECK(!timestamp_offset_during_append_); |
164 append_window_start_during_append_ = append_window_start; | 164 append_window_start_during_append_ = append_window_start; |
165 append_window_end_during_append_ = append_window_end; | 165 append_window_end_during_append_ = append_window_end; |
166 timestamp_offset_during_append_ = timestamp_offset; | 166 timestamp_offset_during_append_ = timestamp_offset; |
167 | 167 |
168 // TODO(wolenetz/acolwell): Curry and pass a NewBuffersCB here bound with | 168 // TODO(wolenetz/acolwell): Curry and pass a NewBuffersCB here bound with |
169 // append window and timestamp offset pointer. See http://crbug.com/351454. | 169 // append window and timestamp offset pointer. See http://crbug.com/351454. |
170 bool result = stream_parser_->Parse(data, length); | 170 bool result = stream_parser_->Parse(data, length); |
171 if (!result) { | 171 if (!result) { |
172 MEDIA_LOG(ERROR, media_log_) | 172 MEDIA_LOG(ERROR, media_log_) |
173 << __FUNCTION__ << ": stream parsing failed." | 173 << __func__ << ": stream parsing failed. Data size=" << length |
174 << " Data size=" << length | |
175 << " append_window_start=" << append_window_start.InSecondsF() | 174 << " append_window_start=" << append_window_start.InSecondsF() |
176 << " append_window_end=" << append_window_end.InSecondsF(); | 175 << " append_window_end=" << append_window_end.InSecondsF(); |
177 } | 176 } |
178 timestamp_offset_during_append_ = NULL; | 177 timestamp_offset_during_append_ = NULL; |
179 append_in_progress_ = false; | 178 append_in_progress_ = false; |
180 return result; | 179 return result; |
181 } | 180 } |
182 | 181 |
183 void MediaSourceState::ResetParserState(TimeDelta append_window_start, | 182 void MediaSourceState::ResetParserState(TimeDelta append_window_start, |
184 TimeDelta append_window_end, | 183 TimeDelta append_window_end, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 CHECK_GE(videoRatio, 0.0); | 244 CHECK_GE(videoRatio, 0.0); |
246 CHECK_LE(videoRatio, 1.0); | 245 CHECK_LE(videoRatio, 1.0); |
247 double estimatedVideoSize = muxed_data_chunk_size * videoRatio; | 246 double estimatedVideoSize = muxed_data_chunk_size * videoRatio; |
248 return static_cast<size_t>(estimatedVideoSize); | 247 return static_cast<size_t>(estimatedVideoSize); |
249 } | 248 } |
250 | 249 |
251 bool MediaSourceState::EvictCodedFrames(DecodeTimestamp media_time, | 250 bool MediaSourceState::EvictCodedFrames(DecodeTimestamp media_time, |
252 size_t newDataSize) { | 251 size_t newDataSize) { |
253 bool success = true; | 252 bool success = true; |
254 | 253 |
255 DVLOG(3) << __FUNCTION__ << " media_time=" << media_time.InSecondsF() | 254 DVLOG(3) << __func__ << " media_time=" << media_time.InSecondsF() |
256 << " newDataSize=" << newDataSize | 255 << " newDataSize=" << newDataSize |
257 << " videoBufferedSize=" << (video_ ? video_->GetBufferedSize() : 0) | 256 << " videoBufferedSize=" << (video_ ? video_->GetBufferedSize() : 0) |
258 << " audioBufferedSize=" << (audio_ ? audio_->GetBufferedSize() : 0); | 257 << " audioBufferedSize=" << (audio_ ? audio_->GetBufferedSize() : 0); |
259 | 258 |
260 size_t newAudioSize = 0; | 259 size_t newAudioSize = 0; |
261 size_t newVideoSize = 0; | 260 size_t newVideoSize = 0; |
262 if (audio_ && video_) { | 261 if (audio_ && video_) { |
263 newVideoSize = EstimateVideoDataSize(newDataSize); | 262 newVideoSize = EstimateVideoDataSize(newDataSize); |
264 newAudioSize = newDataSize - newVideoSize; | 263 newAudioSize = newDataSize - newVideoSize; |
265 } else if (video_) { | 264 } else if (video_) { |
266 newVideoSize = newDataSize; | 265 newVideoSize = newDataSize; |
267 } else if (audio_) { | 266 } else if (audio_) { |
268 newAudioSize = newDataSize; | 267 newAudioSize = newDataSize; |
269 } | 268 } |
270 | 269 |
271 DVLOG(3) << __FUNCTION__ << " estimated audio/video sizes: " | 270 DVLOG(3) << __func__ |
272 << " newVideoSize=" << newVideoSize | 271 << " estimated audio/video sizes: newVideoSize=" << newVideoSize |
273 << " newAudioSize=" << newAudioSize; | 272 << " newAudioSize=" << newAudioSize; |
274 | 273 |
275 if (audio_) | 274 if (audio_) |
276 success = audio_->EvictCodedFrames(media_time, newAudioSize) && success; | 275 success = audio_->EvictCodedFrames(media_time, newAudioSize) && success; |
277 | 276 |
278 if (video_) | 277 if (video_) |
279 success = video_->EvictCodedFrames(media_time, newVideoSize) && success; | 278 success = video_->EvictCodedFrames(media_time, newVideoSize) && success; |
280 | 279 |
281 for (TextStreamMap::iterator itr = text_stream_map_.begin(); | 280 for (TextStreamMap::iterator itr = text_stream_map_.begin(); |
282 itr != text_stream_map_.end(); ++itr) { | 281 itr != text_stream_map_.end(); ++itr) { |
283 success = itr->second->EvictCodedFrames(media_time, 0) && success; | 282 success = itr->second->EvictCodedFrames(media_time, 0) && success; |
284 } | 283 } |
285 | 284 |
286 DVLOG(3) << __FUNCTION__ << " result=" << success | 285 DVLOG(3) << __func__ << " result=" << success |
287 << " videoBufferedSize=" << (video_ ? video_->GetBufferedSize() : 0) | 286 << " videoBufferedSize=" << (video_ ? video_->GetBufferedSize() : 0) |
288 << " audioBufferedSize=" << (audio_ ? audio_->GetBufferedSize() : 0); | 287 << " audioBufferedSize=" << (audio_ ? audio_->GetBufferedSize() : 0); |
289 | 288 |
290 return success; | 289 return success; |
291 } | 290 } |
292 | 291 |
293 Ranges<TimeDelta> MediaSourceState::GetBufferedRanges(TimeDelta duration, | 292 Ranges<TimeDelta> MediaSourceState::GetBufferedRanges(TimeDelta duration, |
294 bool ended) const { | 293 bool ended) const { |
295 // TODO(acolwell): When we start allowing disabled tracks we'll need to update | 294 // TODO(acolwell): When we start allowing disabled tracks we'll need to update |
296 // this code to only add ranges from active tracks. | 295 // this code to only add ranges from active tracks. |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 | 791 |
793 void MediaSourceState::OnSourceInitDone( | 792 void MediaSourceState::OnSourceInitDone( |
794 const StreamParser::InitParameters& params) { | 793 const StreamParser::InitParameters& params) { |
795 DCHECK_EQ(state_, PENDING_PARSER_INIT); | 794 DCHECK_EQ(state_, PENDING_PARSER_INIT); |
796 state_ = PARSER_INITIALIZED; | 795 state_ = PARSER_INITIALIZED; |
797 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; | 796 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; |
798 base::ResetAndReturn(&init_cb_).Run(params); | 797 base::ResetAndReturn(&init_cb_).Run(params); |
799 } | 798 } |
800 | 799 |
801 } // namespace media | 800 } // namespace media |
OLD | NEW |