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