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_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 IsCodecDisabledByCommanLine(std::string codec_name) { | |
19 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
DaleCurtis
2016/09/29 00:31:36
Pass in?
braveyao
2016/09/29 19:26:26
Done.
| |
20 bool result = true; | |
21 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding) || | |
DaleCurtis
2016/09/29 00:31:35
early return. store getswithvalueascii for compari
braveyao
2016/09/29 19:26:26
Done.
| |
22 (!cmd_line->GetSwitchValueASCII(switches::kDisableWebRtcHWEncoding) | |
23 .empty() && | |
24 cmd_line->GetSwitchValueASCII(switches::kDisableWebRtcHWEncoding) != | |
25 codec_name)) { | |
26 result = false; | |
27 } | |
28 return result; | |
29 } | |
18 | 30 |
19 // Translate from media::VideoEncodeAccelerator::SupportedProfile to | 31 // Translate from media::VideoEncodeAccelerator::SupportedProfile to |
20 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec | 32 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec |
21 void VEAToWebRTCCodecs( | 33 void VEAToWebRTCCodecs( |
22 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, | 34 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, |
23 const media::VideoEncodeAccelerator::SupportedProfile& profile) { | 35 const media::VideoEncodeAccelerator::SupportedProfile& profile) { |
24 const int width = profile.max_resolution.width(); | 36 const int width = profile.max_resolution.width(); |
25 const int height = profile.max_resolution.height(); | 37 const int height = profile.max_resolution.height(); |
26 const int fps = profile.max_framerate_numerator; | 38 const int fps = profile.max_framerate_numerator; |
27 DCHECK_EQ(profile.max_framerate_denominator, 1U); | 39 DCHECK_EQ(profile.max_framerate_denominator, 1U); |
28 | 40 |
29 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 41 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
30 if (profile.profile >= media::VP8PROFILE_MIN && | 42 if (profile.profile >= media::VP8PROFILE_MIN && |
31 profile.profile <= media::VP8PROFILE_MAX) { | 43 profile.profile <= media::VP8PROFILE_MAX) { |
32 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( | 44 if (!IsCodecDisabledByCommanLine(switches::kDisableWebRtcHWEncodingVPx)) { |
DaleCurtis
2016/09/29 00:31:35
CommandLine.
braveyao
2016/09/29 19:26:26
Done.
| |
33 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); | 45 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( |
46 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); | |
47 } | |
34 } else if (profile.profile >= media::H264PROFILE_MIN && | 48 } else if (profile.profile >= media::H264PROFILE_MIN && |
35 profile.profile <= media::H264PROFILE_MAX) { | 49 profile.profile <= media::H264PROFILE_MAX) { |
36 // Enable H264 HW encode for WebRTC when SW fallback is available, which is | 50 // Enable H264 HW encode for WebRTC when SW fallback is available, which is |
37 // checked by kWebRtcH264WithOpenH264FFmpeg flag. This check should be | 51 // checked by kWebRtcH264WithOpenH264FFmpeg flag. This check should be |
38 // removed when SW implementation is fully enabled. | 52 // removed when SW implementation is fully enabled. |
39 // kEnableWebRtcHWH264Encoding flag is only enabled for extensions, and | 53 // kEnableWebRtcHWH264Encoding flag is only enabled for extensions, and |
40 // can be used without SW fallback. | 54 // can be used without SW fallback. |
41 bool webrtc_h264_sw_enabled = false; | 55 bool webrtc_h264_sw_enabled = false; |
42 #if BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG) | 56 #if BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG) |
43 webrtc_h264_sw_enabled = | 57 webrtc_h264_sw_enabled = |
44 base::FeatureList::IsEnabled(kWebRtcH264WithOpenH264FFmpeg); | 58 base::FeatureList::IsEnabled(kWebRtcH264WithOpenH264FFmpeg); |
45 #endif // BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG) | 59 #endif // BUILDFLAG(RTC_USE_H264) && !defined(MEDIA_DISABLE_FFMPEG) |
46 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWH264Encoding) || | 60 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWH264Encoding) || |
DaleCurtis
2016/09/29 00:31:36
Can this flag be deleted now?
braveyao
2016/09/29 19:26:26
No. This is for extension on Mac. please see the c
DaleCurtis
2016/09/29 19:34:14
How is that flag passed? Can you remove that flag
braveyao
2016/09/30 18:22:02
You are right. I'll discuss with other and follow
| |
47 webrtc_h264_sw_enabled) { | 61 webrtc_h264_sw_enabled || |
62 !IsCodecDisabledByCommanLine(switches::kDisableWebRtcHWEncodingH264)) { | |
48 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( | 63 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( |
49 webrtc::kVideoCodecH264, "H264", width, height, fps)); | 64 webrtc::kVideoCodecH264, "H264", width, height, fps)); |
50 } | 65 } |
51 } | 66 } |
52 } | 67 } |
53 | 68 |
54 } // anonymous namespace | 69 } // anonymous namespace |
55 | 70 |
56 RTCVideoEncoderFactory::RTCVideoEncoderFactory( | 71 RTCVideoEncoderFactory::RTCVideoEncoderFactory( |
57 media::GpuVideoAcceleratorFactories* gpu_factories) | 72 media::GpuVideoAcceleratorFactories* gpu_factories) |
(...skipping 19 matching lines...) Expand all Loading... | |
77 RTCVideoEncoderFactory::codecs() const { | 92 RTCVideoEncoderFactory::codecs() const { |
78 return codecs_; | 93 return codecs_; |
79 } | 94 } |
80 | 95 |
81 void RTCVideoEncoderFactory::DestroyVideoEncoder( | 96 void RTCVideoEncoderFactory::DestroyVideoEncoder( |
82 webrtc::VideoEncoder* encoder) { | 97 webrtc::VideoEncoder* encoder) { |
83 delete encoder; | 98 delete encoder; |
84 } | 99 } |
85 | 100 |
86 } // namespace content | 101 } // namespace content |
OLD | NEW |