| 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" | 10 #include "content/common/gpu/client/gpu_channel_host.h" |
| 11 #include "content/common/gpu/media/gpu_video_accelerator_util.h" | 11 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
| 12 #include "content/common/gpu/media/media_messages.h" | 12 #include "content/common/gpu/media_messages.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 GpuChannelHost* channel, |
| 21 CommandBufferProxyImpl* impl) | 21 CommandBufferProxyImpl* impl) |
| 22 : channel_(channel), | 22 : channel_(channel), |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 DCHECK(CalledOnValidThread()); | 86 DCHECK(CalledOnValidThread()); |
| 87 client_ = client; | 87 client_ = client; |
| 88 if (!impl_) { | 88 if (!impl_) { |
| 89 DLOG(ERROR) << "impl_ destroyed"; | 89 DLOG(ERROR) << "impl_ destroyed"; |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 int32_t route_id = channel_->GenerateRouteID(); | 93 int32_t route_id = channel_->GenerateRouteID(); |
| 94 channel_->AddRoute(route_id, weak_this_factory_.GetWeakPtr()); | 94 channel_->AddRoute(route_id, weak_this_factory_.GetWeakPtr()); |
| 95 | 95 |
| 96 CreateVideoEncoderParams params; | |
| 97 params.command_buffer_route_id = impl_->route_id(); | |
| 98 params.input_format = input_format; | |
| 99 params.input_visible_size = input_visible_size; | |
| 100 params.output_profile = output_profile; | |
| 101 params.initial_bitrate = initial_bitrate; | |
| 102 params.encoder_route_id = route_id; | |
| 103 bool succeeded = false; | 96 bool succeeded = false; |
| 104 Send(new GpuCommandBufferMsg_CreateVideoEncoder(params, &succeeded)); | 97 Send(new GpuCommandBufferMsg_CreateVideoEncoder( |
| 98 impl_->route_id(), input_format, input_visible_size, output_profile, |
| 99 initial_bitrate, route_id, &succeeded)); |
| 105 if (!succeeded) { | 100 if (!succeeded) { |
| 106 DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoEncoder()) failed"; | 101 DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoEncoder()) failed"; |
| 107 channel_->RemoveRoute(route_id); | 102 channel_->RemoveRoute(route_id); |
| 108 return false; | 103 return false; |
| 109 } | 104 } |
| 110 encoder_route_id_ = route_id; | 105 encoder_route_id_ = route_id; |
| 111 return true; | 106 return true; |
| 112 } | 107 } |
| 113 | 108 |
| 114 void GpuVideoEncodeAcceleratorHost::Encode( | 109 void GpuVideoEncodeAcceleratorHost::Encode( |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 weak_this_factory_.InvalidateWeakPtrs(); | 315 weak_this_factory_.InvalidateWeakPtrs(); |
| 321 | 316 |
| 322 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 317 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
| 323 // last thing done on this stack! | 318 // last thing done on this stack! |
| 324 media::VideoEncodeAccelerator::Client* client = NULL; | 319 media::VideoEncodeAccelerator::Client* client = NULL; |
| 325 std::swap(client_, client); | 320 std::swap(client_, client); |
| 326 client->NotifyError(error); | 321 client->NotifyError(error); |
| 327 } | 322 } |
| 328 | 323 |
| 329 } // namespace content | 324 } // namespace content |
| OLD | NEW |