| 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 WebKit::WebAudioSourceProvider* audio_source_provider, | 108 WebKit::WebAudioSourceProvider* audio_source_provider, |
| 109 media::AudioRendererSink* audio_renderer_sink, | 109 media::AudioRendererSink* audio_renderer_sink, |
| 110 media::MessageLoopFactory* message_loop_factory, | 110 media::MessageLoopFactory* message_loop_factory, |
| 111 MediaStreamClient* media_stream_client, | 111 MediaStreamClient* media_stream_client, |
| 112 media::MediaLog* media_log) | 112 media::MediaLog* media_log) |
| 113 : frame_(frame), | 113 : frame_(frame), |
| 114 network_state_(WebMediaPlayer::NetworkStateEmpty), | 114 network_state_(WebMediaPlayer::NetworkStateEmpty), |
| 115 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 115 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 116 main_loop_(MessageLoop::current()), | 116 main_loop_(MessageLoop::current()), |
| 117 filter_collection_(collection), | 117 filter_collection_(collection), |
| 118 started_(false), | |
| 119 message_loop_factory_(message_loop_factory), | 118 message_loop_factory_(message_loop_factory), |
| 120 paused_(true), | 119 paused_(true), |
| 121 seeking_(false), | 120 seeking_(false), |
| 122 playback_rate_(0.0f), | 121 playback_rate_(0.0f), |
| 123 pending_seek_(false), | 122 pending_seek_(false), |
| 124 pending_seek_seconds_(0.0f), | 123 pending_seek_seconds_(0.0f), |
| 125 client_(client), | 124 client_(client), |
| 126 proxy_(new WebMediaPlayerProxy(main_loop_->message_loop_proxy(), this)), | 125 proxy_(new WebMediaPlayerProxy(main_loop_->message_loop_proxy(), this)), |
| 127 delegate_(delegate), | 126 delegate_(delegate), |
| 128 media_stream_client_(media_stream_client), | 127 media_stream_client_(media_stream_client), |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 SetNetworkState(WebMediaPlayer::NetworkStateIdle); | 946 SetNetworkState(WebMediaPlayer::NetworkStateIdle); |
| 948 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) | 947 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) |
| 949 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 948 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
| 950 media_log_->AddEvent( | 949 media_log_->AddEvent( |
| 951 media_log_->CreateBooleanEvent( | 950 media_log_->CreateBooleanEvent( |
| 952 media::MediaLogEvent::NETWORK_ACTIVITY_SET, | 951 media::MediaLogEvent::NETWORK_ACTIVITY_SET, |
| 953 "is_downloading_data", is_downloading)); | 952 "is_downloading_data", is_downloading)); |
| 954 } | 953 } |
| 955 | 954 |
| 956 void WebMediaPlayerImpl::StartPipeline() { | 955 void WebMediaPlayerImpl::StartPipeline() { |
| 957 started_ = true; | |
| 958 pipeline_->Start( | 956 pipeline_->Start( |
| 959 filter_collection_.Pass(), | 957 filter_collection_.Pass(), |
| 960 base::Bind(&WebMediaPlayerProxy::PipelineEndedCallback, proxy_.get()), | 958 base::Bind(&WebMediaPlayerProxy::PipelineEndedCallback, proxy_.get()), |
| 961 base::Bind(&WebMediaPlayerProxy::PipelineErrorCallback, proxy_.get()), | 959 base::Bind(&WebMediaPlayerProxy::PipelineErrorCallback, proxy_.get()), |
| 962 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, | 960 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, |
| 963 proxy_.get())); | 961 proxy_.get())); |
| 964 } | 962 } |
| 965 | 963 |
| 966 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { | 964 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { |
| 967 DCHECK_EQ(main_loop_, MessageLoop::current()); | 965 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 984 | 982 |
| 985 // Tell the data source to abort any pending reads so that the pipeline is | 983 // Tell the data source to abort any pending reads so that the pipeline is |
| 986 // not blocked when issuing stop commands to the other filters. | 984 // not blocked when issuing stop commands to the other filters. |
| 987 if (proxy_) { | 985 if (proxy_) { |
| 988 proxy_->AbortDataSource(); | 986 proxy_->AbortDataSource(); |
| 989 proxy_->DemuxerShutdown(); | 987 proxy_->DemuxerShutdown(); |
| 990 } | 988 } |
| 991 | 989 |
| 992 // Make sure to kill the pipeline so there's no more media threads running. | 990 // Make sure to kill the pipeline so there's no more media threads running. |
| 993 // Note: stopping the pipeline might block for a long time. | 991 // Note: stopping the pipeline might block for a long time. |
| 994 if (started_) { | 992 base::WaitableEvent waiter(false, false); |
| 995 base::WaitableEvent waiter(false, false); | 993 pipeline_->Stop(base::Bind( |
| 996 pipeline_->Stop(base::Bind( | 994 &base::WaitableEvent::Signal, base::Unretained(&waiter))); |
| 997 &base::WaitableEvent::Signal, base::Unretained(&waiter))); | 995 waiter.Wait(); |
| 998 waiter.Wait(); | |
| 999 started_ = false; | |
| 1000 } | |
| 1001 | 996 |
| 1002 // Let V8 know we are not using extra resources anymore. | 997 // Let V8 know we are not using extra resources anymore. |
| 1003 if (incremented_externally_allocated_memory_) { | 998 if (incremented_externally_allocated_memory_) { |
| 1004 v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory); | 999 v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory); |
| 1005 incremented_externally_allocated_memory_ = false; | 1000 incremented_externally_allocated_memory_ = false; |
| 1006 } | 1001 } |
| 1007 | 1002 |
| 1008 message_loop_factory_.reset(); | 1003 message_loop_factory_.reset(); |
| 1009 | 1004 |
| 1010 // And then detach the proxy, it may live on the render thread for a little | 1005 // And then detach the proxy, it may live on the render thread for a little |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1025 return audio_source_provider_; | 1020 return audio_source_provider_; |
| 1026 } | 1021 } |
| 1027 | 1022 |
| 1028 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 1023 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 1029 DCHECK_EQ(main_loop_, MessageLoop::current()); | 1024 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 1030 incremented_externally_allocated_memory_ = true; | 1025 incremented_externally_allocated_memory_ = true; |
| 1031 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 1026 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 1032 } | 1027 } |
| 1033 | 1028 |
| 1034 } // namespace webkit_media | 1029 } // namespace webkit_media |
| OLD | NEW |