| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", | 735 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", |
| 736 is_accelerated_compositing_active_); | 736 is_accelerated_compositing_active_); |
| 737 } else { | 737 } else { |
| 738 GetClient()->disableAcceleratedCompositing(); | 738 GetClient()->disableAcceleratedCompositing(); |
| 739 } | 739 } |
| 740 | 740 |
| 741 if (pipeline_->IsLocalSource()) | 741 if (pipeline_->IsLocalSource()) |
| 742 SetNetworkState(WebKit::WebMediaPlayer::Loaded); | 742 SetNetworkState(WebKit::WebMediaPlayer::Loaded); |
| 743 | 743 |
| 744 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); | 744 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); |
| 745 // Fire canplaythrough immediately after playback begins because of | 745 SetReadyState(WebKit::WebMediaPlayer::HaveFutureData); |
| 746 // crbug.com/106480. | |
| 747 // TODO(vrk): set ready state to HaveFutureData when bug above is fixed. | |
| 748 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); | |
| 749 } else { | 746 } else { |
| 750 // TODO(hclam): should use |status| to determine the state | 747 // TODO(hclam): should use |status| to determine the state |
| 751 // properly and reports error using MediaError. | 748 // properly and reports error using MediaError. |
| 752 // WebKit uses FormatError to indicate an error for bogus URL or bad file. | 749 // WebKit uses FormatError to indicate an error for bogus URL or bad file. |
| 753 // Since we are at the initialization stage we can safely treat every error | 750 // Since we are at the initialization stage we can safely treat every error |
| 754 // as format error. Should post a task to call to |webmediaplayer_|. | 751 // as format error. Should post a task to call to |webmediaplayer_|. |
| 755 SetNetworkState(WebKit::WebMediaPlayer::FormatError); | 752 SetNetworkState(WebKit::WebMediaPlayer::FormatError); |
| 756 } | 753 } |
| 757 | 754 |
| 758 // Repaint to trigger UI update. | 755 // Repaint to trigger UI update. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) { | 824 void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) { |
| 828 DCHECK_EQ(main_loop_, MessageLoop::current()); | 825 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 829 switch(type) { | 826 switch(type) { |
| 830 case media::DOWNLOAD_CONTINUED: | 827 case media::DOWNLOAD_CONTINUED: |
| 831 SetNetworkState(WebKit::WebMediaPlayer::Loading); | 828 SetNetworkState(WebKit::WebMediaPlayer::Loading); |
| 832 break; | 829 break; |
| 833 case media::DOWNLOAD_PAUSED: | 830 case media::DOWNLOAD_PAUSED: |
| 834 SetNetworkState(WebKit::WebMediaPlayer::Idle); | 831 SetNetworkState(WebKit::WebMediaPlayer::Idle); |
| 835 break; | 832 break; |
| 836 case media::CAN_PLAY_THROUGH: | 833 case media::CAN_PLAY_THROUGH: |
| 837 // Temporarily disable delayed firing of CAN_PLAY_THROUGH due to | 834 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); |
| 838 // crbug.com/106480. | |
| 839 // TODO(vrk): uncomment code below when bug above is fixed. | |
| 840 // SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); | |
| 841 break; | 835 break; |
| 842 default: | 836 default: |
| 843 NOTREACHED(); | 837 NOTREACHED(); |
| 844 } | 838 } |
| 845 } | 839 } |
| 846 | 840 |
| 847 void WebMediaPlayerImpl::OnDemuxerOpened() { | 841 void WebMediaPlayerImpl::OnDemuxerOpened() { |
| 848 DCHECK_EQ(main_loop_, MessageLoop::current()); | 842 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 849 | 843 |
| 850 GetClient()->sourceOpened(); | 844 GetClient()->sourceOpened(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 return audio_source_provider_; | 910 return audio_source_provider_; |
| 917 } | 911 } |
| 918 | 912 |
| 919 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 913 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 920 DCHECK_EQ(main_loop_, MessageLoop::current()); | 914 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 921 incremented_externally_allocated_memory_ = true; | 915 incremented_externally_allocated_memory_ = true; |
| 922 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 916 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 923 } | 917 } |
| 924 | 918 |
| 925 } // namespace webkit_media | 919 } // namespace webkit_media |
| OLD | NEW |