| 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", | 694 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", |
| 695 is_accelerated_compositing_active_); | 695 is_accelerated_compositing_active_); |
| 696 } else { | 696 } else { |
| 697 GetClient()->disableAcceleratedCompositing(); | 697 GetClient()->disableAcceleratedCompositing(); |
| 698 } | 698 } |
| 699 | 699 |
| 700 if (pipeline_->IsLocalSource()) | 700 if (pipeline_->IsLocalSource()) |
| 701 SetNetworkState(WebKit::WebMediaPlayer::Loaded); | 701 SetNetworkState(WebKit::WebMediaPlayer::Loaded); |
| 702 | 702 |
| 703 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); | 703 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); |
| 704 SetReadyState(WebKit::WebMediaPlayer::HaveFutureData); | 704 // Fire canplaythrough immediately after playback begins because of |
| 705 // crbug.com/106480. |
| 706 // TODO(vrk): set ready state to HaveFutureData when bug above is fixed. |
| 707 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); |
| 705 } else { | 708 } else { |
| 706 // TODO(hclam): should use |status| to determine the state | 709 // TODO(hclam): should use |status| to determine the state |
| 707 // properly and reports error using MediaError. | 710 // properly and reports error using MediaError. |
| 708 // WebKit uses FormatError to indicate an error for bogus URL or bad file. | 711 // WebKit uses FormatError to indicate an error for bogus URL or bad file. |
| 709 // Since we are at the initialization stage we can safely treat every error | 712 // Since we are at the initialization stage we can safely treat every error |
| 710 // as format error. Should post a task to call to |webmediaplayer_|. | 713 // as format error. Should post a task to call to |webmediaplayer_|. |
| 711 SetNetworkState(WebKit::WebMediaPlayer::FormatError); | 714 SetNetworkState(WebKit::WebMediaPlayer::FormatError); |
| 712 } | 715 } |
| 713 | 716 |
| 714 // Repaint to trigger UI update. | 717 // Repaint to trigger UI update. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 Repaint(); | 783 Repaint(); |
| 781 } | 784 } |
| 782 | 785 |
| 783 void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) { | 786 void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) { |
| 784 DCHECK_EQ(main_loop_, MessageLoop::current()); | 787 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 785 switch(type) { | 788 switch(type) { |
| 786 case media::DOWNLOAD_CONTINUED: | 789 case media::DOWNLOAD_CONTINUED: |
| 787 SetNetworkState(WebKit::WebMediaPlayer::Loading); | 790 SetNetworkState(WebKit::WebMediaPlayer::Loading); |
| 788 break; | 791 break; |
| 789 case media::DOWNLOAD_PAUSED: | 792 case media::DOWNLOAD_PAUSED: |
| 790 if (!pipeline_->IsLocalSource()) | 793 SetNetworkState(WebKit::WebMediaPlayer::Idle); |
| 791 SetNetworkState(WebKit::WebMediaPlayer::Idle); | |
| 792 break; | 794 break; |
| 793 case media::CAN_PLAY_THROUGH: | 795 case media::CAN_PLAY_THROUGH: |
| 794 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); | 796 // Temporarily disable delayed firing of CAN_PLAY_THROUGH due to |
| 797 // crbug.com/106480. |
| 798 // TODO(vrk): uncomment code below when bug above is fixed. |
| 799 // SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); |
| 795 break; | 800 break; |
| 796 default: | 801 default: |
| 797 NOTREACHED(); | 802 NOTREACHED(); |
| 798 } | 803 } |
| 799 } | 804 } |
| 800 | 805 |
| 801 void WebMediaPlayerImpl::OnDemuxerOpened() { | 806 void WebMediaPlayerImpl::OnDemuxerOpened() { |
| 802 DCHECK_EQ(main_loop_, MessageLoop::current()); | 807 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 803 | 808 |
| 804 GetClient()->sourceOpened(); | 809 GetClient()->sourceOpened(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 return audio_source_provider_; | 902 return audio_source_provider_; |
| 898 } | 903 } |
| 899 | 904 |
| 900 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 905 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 901 DCHECK_EQ(main_loop_, MessageLoop::current()); | 906 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 902 incremented_externally_allocated_memory_ = true; | 907 incremented_externally_allocated_memory_ = true; |
| 903 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 908 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 904 } | 909 } |
| 905 | 910 |
| 906 } // namespace webkit_media | 911 } // namespace webkit_media |
| OLD | NEW |