Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: content/renderer/gpu/gpu_video_decode_accelerator_host.cc

Issue 9340012: Move gpu client files to content_common, in content/common/gpu/client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unneeded enums Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 "content/renderer/gpu/gpu_video_decode_accelerator_host.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/message_loop.h"
10 #include "content/common/gpu/gpu_messages.h"
11 #include "content/common/view_messages.h"
12 #include "content/renderer/gpu/gpu_channel_host.h"
13 #include "ipc/ipc_message_macros.h"
14 #include "ipc/ipc_message_utils.h"
15
16 using media::VideoDecodeAccelerator;
17
18 GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost(
19 GpuChannelHost* channel,
20 int32 decoder_route_id,
21 VideoDecodeAccelerator::Client* client)
22 : channel_(channel),
23 decoder_route_id_(decoder_route_id),
24 client_(client) {
25 DCHECK(channel_);
26 DCHECK(client_);
27 }
28
29 GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() {}
30
31 void GpuVideoDecodeAcceleratorHost::OnChannelError() {
32 OnErrorNotification(PLATFORM_FAILURE);
33 channel_ = NULL;
34 }
35
36 bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) {
37 DCHECK(CalledOnValidThread());
38 bool handled = true;
39 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAcceleratorHost, msg)
40 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed,
41 OnBitstreamBufferProcessed)
42 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers,
43 OnProvidePictureBuffer)
44 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady,
45 OnPictureReady)
46 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone,
47 OnFlushDone)
48 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone,
49 OnResetDone)
50 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ErrorNotification,
51 OnErrorNotification)
52 IPC_MESSAGE_UNHANDLED(handled = false)
53 IPC_END_MESSAGE_MAP()
54 DCHECK(handled);
55 return handled;
56 }
57
58 bool GpuVideoDecodeAcceleratorHost::Initialize(Profile profile) {
59 NOTREACHED();
60 return true;
61 }
62
63 void GpuVideoDecodeAcceleratorHost::Decode(
64 const media::BitstreamBuffer& bitstream_buffer) {
65 DCHECK(CalledOnValidThread());
66 Send(new AcceleratedVideoDecoderMsg_Decode(
67 decoder_route_id_, bitstream_buffer.handle(),
68 bitstream_buffer.id(), bitstream_buffer.size()));
69 }
70
71 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers(
72 const std::vector<media::PictureBuffer>& buffers) {
73 DCHECK(CalledOnValidThread());
74 // Rearrange data for IPC command.
75 std::vector<int32> buffer_ids;
76 std::vector<uint32> texture_ids;
77 std::vector<gfx::Size> sizes;
78 for (uint32 i = 0; i < buffers.size(); i++) {
79 const media::PictureBuffer& buffer = buffers[i];
80 texture_ids.push_back(buffer.texture_id());
81 buffer_ids.push_back(buffer.id());
82 sizes.push_back(buffer.size());
83 }
84 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers(
85 decoder_route_id_, buffer_ids, texture_ids, sizes));
86 }
87
88 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer(
89 int32 picture_buffer_id) {
90 DCHECK(CalledOnValidThread());
91 Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer(
92 decoder_route_id_, picture_buffer_id));
93 }
94
95 void GpuVideoDecodeAcceleratorHost::Flush() {
96 DCHECK(CalledOnValidThread());
97 Send(new AcceleratedVideoDecoderMsg_Flush(decoder_route_id_));
98 }
99
100 void GpuVideoDecodeAcceleratorHost::Reset() {
101 DCHECK(CalledOnValidThread());
102 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_));
103 }
104
105 void GpuVideoDecodeAcceleratorHost::Destroy() {
106 DCHECK(CalledOnValidThread());
107 channel_->RemoveRoute(decoder_route_id_);
108 client_ = NULL;
109 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_));
110 }
111
112 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) {
113 // After OnChannelError is called, the client should no longer send
114 // messages to the gpu channel through this object.
115 DCHECK(channel_);
116 if (!channel_ || !channel_->Send(message)) {
117 DLOG(ERROR) << "Send(" << message->type() << ") failed";
118 OnErrorNotification(PLATFORM_FAILURE);
119 }
120 }
121
122 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed(
123 int32 bitstream_buffer_id) {
124 DCHECK(CalledOnValidThread());
125 if (client_)
126 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id);
127 }
128
129 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer(
130 uint32 num_requested_buffers,
131 const gfx::Size& buffer_size) {
132 DCHECK(CalledOnValidThread());
133 if (client_)
134 client_->ProvidePictureBuffers(num_requested_buffers, buffer_size);
135 }
136
137 void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer(
138 int32 picture_buffer_id) {
139 DCHECK(CalledOnValidThread());
140 if (client_)
141 client_->DismissPictureBuffer(picture_buffer_id);
142 }
143
144 void GpuVideoDecodeAcceleratorHost::OnPictureReady(
145 int32 picture_buffer_id, int32 bitstream_buffer_id) {
146 DCHECK(CalledOnValidThread());
147 if (!client_)
148 return;
149 media::Picture picture(picture_buffer_id, bitstream_buffer_id);
150 client_->PictureReady(picture);
151 }
152
153 void GpuVideoDecodeAcceleratorHost::OnFlushDone() {
154 DCHECK(CalledOnValidThread());
155 if (client_)
156 client_->NotifyFlushDone();
157 }
158
159 void GpuVideoDecodeAcceleratorHost::OnResetDone() {
160 DCHECK(CalledOnValidThread());
161 if (client_)
162 client_->NotifyResetDone();
163 }
164
165 void GpuVideoDecodeAcceleratorHost::OnErrorNotification(uint32 error) {
166 DCHECK(CalledOnValidThread());
167 if (!client_)
168 return;
169 client_->NotifyError(
170 static_cast<media::VideoDecodeAccelerator::Error>(error));
171 }
OLDNEW
« no previous file with comments | « content/renderer/gpu/gpu_video_decode_accelerator_host.h ('k') | content/renderer/gpu/renderer_gl_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698