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

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

Issue 453063002: Only allow webrtc HW offload for H264 encode for extension process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add ifdef for WEBRTC Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/rtc_video_encoder_factory.h" 5 #include "content/renderer/media/rtc_video_encoder_factory.h"
6 6
7 #include "base/command_line.h"
7 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" 8 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h"
9 #include "content/public/common/content_switches.h"
8 #include "content/renderer/media/rtc_video_encoder.h" 10 #include "content/renderer/media/rtc_video_encoder.h"
9 #include "media/filters/gpu_video_accelerator_factories.h" 11 #include "media/filters/gpu_video_accelerator_factories.h"
10 #include "media/video/video_encode_accelerator.h" 12 #include "media/video/video_encode_accelerator.h"
11 13
12 namespace content { 14 namespace content {
13 15
14 namespace { 16 namespace {
15 17
16 // Translate from media::VideoEncodeAccelerator::SupportedProfile to 18 // Translate from media::VideoEncodeAccelerator::SupportedProfile to
17 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec 19 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec
18 void VEAToWebRTCCodecs( 20 void VEAToWebRTCCodecs(
19 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, 21 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs,
20 const media::VideoEncodeAccelerator::SupportedProfile& profile) { 22 const media::VideoEncodeAccelerator::SupportedProfile& profile) {
21 int width = profile.max_resolution.width(); 23 int width = profile.max_resolution.width();
22 int height = profile.max_resolution.height(); 24 int height = profile.max_resolution.height();
23 int fps = profile.max_framerate.numerator; 25 int fps = profile.max_framerate.numerator;
24 DCHECK_EQ(profile.max_framerate.denominator, 1U); 26 DCHECK_EQ(profile.max_framerate.denominator, 1U);
25 27
28 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
26 if (profile.profile >= media::VP8PROFILE_MIN && 29 if (profile.profile >= media::VP8PROFILE_MIN &&
27 profile.profile <= media::VP8PROFILE_MAX) { 30 profile.profile <= media::VP8PROFILE_MAX) {
28 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( 31 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWVp8Encoding)) {
29 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); 32 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
33 webrtc::kVideoCodecVP8, "VP8", width, height, fps));
34 }
30 } else if (profile.profile >= media::H264PROFILE_MIN && 35 } else if (profile.profile >= media::H264PROFILE_MIN &&
31 profile.profile <= media::H264PROFILE_MAX) { 36 profile.profile <= media::H264PROFILE_MAX) {
37 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWH264Encoding)) {
38 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
39 webrtc::kVideoCodecH264, "H264", width, height, fps));
40 }
41 // TODO(hshi): remove the generic codec type after CASTv1 deprecation.
32 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( 42 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
33 webrtc::kVideoCodecGeneric, "CAST1", width, height, fps)); 43 webrtc::kVideoCodecGeneric, "CAST1", width, height, fps));
34 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
35 webrtc::kVideoCodecH264, "H264", width, height, fps));
36 } 44 }
37 } 45 }
38 46
39 // Translate from cricket::WebRtcVideoEncoderFactory::VideoCodec to 47 // Translate from cricket::WebRtcVideoEncoderFactory::VideoCodec to
40 // media::VideoCodecProfile. Pick a default profile for each codec type. 48 // media::VideoCodecProfile. Pick a default profile for each codec type.
41 media::VideoCodecProfile WebRTCCodecToVideoCodecProfile( 49 media::VideoCodecProfile WebRTCCodecToVideoCodecProfile(
42 webrtc::VideoCodecType type) { 50 webrtc::VideoCodecType type) {
43 switch (type) { 51 switch (type) {
44 case webrtc::kVideoCodecVP8: 52 case webrtc::kVideoCodecVP8:
45 return media::VP8PROFILE_ANY; 53 return media::VP8PROFILE_ANY;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 RTCVideoEncoderFactory::codecs() const { 98 RTCVideoEncoderFactory::codecs() const {
91 return codecs_; 99 return codecs_;
92 } 100 }
93 101
94 void RTCVideoEncoderFactory::DestroyVideoEncoder( 102 void RTCVideoEncoderFactory::DestroyVideoEncoder(
95 webrtc::VideoEncoder* encoder) { 103 webrtc::VideoEncoder* encoder) {
96 delete encoder; 104 delete encoder;
97 } 105 }
98 106
99 } // namespace content 107 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698