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_service_host.h" | 5 #include "chrome/renderer/gpu_video_service_host.h" |
6 | 6 |
7 #include "chrome/common/gpu_messages.h" | 7 #include "chrome/common/gpu_messages.h" |
8 #include "chrome/renderer/gpu_video_decoder_host.h" | 8 #include "chrome/renderer/gpu_video_decoder_host.h" |
9 #include "chrome/renderer/render_thread.h" | 9 #include "chrome/renderer/render_thread.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 void GpuVideoServiceHost::OnMessageReceived(const IPC::Message& msg) { | 23 void GpuVideoServiceHost::OnMessageReceived(const IPC::Message& msg) { |
24 #if 0 | 24 #if 0 |
25 IPC_BEGIN_MESSAGE_MAP(GpuVideoServiceHost, msg) | 25 IPC_BEGIN_MESSAGE_MAP(GpuVideoServiceHost, msg) |
26 IPC_MESSAGE_UNHANDLED_ERROR() | 26 IPC_MESSAGE_UNHANDLED_ERROR() |
27 IPC_END_MESSAGE_MAP() | 27 IPC_END_MESSAGE_MAP() |
28 #endif | 28 #endif |
29 } | 29 } |
30 | 30 |
31 scoped_refptr<GpuVideoDecoderHost> GpuVideoServiceHost::CreateVideoDecoder( | |
32 GpuVideoDecoderHost::EventHandler* event_handler) { | |
33 DCHECK(RenderThread::current()); | |
34 | |
35 if (!channel_host_.get() || !service_info_.service_available_) | |
36 return NULL; | |
37 | |
38 GpuVideoDecoderInfoParam param; | |
39 if (!channel_host_->Send(new GpuChannelMsg_CreateVideoDecoder(¶m))) { | |
40 LOG(ERROR) << "GpuChannelMsg_CreateVideoDecoder failed"; | |
41 return NULL; | |
42 } | |
43 | |
44 scoped_refptr<GpuVideoDecoderHost> gpu_video_decoder_host = | |
45 new GpuVideoDecoderHost(this, channel_host_, event_handler, param); | |
46 if (!gpu_video_decoder_host.get()) { | |
47 if (!channel_host_->Send( | |
48 new GpuChannelMsg_DestroyVideoDecoder(param.decoder_id_))) { | |
49 LOG(ERROR) << "GpuChannelMsg_DestroyVideoDecoder failed"; | |
50 } | |
51 return NULL; | |
52 } | |
53 | |
54 router_->AddRoute(gpu_video_decoder_host->my_route_id(), | |
55 gpu_video_decoder_host.get()); | |
56 return gpu_video_decoder_host; | |
57 } | |
58 | |
59 void GpuVideoServiceHost::DestroyVideoDecoder( | |
60 scoped_refptr<GpuVideoDecoderHost> gpu_video_decoder_host) { | |
61 DCHECK(RenderThread::current()); | |
62 | |
63 if (!channel_host_.get() || !service_info_.service_available_) | |
64 return; | |
65 | |
66 DCHECK(gpu_video_decoder_host.get()); | |
67 | |
68 int32 decoder_id = gpu_video_decoder_host->decoder_id(); | |
69 if (!channel_host_->Send(new GpuChannelMsg_DestroyVideoDecoder(decoder_id))) { | |
70 LOG(ERROR) << "GpuChannelMsg_DestroyVideoDecoder failed"; | |
71 } | |
72 | |
73 router_->RemoveRoute(gpu_video_decoder_host->my_route_id()); | |
74 } | |
75 | |
76 void GpuVideoServiceHost::OnRendererThreadInit(MessageLoop* message_loop) { | 31 void GpuVideoServiceHost::OnRendererThreadInit(MessageLoop* message_loop) { |
77 message_loop_ = message_loop; | 32 message_loop_ = message_loop; |
78 } | 33 } |
79 | 34 |
80 void GpuVideoServiceHost::OnGpuChannelConnected( | 35 void GpuVideoServiceHost::OnGpuChannelConnected( |
81 GpuChannelHost* channel_host, | 36 GpuChannelHost* channel_host, |
82 MessageRouter* router, | 37 MessageRouter* router, |
83 IPC::SyncChannel* channel) { | 38 IPC::SyncChannel* channel) { |
84 | 39 |
85 channel_host_ = channel_host; | 40 channel_host_ = channel_host; |
86 router_ = router; | 41 router_ = router; |
87 | 42 |
88 // Get the routing_id of video service in GPU process. | 43 // Get the routing_id of video service in GPU process. |
89 service_info_.service_available_ = 0; | 44 service_info_.service_available_ = 0; |
90 if (!channel_host_->Send(new GpuChannelMsg_GetVideoService(&service_info_))) { | 45 if (!channel_host_->Send(new GpuChannelMsg_GetVideoService(&service_info_))) { |
91 LOG(ERROR) << "GpuChannelMsg_GetVideoService failed"; | 46 LOG(ERROR) << "GpuChannelMsg_GetVideoService failed"; |
92 } | 47 } |
93 | 48 |
94 if (service_info_.service_available_) | 49 if (service_info_.service_available_) |
95 router->AddRoute(service_info_.video_service_host_route_id_, this); | 50 router->AddRoute(service_info_.video_service_host_route_id_, this); |
96 } | 51 } |
97 | 52 |
| 53 GpuVideoDecoderHost* GpuVideoServiceHost::CreateVideoDecoder( |
| 54 int context_route_id) { |
| 55 DCHECK(RenderThread::current()); |
| 56 |
| 57 return new GpuVideoDecoderHost(this, channel_host_, context_route_id); |
| 58 } |
| 59 |
| 60 void GpuVideoServiceHost::AddRoute(int route_id, |
| 61 GpuVideoDecoderHost* decoder_host) { |
| 62 router_->AddRoute(route_id, decoder_host); |
| 63 } |
| 64 |
| 65 void GpuVideoServiceHost::RemoveRoute(int route_id) { |
| 66 router_->RemoveRoute(route_id); |
| 67 } |
OLD | NEW |