OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/base/android/media_source_player.h" | 5 #include "media/base/android/media_source_player.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 RetryDecoderCreation(false, true); | 97 RetryDecoderCreation(false, true); |
98 } | 98 } |
99 | 99 |
100 void MediaSourcePlayer::ScheduleSeekEventAndStopDecoding( | 100 void MediaSourcePlayer::ScheduleSeekEventAndStopDecoding( |
101 base::TimeDelta seek_time) { | 101 base::TimeDelta seek_time) { |
102 DVLOG(1) << __FUNCTION__ << "(" << seek_time.InSecondsF() << ")"; | 102 DVLOG(1) << __FUNCTION__ << "(" << seek_time.InSecondsF() << ")"; |
103 DCHECK(!IsEventPending(SEEK_EVENT_PENDING)); | 103 DCHECK(!IsEventPending(SEEK_EVENT_PENDING)); |
104 | 104 |
105 pending_seek_ = false; | 105 pending_seek_ = false; |
106 | 106 |
107 interpolator_.SetBounds(seek_time, seek_time); | 107 interpolator_.SetBounds(seek_time, seek_time, default_tick_clock_.NowTicks()); |
108 | 108 |
109 if (audio_decoder_job_->is_decoding()) | 109 if (audio_decoder_job_->is_decoding()) |
110 audio_decoder_job_->StopDecode(); | 110 audio_decoder_job_->StopDecode(); |
111 if (video_decoder_job_->is_decoding()) | 111 if (video_decoder_job_->is_decoding()) |
112 video_decoder_job_->StopDecode(); | 112 video_decoder_job_->StopDecode(); |
113 | 113 |
114 SetPendingEvent(SEEK_EVENT_PENDING); | 114 SetPendingEvent(SEEK_EVENT_PENDING); |
115 ProcessPendingEvents(); | 115 ProcessPendingEvents(); |
116 } | 116 } |
117 | 117 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // I-frame later than the requested one due to data removal or GC. Update | 359 // I-frame later than the requested one due to data removal or GC. Update |
360 // player clock to the actual seek target. | 360 // player clock to the actual seek target. |
361 if (doing_browser_seek_) { | 361 if (doing_browser_seek_) { |
362 DCHECK(actual_browser_seek_time != kNoTimestamp); | 362 DCHECK(actual_browser_seek_time != kNoTimestamp); |
363 base::TimeDelta seek_time = actual_browser_seek_time; | 363 base::TimeDelta seek_time = actual_browser_seek_time; |
364 // A browser seek must not jump into the past. Ideally, it seeks to the | 364 // A browser seek must not jump into the past. Ideally, it seeks to the |
365 // requested time, but it might jump into the future. | 365 // requested time, but it might jump into the future. |
366 DCHECK(seek_time >= GetCurrentTime()); | 366 DCHECK(seek_time >= GetCurrentTime()); |
367 DVLOG(1) << __FUNCTION__ << " : setting clock to actual browser seek time: " | 367 DVLOG(1) << __FUNCTION__ << " : setting clock to actual browser seek time: " |
368 << seek_time.InSecondsF(); | 368 << seek_time.InSecondsF(); |
369 interpolator_.SetBounds(seek_time, seek_time); | 369 interpolator_.SetBounds(seek_time, seek_time, |
| 370 default_tick_clock_.NowTicks()); |
370 audio_decoder_job_->SetBaseTimestamp(seek_time); | 371 audio_decoder_job_->SetBaseTimestamp(seek_time); |
371 } else { | 372 } else { |
372 DCHECK(actual_browser_seek_time == kNoTimestamp); | 373 DCHECK(actual_browser_seek_time == kNoTimestamp); |
373 } | 374 } |
374 | 375 |
375 base::TimeDelta current_time = GetCurrentTime(); | 376 base::TimeDelta current_time = GetCurrentTime(); |
376 // TODO(qinmin): Simplify the logic by using |start_presentation_timestamp_| | 377 // TODO(qinmin): Simplify the logic by using |start_presentation_timestamp_| |
377 // to preroll media decoder jobs. Currently |start_presentation_timestamp_| | 378 // to preroll media decoder jobs. Currently |start_presentation_timestamp_| |
378 // is calculated from decoder output, while preroll relies on the access | 379 // is calculated from decoder output, while preroll relies on the access |
379 // unit's timestamp. There are some differences between the two. | 380 // unit's timestamp. There are some differences between the two. |
380 preroll_timestamp_ = current_time; | 381 preroll_timestamp_ = current_time; |
381 if (HasAudio()) | 382 if (HasAudio()) |
382 audio_decoder_job_->BeginPrerolling(preroll_timestamp_); | 383 audio_decoder_job_->BeginPrerolling(preroll_timestamp_); |
383 if (HasVideo()) | 384 if (HasVideo()) |
384 video_decoder_job_->BeginPrerolling(preroll_timestamp_); | 385 video_decoder_job_->BeginPrerolling(preroll_timestamp_); |
385 prerolling_ = true; | 386 prerolling_ = true; |
386 | 387 |
387 if (!doing_browser_seek_) | 388 if (!doing_browser_seek_) |
388 manager()->OnSeekComplete(player_id(), current_time); | 389 manager()->OnSeekComplete(player_id(), current_time); |
389 | 390 |
390 ProcessPendingEvents(); | 391 ProcessPendingEvents(); |
391 } | 392 } |
392 | 393 |
393 void MediaSourcePlayer::UpdateTimestamps( | 394 void MediaSourcePlayer::UpdateTimestamps( |
394 base::TimeDelta current_presentation_timestamp, | 395 base::TimeDelta current_presentation_timestamp, |
395 base::TimeDelta max_presentation_timestamp) { | 396 base::TimeDelta max_presentation_timestamp) { |
| 397 base::TimeTicks now_ticks = default_tick_clock_.NowTicks(); |
396 interpolator_.SetBounds(current_presentation_timestamp, | 398 interpolator_.SetBounds(current_presentation_timestamp, |
397 max_presentation_timestamp); | 399 max_presentation_timestamp, now_ticks); |
398 manager()->OnTimeUpdate(player_id(), | 400 manager()->OnTimeUpdate(player_id(), GetCurrentTime(), now_ticks); |
399 GetCurrentTime(), | |
400 base::TimeTicks::Now()); | |
401 } | 401 } |
402 | 402 |
403 void MediaSourcePlayer::ProcessPendingEvents() { | 403 void MediaSourcePlayer::ProcessPendingEvents() { |
404 DVLOG(1) << __FUNCTION__ << " : 0x" << std::hex << pending_event_; | 404 DVLOG(1) << __FUNCTION__ << " : 0x" << std::hex << pending_event_; |
405 // Wait for all the decoding jobs to finish before processing pending tasks. | 405 // Wait for all the decoding jobs to finish before processing pending tasks. |
406 if (video_decoder_job_->is_decoding()) { | 406 if (video_decoder_job_->is_decoding()) { |
407 DVLOG(1) << __FUNCTION__ << " : A video job is still decoding."; | 407 DVLOG(1) << __FUNCTION__ << " : A video job is still decoding."; |
408 return; | 408 return; |
409 } | 409 } |
410 | 410 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 is_waiting_for_key_ = false; | 857 is_waiting_for_key_ = false; |
858 key_added_while_decode_pending_ = false; | 858 key_added_while_decode_pending_ = false; |
859 | 859 |
860 // StartInternal() will trigger a prefetch, where in most cases we'll just | 860 // StartInternal() will trigger a prefetch, where in most cases we'll just |
861 // use previously received data. | 861 // use previously received data. |
862 if (playing_) | 862 if (playing_) |
863 StartInternal(); | 863 StartInternal(); |
864 } | 864 } |
865 | 865 |
866 } // namespace media | 866 } // namespace media |
OLD | NEW |