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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/numerics/safe_math.h" | 12 #include "base/numerics/safe_math.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "content/common/gpu/gpu_channel.h" | 15 #include "content/common/gpu/gpu_channel.h" |
16 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
| 17 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
18 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
19 #include "media/base/limits.h" | 20 #include "media/base/limits.h" |
20 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
21 | 22 |
22 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
23 #if defined(USE_V4L2_CODEC) | 24 #if defined(USE_V4L2_CODEC) |
24 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 25 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
25 #endif | 26 #endif |
26 #if defined(ARCH_CPU_X86_FAMILY) | 27 #if defined(ARCH_CPU_X86_FAMILY) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 157 |
157 void GpuVideoEncodeAccelerator::OnWillDestroyStub() { | 158 void GpuVideoEncodeAccelerator::OnWillDestroyStub() { |
158 DCHECK(stub_); | 159 DCHECK(stub_); |
159 stub_->channel()->RemoveRoute(host_route_id_); | 160 stub_->channel()->RemoveRoute(host_route_id_); |
160 stub_->RemoveDestructionObserver(this); | 161 stub_->RemoveDestructionObserver(this); |
161 encoder_.reset(); | 162 encoder_.reset(); |
162 delete this; | 163 delete this; |
163 } | 164 } |
164 | 165 |
165 // static | 166 // static |
166 std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> | 167 void GpuVideoEncodeAccelerator::GetSupportedProfiles( |
167 GpuVideoEncodeAccelerator::GetSupportedProfiles() { | 168 std::vector<gpu::VideoEncodeAcceleratorSupportedProfile>* |
| 169 supported_profiles) { |
168 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; | 170 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; |
169 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> | 171 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> |
170 create_vea_fps = CreateVEAFps(); | 172 create_vea_fps = CreateVEAFps(); |
171 | 173 |
172 for (size_t i = 0; i < create_vea_fps.size(); ++i) { | 174 for (size_t i = 0; i < create_vea_fps.size(); ++i) { |
173 scoped_ptr<media::VideoEncodeAccelerator> | 175 scoped_ptr<media::VideoEncodeAccelerator> |
174 encoder = (*create_vea_fps[i])(); | 176 encoder = (*create_vea_fps[i])(); |
175 if (!encoder) | 177 if (!encoder) |
176 continue; | 178 continue; |
177 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 179 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
178 vea_profiles = encoder->GetSupportedProfiles(); | 180 vea_profiles = encoder->GetSupportedProfiles(); |
179 profiles.insert(profiles.end(), vea_profiles.begin(), vea_profiles.end()); | 181 GpuVideoAcceleratorUtil::UniqueInsertEncodeProfiles( |
| 182 &profiles, vea_profiles); |
180 } | 183 } |
181 return ConvertMediaToGpuProfiles(profiles); | 184 *supported_profiles = |
| 185 GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles(profiles); |
182 } | 186 } |
183 | 187 |
184 // static | 188 // static |
185 std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> | |
186 GpuVideoEncodeAccelerator::ConvertMediaToGpuProfiles(const std::vector< | |
187 media::VideoEncodeAccelerator::SupportedProfile>& media_profiles) { | |
188 std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> profiles; | |
189 for (size_t i = 0; i < media_profiles.size(); i++) { | |
190 gpu::VideoEncodeAcceleratorSupportedProfile profile; | |
191 profile.profile = | |
192 static_cast<gpu::VideoCodecProfile>(media_profiles[i].profile); | |
193 profile.max_resolution = media_profiles[i].max_resolution; | |
194 profile.max_framerate_numerator = media_profiles[i].max_framerate_numerator; | |
195 profile.max_framerate_denominator = | |
196 media_profiles[i].max_framerate_denominator; | |
197 profiles.push_back(profile); | |
198 } | |
199 return profiles; | |
200 } | |
201 | |
202 // static | |
203 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> | 189 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> |
204 GpuVideoEncodeAccelerator::CreateVEAFps() { | 190 GpuVideoEncodeAccelerator::CreateVEAFps() { |
205 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; | 191 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; |
206 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); | 192 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); |
207 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); | 193 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); |
208 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); | 194 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); |
209 return create_vea_fps; | 195 return create_vea_fps; |
210 } | 196 } |
211 | 197 |
212 // static | 198 // static |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 stub_->channel()->Send(message); | 353 stub_->channel()->Send(message); |
368 } | 354 } |
369 | 355 |
370 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, | 356 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, |
371 bool succeeded) { | 357 bool succeeded) { |
372 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); | 358 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); |
373 Send(message); | 359 Send(message); |
374 } | 360 } |
375 | 361 |
376 } // namespace content | 362 } // namespace content |
OLD | NEW |