| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 is_local 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 Loading... |
| 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 SetReadyState(WebKit::WebMediaPlayer::HaveFutureData); | 758 SetReadyState(WebKit::WebMediaPlayer::HaveFutureData); |
| 754 } else { | 759 } else { |
| 755 // TODO(hclam): should use |status| to determine the state | 760 // TODO(hclam): should use |status| to determine the state |
| 756 // properly and reports error using MediaError. | 761 // properly and reports error using MediaError. |
| 757 // 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. |
| 758 // 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 |
| 759 // as format error. Should post a task to call to |webmediaplayer_|. | 764 // 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_; | 913 return client_; |
| 909 } | 914 } |
| 910 | 915 |
| 911 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 916 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 912 DCHECK_EQ(main_loop_, MessageLoop::current()); | 917 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 913 incremented_externally_allocated_memory_ = true; | 918 incremented_externally_allocated_memory_ = true; |
| 914 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 919 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 915 } | 920 } |
| 916 | 921 |
| 917 } // namespace webkit_media | 922 } // namespace webkit_media |
| OLD | NEW |