Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 8661002: Fire CanPlayThrough immediately for local and streaming media files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase ToT Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 media_stream_client_->GetVideoDecoder(url, message_loop_factory_.get()); 284 media_stream_client_->GetVideoDecoder(url, message_loop_factory_.get());
285 if (new_decoder.get()) { 285 if (new_decoder.get()) {
286 // Remove the default decoder. 286 // Remove the default decoder.
287 scoped_refptr<media::VideoDecoder> old_videodecoder; 287 scoped_refptr<media::VideoDecoder> old_videodecoder;
288 filter_collection_->SelectVideoDecoder(&old_videodecoder); 288 filter_collection_->SelectVideoDecoder(&old_videodecoder);
289 filter_collection_->AddVideoDecoder(new_decoder.get()); 289 filter_collection_->AddVideoDecoder(new_decoder.get());
290 has_video = true; 290 has_video = true;
291 } 291 }
292 292
293 // TODO(wjia): add audio decoder handling when it's available. 293 // TODO(wjia): add audio decoder handling when it's available.
294 if (has_video || has_audio) 294 if (has_video || has_audio) {
295 // TODO(vrk/wjia): Setting true for local_source is under the assumption
296 // that the MediaStream represents a local webcam. This will need to
297 // change in the future when GetVideoDecoder is no longer hardcoded to
298 // only return CaptureVideoDecoders.
295 filter_collection_->SetDemuxerFactory( 299 filter_collection_->SetDemuxerFactory(
296 new media::DummyDemuxerFactory(has_video, has_audio)); 300 new media::DummyDemuxerFactory(has_video, has_audio, true));
301 }
297 } 302 }
298 303
299 // Handle any volume changes that occured before load(). 304 // Handle any volume changes that occured before load().
300 setVolume(GetClient()->volume()); 305 setVolume(GetClient()->volume());
301 // Get the preload value. 306 // Get the preload value.
302 setPreload(GetClient()->preload()); 307 setPreload(GetClient()->preload());
303 308
304 // Initialize the pipeline. 309 // Initialize the pipeline.
305 SetNetworkState(WebKit::WebMediaPlayer::Loading); 310 SetNetworkState(WebKit::WebMediaPlayer::Loading);
306 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); 311 SetReadyState(WebKit::WebMediaPlayer::HaveNothing);
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 new_buffered[0].start = 0.0f; 744 new_buffered[0].start = 0.0f;
740 new_buffered[0].end = 745 new_buffered[0].end =
741 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); 746 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF());
742 buffered_.swap(new_buffered); 747 buffered_.swap(new_buffered);
743 748
744 if (hasVideo()) { 749 if (hasVideo()) {
745 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", 750 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive",
746 is_accelerated_compositing_active_); 751 is_accelerated_compositing_active_);
747 } 752 }
748 753
749 if (pipeline_->IsLoaded()) 754 if (pipeline_->IsLocalSource())
750 SetNetworkState(WebKit::WebMediaPlayer::Loaded); 755 SetNetworkState(WebKit::WebMediaPlayer::Loaded);
751 756
752 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); 757 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
753 // Fire canplaythrough immediately after playback begins because of 758 SetReadyState(WebKit::WebMediaPlayer::HaveFutureData);
754 // crbug.com/105163.
755 // TODO(vrk): set ready state to HaveFutureData when bug above is fixed.
756 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
757 } else { 759 } else {
758 // TODO(hclam): should use |status| to determine the state 760 // TODO(hclam): should use |status| to determine the state
759 // properly and reports error using MediaError. 761 // properly and reports error using MediaError.
760 // WebKit uses FormatError to indicate an error for bogus URL or bad file. 762 // WebKit uses FormatError to indicate an error for bogus URL or bad file.
761 // Since we are at the initialization stage we can safely treat every error 763 // Since we are at the initialization stage we can safely treat every error
762 // as format error. Should post a task to call to |webmediaplayer_|. 764 // as format error. Should post a task to call to |webmediaplayer_|.
763 SetNetworkState(WebKit::WebMediaPlayer::FormatError); 765 SetNetworkState(WebKit::WebMediaPlayer::FormatError);
764 } 766 }
765 767
766 // Repaint to trigger UI update. 768 // Repaint to trigger UI update.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) { 837 void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) {
836 DCHECK_EQ(main_loop_, MessageLoop::current()); 838 DCHECK_EQ(main_loop_, MessageLoop::current());
837 switch(type) { 839 switch(type) {
838 case media::DOWNLOAD_CONTINUED: 840 case media::DOWNLOAD_CONTINUED:
839 SetNetworkState(WebKit::WebMediaPlayer::Loading); 841 SetNetworkState(WebKit::WebMediaPlayer::Loading);
840 break; 842 break;
841 case media::DOWNLOAD_PAUSED: 843 case media::DOWNLOAD_PAUSED:
842 SetNetworkState(WebKit::WebMediaPlayer::Idle); 844 SetNetworkState(WebKit::WebMediaPlayer::Idle);
843 break; 845 break;
844 case media::CAN_PLAY_THROUGH: 846 case media::CAN_PLAY_THROUGH:
845 // Temporarily disable delayed firing of CAN_PLAY_THROUGH due to 847 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
846 // crbug.com/105163.
847 // TODO(vrk): uncomment code below when bug above is fixed.
848 // SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
849 break; 848 break;
850 default: 849 default:
851 NOTREACHED(); 850 NOTREACHED();
852 } 851 }
853 } 852 }
854 853
855 void WebMediaPlayerImpl::OnDemuxerOpened() { 854 void WebMediaPlayerImpl::OnDemuxerOpened() {
856 DCHECK_EQ(main_loop_, MessageLoop::current()); 855 DCHECK_EQ(main_loop_, MessageLoop::current());
857 856
858 GetClient()->sourceOpened(); 857 GetClient()->sourceOpened();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 return client_; 913 return client_;
915 } 914 }
916 915
917 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 916 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
918 DCHECK_EQ(main_loop_, MessageLoop::current()); 917 DCHECK_EQ(main_loop_, MessageLoop::current());
919 incremented_externally_allocated_memory_ = true; 918 incremented_externally_allocated_memory_ = true;
920 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 919 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
921 } 920 }
922 921
923 } // namespace webkit_media 922 } // namespace webkit_media
OLDNEW
« media/filters/dummy_demuxer.cc ('K') | « webkit/media/simple_data_source_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698