| 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_messages.h" | 12 #include "content/common/gpu/media/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.input_format = input_format; |
| 98 params.input_visible_size = input_visible_size; |
| 99 params.output_profile = output_profile; |
| 100 params.initial_bitrate = initial_bitrate; |
| 101 params.encoder_route_id = route_id; |
| 96 bool succeeded = false; | 102 bool succeeded = false; |
| 97 Send(new GpuCommandBufferMsg_CreateVideoEncoder( | 103 Send(new GpuCommandBufferMsg_CreateVideoEncoder(impl_->route_id(), params, |
| 98 impl_->route_id(), input_format, input_visible_size, output_profile, | 104 &succeeded)); |
| 99 initial_bitrate, route_id, &succeeded)); | |
| 100 if (!succeeded) { | 105 if (!succeeded) { |
| 101 DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoEncoder()) failed"; | 106 DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoEncoder()) failed"; |
| 102 channel_->RemoveRoute(route_id); | 107 channel_->RemoveRoute(route_id); |
| 103 return false; | 108 return false; |
| 104 } | 109 } |
| 105 encoder_route_id_ = route_id; | 110 encoder_route_id_ = route_id; |
| 106 return true; | 111 return true; |
| 107 } | 112 } |
| 108 | 113 |
| 109 void GpuVideoEncodeAcceleratorHost::Encode( | 114 void GpuVideoEncodeAcceleratorHost::Encode( |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 weak_this_factory_.InvalidateWeakPtrs(); | 320 weak_this_factory_.InvalidateWeakPtrs(); |
| 316 | 321 |
| 317 // 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 |
| 318 // last thing done on this stack! | 323 // last thing done on this stack! |
| 319 media::VideoEncodeAccelerator::Client* client = NULL; | 324 media::VideoEncodeAccelerator::Client* client = NULL; |
| 320 std::swap(client_, client); | 325 std::swap(client_, client); |
| 321 client->NotifyError(error); | 326 client->NotifyError(error); |
| 322 } | 327 } |
| 323 | 328 |
| 324 } // namespace content | 329 } // namespace content |
| OLD | NEW |