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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 media::FilterCollection* collection, | 107 media::FilterCollection* collection, |
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), |
Ami GONE FROM CHROMIUM
2012/08/09 20:55:41
remove started_ from wmpi.h?
scherkus (not reviewing)
2012/08/09 22:07:49
Done.
| |
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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 SetNetworkState(WebMediaPlayer::NetworkStateIdle); | 947 SetNetworkState(WebMediaPlayer::NetworkStateIdle); |
949 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) | 948 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) |
950 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 949 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
951 media_log_->AddEvent( | 950 media_log_->AddEvent( |
952 media_log_->CreateBooleanEvent( | 951 media_log_->CreateBooleanEvent( |
953 media::MediaLogEvent::NETWORK_ACTIVITY_SET, | 952 media::MediaLogEvent::NETWORK_ACTIVITY_SET, |
954 "is_downloading_data", is_downloading)); | 953 "is_downloading_data", is_downloading)); |
955 } | 954 } |
956 | 955 |
957 void WebMediaPlayerImpl::StartPipeline() { | 956 void WebMediaPlayerImpl::StartPipeline() { |
958 started_ = true; | |
959 pipeline_->Start( | 957 pipeline_->Start( |
960 filter_collection_.Pass(), | 958 filter_collection_.Pass(), |
961 base::Bind(&WebMediaPlayerProxy::PipelineEndedCallback, proxy_.get()), | 959 base::Bind(&WebMediaPlayerProxy::PipelineEndedCallback, proxy_.get()), |
962 base::Bind(&WebMediaPlayerProxy::PipelineErrorCallback, proxy_.get()), | 960 base::Bind(&WebMediaPlayerProxy::PipelineErrorCallback, proxy_.get()), |
963 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, | 961 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, |
964 proxy_.get())); | 962 proxy_.get())); |
965 } | 963 } |
966 | 964 |
967 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { | 965 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { |
968 DCHECK_EQ(main_loop_, MessageLoop::current()); | 966 DCHECK_EQ(main_loop_, MessageLoop::current()); |
(...skipping 16 matching lines...) Expand all Loading... | |
985 | 983 |
986 // Tell the data source to abort any pending reads so that the pipeline is | 984 // Tell the data source to abort any pending reads so that the pipeline is |
987 // not blocked when issuing stop commands to the other filters. | 985 // not blocked when issuing stop commands to the other filters. |
988 if (proxy_) { | 986 if (proxy_) { |
989 proxy_->AbortDataSource(); | 987 proxy_->AbortDataSource(); |
990 proxy_->DemuxerShutdown(); | 988 proxy_->DemuxerShutdown(); |
991 } | 989 } |
992 | 990 |
993 // Make sure to kill the pipeline so there's no more media threads running. | 991 // Make sure to kill the pipeline so there's no more media threads running. |
994 // Note: stopping the pipeline might block for a long time. | 992 // Note: stopping the pipeline might block for a long time. |
995 if (started_) { | 993 base::WaitableEvent waiter(false, false); |
996 base::WaitableEvent waiter(false, false); | 994 pipeline_->Stop(base::Bind( |
997 pipeline_->Stop(base::Bind( | 995 &base::WaitableEvent::Signal, base::Unretained(&waiter))); |
998 &base::WaitableEvent::Signal, base::Unretained(&waiter))); | 996 waiter.Wait(); |
999 waiter.Wait(); | |
1000 started_ = false; | |
1001 } | |
1002 | 997 |
1003 // Let V8 know we are not using extra resources anymore. | 998 // Let V8 know we are not using extra resources anymore. |
1004 if (incremented_externally_allocated_memory_) { | 999 if (incremented_externally_allocated_memory_) { |
1005 v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory); | 1000 v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory); |
1006 incremented_externally_allocated_memory_ = false; | 1001 incremented_externally_allocated_memory_ = false; |
1007 } | 1002 } |
1008 | 1003 |
1009 message_loop_factory_.reset(); | 1004 message_loop_factory_.reset(); |
1010 | 1005 |
1011 // And then detach the proxy, it may live on the render thread for a little | 1006 // And then detach the proxy, it may live on the render thread for a little |
(...skipping 14 matching lines...) Expand all Loading... | |
1026 return audio_source_provider_; | 1021 return audio_source_provider_; |
1027 } | 1022 } |
1028 | 1023 |
1029 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 1024 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
1030 DCHECK_EQ(main_loop_, MessageLoop::current()); | 1025 DCHECK_EQ(main_loop_, MessageLoop::current()); |
1031 incremented_externally_allocated_memory_ = true; | 1026 incremented_externally_allocated_memory_ = true; |
1032 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 1027 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
1033 } | 1028 } |
1034 | 1029 |
1035 } // namespace webkit_media | 1030 } // namespace webkit_media |
OLD | NEW |