OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/webmediaplayer_impl.h" | 5 #include "webkit/glue/webmediaplayer_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 playback_rate_(0.0f), | 237 playback_rate_(0.0f), |
238 client_(client), | 238 client_(client), |
239 proxy_(NULL), | 239 proxy_(NULL), |
240 pipeline_stopped_(false, false) { | 240 pipeline_stopped_(false, false) { |
241 // Saves the current message loop. | 241 // Saves the current message loop. |
242 DCHECK(!main_loop_); | 242 DCHECK(!main_loop_); |
243 main_loop_ = MessageLoop::current(); | 243 main_loop_ = MessageLoop::current(); |
244 } | 244 } |
245 | 245 |
246 bool WebMediaPlayerImpl::Initialize( | 246 bool WebMediaPlayerImpl::Initialize( |
247 WebKit::WebFrame* frame, | 247 MediaResourceLoaderBridgeFactory* bridge_factory_simple, |
| 248 MediaResourceLoaderBridgeFactory* bridge_factory_buffered, |
248 bool use_simple_data_source, | 249 bool use_simple_data_source, |
249 scoped_refptr<WebVideoRenderer> web_video_renderer) { | 250 scoped_refptr<WebVideoRenderer> web_video_renderer) { |
250 // Create the pipeline and its thread. | 251 // Create the pipeline and its thread. |
251 if (!pipeline_thread_.Start()) { | 252 if (!pipeline_thread_.Start()) { |
252 NOTREACHED() << "Could not start PipelineThread"; | 253 NOTREACHED() << "Could not start PipelineThread"; |
253 return false; | 254 return false; |
254 } | 255 } |
255 | 256 |
256 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop()); | 257 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop()); |
257 | 258 |
258 // Also we want to be notified of |main_loop_| destruction. | 259 // Also we want to be notified of |main_loop_| destruction. |
259 main_loop_->AddDestructionObserver(this); | 260 main_loop_->AddDestructionObserver(this); |
260 | 261 |
261 // Creates the proxy. | 262 // Creates the proxy. |
262 proxy_ = new Proxy(main_loop_, this); | 263 proxy_ = new Proxy(main_loop_, this); |
263 web_video_renderer->SetWebMediaPlayerImplProxy(proxy_); | 264 web_video_renderer->SetWebMediaPlayerImplProxy(proxy_); |
264 proxy_->SetVideoRenderer(web_video_renderer); | 265 proxy_->SetVideoRenderer(web_video_renderer); |
265 | 266 |
266 // Set our pipeline callbacks. | 267 // Set our pipeline callbacks. |
267 pipeline_->Init( | 268 pipeline_->Init( |
268 NewCallback(proxy_.get(), | 269 NewCallback(proxy_.get(), |
269 &WebMediaPlayerImpl::Proxy::PipelineEndedCallback), | 270 &WebMediaPlayerImpl::Proxy::PipelineEndedCallback), |
270 NewCallback(proxy_.get(), | 271 NewCallback(proxy_.get(), |
271 &WebMediaPlayerImpl::Proxy::PipelineErrorCallback), | 272 &WebMediaPlayerImpl::Proxy::PipelineErrorCallback), |
272 NewCallback(proxy_.get(), | 273 NewCallback(proxy_.get(), |
273 &WebMediaPlayerImpl::Proxy::NetworkEventCallback)); | 274 &WebMediaPlayerImpl::Proxy::NetworkEventCallback)); |
274 | 275 |
275 // A simple data source that keeps all data in memory. | 276 // A simple data source that keeps all data in memory. |
276 scoped_refptr<SimpleDataSource> simple_data_source( | 277 scoped_refptr<SimpleDataSource> simple_data_source( |
277 new SimpleDataSource(MessageLoop::current(), frame)); | 278 new SimpleDataSource(MessageLoop::current(), bridge_factory_simple)); |
278 | 279 |
279 // A sophisticated data source that does memory caching. | 280 // A sophisticated data source that does memory caching. |
280 scoped_refptr<BufferedDataSource> buffered_data_source( | 281 scoped_refptr<BufferedDataSource> buffered_data_source( |
281 new BufferedDataSource(MessageLoop::current(), frame)); | 282 new BufferedDataSource(MessageLoop::current(), bridge_factory_buffered)); |
282 proxy_->SetDataSource(buffered_data_source); | 283 proxy_->SetDataSource(buffered_data_source); |
283 | 284 |
284 if (use_simple_data_source) { | 285 if (use_simple_data_source) { |
285 filter_collection_->AddDataSource(simple_data_source); | 286 filter_collection_->AddDataSource(simple_data_source); |
286 filter_collection_->AddDataSource(buffered_data_source); | 287 filter_collection_->AddDataSource(buffered_data_source); |
287 } else { | 288 } else { |
288 filter_collection_->AddDataSource(buffered_data_source); | 289 filter_collection_->AddDataSource(buffered_data_source); |
289 filter_collection_->AddDataSource(simple_data_source); | 290 filter_collection_->AddDataSource(simple_data_source); |
290 } | 291 } |
291 | 292 |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 pipeline_stopped_.Signal(); | 802 pipeline_stopped_.Signal(); |
802 } | 803 } |
803 | 804 |
804 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 805 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
805 DCHECK(MessageLoop::current() == main_loop_); | 806 DCHECK(MessageLoop::current() == main_loop_); |
806 DCHECK(client_); | 807 DCHECK(client_); |
807 return client_; | 808 return client_; |
808 } | 809 } |
809 | 810 |
810 } // namespace webkit_glue | 811 } // namespace webkit_glue |
OLD | NEW |