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