Commit 44954d45 authored by hshi's avatar hshi Committed by Commit bot

Only allow webrtc HW offload for H264 encode for extension process.

Add cmdline switch::kEnableWebRtcHWH264Encoding to control whether
to report WebRtc HW H264 encoding capability.

BUG=385941
R=xiyuan@chromium.org,kalman@chromium.org,posicak@chromium.org,jamesr@chromium.org
TBR=piman@chromium.org

Review URL: https://codereview.chromium.org/453063002

Cr-Commit-Position: refs/heads/master@{#292028}
parent e226c78e
...@@ -151,6 +151,7 @@ std::string DeriveCommandLine(const GURL& start_url, ...@@ -151,6 +151,7 @@ std::string DeriveCommandLine(const GURL& start_url,
::switches::kDisableWebRtcHWDecoding, ::switches::kDisableWebRtcHWDecoding,
::switches::kDisableWebRtcHWEncoding, ::switches::kDisableWebRtcHWEncoding,
::switches::kEnableWebRtcHWVp8Encoding, ::switches::kEnableWebRtcHWVp8Encoding,
::switches::kEnableWebRtcHWH264Encoding,
#endif #endif
::switches::kDisableVaapiAcceleratedVideoEncode, ::switches::kDisableVaapiAcceleratedVideoEncode,
#if defined(USE_OZONE) #if defined(USE_OZONE)
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h" #include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "extensions/browser/extension_host.h" #include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_message_filter.h" #include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
...@@ -526,8 +527,12 @@ void ChromeContentBrowserClientExtensionsPart:: ...@@ -526,8 +527,12 @@ void ChromeContentBrowserClientExtensionsPart::
if (!process) if (!process)
return; return;
DCHECK(profile); DCHECK(profile);
if (ProcessMap::Get(profile)->Contains(process->GetID())) if (ProcessMap::Get(profile)->Contains(process->GetID())) {
command_line->AppendSwitch(switches::kExtensionProcess); command_line->AppendSwitch(switches::kExtensionProcess);
#if defined(ENABLE_WEBRTC)
command_line->AppendSwitch(::switches::kEnableWebRtcHWH264Encoding);
#endif
}
} }
} // namespace extensions } // namespace extensions
...@@ -1235,6 +1235,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( ...@@ -1235,6 +1235,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kDisableWebRtcHWDecoding, switches::kDisableWebRtcHWDecoding,
switches::kDisableWebRtcHWEncoding, switches::kDisableWebRtcHWEncoding,
switches::kEnableWebRtcHWVp8Encoding, switches::kEnableWebRtcHWVp8Encoding,
switches::kEnableWebRtcHWH264Encoding,
#endif #endif
switches::kLowEndDeviceMode, switches::kLowEndDeviceMode,
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
......
...@@ -855,6 +855,9 @@ const char kDisableWebRtcHWEncoding[] = "disable-webrtc-hw-encoding"; ...@@ -855,6 +855,9 @@ const char kDisableWebRtcHWEncoding[] = "disable-webrtc-hw-encoding";
// Enables VP8 HW encode acceleration for WebRTC. // Enables VP8 HW encode acceleration for WebRTC.
const char kEnableWebRtcHWVp8Encoding[] = "enable-webrtc-hw-vp8-encoding"; const char kEnableWebRtcHWVp8Encoding[] = "enable-webrtc-hw-vp8-encoding";
// Enables H264 HW encode acceleration for WebRTC.
const char kEnableWebRtcHWH264Encoding[] = "enable-webrtc-hw-h264-encoding";
#endif #endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
......
...@@ -242,6 +242,7 @@ CONTENT_EXPORT extern const char kDisableWebRtcHWDecoding[]; ...@@ -242,6 +242,7 @@ CONTENT_EXPORT extern const char kDisableWebRtcHWDecoding[];
CONTENT_EXPORT extern const char kDisableWebRtcEncryption[]; CONTENT_EXPORT extern const char kDisableWebRtcEncryption[];
CONTENT_EXPORT extern const char kDisableWebRtcHWEncoding[]; CONTENT_EXPORT extern const char kDisableWebRtcHWEncoding[];
CONTENT_EXPORT extern const char kEnableWebRtcHWVp8Encoding[]; CONTENT_EXPORT extern const char kEnableWebRtcHWVp8Encoding[];
CONTENT_EXPORT extern const char kEnableWebRtcHWH264Encoding[];
#endif #endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#include "content/renderer/media/rtc_video_encoder_factory.h" #include "content/renderer/media/rtc_video_encoder_factory.h"
#include "base/command_line.h"
#include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h"
#include "content/public/common/content_switches.h"
#include "content/renderer/media/rtc_video_encoder.h" #include "content/renderer/media/rtc_video_encoder.h"
#include "media/filters/gpu_video_accelerator_factories.h" #include "media/filters/gpu_video_accelerator_factories.h"
#include "media/video/video_encode_accelerator.h" #include "media/video/video_encode_accelerator.h"
...@@ -23,16 +25,22 @@ void VEAToWebRTCCodecs( ...@@ -23,16 +25,22 @@ void VEAToWebRTCCodecs(
int fps = profile.max_framerate.numerator; int fps = profile.max_framerate.numerator;
DCHECK_EQ(profile.max_framerate.denominator, 1U); DCHECK_EQ(profile.max_framerate.denominator, 1U);
const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
if (profile.profile >= media::VP8PROFILE_MIN && if (profile.profile >= media::VP8PROFILE_MIN &&
profile.profile <= media::VP8PROFILE_MAX) { profile.profile <= media::VP8PROFILE_MAX) {
codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( if (cmd_line->HasSwitch(switches::kEnableWebRtcHWVp8Encoding)) {
webrtc::kVideoCodecVP8, "VP8", width, height, fps)); codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
webrtc::kVideoCodecVP8, "VP8", width, height, fps));
}
} else if (profile.profile >= media::H264PROFILE_MIN && } else if (profile.profile >= media::H264PROFILE_MIN &&
profile.profile <= media::H264PROFILE_MAX) { profile.profile <= media::H264PROFILE_MAX) {
if (cmd_line->HasSwitch(switches::kEnableWebRtcHWH264Encoding)) {
codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
webrtc::kVideoCodecH264, "H264", width, height, fps));
}
// TODO(hshi): remove the generic codec type after CASTv1 deprecation.
codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
webrtc::kVideoCodecGeneric, "CAST1", width, height, fps)); webrtc::kVideoCodecGeneric, "CAST1", width, height, fps));
codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
webrtc::kVideoCodecH264, "H264", width, height, fps));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment