| 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/renderer/media/gpu/rtc_video_encoder_factory.h" | 5 #include "content/renderer/media/gpu/rtc_video_encoder_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/public/common/content_features.h" | 8 #include "content/public/common/content_features.h" |
| 9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
| 10 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h" | 10 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h" |
| 11 #include "content/renderer/media/gpu/rtc_video_encoder.h" | 11 #include "content/renderer/media/gpu/rtc_video_encoder.h" |
| 12 #include "media/gpu/ipc/client/gpu_video_encode_accelerator_host.h" | 12 #include "media/gpu/ipc/client/gpu_video_encode_accelerator_host.h" |
| 13 #include "media/renderers/gpu_video_accelerator_factories.h" | 13 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 14 #include "media/video/video_encode_accelerator.h" | 14 #include "media/video/video_encode_accelerator.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // Translate from media::VideoEncodeAccelerator::SupportedProfile to | 20 // Translate from media::VideoEncodeAccelerator::SupportedProfile to |
| 21 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec | 21 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec |
| 22 void VEAToWebRTCCodecs( | 22 void VEAToWebRTCCodecs( |
| 23 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, | 23 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, |
| 24 const media::VideoEncodeAccelerator::SupportedProfile& profile) { | 24 const media::VideoEncodeAccelerator::SupportedProfile& profile) { |
| 25 const int width = profile.max_resolution.width(); | 25 const int width = profile.max_resolution.width(); |
| 26 const int height = profile.max_resolution.height(); | 26 const int height = profile.max_resolution.height(); |
| 27 const int fps = profile.max_framerate_numerator; | 27 const int fps = profile.max_framerate_numerator; |
| 28 DCHECK_EQ(profile.max_framerate_denominator, 1U); | 28 DCHECK_EQ(profile.max_framerate_denominator, 1U); |
| 29 | 29 |
| 30 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
| 31 if (profile.profile >= media::VP8PROFILE_MIN && | 30 if (profile.profile >= media::VP8PROFILE_MIN && |
| 32 profile.profile <= media::VP8PROFILE_MAX) { | 31 profile.profile <= media::VP8PROFILE_MAX) { |
| 33 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWVP8Encoding)) { | 32 if (base::FeatureList::IsEnabled(features::kWebRtcHWVP8Encoding)) { |
| 34 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( | 33 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( |
| 35 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); | 34 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); |
| 36 } | 35 } |
| 37 } else if (profile.profile >= media::H264PROFILE_MIN && | 36 } else if (profile.profile >= media::H264PROFILE_MIN && |
| 38 profile.profile <= media::H264PROFILE_MAX) { | 37 profile.profile <= media::H264PROFILE_MAX) { |
| 39 // Enable H264 HW encode for WebRTC when SW fallback is available, which is | 38 // Enable H264 HW encode for WebRTC when SW fallback is available, which is |
| 40 // checked by kWebRtcH264WithOpenH264FFmpeg flag. This check should be | 39 // checked by kWebRtcH264WithOpenH264FFmpeg flag. This check should be |
| 41 // removed when SW implementation is fully enabled. | 40 // removed when SW implementation is fully enabled. |
| 42 bool webrtc_h264_sw_enabled = false; | 41 bool webrtc_h264_sw_enabled = false; |
| 43 #if BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG) | 42 #if BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 RTCVideoEncoderFactory::codecs() const { | 77 RTCVideoEncoderFactory::codecs() const { |
| 79 return codecs_; | 78 return codecs_; |
| 80 } | 79 } |
| 81 | 80 |
| 82 void RTCVideoEncoderFactory::DestroyVideoEncoder( | 81 void RTCVideoEncoderFactory::DestroyVideoEncoder( |
| 83 webrtc::VideoEncoder* encoder) { | 82 webrtc::VideoEncoder* encoder) { |
| 84 delete encoder; | 83 delete encoder; |
| 85 } | 84 } |
| 86 | 85 |
| 87 } // namespace content | 86 } // namespace content |
| OLD | NEW |