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 "content/common/gpu/gpu_channel.h" | 11 #include "content/common/gpu/gpu_channel.h" |
12 #include "content/common/gpu/gpu_messages.h" | 12 #include "content/common/gpu/gpu_messages.h" |
13 #include "ipc/ipc_message_macros.h" | 13 #include "ipc/ipc_message_macros.h" |
14 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
15 | 15 |
| 16 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 17 #include "content/common/gpu/media/exynos_video_encode_accelerator.h" |
| 18 #endif |
| 19 |
16 namespace content { | 20 namespace content { |
17 | 21 |
18 GpuVideoEncodeAccelerator::GpuVideoEncodeAccelerator(GpuChannel* gpu_channel, | 22 GpuVideoEncodeAccelerator::GpuVideoEncodeAccelerator(GpuChannel* gpu_channel, |
19 int32 route_id) | 23 int32 route_id) |
20 : weak_this_factory_(this), | 24 : weak_this_factory_(this), |
21 channel_(gpu_channel), | 25 channel_(gpu_channel), |
22 route_id_(route_id), | 26 route_id_(route_id), |
23 input_format_(media::VideoFrame::INVALID), | 27 input_format_(media::VideoFrame::INVALID), |
24 output_buffer_size_(0) {} | 28 output_buffer_size_(0) {} |
25 | 29 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 void GpuVideoEncodeAccelerator::NotifyError( | 77 void GpuVideoEncodeAccelerator::NotifyError( |
74 media::VideoEncodeAccelerator::Error error) { | 78 media::VideoEncodeAccelerator::Error error) { |
75 Send(new AcceleratedVideoEncoderHostMsg_NotifyError(route_id_, error)); | 79 Send(new AcceleratedVideoEncoderHostMsg_NotifyError(route_id_, error)); |
76 } | 80 } |
77 | 81 |
78 // static | 82 // static |
79 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 83 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
80 GpuVideoEncodeAccelerator::GetSupportedProfiles() { | 84 GpuVideoEncodeAccelerator::GetSupportedProfiles() { |
81 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; | 85 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; |
82 | 86 |
| 87 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 88 profiles = ExynosVideoEncodeAccelerator::GetSupportedProfiles(); |
| 89 #endif |
| 90 |
83 // TODO(sheu): return platform-specific profiles. | 91 // TODO(sheu): return platform-specific profiles. |
84 return profiles; | 92 return profiles; |
85 } | 93 } |
86 | 94 |
87 void GpuVideoEncodeAccelerator::CreateEncoder() { | 95 void GpuVideoEncodeAccelerator::CreateEncoder() { |
88 // TODO(sheu): actual create the encoder. | 96 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 97 encoder_.reset(new ExynosVideoEncodeAccelerator(this)); |
| 98 #endif |
89 } | 99 } |
90 | 100 |
91 void GpuVideoEncodeAccelerator::OnInitialize( | 101 void GpuVideoEncodeAccelerator::OnInitialize( |
92 media::VideoFrame::Format input_format, | 102 media::VideoFrame::Format input_format, |
93 const gfx::Size& input_visible_size, | 103 const gfx::Size& input_visible_size, |
94 media::VideoCodecProfile output_profile, | 104 media::VideoCodecProfile output_profile, |
95 uint32 initial_bitrate) { | 105 uint32 initial_bitrate) { |
96 DVLOG(2) << "GpuVideoEncodeAccelerator::OnInitialize(): " | 106 DVLOG(2) << "GpuVideoEncodeAccelerator::OnInitialize(): " |
97 "input_format=" << input_format | 107 "input_format=" << input_format |
98 << ", input_visible_size=" << input_visible_size.ToString() | 108 << ", input_visible_size=" << input_visible_size.ToString() |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 new base::SharedMemory(buffer_handle, true)); | 150 new base::SharedMemory(buffer_handle, true)); |
141 if (!shm->Map(buffer_size)) { | 151 if (!shm->Map(buffer_size)) { |
142 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " | 152 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " |
143 "could not map frame_id=" << frame_id; | 153 "could not map frame_id=" << frame_id; |
144 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 154 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); |
145 return; | 155 return; |
146 } | 156 } |
147 | 157 |
148 scoped_refptr<media::VideoFrame> frame = | 158 scoped_refptr<media::VideoFrame> frame = |
149 media::VideoFrame::WrapExternalSharedMemory( | 159 media::VideoFrame::WrapExternalSharedMemory( |
150 media::VideoFrame::I420, | 160 input_format_, |
151 input_coded_size_, | 161 input_coded_size_, |
152 gfx::Rect(input_visible_size_), | 162 gfx::Rect(input_visible_size_), |
153 input_visible_size_, | 163 input_visible_size_, |
154 reinterpret_cast<uint8*>(shm->memory()), | 164 reinterpret_cast<uint8*>(shm->memory()), |
155 buffer_handle, | 165 buffer_handle, |
156 base::TimeDelta(), | 166 base::TimeDelta(), |
157 // It's turtles all the way down... | 167 // It's turtles all the way down... |
158 base::Bind(base::IgnoreResult(&base::MessageLoopProxy::PostTask), | 168 base::Bind(base::IgnoreResult(&base::MessageLoopProxy::PostTask), |
159 base::MessageLoopProxy::current(), | 169 base::MessageLoopProxy::current(), |
160 FROM_HERE, | 170 FROM_HERE, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 return; | 233 return; |
224 } else if (!channel_->Send(message)) { | 234 } else if (!channel_->Send(message)) { |
225 DLOG(ERROR) << "GpuVideoEncodeAccelerator::Send(): sending failed: " | 235 DLOG(ERROR) << "GpuVideoEncodeAccelerator::Send(): sending failed: " |
226 "message->type()=" << message->type(); | 236 "message->type()=" << message->type(); |
227 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 237 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); |
228 return; | 238 return; |
229 } | 239 } |
230 } | 240 } |
231 | 241 |
232 } // namespace content | 242 } // namespace content |
OLD | NEW |