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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 if (is_audio) | 557 if (is_audio) |
558 return !HasAudio() || !audio_decoder_job_->prerolling(); | 558 return !HasAudio() || !audio_decoder_job_->prerolling(); |
559 return !HasVideo() || !video_decoder_job_->prerolling(); | 559 return !HasVideo() || !video_decoder_job_->prerolling(); |
560 } | 560 } |
561 | 561 |
562 void MediaSourcePlayer::DecodeMoreAudio() { | 562 void MediaSourcePlayer::DecodeMoreAudio() { |
563 DVLOG(1) << __FUNCTION__; | 563 DVLOG(1) << __FUNCTION__; |
564 DCHECK(!audio_decoder_job_->is_decoding()); | 564 DCHECK(!audio_decoder_job_->is_decoding()); |
565 DCHECK(!AudioFinished()); | 565 DCHECK(!AudioFinished()); |
566 | 566 |
567 if (audio_decoder_job_->Decode( | 567 if (MediaDecoderJob::STATUS_SUCCESS == audio_decoder_job_->Decode( |
wolenetz
2015/02/04 21:07:23
nit: here and in DecodeMoreVideo(), use a switch t
qinmin
2015/02/04 23:11:23
Done.
| |
568 start_time_ticks_, | 568 start_time_ticks_, |
569 start_presentation_timestamp_, | 569 start_presentation_timestamp_, |
570 base::Bind(&MediaSourcePlayer::MediaDecoderCallback, weak_this_, true))) { | 570 base::Bind(&MediaSourcePlayer::MediaDecoderCallback, weak_this_, true))) { |
571 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreAudio", | 571 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreAudio", |
572 audio_decoder_job_.get()); | 572 audio_decoder_job_.get()); |
573 return; | 573 return; |
574 } | 574 } |
575 | 575 |
576 is_waiting_for_audio_decoder_ = true; | 576 is_waiting_for_audio_decoder_ = true; |
577 if (!IsEventPending(DECODER_CREATION_EVENT_PENDING)) | 577 if (!IsEventPending(DECODER_CREATION_EVENT_PENDING)) |
578 SetPendingEvent(DECODER_CREATION_EVENT_PENDING); | 578 SetPendingEvent(DECODER_CREATION_EVENT_PENDING); |
579 } | 579 } |
580 | 580 |
581 void MediaSourcePlayer::DecodeMoreVideo() { | 581 void MediaSourcePlayer::DecodeMoreVideo() { |
582 DVLOG(1) << __FUNCTION__; | 582 DVLOG(1) << __FUNCTION__; |
583 DCHECK(!video_decoder_job_->is_decoding()); | 583 DCHECK(!video_decoder_job_->is_decoding()); |
584 DCHECK(!VideoFinished()); | 584 DCHECK(!VideoFinished()); |
585 | 585 |
586 if (video_decoder_job_->Decode( | 586 MediaDecoderJob::MediaDecoderJobStatus status = video_decoder_job_->Decode( |
587 start_time_ticks_, | 587 start_time_ticks_, |
588 start_presentation_timestamp_, | 588 start_presentation_timestamp_, |
589 base::Bind(&MediaSourcePlayer::MediaDecoderCallback, weak_this_, | 589 base::Bind(&MediaSourcePlayer::MediaDecoderCallback, weak_this_, |
590 false))) { | 590 false)); |
591 if (status == MediaDecoderJob::STATUS_SUCCESS) { | |
591 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreVideo", | 592 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreVideo", |
592 video_decoder_job_.get()); | 593 video_decoder_job_.get()); |
593 return; | 594 return; |
594 } | 595 } |
595 | 596 |
596 // If the decoder is waiting for iframe, trigger a browser seek. | 597 // If the decoder is waiting for iframe, trigger a browser seek. |
597 if (!video_decoder_job_->next_video_data_is_iframe()) { | 598 if (status == MediaDecoderJob::STATUS_KEY_FRAME_REQUIRED) { |
598 BrowserSeekToCurrentTime(); | 599 BrowserSeekToCurrentTime(); |
599 return; | 600 return; |
600 } | 601 } |
601 | 602 |
602 is_waiting_for_video_decoder_ = true; | 603 is_waiting_for_video_decoder_ = true; |
603 if (!IsEventPending(DECODER_CREATION_EVENT_PENDING)) | 604 if (!IsEventPending(DECODER_CREATION_EVENT_PENDING)) |
604 SetPendingEvent(DECODER_CREATION_EVENT_PENDING); | 605 SetPendingEvent(DECODER_CREATION_EVENT_PENDING); |
605 } | 606 } |
606 | 607 |
607 void MediaSourcePlayer::PlaybackCompleted(bool is_audio) { | 608 void MediaSourcePlayer::PlaybackCompleted(bool is_audio) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 // support setMediaKeys(0) (see http://crbug.com/330324), or when we release | 808 // support setMediaKeys(0) (see http://crbug.com/330324), or when we release |
808 // MediaDrm when the video is paused, or when the device goes to sleep (see | 809 // MediaDrm when the video is paused, or when the device goes to sleep (see |
809 // http://crbug.com/272421). | 810 // http://crbug.com/272421). |
810 audio_decoder_job_->SetDrmBridge(NULL); | 811 audio_decoder_job_->SetDrmBridge(NULL); |
811 video_decoder_job_->SetDrmBridge(NULL); | 812 video_decoder_job_->SetDrmBridge(NULL); |
812 cdm_registration_id_ = 0; | 813 cdm_registration_id_ = 0; |
813 drm_bridge_ = NULL; | 814 drm_bridge_ = NULL; |
814 } | 815 } |
815 | 816 |
816 } // namespace media | 817 } // namespace media |
OLD | NEW |