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