OLD | NEW |
---|---|
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 bool has_video = false; | 281 bool has_video = false; |
282 bool has_audio = false; | 282 bool has_audio = false; |
283 scoped_refptr<media::VideoDecoder> new_decoder = | 283 scoped_refptr<media::VideoDecoder> new_decoder = |
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 | |
292 // TODO(vrk/wjia): This is under the assumption that the MediaStream | |
293 // represents a local webcam. This will need to change in the future when | |
294 // GetVideoDecoder is no longer hardcoded to only return | |
295 // CaptureVideoDecoders. | |
296 pipeline_->SetLocalSource(true); | |
scherkus (not reviewing)
2011/11/28 21:35:03
we should try to have a single way to set this att
| |
291 } | 297 } |
292 | 298 |
293 // TODO(wjia): add audio decoder handling when it's available. | 299 // TODO(wjia): add audio decoder handling when it's available. |
294 if (has_video || has_audio) | 300 if (has_video || has_audio) { |
295 filter_collection_->SetDemuxerFactory( | 301 filter_collection_->SetDemuxerFactory( |
296 new media::DummyDemuxerFactory(has_video, has_audio)); | 302 new media::DummyDemuxerFactory(has_video, has_audio)); |
303 } | |
297 } | 304 } |
298 | 305 |
299 // Handle any volume changes that occured before load(). | 306 // Handle any volume changes that occured before load(). |
300 setVolume(GetClient()->volume()); | 307 setVolume(GetClient()->volume()); |
301 // Get the preload value. | 308 // Get the preload value. |
302 setPreload(GetClient()->preload()); | 309 setPreload(GetClient()->preload()); |
303 | 310 |
304 // Initialize the pipeline. | 311 // Initialize the pipeline. |
305 SetNetworkState(WebKit::WebMediaPlayer::Loading); | 312 SetNetworkState(WebKit::WebMediaPlayer::Loading); |
306 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); | 313 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 new_buffered[0].start = 0.0f; | 746 new_buffered[0].start = 0.0f; |
740 new_buffered[0].end = | 747 new_buffered[0].end = |
741 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); | 748 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); |
742 buffered_.swap(new_buffered); | 749 buffered_.swap(new_buffered); |
743 | 750 |
744 if (hasVideo()) { | 751 if (hasVideo()) { |
745 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", | 752 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", |
746 is_accelerated_compositing_active_); | 753 is_accelerated_compositing_active_); |
747 } | 754 } |
748 | 755 |
749 if (pipeline_->IsLoaded()) | 756 if (pipeline_->IsLocalSource()) |
750 SetNetworkState(WebKit::WebMediaPlayer::Loaded); | 757 SetNetworkState(WebKit::WebMediaPlayer::Loaded); |
751 | 758 |
752 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); | 759 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); |
753 SetReadyState(WebKit::WebMediaPlayer::HaveFutureData); | 760 SetReadyState(WebKit::WebMediaPlayer::HaveFutureData); |
754 } else { | 761 } else { |
755 // TODO(hclam): should use |status| to determine the state | 762 // TODO(hclam): should use |status| to determine the state |
756 // properly and reports error using MediaError. | 763 // properly and reports error using MediaError. |
757 // WebKit uses FormatError to indicate an error for bogus URL or bad file. | 764 // WebKit uses FormatError to indicate an error for bogus URL or bad file. |
758 // Since we are at the initialization stage we can safely treat every error | 765 // Since we are at the initialization stage we can safely treat every error |
759 // as format error. Should post a task to call to |webmediaplayer_|. | 766 // as format error. Should post a task to call to |webmediaplayer_|. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 return client_; | 915 return client_; |
909 } | 916 } |
910 | 917 |
911 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 918 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
912 DCHECK_EQ(main_loop_, MessageLoop::current()); | 919 DCHECK_EQ(main_loop_, MessageLoop::current()); |
913 incremented_externally_allocated_memory_ = true; | 920 incremented_externally_allocated_memory_ = true; |
914 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 921 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
915 } | 922 } |
916 | 923 |
917 } // namespace webkit_media | 924 } // namespace webkit_media |
OLD | NEW |