OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
782 if (error == PIPELINE_ERROR_DECRYPT) | 782 if (error == PIPELINE_ERROR_DECRYPT) |
783 encrypted_media_support_.OnPipelineDecryptError(); | 783 encrypted_media_support_.OnPipelineDecryptError(); |
784 } | 784 } |
785 | 785 |
786 void WebMediaPlayerImpl::OnPipelineMetadata( | 786 void WebMediaPlayerImpl::OnPipelineMetadata( |
787 PipelineMetadata metadata) { | 787 PipelineMetadata metadata) { |
788 DVLOG(1) << __FUNCTION__; | 788 DVLOG(1) << __FUNCTION__; |
789 | 789 |
790 pipeline_metadata_ = metadata; | 790 pipeline_metadata_ = metadata; |
791 | 791 |
792 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", | 792 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, |
793 metadata.video_rotation, | |
794 VIDEO_ROTATION_MAX + 1); | 793 VIDEO_ROTATION_MAX + 1); |
795 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 794 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
796 | 795 |
797 if (hasVideo()) { | 796 if (hasVideo()) { |
798 DCHECK(!video_weblayer_); | 797 DCHECK(!video_weblayer_); |
799 scoped_refptr<cc::VideoLayer> layer = | 798 scoped_refptr<cc::VideoLayer> layer = |
800 cc::VideoLayer::Create(compositor_, pipeline_metadata_.video_rotation); | 799 cc::VideoLayer::Create(compositor_, pipeline_metadata_.video_rotation); |
801 | 800 |
802 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || | 801 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || |
803 pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) { | 802 pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) { |
(...skipping 13 matching lines...) Expand all Loading... | |
817 | 816 |
818 // Ignore buffering state changes until we've completed all outstanding seeks. | 817 // Ignore buffering state changes until we've completed all outstanding seeks. |
819 if (seeking_ || pending_seek_) | 818 if (seeking_ || pending_seek_) |
820 return; | 819 return; |
821 | 820 |
822 // TODO(scherkus): Handle other buffering states when Pipeline starts using | 821 // TODO(scherkus): Handle other buffering states when Pipeline starts using |
823 // them and translate them ready state changes http://crbug.com/144683 | 822 // them and translate them ready state changes http://crbug.com/144683 |
824 DCHECK_EQ(buffering_state, BUFFERING_HAVE_ENOUGH); | 823 DCHECK_EQ(buffering_state, BUFFERING_HAVE_ENOUGH); |
825 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); | 824 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); |
826 | 825 |
826 // If we were only tasked to preload and a play request hasn't come in yet, | |
827 // cancel the DataSource once it reaches the deferred state if it isn't | |
828 // already. Subsequent play requests will restart the DataSource. | |
829 if (preload_ == BufferedDataSource::METADATA && data_source_ && | |
830 !data_source_->IsStreaming() && !data_source_->media_has_played()) { | |
831 data_source_->CancelUponDeferral(); | |
832 } | |
xhwang
2015/03/26 07:21:55
Seems like |data_source_| knows the preload type,
DaleCurtis
2015/03/26 17:22:00
Great idea!
| |
833 | |
827 // Blink expects a timeChanged() in response to a seek(). | 834 // Blink expects a timeChanged() in response to a seek(). |
828 if (should_notify_time_changed_) | 835 if (should_notify_time_changed_) |
829 client_->timeChanged(); | 836 client_->timeChanged(); |
830 } | 837 } |
831 | 838 |
832 void WebMediaPlayerImpl::OnDemuxerOpened() { | 839 void WebMediaPlayerImpl::OnDemuxerOpened() { |
833 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 840 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
834 client_->mediaSourceOpened(new WebMediaSourceImpl( | 841 client_->mediaSourceOpened(new WebMediaSourceImpl( |
835 chunk_demuxer_, base::Bind(&LogMediaSourceError, media_log_))); | 842 chunk_demuxer_, base::Bind(&LogMediaSourceError, media_log_))); |
836 } | 843 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1035 | 1042 |
1036 // pause() may be called after playback has ended and the HTMLMediaElement | 1043 // pause() may be called after playback has ended and the HTMLMediaElement |
1037 // requires that currentTime() == duration() after ending. We want to ensure | 1044 // requires that currentTime() == duration() after ending. We want to ensure |
1038 // |paused_time_| matches currentTime() in this case or a future seek() may | 1045 // |paused_time_| matches currentTime() in this case or a future seek() may |
1039 // incorrectly discard what it thinks is a seek to the existing time. | 1046 // incorrectly discard what it thinks is a seek to the existing time. |
1040 paused_time_ = | 1047 paused_time_ = |
1041 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 1048 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
1042 } | 1049 } |
1043 | 1050 |
1044 } // namespace media | 1051 } // namespace media |
OLD | NEW |