Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: webkit/media/webmediaplayer_impl.cc

Issue 11468033: Vanquish the remnants of media::MessageLoopFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/media/webmediaplayer_impl.cc
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index 0941666e2bef0e8298c5e04ebb9fda9402b6a00d..8ee584afe5373d0be78c367d84d85f03d821257f 100644
--- a/webkit/media/webmediaplayer_impl.cc
+++ b/webkit/media/webmediaplayer_impl.cc
@@ -122,18 +122,17 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
WebKit::WebFrame* frame,
WebKit::WebMediaPlayerClient* client,
base::WeakPtr<WebMediaPlayerDelegate> delegate,
- media::FilterCollection* collection,
WebKit::WebAudioSourceProvider* audio_source_provider,
media::AudioRendererSink* audio_renderer_sink,
- media::MessageLoopFactory* message_loop_factory,
+ const scoped_refptr<media::GpuVideoDecoder::Factories>& gpu_factories,
MediaStreamClient* media_stream_client,
media::MediaLog* media_log)
: frame_(frame),
network_state_(WebMediaPlayer::NetworkStateEmpty),
ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
main_loop_(MessageLoop::current()),
- filter_collection_(collection),
- message_loop_factory_(message_loop_factory),
+ filter_collection_(new media::FilterCollection()),
+ media_thread_("MediaPipeline"),
paused_(true),
seeking_(false),
playback_rate_(0.0f),
@@ -154,10 +153,12 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
media_log_->AddEvent(
media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED));
- scoped_refptr<base::MessageLoopProxy> pipeline_message_loop =
- message_loop_factory_->GetMessageLoop(
- media::MessageLoopFactory::kPipeline);
- pipeline_ = new media::Pipeline(pipeline_message_loop, media_log_);
+ CHECK(media_thread_.Start());
+ pipeline_ = new media::Pipeline(
+ media_thread_.message_loop_proxy(), media_log_);
+
+ decryptor_.reset(new ProxyDecryptor(
+ media_thread_.message_loop_proxy(), proxy_.get(), client, frame));
// Let V8 know we started new thread if we did not did it yet.
// Made separate task to avoid deletion of player currently being created.
@@ -173,23 +174,34 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
// Also we want to be notified of |main_loop_| destruction.
main_loop_->AddDestructionObserver(this);
+ // Create the GPU video decoder if factories were provided.
+ if (gpu_factories) {
+ filter_collection_->GetVideoDecoders()->push_back(
+ new media::GpuVideoDecoder(
+ media_thread_.message_loop_proxy(),
+ gpu_factories));
+ }
+
// Create default video renderer.
scoped_refptr<media::VideoRendererBase> video_renderer =
new media::VideoRendererBase(
- pipeline_message_loop,
+ media_thread_.message_loop_proxy(),
base::Bind(&WebMediaPlayerProxy::Repaint, proxy_),
BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::SetOpaque),
true);
filter_collection_->AddVideoRenderer(video_renderer);
proxy_->set_frame_provider(video_renderer);
- // Create default audio renderer.
+ // Create default audio renderer using the null sink if no sink was provided.
+ if (!audio_renderer_sink) {
acolwell GONE FROM CHROMIUM 2012/12/10 18:12:16 Why are these audio changes included in this CL?
+ audio_renderer_sink = new media::NullAudioSink();
+ }
filter_collection_->AddAudioRenderer(
- new media::AudioRendererImpl(new media::NullAudioSink()));
+ new media::AudioRendererImpl(audio_renderer_sink));
if (WebKit::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
- decryptor_.reset(new ProxyDecryptor(message_loop_factory_->GetMessageLoop(
- media::MessageLoopFactory::kPipeline), proxy_.get(), client, frame));
+ decryptor_.reset(new ProxyDecryptor(
+ media_thread_.message_loop_proxy(), proxy_.get(), client, frame));
}
}
@@ -257,13 +269,9 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) {
SetReadyState(WebMediaPlayer::ReadyStateHaveNothing);
media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec()));
- scoped_refptr<base::MessageLoopProxy> message_loop =
- message_loop_factory_->GetMessageLoop(
- media::MessageLoopFactory::kPipeline);
-
// Media streams pipelines can start immediately.
if (BuildMediaStreamCollection(url, media_stream_client_,
- message_loop,
+ media_thread_.message_loop_proxy(),
filter_collection_.get())) {
supports_save_ = false;
StartPipeline();
@@ -277,7 +285,7 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) {
BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""));
BuildMediaSourceCollection(chunk_demuxer_,
- message_loop,
+ media_thread_.message_loop_proxy(),
filter_collection_.get(),
decryptor_.get());
supports_save_ = false;
@@ -299,7 +307,7 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) {
is_local_source_ = !gurl.SchemeIs("http") && !gurl.SchemeIs("https");
BuildDefaultCollection(proxy_->data_source(),
- message_loop,
+ media_thread_.message_loop_proxy(),
filter_collection_.get(),
decryptor_.get());
}
@@ -810,8 +818,8 @@ WebMediaPlayerImpl::GenerateKeyRequestInternal(
// the same "type") for now. In the future, the "type" should be passed down
// from the application.
if (!decryptor_->GenerateKeyRequest(key_system.utf8(),
- init_data_type_,
- init_data, init_data_length)) {
+ init_data_type_,
+ init_data, init_data_length)) {
current_key_system_.reset();
return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
}
@@ -857,7 +865,7 @@ WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::AddKeyInternal(
<< " [" << session_id.utf8().data() << "]";
decryptor_->AddKey(key_system.utf8(), key, key_length,
- init_data, init_data_length, session_id.utf8());
+ init_data, init_data_length, session_id.utf8());
return WebMediaPlayer::MediaKeyExceptionNoError;
}
@@ -1180,7 +1188,7 @@ void WebMediaPlayerImpl::Destroy() {
incremented_externally_allocated_memory_ = false;
}
- message_loop_factory_.reset();
+ media_thread_.Stop();
// And then detach the proxy, it may live on the render thread for a little
// longer until all the tasks are finished.

Powered by Google App Engine
This is Rietveld 408576698