| 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 MediaDecoderJob::MediaDecoderJobStatus status = audio_decoder_job_->Decode( |
| 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 |
| 572 audio_decoder_job_.get()); | 572 switch (status) { |
| 573 return; | 573 case MediaDecoderJob::STATUS_SUCCESS: |
| 574 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreAudio", |
| 575 audio_decoder_job_.get()); |
| 576 break; |
| 577 case MediaDecoderJob::STATUS_KEY_FRAME_REQUIRED: |
| 578 NOTREACHED(); |
| 579 break; |
| 580 case MediaDecoderJob::STATUS_FAILURE: |
| 581 is_waiting_for_audio_decoder_ = true; |
| 582 if (!IsEventPending(DECODER_CREATION_EVENT_PENDING)) |
| 583 SetPendingEvent(DECODER_CREATION_EVENT_PENDING); |
| 584 break; |
| 574 } | 585 } |
| 575 | |
| 576 is_waiting_for_audio_decoder_ = true; | |
| 577 if (!IsEventPending(DECODER_CREATION_EVENT_PENDING)) | |
| 578 SetPendingEvent(DECODER_CREATION_EVENT_PENDING); | |
| 579 } | 586 } |
| 580 | 587 |
| 581 void MediaSourcePlayer::DecodeMoreVideo() { | 588 void MediaSourcePlayer::DecodeMoreVideo() { |
| 582 DVLOG(1) << __FUNCTION__; | 589 DVLOG(1) << __FUNCTION__; |
| 583 DCHECK(!video_decoder_job_->is_decoding()); | 590 DCHECK(!video_decoder_job_->is_decoding()); |
| 584 DCHECK(!VideoFinished()); | 591 DCHECK(!VideoFinished()); |
| 585 | 592 |
| 586 if (video_decoder_job_->Decode( | 593 MediaDecoderJob::MediaDecoderJobStatus status = video_decoder_job_->Decode( |
| 587 start_time_ticks_, | 594 start_time_ticks_, |
| 588 start_presentation_timestamp_, | 595 start_presentation_timestamp_, |
| 589 base::Bind(&MediaSourcePlayer::MediaDecoderCallback, weak_this_, | 596 base::Bind(&MediaSourcePlayer::MediaDecoderCallback, weak_this_, |
| 590 false))) { | 597 false)); |
| 591 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreVideo", | 598 |
| 592 video_decoder_job_.get()); | 599 switch (status) { |
| 593 return; | 600 case MediaDecoderJob::STATUS_SUCCESS: |
| 601 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreVideo", |
| 602 video_decoder_job_.get()); |
| 603 break; |
| 604 case MediaDecoderJob::STATUS_KEY_FRAME_REQUIRED: |
| 605 BrowserSeekToCurrentTime(); |
| 606 break; |
| 607 case MediaDecoderJob::STATUS_FAILURE: |
| 608 is_waiting_for_video_decoder_ = true; |
| 609 if (!IsEventPending(DECODER_CREATION_EVENT_PENDING)) |
| 610 SetPendingEvent(DECODER_CREATION_EVENT_PENDING); |
| 611 break; |
| 594 } | 612 } |
| 595 | |
| 596 // If the decoder is waiting for iframe, trigger a browser seek. | |
| 597 if (!video_decoder_job_->next_video_data_is_iframe()) { | |
| 598 BrowserSeekToCurrentTime(); | |
| 599 return; | |
| 600 } | |
| 601 | |
| 602 is_waiting_for_video_decoder_ = true; | |
| 603 if (!IsEventPending(DECODER_CREATION_EVENT_PENDING)) | |
| 604 SetPendingEvent(DECODER_CREATION_EVENT_PENDING); | |
| 605 } | 613 } |
| 606 | 614 |
| 607 void MediaSourcePlayer::PlaybackCompleted(bool is_audio) { | 615 void MediaSourcePlayer::PlaybackCompleted(bool is_audio) { |
| 608 DVLOG(1) << __FUNCTION__ << "(" << is_audio << ")"; | 616 DVLOG(1) << __FUNCTION__ << "(" << is_audio << ")"; |
| 609 | 617 |
| 610 if (AudioFinished() && VideoFinished()) { | 618 if (AudioFinished() && VideoFinished()) { |
| 611 playing_ = false; | 619 playing_ = false; |
| 612 start_time_ticks_ = base::TimeTicks(); | 620 start_time_ticks_ = base::TimeTicks(); |
| 613 manager()->OnPlaybackComplete(player_id()); | 621 manager()->OnPlaybackComplete(player_id()); |
| 614 } | 622 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 // support setMediaKeys(0) (see http://crbug.com/330324), or when we release | 815 // 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 | 816 // MediaDrm when the video is paused, or when the device goes to sleep (see |
| 809 // http://crbug.com/272421). | 817 // http://crbug.com/272421). |
| 810 audio_decoder_job_->SetDrmBridge(NULL); | 818 audio_decoder_job_->SetDrmBridge(NULL); |
| 811 video_decoder_job_->SetDrmBridge(NULL); | 819 video_decoder_job_->SetDrmBridge(NULL); |
| 812 cdm_registration_id_ = 0; | 820 cdm_registration_id_ = 0; |
| 813 drm_bridge_ = NULL; | 821 drm_bridge_ = NULL; |
| 814 } | 822 } |
| 815 | 823 |
| 816 } // namespace media | 824 } // namespace media |
| OLD | NEW |