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

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: Created 6 years, 4 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
« content/renderer/DEPS ('K') | « content/renderer/DEPS ('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"
8 #include "content/renderer/media/rtc_video_encoder.h" 9 #include "content/renderer/media/rtc_video_encoder.h"
10 #include "extensions/common/switches.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
18 bool IsExtensionProcess() {
19 return CommandLine::ForCurrentProcess()->HasSwitch(
20 extensions::switches::kExtensionProcess);
21 }
22
16 // Translate from media::VideoEncodeAccelerator::SupportedProfile to 23 // Translate from media::VideoEncodeAccelerator::SupportedProfile to
17 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec 24 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec
18 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec> VEAToWebRTCCodecs( 25 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec> VEAToWebRTCCodecs(
19 const media::VideoEncodeAccelerator::SupportedProfile& profile) { 26 const media::VideoEncodeAccelerator::SupportedProfile& profile) {
20 int width = profile.max_resolution.width(); 27 int width = profile.max_resolution.width();
21 int height = profile.max_resolution.height(); 28 int height = profile.max_resolution.height();
22 int fps = profile.max_framerate.numerator; 29 int fps = profile.max_framerate.numerator;
23 DCHECK_EQ(profile.max_framerate.denominator, 1U); 30 DCHECK_EQ(profile.max_framerate.denominator, 1U);
24 31
25 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec> codecs; 32 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec> codecs;
26 if (profile.profile >= media::VP8PROFILE_MIN && 33 if (profile.profile >= media::VP8PROFILE_MIN &&
27 profile.profile <= media::VP8PROFILE_MAX) { 34 profile.profile <= media::VP8PROFILE_MAX) {
28 codecs.push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( 35 codecs.push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
29 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); 36 webrtc::kVideoCodecVP8, "VP8", width, height, fps));
30 } else if (profile.profile >= media::H264PROFILE_MIN && 37 } else if (profile.profile >= media::H264PROFILE_MIN &&
31 profile.profile <= media::H264PROFILE_MAX) { 38 profile.profile <= media::H264PROFILE_MAX) {
32 codecs.push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( 39 codecs.push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
33 webrtc::kVideoCodecGeneric, "CAST1", width, height, fps)); 40 webrtc::kVideoCodecGeneric, "CAST1", width, height, fps));
34 codecs.push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( 41 if (IsExtensionProcess()) {
35 webrtc::kVideoCodecH264, "H264", width, height, fps)); 42 codecs.push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
43 webrtc::kVideoCodecH264, "H264", width, height, fps));
44 }
36 } 45 }
37 46
38 return codecs; 47 return codecs;
39 } 48 }
40 49
41 // Translate from cricket::WebRtcVideoEncoderFactory::VideoCodec to 50 // Translate from cricket::WebRtcVideoEncoderFactory::VideoCodec to
42 // media::VideoCodecProfile. Pick a default profile for each codec type. 51 // media::VideoCodecProfile. Pick a default profile for each codec type.
43 media::VideoCodecProfile WebRTCCodecToVideoCodecProfile( 52 media::VideoCodecProfile WebRTCCodecToVideoCodecProfile(
44 webrtc::VideoCodecType type) { 53 webrtc::VideoCodecType type) {
45 switch (type) { 54 switch (type) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 RTCVideoEncoderFactory::codecs() const { 103 RTCVideoEncoderFactory::codecs() const {
95 return codecs_; 104 return codecs_;
96 } 105 }
97 106
98 void RTCVideoEncoderFactory::DestroyVideoEncoder( 107 void RTCVideoEncoderFactory::DestroyVideoEncoder(
99 webrtc::VideoEncoder* encoder) { 108 webrtc::VideoEncoder* encoder) {
100 delete encoder; 109 delete encoder;
101 } 110 }
102 111
103 } // namespace content 112 } // namespace content
OLDNEW
« content/renderer/DEPS ('K') | « content/renderer/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698