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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 channel_ = NULL; | 67 channel_ = NULL; |
68 } | 68 } |
69 NOTIFY_ERROR(kPlatformFailureError) << "OnChannelError()"; | 69 NOTIFY_ERROR(kPlatformFailureError) << "OnChannelError()"; |
70 } | 70 } |
71 | 71 |
72 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 72 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
73 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles() { | 73 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles() { |
74 DCHECK(CalledOnValidThread()); | 74 DCHECK(CalledOnValidThread()); |
75 if (!channel_) | 75 if (!channel_) |
76 return std::vector<media::VideoEncodeAccelerator::SupportedProfile>(); | 76 return std::vector<media::VideoEncodeAccelerator::SupportedProfile>(); |
77 return channel_->gpu_info().video_encode_accelerator_supported_profiles; | 77 return ConvertGpuToMediaProfiles( |
| 78 channel_->gpu_info().video_encode_accelerator_supported_profiles); |
| 79 } |
| 80 |
| 81 // Make sure the enum values of media::VideoCodecProfile and |
| 82 // gpu::VideoCodecProfile match. |
| 83 #define STATIC_ASSERT_ENUM_MATCH(name) \ |
| 84 static_assert( \ |
| 85 media::name == static_cast<media::VideoCodecProfile>(gpu::name), \ |
| 86 #name " value must match in media and gpu.") |
| 87 |
| 88 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_UNKNOWN); |
| 89 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MIN); |
| 90 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_BASELINE); |
| 91 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MAIN); |
| 92 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_EXTENDED); |
| 93 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH); |
| 94 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH10PROFILE); |
| 95 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH422PROFILE); |
| 96 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH444PREDICTIVEPROFILE); |
| 97 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEBASELINE); |
| 98 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEHIGH); |
| 99 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_STEREOHIGH); |
| 100 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MULTIVIEWHIGH); |
| 101 STATIC_ASSERT_ENUM_MATCH(VP8PROFILE_ANY); |
| 102 STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_ANY); |
| 103 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MAX); |
| 104 |
| 105 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
| 106 GpuVideoEncodeAcceleratorHost::ConvertGpuToMediaProfiles(const std::vector< |
| 107 gpu::VideoEncodeAcceleratorSupportedProfile>& gpu_profiles) { |
| 108 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; |
| 109 for (size_t i = 0; i < gpu_profiles.size(); i++) { |
| 110 media::VideoEncodeAccelerator::SupportedProfile profile; |
| 111 profile.profile = |
| 112 static_cast<media::VideoCodecProfile>(gpu_profiles[i].profile); |
| 113 profile.max_resolution = gpu_profiles[i].max_resolution; |
| 114 profile.max_framerate_numerator = gpu_profiles[i].max_framerate_numerator; |
| 115 profile.max_framerate_denominator = |
| 116 gpu_profiles[i].max_framerate_denominator; |
| 117 profiles.push_back(profile); |
| 118 } |
| 119 return profiles; |
78 } | 120 } |
79 | 121 |
80 bool GpuVideoEncodeAcceleratorHost::Initialize( | 122 bool GpuVideoEncodeAcceleratorHost::Initialize( |
81 media::VideoFrame::Format input_format, | 123 media::VideoFrame::Format input_format, |
82 const gfx::Size& input_visible_size, | 124 const gfx::Size& input_visible_size, |
83 media::VideoCodecProfile output_profile, | 125 media::VideoCodecProfile output_profile, |
84 uint32 initial_bitrate, | 126 uint32 initial_bitrate, |
85 Client* client) { | 127 Client* client) { |
86 DCHECK(CalledOnValidThread()); | 128 DCHECK(CalledOnValidThread()); |
87 client_ = client; | 129 client_ = client; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 weak_this_factory_.InvalidateWeakPtrs(); | 311 weak_this_factory_.InvalidateWeakPtrs(); |
270 | 312 |
271 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 313 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
272 // last thing done on this stack! | 314 // last thing done on this stack! |
273 media::VideoEncodeAccelerator::Client* client = NULL; | 315 media::VideoEncodeAccelerator::Client* client = NULL; |
274 std::swap(client_, client); | 316 std::swap(client_, client); |
275 client->NotifyError(error); | 317 client->NotifyError(error); |
276 } | 318 } |
277 | 319 |
278 } // namespace content | 320 } // namespace content |
OLD | NEW |