diff options
Diffstat (limited to 'chrome/renderer/gpu_video_decoder_host.cc')
-rw-r--r-- | chrome/renderer/gpu_video_decoder_host.cc | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/chrome/renderer/gpu_video_decoder_host.cc b/chrome/renderer/gpu_video_decoder_host.cc index f031ab7..5afa69c 100644 --- a/chrome/renderer/gpu_video_decoder_host.cc +++ b/chrome/renderer/gpu_video_decoder_host.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,12 +19,13 @@ GpuVideoDecoderHost::GpuVideoDecoderHost(MessageRouter* router, message_loop_(NULL), event_handler_(NULL), context_(NULL), + width_(0), + height_(0), state_(kStateUninitialized), decoder_host_id_(decoder_host_id), decoder_id_(0), input_buffer_busy_(false), current_frame_id_(0) { - memset(&config_, 0, sizeof(config_)); } GpuVideoDecoderHost::~GpuVideoDecoderHost() {} @@ -65,33 +66,21 @@ bool GpuVideoDecoderHost::OnMessageReceived(const IPC::Message& msg) { void GpuVideoDecoderHost::Initialize( MessageLoop* message_loop, VideoDecodeEngine::EventHandler* event_handler, media::VideoDecodeContext* context, const media::VideoCodecConfig& config) { - if (MessageLoop::current() != message_loop) { - message_loop->PostTask( - FROM_HERE, - NewRunnableMethod(this, &GpuVideoDecoderHost::Initialize, message_loop, - event_handler, context, config)); - return; - } - - // Initialization operations should be performed on the message loop assigned. - // Save the parameters and post a task to complete initialization. DCHECK_EQ(kStateUninitialized, state_); DCHECK(!message_loop_); message_loop_ = message_loop; event_handler_ = event_handler; context_ = context; - config_ = config; - - // Add the route so we'll receive messages. - router_->AddRoute(decoder_host_id_, this); + width_ = config.width(); + height_ = config.height(); - if (!ipc_sender_->Send( - new GpuChannelMsg_CreateVideoDecoder(context_route_id_, - decoder_host_id_))) { - LOG(ERROR) << "GpuChannelMsg_CreateVideoDecoder failed"; - event_handler_->OnError(); + if (MessageLoop::current() != message_loop) { + message_loop->PostTask( + FROM_HERE, + NewRunnableMethod(this, &GpuVideoDecoderHost::CreateVideoDecoder)); return; } + CreateVideoDecoder(); } void GpuVideoDecoderHost::ConsumeVideoSample(scoped_refptr<Buffer> buffer) { @@ -190,14 +179,29 @@ void GpuVideoDecoderHost::Seek() { } } +void GpuVideoDecoderHost::CreateVideoDecoder() { + DCHECK_EQ(message_loop_, MessageLoop::current()); + + // Add the route so we'll receive messages. + router_->AddRoute(decoder_host_id_, this); + + if (!ipc_sender_->Send( + new GpuChannelMsg_CreateVideoDecoder(context_route_id_, + decoder_host_id_))) { + LOG(ERROR) << "GpuChannelMsg_CreateVideoDecoder failed"; + event_handler_->OnError(); + return; + } +} + void GpuVideoDecoderHost::OnCreateVideoDecoderDone(int32 decoder_id) { DCHECK_EQ(message_loop_, MessageLoop::current()); decoder_id_ = decoder_id; // TODO(hclam): Initialize |param| with the right values. GpuVideoDecoderInitParam param; - param.width = config_.width; - param.height = config_.height; + param.width = width_; + param.height = height_; if (!ipc_sender_->Send( new GpuVideoDecoderMsg_Initialize(decoder_id, param))) { @@ -225,8 +229,8 @@ void GpuVideoDecoderHost::OnInitializeDone( // TODO(hclam): Need to fill in more information. media::VideoCodecInfo info; info.success = success; - info.stream_info.surface_width = config_.width; - info.stream_info.surface_height = config_.height; + info.stream_info.surface_width = width_; + info.stream_info.surface_height = height_; event_handler_->OnInitializeComplete(info); } |