| 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 "chrome/renderer/gpu_video_decoder_host.h" | 5 #include "chrome/renderer/gpu_video_decoder_host.h" |
| 6 | 6 |
| 7 #include "chrome/common/gpu_messages.h" | 7 #include "chrome/common/gpu_messages.h" |
| 8 #include "chrome/common/message_router.h" | 8 #include "chrome/common/message_router.h" |
| 9 #include "media/video/video_decode_context.h" | 9 #include "media/video/video_decode_context.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 current_frame_id_(0) { | 25 current_frame_id_(0) { |
| 26 memset(&config_, 0, sizeof(config_)); | 26 memset(&config_, 0, sizeof(config_)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 GpuVideoDecoderHost::~GpuVideoDecoderHost() {} | 29 GpuVideoDecoderHost::~GpuVideoDecoderHost() {} |
| 30 | 30 |
| 31 void GpuVideoDecoderHost::OnChannelError() { | 31 void GpuVideoDecoderHost::OnChannelError() { |
| 32 ipc_sender_ = NULL; | 32 ipc_sender_ = NULL; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void GpuVideoDecoderHost::OnMessageReceived(const IPC::Message& msg) { | 35 bool GpuVideoDecoderHost::OnMessageReceived(const IPC::Message& msg) { |
| 36 bool handled = true; |
| 36 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecoderHost, msg) | 37 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecoderHost, msg) |
| 37 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_CreateVideoDecoderDone, | 38 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_CreateVideoDecoderDone, |
| 38 OnCreateVideoDecoderDone) | 39 OnCreateVideoDecoderDone) |
| 39 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_InitializeACK, | 40 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_InitializeACK, |
| 40 OnInitializeDone) | 41 OnInitializeDone) |
| 41 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_DestroyACK, | 42 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_DestroyACK, |
| 42 OnUninitializeDone) | 43 OnUninitializeDone) |
| 43 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FlushACK, | 44 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FlushACK, |
| 44 OnFlushDone) | 45 OnFlushDone) |
| 45 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_PrerollDone, | 46 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_PrerollDone, |
| 46 OnPrerollDone) | 47 OnPrerollDone) |
| 47 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferACK, | 48 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferACK, |
| 48 OnEmptyThisBufferACK) | 49 OnEmptyThisBufferACK) |
| 49 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferDone, | 50 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferDone, |
| 50 OnProduceVideoSample) | 51 OnProduceVideoSample) |
| 51 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_ConsumeVideoFrame, | 52 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_ConsumeVideoFrame, |
| 52 OnConsumeVideoFrame) | 53 OnConsumeVideoFrame) |
| 53 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_AllocateVideoFrames, | 54 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_AllocateVideoFrames, |
| 54 OnAllocateVideoFrames) | 55 OnAllocateVideoFrames) |
| 55 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_ReleaseAllVideoFrames, | 56 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_ReleaseAllVideoFrames, |
| 56 OnReleaseAllVideoFrames) | 57 OnReleaseAllVideoFrames) |
| 57 IPC_MESSAGE_UNHANDLED_ERROR() | 58 IPC_MESSAGE_UNHANDLED(handled = false) |
| 58 IPC_END_MESSAGE_MAP() | 59 IPC_END_MESSAGE_MAP() |
| 60 DCHECK(handled); |
| 61 return handled; |
| 59 } | 62 } |
| 60 | 63 |
| 61 void GpuVideoDecoderHost::Initialize( | 64 void GpuVideoDecoderHost::Initialize( |
| 62 MessageLoop* message_loop, VideoDecodeEngine::EventHandler* event_handler, | 65 MessageLoop* message_loop, VideoDecodeEngine::EventHandler* event_handler, |
| 63 media::VideoDecodeContext* context, const media::VideoCodecConfig& config) { | 66 media::VideoDecodeContext* context, const media::VideoCodecConfig& config) { |
| 64 if (MessageLoop::current() != message_loop) { | 67 if (MessageLoop::current() != message_loop) { |
| 65 message_loop->PostTask( | 68 message_loop->PostTask( |
| 66 FROM_HERE, | 69 FROM_HERE, |
| 67 NewRunnableMethod(this, &GpuVideoDecoderHost::Initialize, message_loop, | 70 NewRunnableMethod(this, &GpuVideoDecoderHost::Initialize, message_loop, |
| 68 event_handler, context, config)); | 71 event_handler, context, config)); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 382 } |
| 380 | 383 |
| 381 DCHECK(found) << "Invalid video frame received"; | 384 DCHECK(found) << "Invalid video frame received"; |
| 382 if (found && !ipc_sender_->Send( | 385 if (found && !ipc_sender_->Send( |
| 383 new GpuVideoDecoderMsg_ProduceVideoFrame(decoder_id_, frame_id))) { | 386 new GpuVideoDecoderMsg_ProduceVideoFrame(decoder_id_, frame_id))) { |
| 384 LOG(ERROR) << "GpuVideoDecoderMsg_ProduceVideoFrame failed"; | 387 LOG(ERROR) << "GpuVideoDecoderMsg_ProduceVideoFrame failed"; |
| 385 } | 388 } |
| 386 } | 389 } |
| 387 | 390 |
| 388 DISABLE_RUNNABLE_METHOD_REFCOUNT(GpuVideoDecoderHost); | 391 DISABLE_RUNNABLE_METHOD_REFCOUNT(GpuVideoDecoderHost); |
| OLD | NEW |