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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "content/common/gpu/client/gpu_channel_host.h" | 9 #include "content/common/gpu/client/gpu_channel_host.h" |
10 #include "content/common/gpu/gpu_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 GpuVideoEncodeAcceleratorHost::~GpuVideoEncodeAcceleratorHost() { | 34 GpuVideoEncodeAcceleratorHost::~GpuVideoEncodeAcceleratorHost() { |
35 DCHECK(CalledOnValidThread()); | 35 DCHECK(CalledOnValidThread()); |
36 if (channel_ && encoder_route_id_ != MSG_ROUTING_NONE) | 36 if (channel_ && encoder_route_id_ != MSG_ROUTING_NONE) |
37 channel_->RemoveRoute(encoder_route_id_); | 37 channel_->RemoveRoute(encoder_route_id_); |
38 if (impl_) | 38 if (impl_) |
39 impl_->RemoveDeletionObserver(this); | 39 impl_->RemoveDeletionObserver(this); |
40 } | 40 } |
41 | 41 |
42 // static | |
43 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | |
44 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles() { | |
45 return GpuVideoEncodeAccelerator::GetSupportedProfiles(); | |
46 } | |
47 | |
48 bool GpuVideoEncodeAcceleratorHost::OnMessageReceived( | 42 bool GpuVideoEncodeAcceleratorHost::OnMessageReceived( |
49 const IPC::Message& message) { | 43 const IPC::Message& message) { |
50 bool handled = true; | 44 bool handled = true; |
51 IPC_BEGIN_MESSAGE_MAP(GpuVideoEncodeAcceleratorHost, message) | 45 IPC_BEGIN_MESSAGE_MAP(GpuVideoEncodeAcceleratorHost, message) |
52 IPC_MESSAGE_HANDLER(AcceleratedVideoEncoderHostMsg_RequireBitstreamBuffers, | 46 IPC_MESSAGE_HANDLER(AcceleratedVideoEncoderHostMsg_RequireBitstreamBuffers, |
53 OnRequireBitstreamBuffers) | 47 OnRequireBitstreamBuffers) |
54 IPC_MESSAGE_HANDLER(AcceleratedVideoEncoderHostMsg_NotifyInputDone, | 48 IPC_MESSAGE_HANDLER(AcceleratedVideoEncoderHostMsg_NotifyInputDone, |
55 OnNotifyInputDone) | 49 OnNotifyInputDone) |
56 IPC_MESSAGE_HANDLER(AcceleratedVideoEncoderHostMsg_BitstreamBufferReady, | 50 IPC_MESSAGE_HANDLER(AcceleratedVideoEncoderHostMsg_BitstreamBufferReady, |
57 OnBitstreamBufferReady) | 51 OnBitstreamBufferReady) |
(...skipping 10 matching lines...) Expand all Loading... |
68 void GpuVideoEncodeAcceleratorHost::OnChannelError() { | 62 void GpuVideoEncodeAcceleratorHost::OnChannelError() { |
69 DCHECK(CalledOnValidThread()); | 63 DCHECK(CalledOnValidThread()); |
70 if (channel_) { | 64 if (channel_) { |
71 if (encoder_route_id_ != MSG_ROUTING_NONE) | 65 if (encoder_route_id_ != MSG_ROUTING_NONE) |
72 channel_->RemoveRoute(encoder_route_id_); | 66 channel_->RemoveRoute(encoder_route_id_); |
73 channel_ = NULL; | 67 channel_ = NULL; |
74 } | 68 } |
75 NOTIFY_ERROR(kPlatformFailureError) << "OnChannelError()"; | 69 NOTIFY_ERROR(kPlatformFailureError) << "OnChannelError()"; |
76 } | 70 } |
77 | 71 |
| 72 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
| 73 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles() { |
| 74 DCHECK(CalledOnValidThread()); |
| 75 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; |
| 76 if (!channel_) |
| 77 return profiles; |
| 78 |
| 79 Send(new GpuCommandBufferMsg_VideoEncodeAcceleratorGetSupportedProfiles( |
| 80 impl_->GetRouteID(), &profiles)); |
| 81 return profiles; |
| 82 } |
| 83 |
78 bool GpuVideoEncodeAcceleratorHost::Initialize( | 84 bool GpuVideoEncodeAcceleratorHost::Initialize( |
79 media::VideoFrame::Format input_format, | 85 media::VideoFrame::Format input_format, |
80 const gfx::Size& input_visible_size, | 86 const gfx::Size& input_visible_size, |
81 media::VideoCodecProfile output_profile, | 87 media::VideoCodecProfile output_profile, |
82 uint32 initial_bitrate, | 88 uint32 initial_bitrate, |
83 Client* client) { | 89 Client* client) { |
84 DCHECK(CalledOnValidThread()); | 90 DCHECK(CalledOnValidThread()); |
85 client_ = client; | 91 client_ = client; |
86 if (!impl_) { | 92 if (!impl_) { |
87 DLOG(ERROR) << "impl_ destroyed"; | 93 DLOG(ERROR) << "impl_ destroyed"; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 weak_this_factory_.InvalidateWeakPtrs(); | 273 weak_this_factory_.InvalidateWeakPtrs(); |
268 | 274 |
269 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 275 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
270 // last thing done on this stack! | 276 // last thing done on this stack! |
271 media::VideoEncodeAccelerator::Client* client = NULL; | 277 media::VideoEncodeAccelerator::Client* client = NULL; |
272 std::swap(client_, client); | 278 std::swap(client_, client); |
273 client->NotifyError(error); | 279 client->NotifyError(error); |
274 } | 280 } |
275 | 281 |
276 } // namespace content | 282 } // namespace content |
OLD | NEW |