Chromium Code Reviews| 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 "content/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 stream_texture_factory_(factory), | 139 stream_texture_factory_(factory), |
| 140 needs_external_surface_(false), | 140 needs_external_surface_(false), |
| 141 video_frame_provider_client_(NULL), | 141 video_frame_provider_client_(NULL), |
| 142 pending_playback_(false), | 142 pending_playback_(false), |
| 143 player_type_(MEDIA_PLAYER_TYPE_URL), | 143 player_type_(MEDIA_PLAYER_TYPE_URL), |
| 144 current_time_(0), | 144 current_time_(0), |
| 145 is_remote_(false), | 145 is_remote_(false), |
| 146 media_log_(media_log), | 146 media_log_(media_log), |
| 147 web_cdm_(NULL), | 147 web_cdm_(NULL), |
| 148 allow_stored_credentials_(false), | 148 allow_stored_credentials_(false), |
| 149 is_local_resource_(false), | |
| 149 weak_factory_(this) { | 150 weak_factory_(this) { |
| 150 DCHECK(player_manager_); | 151 DCHECK(player_manager_); |
| 151 DCHECK(cdm_manager_); | 152 DCHECK(cdm_manager_); |
| 152 | 153 |
| 153 DCHECK(main_thread_checker_.CalledOnValidThread()); | 154 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 154 | 155 |
| 155 player_id_ = player_manager_->RegisterMediaPlayer(this); | 156 player_id_ = player_manager_->RegisterMediaPlayer(this); |
| 156 | 157 |
| 157 #if defined(VIDEO_HOLE) | 158 #if defined(VIDEO_HOLE) |
| 158 force_use_overlay_embedded_video_ = CommandLine::ForCurrentProcess()-> | 159 force_use_overlay_embedded_video_ = CommandLine::ForCurrentProcess()-> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE; | 210 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE; |
| 210 break; | 211 break; |
| 211 | 212 |
| 212 case LoadTypeMediaStream: | 213 case LoadTypeMediaStream: |
| 213 CHECK(false) << "WebMediaPlayerAndroid doesn't support MediaStream on " | 214 CHECK(false) << "WebMediaPlayerAndroid doesn't support MediaStream on " |
| 214 "this platform"; | 215 "this platform"; |
| 215 return; | 216 return; |
| 216 } | 217 } |
| 217 | 218 |
| 218 url_ = url; | 219 url_ = url; |
| 220 is_local_resource_ = url_.SchemeIsFile() || url_.SchemeIs("blob"); | |
|
amogh.bihani
2014/08/21 09:06:31
Ah! sorry I'll make it to SchemeIsBlob in next PS.
qinmin
2014/08/21 16:43:07
I think you should also check whether the address
| |
| 219 int demuxer_client_id = 0; | 221 int demuxer_client_id = 0; |
| 220 if (player_type_ != MEDIA_PLAYER_TYPE_URL) { | 222 if (player_type_ != MEDIA_PLAYER_TYPE_URL) { |
| 221 RendererDemuxerAndroid* demuxer = | 223 RendererDemuxerAndroid* demuxer = |
| 222 RenderThreadImpl::current()->renderer_demuxer(); | 224 RenderThreadImpl::current()->renderer_demuxer(); |
| 223 demuxer_client_id = demuxer->GetNextDemuxerClientID(); | 225 demuxer_client_id = demuxer->GetNextDemuxerClientID(); |
| 224 | 226 |
| 225 media_source_delegate_.reset(new MediaSourceDelegate( | 227 media_source_delegate_.reset(new MediaSourceDelegate( |
| 226 demuxer, demuxer_client_id, media_loop_, media_log_)); | 228 demuxer, demuxer_client_id, media_loop_, media_log_)); |
| 227 | 229 |
| 228 if (player_type_ == MEDIA_PLAYER_TYPE_MEDIA_SOURCE) { | 230 if (player_type_ == MEDIA_PLAYER_TYPE_MEDIA_SOURCE) { |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 return media_source_delegate_->VideoDecodedByteCount(); | 674 return media_source_delegate_->VideoDecodedByteCount(); |
| 673 NOTIMPLEMENTED(); | 675 NOTIMPLEMENTED(); |
| 674 return 0; | 676 return 0; |
| 675 } | 677 } |
| 676 | 678 |
| 677 void WebMediaPlayerAndroid::OnMediaMetadataChanged( | 679 void WebMediaPlayerAndroid::OnMediaMetadataChanged( |
| 678 const base::TimeDelta& duration, int width, int height, bool success) { | 680 const base::TimeDelta& duration, int width, int height, bool success) { |
| 679 DCHECK(main_thread_checker_.CalledOnValidThread()); | 681 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 680 bool need_to_signal_duration_changed = false; | 682 bool need_to_signal_duration_changed = false; |
| 681 | 683 |
| 682 if (url_.SchemeIs("file")) | 684 if (is_local_resource_) |
| 683 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); | 685 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); |
| 684 | 686 |
| 685 // Update duration, if necessary, prior to ready state updates that may | 687 // Update duration, if necessary, prior to ready state updates that may |
| 686 // cause duration() query. | 688 // cause duration() query. |
| 687 if (!ignore_metadata_duration_change_ && duration_ != duration) { | 689 if (!ignore_metadata_duration_change_ && duration_ != duration) { |
| 688 duration_ = duration; | 690 duration_ = duration; |
| 689 | 691 |
| 690 // Client readyState transition from HAVE_NOTHING to HAVE_METADATA | 692 // Client readyState transition from HAVE_NOTHING to HAVE_METADATA |
| 691 // already triggers a durationchanged event. If this is a different | 693 // already triggers a durationchanged event. If this is a different |
| 692 // transition, remember to signal durationchanged. | 694 // transition, remember to signal durationchanged. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 | 832 |
| 831 // TODO(qinmin): This is a hack. We need the media element to stop showing the | 833 // TODO(qinmin): This is a hack. We need the media element to stop showing the |
| 832 // poster image by forcing it to call setDisplayMode(video). Should move the | 834 // poster image by forcing it to call setDisplayMode(video). Should move the |
| 833 // logic into HTMLMediaElement.cpp. | 835 // logic into HTMLMediaElement.cpp. |
| 834 client_->timeChanged(); | 836 client_->timeChanged(); |
| 835 } | 837 } |
| 836 | 838 |
| 837 void WebMediaPlayerAndroid::OnTimeUpdate(const base::TimeDelta& current_time) { | 839 void WebMediaPlayerAndroid::OnTimeUpdate(const base::TimeDelta& current_time) { |
| 838 DCHECK(main_thread_checker_.CalledOnValidThread()); | 840 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 839 current_time_ = current_time.InSecondsF(); | 841 current_time_ = current_time.InSecondsF(); |
| 842 if (is_local_resource_ && current_time_ <= duration()) | |
| 843 buffered_[0].end = current_time_; | |
| 840 } | 844 } |
| 841 | 845 |
| 842 void WebMediaPlayerAndroid::OnConnectedToRemoteDevice( | 846 void WebMediaPlayerAndroid::OnConnectedToRemoteDevice( |
| 843 const std::string& remote_playback_message) { | 847 const std::string& remote_playback_message) { |
| 844 DCHECK(main_thread_checker_.CalledOnValidThread()); | 848 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 845 DCHECK(!media_source_delegate_); | 849 DCHECK(!media_source_delegate_); |
| 846 DrawRemotePlaybackText(remote_playback_message); | 850 DrawRemotePlaybackText(remote_playback_message); |
| 847 is_remote_ = true; | 851 is_remote_ = true; |
| 848 SetNeedsEstablishPeer(false); | 852 SetNeedsEstablishPeer(false); |
| 849 } | 853 } |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1721 player_manager_->EnterFullscreen(player_id_, frame_); | 1725 player_manager_->EnterFullscreen(player_id_, frame_); |
| 1722 SetNeedsEstablishPeer(false); | 1726 SetNeedsEstablishPeer(false); |
| 1723 } | 1727 } |
| 1724 } | 1728 } |
| 1725 | 1729 |
| 1726 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1730 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 1727 return player_manager_->CanEnterFullscreen(frame_); | 1731 return player_manager_->CanEnterFullscreen(frame_); |
| 1728 } | 1732 } |
| 1729 | 1733 |
| 1730 } // namespace content | 1734 } // namespace content |
| OLD | NEW |