| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> | 170 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> |
| 170 create_vea_fps = CreateVEAFps(); | 171 create_vea_fps = CreateVEAFps(); |
| 171 | 172 |
| 172 for (size_t i = 0; i < create_vea_fps.size(); ++i) { | 173 for (size_t i = 0; i < create_vea_fps.size(); ++i) { |
| 173 scoped_ptr<media::VideoEncodeAccelerator> | 174 scoped_ptr<media::VideoEncodeAccelerator> |
| 174 encoder = (*create_vea_fps[i])(); | 175 encoder = (*create_vea_fps[i])(); |
| 175 if (!encoder) | 176 if (!encoder) |
| 176 continue; | 177 continue; |
| 177 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 178 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
| 178 vea_profiles = encoder->GetSupportedProfiles(); | 179 vea_profiles = encoder->GetSupportedProfiles(); |
| 179 profiles.insert(profiles.end(), vea_profiles.begin(), vea_profiles.end()); | 180 GpuVideoAcceleratorUtil::InsertUniqueEncodeProfiles( |
| 181 vea_profiles, &profiles); |
| 180 } | 182 } |
| 181 return ConvertMediaToGpuProfiles(profiles); | 183 return GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles(profiles); |
| 182 } | 184 } |
| 183 | 185 |
| 184 // static | 186 // 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> | 187 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> |
| 204 GpuVideoEncodeAccelerator::CreateVEAFps() { | 188 GpuVideoEncodeAccelerator::CreateVEAFps() { |
| 205 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; | 189 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; |
| 206 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); | 190 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); |
| 207 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); | 191 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); |
| 208 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); | 192 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); |
| 209 return create_vea_fps; | 193 return create_vea_fps; |
| 210 } | 194 } |
| 211 | 195 |
| 212 // static | 196 // static |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 stub_->channel()->Send(message); | 351 stub_->channel()->Send(message); |
| 368 } | 352 } |
| 369 | 353 |
| 370 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, | 354 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, |
| 371 bool succeeded) { | 355 bool succeeded) { |
| 372 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); | 356 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); |
| 373 Send(message); | 357 Send(message); |
| 374 } | 358 } |
| 375 | 359 |
| 376 } // namespace content | 360 } // namespace content |
| OLD | NEW |