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/renderer/gpu_video_service_host.h" | 8 #include "chrome/renderer/gpu_video_service_host.h" |
9 #include "chrome/renderer/render_thread.h" | 9 #include "chrome/renderer/render_thread.h" |
10 | 10 |
11 GpuVideoDecoderHost::GpuVideoDecoderHost(GpuVideoServiceHost* service_host, | 11 GpuVideoDecoderHost::GpuVideoDecoderHost(GpuVideoServiceHost* service_host, |
12 GpuChannelHost* channel_host, | 12 GpuChannelHost* channel_host, |
13 EventHandler* event_handler, | 13 int context_route_id) |
14 GpuVideoDecoderInfoParam decoder_info) | |
15 : gpu_video_service_host_(service_host), | 14 : gpu_video_service_host_(service_host), |
16 channel_host_(channel_host), | 15 channel_host_(channel_host), |
17 event_handler_(event_handler), | 16 context_route_id_(context_route_id), |
18 decoder_info_(decoder_info), | 17 event_handler_(NULL), |
19 buffer_id_serial_(0), | 18 buffer_id_serial_(0), |
20 state_(kStateUninitialized), | 19 state_(kStateUninitialized), |
21 input_buffer_busy_(false) { | 20 input_buffer_busy_(false) { |
22 memset(&init_param_, 0, sizeof(init_param_)); | 21 memset(&init_param_, 0, sizeof(init_param_)); |
23 memset(&done_param_, 0, sizeof(done_param_)); | 22 memset(&done_param_, 0, sizeof(done_param_)); |
24 } | 23 } |
25 | 24 |
26 void GpuVideoDecoderHost::OnChannelError() { | 25 void GpuVideoDecoderHost::OnChannelError() { |
27 channel_host_.release(); | 26 channel_host_.release(); |
28 } | 27 } |
29 | 28 |
30 void GpuVideoDecoderHost::OnMessageReceived(const IPC::Message& msg) { | 29 void GpuVideoDecoderHost::OnMessageReceived(const IPC::Message& msg) { |
31 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecoderHost, msg) | 30 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecoderHost, msg) |
32 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_InitializeACK, | 31 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_InitializeACK, |
33 OnInitializeDone) | 32 OnInitializeDone) |
34 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_DestroyACK, | 33 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_DestroyACK, |
35 OnUninitializeDone) | 34 OnUninitializeDone) |
36 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FlushACK, | 35 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FlushACK, |
37 OnFlushDone) | 36 OnFlushDone) |
38 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferACK, | 37 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferACK, |
39 OnEmptyThisBufferACK) | 38 OnEmptyThisBufferACK) |
40 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferDone, | 39 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferDone, |
41 OnEmptyThisBufferDone) | 40 OnEmptyThisBufferDone) |
42 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FillThisBufferDone, | 41 IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FillThisBufferDone, |
43 OnFillThisBufferDone) | 42 OnFillThisBufferDone) |
44 IPC_MESSAGE_UNHANDLED_ERROR() | 43 IPC_MESSAGE_UNHANDLED_ERROR() |
45 IPC_END_MESSAGE_MAP() | 44 IPC_END_MESSAGE_MAP() |
46 } | 45 } |
47 | 46 |
48 bool GpuVideoDecoderHost::Initialize(const GpuVideoDecoderInitParam& param) { | 47 bool GpuVideoDecoderHost::Initialize(EventHandler* event_handler, |
| 48 const GpuVideoDecoderInitParam& param) { |
49 DCHECK_EQ(state_, kStateUninitialized); | 49 DCHECK_EQ(state_, kStateUninitialized); |
50 | 50 |
| 51 // Save the event handler before we perform initialization operations so |
| 52 // that we can report initialization events. |
| 53 event_handler_ = event_handler; |
| 54 |
| 55 // TODO(hclam): Pass the context route ID here. |
| 56 // TODO(hclam): This create video decoder operation is synchronous, need to |
| 57 // make it asynchronous. |
| 58 if (!channel_host_->Send( |
| 59 new GpuChannelMsg_CreateVideoDecoder(&decoder_info_))) { |
| 60 LOG(ERROR) << "GpuChannelMsg_CreateVideoDecoder failed"; |
| 61 return false; |
| 62 } |
| 63 |
| 64 // Add the route so we'll receive messages. |
| 65 gpu_video_service_host_->AddRoute(my_route_id(), this); |
| 66 |
51 init_param_ = param; | 67 init_param_ = param; |
52 if (!channel_host_->Send( | 68 if (!channel_host_->Send( |
53 new GpuVideoDecoderMsg_Initialize(route_id(), param))) { | 69 new GpuVideoDecoderMsg_Initialize(route_id(), param))) { |
54 LOG(ERROR) << "GpuVideoDecoderMsg_Initialize failed"; | 70 LOG(ERROR) << "GpuVideoDecoderMsg_Initialize failed"; |
55 return false; | 71 return false; |
56 } | 72 } |
57 return true; | 73 return true; |
58 } | 74 } |
59 | 75 |
60 bool GpuVideoDecoderHost::Uninitialize() { | 76 bool GpuVideoDecoderHost::Uninitialize() { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 GpuVideoDecoderInputBufferParam param; | 220 GpuVideoDecoderInputBufferParam param; |
205 param.offset_ = 0; | 221 param.offset_ = 0; |
206 param.size_ = buffer->GetDataSize(); | 222 param.size_ = buffer->GetDataSize(); |
207 param.timestamp_ = buffer->GetTimestamp().InMicroseconds(); | 223 param.timestamp_ = buffer->GetTimestamp().InMicroseconds(); |
208 memcpy(input_transfer_buffer_->memory(), buffer->GetData(), param.size_); | 224 memcpy(input_transfer_buffer_->memory(), buffer->GetData(), param.size_); |
209 if (!channel_host_->Send( | 225 if (!channel_host_->Send( |
210 new GpuVideoDecoderMsg_EmptyThisBuffer(route_id(), param))) { | 226 new GpuVideoDecoderMsg_EmptyThisBuffer(route_id(), param))) { |
211 LOG(ERROR) << "GpuVideoDecoderMsg_EmptyThisBuffer failed"; | 227 LOG(ERROR) << "GpuVideoDecoderMsg_EmptyThisBuffer failed"; |
212 } | 228 } |
213 } | 229 } |
214 | |
OLD | NEW |