Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Side by Side Diff: content/renderer/media/gpu/rtc_video_encoder_factory.cc

Issue 2358683002: Android: enable/disable WebRTC HW H264 with a flag. (Closed)
Patch Set: rebase to Oct17 Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_switches.h" 8 #include "content/public/common/content_switches.h"
9 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h" 9 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h"
10 #include "content/renderer/media/gpu/rtc_video_encoder.h" 10 #include "content/renderer/media/gpu/rtc_video_encoder.h"
11 #include "media/gpu/ipc/client/gpu_video_encode_accelerator_host.h" 11 #include "media/gpu/ipc/client/gpu_video_encode_accelerator_host.h"
12 #include "media/renderers/gpu_video_accelerator_factories.h" 12 #include "media/renderers/gpu_video_accelerator_factories.h"
13 #include "media/video/video_encode_accelerator.h" 13 #include "media/video/video_encode_accelerator.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 namespace { 17 namespace {
18 bool IsCodecDisabledByCommandLine(const base::CommandLine* cmd_line,
19 const std::string codec_name) {
20 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding))
21 return false;
22
23 const std::string codec_filter =
24 cmd_line->GetSwitchValueASCII(switches::kDisableWebRtcHWEncoding);
25 return codec_filter.empty() || codec_filter == codec_name;
26 }
18 27
19 // Translate from media::VideoEncodeAccelerator::SupportedProfile to 28 // Translate from media::VideoEncodeAccelerator::SupportedProfile to
20 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec 29 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec
21 void VEAToWebRTCCodecs( 30 void VEAToWebRTCCodecs(
22 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, 31 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs,
23 const media::VideoEncodeAccelerator::SupportedProfile& profile) { 32 const media::VideoEncodeAccelerator::SupportedProfile& profile) {
24 const int width = profile.max_resolution.width(); 33 const int width = profile.max_resolution.width();
25 const int height = profile.max_resolution.height(); 34 const int height = profile.max_resolution.height();
26 const int fps = profile.max_framerate_numerator; 35 const int fps = profile.max_framerate_numerator;
27 DCHECK_EQ(profile.max_framerate_denominator, 1U); 36 DCHECK_EQ(profile.max_framerate_denominator, 1U);
28 37
29 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 38 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
30 if (profile.profile >= media::VP8PROFILE_MIN && 39 if (profile.profile >= media::VP8PROFILE_MIN &&
31 profile.profile <= media::VP8PROFILE_MAX) { 40 profile.profile <= media::VP8PROFILE_MAX) {
32 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( 41 if (!IsCodecDisabledByCommandLine(cmd_line,
33 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); 42 switches::kDisableWebRtcHWEncodingVPx)) {
43 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
44 webrtc::kVideoCodecVP8, "VP8", width, height, fps));
45 }
34 } else if (profile.profile >= media::H264PROFILE_MIN && 46 } else if (profile.profile >= media::H264PROFILE_MIN &&
35 profile.profile <= media::H264PROFILE_MAX) { 47 profile.profile <= media::H264PROFILE_MAX) {
36 // Enable H264 HW encode for WebRTC when SW fallback is available, which is 48 // Enable H264 HW encode for WebRTC when SW fallback is available, which is
37 // checked by kWebRtcH264WithOpenH264FFmpeg flag. This check should be 49 // checked by kWebRtcH264WithOpenH264FFmpeg flag. This check should be
38 // removed when SW implementation is fully enabled. 50 // removed when SW implementation is fully enabled.
39 // kEnableWebRtcHWH264Encoding flag is only enabled for extensions, and 51 // kEnableWebRtcHWH264Encoding flag is only enabled for extensions, and
40 // can be used without SW fallback. 52 // can be used without SW fallback.
41 bool webrtc_h264_sw_enabled = false; 53 bool webrtc_h264_sw_enabled = false;
42 #if BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG) 54 #if BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG)
43 webrtc_h264_sw_enabled = 55 webrtc_h264_sw_enabled =
44 base::FeatureList::IsEnabled(kWebRtcH264WithOpenH264FFmpeg); 56 base::FeatureList::IsEnabled(kWebRtcH264WithOpenH264FFmpeg);
45 #endif // BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG) 57 #endif // BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG)
46 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWH264Encoding) || 58 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWH264Encoding) ||
47 webrtc_h264_sw_enabled) { 59 webrtc_h264_sw_enabled ||
60 !IsCodecDisabledByCommandLine(cmd_line,
61 switches::kDisableWebRtcHWEncodingH264)) {
48 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( 62 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
49 webrtc::kVideoCodecH264, "H264", width, height, fps)); 63 webrtc::kVideoCodecH264, "H264", width, height, fps));
50 } 64 }
51 } 65 }
52 } 66 }
53 67
54 } // anonymous namespace 68 } // anonymous namespace
55 69
56 RTCVideoEncoderFactory::RTCVideoEncoderFactory( 70 RTCVideoEncoderFactory::RTCVideoEncoderFactory(
57 media::GpuVideoAcceleratorFactories* gpu_factories) 71 media::GpuVideoAcceleratorFactories* gpu_factories)
(...skipping 19 matching lines...) Expand all
77 RTCVideoEncoderFactory::codecs() const { 91 RTCVideoEncoderFactory::codecs() const {
78 return codecs_; 92 return codecs_;
79 } 93 }
80 94
81 void RTCVideoEncoderFactory::DestroyVideoEncoder( 95 void RTCVideoEncoderFactory::DestroyVideoEncoder(
82 webrtc::VideoEncoder* encoder) { 96 webrtc::VideoEncoder* encoder) {
83 delete encoder; 97 delete encoder;
84 } 98 }
85 99
86 } // namespace content 100 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | content/renderer/media/webrtc/peer_connection_dependency_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698