OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/gpu/client/gpu_video_encode_accelerator_host.h" | 5 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "content/common/gpu/client/gpu_channel_host.h" | |
11 #include "content/common/gpu/media/gpu_video_accelerator_util.h" | 10 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
12 #include "content/common/gpu/media/media_messages.h" | 11 #include "content/common/gpu/media/media_messages.h" |
| 12 #include "gpu/ipc/client/gpu_channel_host.h" |
13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
14 #include "media/video/video_encode_accelerator.h" | 14 #include "media/video/video_encode_accelerator.h" |
15 #include "ui/gfx/gpu_memory_buffer.h" | 15 #include "ui/gfx/gpu_memory_buffer.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost( | 19 GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost( |
20 GpuChannelHost* channel, | 20 gpu::GpuChannelHost* channel, |
21 CommandBufferProxyImpl* impl) | 21 gpu::CommandBufferProxyImpl* impl) |
22 : channel_(channel), | 22 : channel_(channel), |
23 encoder_route_id_(MSG_ROUTING_NONE), | 23 encoder_route_id_(MSG_ROUTING_NONE), |
24 client_(NULL), | 24 client_(NULL), |
25 impl_(impl), | 25 impl_(impl), |
26 next_frame_id_(0), | 26 next_frame_id_(0), |
27 weak_this_factory_(this) { | 27 weak_this_factory_(this) { |
28 DCHECK(channel_); | 28 DCHECK(channel_); |
29 DCHECK(impl_); | 29 DCHECK(impl_); |
30 impl_->AddDeletionObserver(this); | 30 impl_->AddDeletionObserver(this); |
31 } | 31 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 if (channel_) | 174 if (channel_) |
175 Send(new AcceleratedVideoEncoderMsg_Destroy(encoder_route_id_)); | 175 Send(new AcceleratedVideoEncoderMsg_Destroy(encoder_route_id_)); |
176 client_ = NULL; | 176 client_ = NULL; |
177 delete this; | 177 delete this; |
178 } | 178 } |
179 | 179 |
180 void GpuVideoEncodeAcceleratorHost::OnWillDeleteImpl() { | 180 void GpuVideoEncodeAcceleratorHost::OnWillDeleteImpl() { |
181 DCHECK(CalledOnValidThread()); | 181 DCHECK(CalledOnValidThread()); |
182 impl_ = NULL; | 182 impl_ = NULL; |
183 | 183 |
184 // The CommandBufferProxyImpl is going away; error out this VEA. | 184 // The gpu::CommandBufferProxyImpl is going away; error out this VEA. |
185 OnChannelError(); | 185 OnChannelError(); |
186 } | 186 } |
187 | 187 |
188 void GpuVideoEncodeAcceleratorHost::EncodeGpuMemoryBufferFrame( | 188 void GpuVideoEncodeAcceleratorHost::EncodeGpuMemoryBufferFrame( |
189 const scoped_refptr<media::VideoFrame>& frame, | 189 const scoped_refptr<media::VideoFrame>& frame, |
190 bool force_keyframe){ | 190 bool force_keyframe){ |
191 DCHECK_EQ(media::VideoFrame::NumPlanes(media::PIXEL_FORMAT_I420), | 191 DCHECK_EQ(media::VideoFrame::NumPlanes(media::PIXEL_FORMAT_I420), |
192 frame->gpu_memory_buffer_handles().size()); | 192 frame->gpu_memory_buffer_handles().size()); |
193 AcceleratedVideoEncoderMsg_Encode_Params2 params; | 193 AcceleratedVideoEncoderMsg_Encode_Params2 params; |
194 params.frame_id = next_frame_id_; | 194 params.frame_id = next_frame_id_; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 weak_this_factory_.InvalidateWeakPtrs(); | 320 weak_this_factory_.InvalidateWeakPtrs(); |
321 | 321 |
322 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 322 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
323 // last thing done on this stack! | 323 // last thing done on this stack! |
324 media::VideoEncodeAccelerator::Client* client = NULL; | 324 media::VideoEncodeAccelerator::Client* client = NULL; |
325 std::swap(client_, client); | 325 std::swap(client_, client); |
326 client->NotifyError(error); | 326 client->NotifyError(error); |
327 } | 327 } |
328 | 328 |
329 } // namespace content | 329 } // namespace content |
OLD | NEW |