| 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" |
| 11 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | 11 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
| 12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 #define NOTIFY_ERROR(error) \ | 16 #define NOTIFY_ERROR(error) \ |
| 17 PostNotifyError(error); \ | 17 PostNotifyError(error); \ |
| 18 DLOG(ERROR) | 18 DLOG(ERROR) |
| 19 | 19 |
| 20 GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost( | 20 GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost( |
| 21 GpuChannelHost* channel, | 21 GpuChannelHost* channel, |
| (...skipping 45 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 ConvertGpuToMediaProfiles( | 77 return GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles( |
| 78 channel_->gpu_info().video_encode_accelerator_supported_profiles); | 78 channel_->gpu_info().video_encode_accelerator_supported_profiles); |
| 79 } | 79 } |
| 80 | 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; | |
| 120 } | |
| 121 | |
| 122 bool GpuVideoEncodeAcceleratorHost::Initialize( | 81 bool GpuVideoEncodeAcceleratorHost::Initialize( |
| 123 media::VideoFrame::Format input_format, | 82 media::VideoFrame::Format input_format, |
| 124 const gfx::Size& input_visible_size, | 83 const gfx::Size& input_visible_size, |
| 125 media::VideoCodecProfile output_profile, | 84 media::VideoCodecProfile output_profile, |
| 126 uint32 initial_bitrate, | 85 uint32 initial_bitrate, |
| 127 Client* client) { | 86 Client* client) { |
| 128 DCHECK(CalledOnValidThread()); | 87 DCHECK(CalledOnValidThread()); |
| 129 client_ = client; | 88 client_ = client; |
| 130 if (!impl_) { | 89 if (!impl_) { |
| 131 DLOG(ERROR) << "impl_ destroyed"; | 90 DLOG(ERROR) << "impl_ destroyed"; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 weak_this_factory_.InvalidateWeakPtrs(); | 271 weak_this_factory_.InvalidateWeakPtrs(); |
| 313 | 272 |
| 314 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 273 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
| 315 // last thing done on this stack! | 274 // last thing done on this stack! |
| 316 media::VideoEncodeAccelerator::Client* client = NULL; | 275 media::VideoEncodeAccelerator::Client* client = NULL; |
| 317 std::swap(client_, client); | 276 std::swap(client_, client); |
| 318 client->NotifyError(error); | 277 client->NotifyError(error); |
| 319 } | 278 } |
| 320 | 279 |
| 321 } // namespace content | 280 } // namespace content |
| OLD | NEW |