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/media/gpu_video_encode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/common/gpu/gpu_channel.h" | 12 #include "content/common/gpu/gpu_channel.h" |
13 #include "content/common/gpu/gpu_messages.h" | 13 #include "content/common/gpu/gpu_messages.h" |
14 #include "ipc/ipc_message_macros.h" | 14 #include "ipc/ipc_message_macros.h" |
15 #include "media/base/limits.h" | 15 #include "media/base/limits.h" |
16 #include "media/base/video_frame.h" | 16 #include "media/base/video_frame.h" |
17 | 17 |
18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
19 #include "content/common/gpu/media/exynos_video_encode_accelerator.h" | 19 #include "content/common/gpu/media/exynos_video_encode_accelerator.h" |
| 20 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 21 #include "content/common/gpu/media/android_video_encode_accelerator.h" |
20 #endif | 22 #endif |
21 | 23 |
22 namespace content { | 24 namespace content { |
23 | 25 |
24 GpuVideoEncodeAccelerator::GpuVideoEncodeAccelerator(GpuChannel* gpu_channel, | 26 GpuVideoEncodeAccelerator::GpuVideoEncodeAccelerator(GpuChannel* gpu_channel, |
25 int32 route_id) | 27 int32 route_id) |
26 : weak_this_factory_(this), | 28 : weak_this_factory_(this), |
27 channel_(gpu_channel), | 29 channel_(gpu_channel), |
28 route_id_(route_id), | 30 route_id_(route_id), |
29 input_format_(media::VideoFrame::UNKNOWN), | 31 input_format_(media::VideoFrame::UNKNOWN), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 Send(new AcceleratedVideoEncoderHostMsg_NotifyError(route_id_, error)); | 83 Send(new AcceleratedVideoEncoderHostMsg_NotifyError(route_id_, error)); |
82 } | 84 } |
83 | 85 |
84 // static | 86 // static |
85 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 87 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
86 GpuVideoEncodeAccelerator::GetSupportedProfiles() { | 88 GpuVideoEncodeAccelerator::GetSupportedProfiles() { |
87 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; | 89 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; |
88 | 90 |
89 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 91 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
90 profiles = ExynosVideoEncodeAccelerator::GetSupportedProfiles(); | 92 profiles = ExynosVideoEncodeAccelerator::GetSupportedProfiles(); |
| 93 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 94 profiles = AndroidVideoEncodeAccelerator::GetSupportedProfiles(); |
91 #endif | 95 #endif |
92 | 96 |
93 // TODO(sheu): return platform-specific profiles. | 97 // TODO(sheu): return platform-specific profiles. |
94 return profiles; | 98 return profiles; |
95 } | 99 } |
96 | 100 |
97 void GpuVideoEncodeAccelerator::CreateEncoder() { | 101 void GpuVideoEncodeAccelerator::CreateEncoder() { |
| 102 DCHECK(!encoder_); |
98 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 103 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
99 encoder_.reset(new ExynosVideoEncodeAccelerator(this)); | 104 encoder_.reset(new ExynosVideoEncodeAccelerator(this)); |
| 105 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 106 encoder_.reset(new AndroidVideoEncodeAccelerator(this)); |
100 #endif | 107 #endif |
101 } | 108 } |
102 | 109 |
103 void GpuVideoEncodeAccelerator::OnInitialize( | 110 void GpuVideoEncodeAccelerator::OnInitialize( |
104 media::VideoFrame::Format input_format, | 111 media::VideoFrame::Format input_format, |
105 const gfx::Size& input_visible_size, | 112 const gfx::Size& input_visible_size, |
106 media::VideoCodecProfile output_profile, | 113 media::VideoCodecProfile output_profile, |
107 uint32 initial_bitrate) { | 114 uint32 initial_bitrate) { |
108 DVLOG(2) << "GpuVideoEncodeAccelerator::OnInitialize(): " | 115 DVLOG(2) << "GpuVideoEncodeAccelerator::OnInitialize(): " |
109 "input_format=" << input_format | 116 "input_format=" << input_format |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return; | 246 return; |
240 } else if (!channel_->Send(message)) { | 247 } else if (!channel_->Send(message)) { |
241 DLOG(ERROR) << "GpuVideoEncodeAccelerator::Send(): sending failed: " | 248 DLOG(ERROR) << "GpuVideoEncodeAccelerator::Send(): sending failed: " |
242 "message->type()=" << message->type(); | 249 "message->type()=" << message->type(); |
243 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 250 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); |
244 return; | 251 return; |
245 } | 252 } |
246 } | 253 } |
247 | 254 |
248 } // namespace content | 255 } // namespace content |
OLD | NEW |