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

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

Issue 568413002: Add VEA supported profiles to GPUInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/bind.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/synchronization/waitable_event.h"
8 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" 12 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h"
9 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
10 #include "content/renderer/media/rtc_video_encoder.h" 14 #include "content/renderer/media/rtc_video_encoder.h"
11 #include "media/filters/gpu_video_accelerator_factories.h" 15 #include "media/filters/gpu_video_accelerator_factories.h"
12 #include "media/video/video_encode_accelerator.h" 16 #include "media/video/video_encode_accelerator.h"
13 17
14 namespace content { 18 namespace content {
15 19
16 namespace { 20 namespace {
17 21
18 // Translate from media::VideoEncodeAccelerator::SupportedProfile to 22 // Translate from media::VideoEncodeAccelerator::SupportedProfile to
19 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec 23 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec
20 void VEAToWebRTCCodecs( 24 void VEAToWebRTCCodecs(
21 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, 25 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs,
22 const media::VideoEncodeAccelerator::SupportedProfile& profile) { 26 const media::VideoEncodeAccelerator::SupportedProfile& profile) {
23 int width = profile.max_resolution.width(); 27 int width = profile.max_resolution.width();
24 int height = profile.max_resolution.height(); 28 int height = profile.max_resolution.height();
25 int fps = profile.max_framerate.numerator; 29 int fps = profile.max_framerate_numerator;
26 DCHECK_EQ(profile.max_framerate.denominator, 1U); 30 DCHECK_EQ(profile.max_framerate_denominator, 1U);
27 31
28 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 32 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
29 if (profile.profile >= media::VP8PROFILE_MIN && 33 if (profile.profile >= media::VP8PROFILE_MIN &&
30 profile.profile <= media::VP8PROFILE_MAX) { 34 profile.profile <= media::VP8PROFILE_MAX) {
31 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWVp8Encoding)) { 35 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWVp8Encoding)) {
32 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( 36 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec(
33 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); 37 webrtc::kVideoCodecVP8, "VP8", width, height, fps));
34 } 38 }
35 } else if (profile.profile >= media::H264PROFILE_MIN && 39 } else if (profile.profile >= media::H264PROFILE_MIN &&
36 profile.profile <= media::H264PROFILE_MAX) { 40 profile.profile <= media::H264PROFILE_MAX) {
(...skipping 20 matching lines...) Expand all
57 default: 61 default:
58 return media::VIDEO_CODEC_PROFILE_UNKNOWN; 62 return media::VIDEO_CODEC_PROFILE_UNKNOWN;
59 } 63 }
60 } 64 }
61 65
62 } // anonymous namespace 66 } // anonymous namespace
63 67
64 RTCVideoEncoderFactory::RTCVideoEncoderFactory( 68 RTCVideoEncoderFactory::RTCVideoEncoderFactory(
65 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) 69 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories)
66 : gpu_factories_(gpu_factories) { 70 : gpu_factories_(gpu_factories) {
67 // Query media::VideoEncodeAccelerator (statically) for our supported codecs. 71 // Query media::VideoEncodeAccelerator for our supported codecs.
68 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles = 72 base::WaitableEvent waiter(true, false);
69 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles(); 73 gpu_factories_->GetTaskRunner()->PostTask(
70 for (size_t i = 0; i < profiles.size(); ++i) 74 FROM_HERE,
71 VEAToWebRTCCodecs(&codecs_, profiles[i]); 75 base::Bind(&RTCVideoEncoderFactory::GetSupportedCodecs,
76 base::Unretained(this),
77 &waiter));
78 waiter.Wait();
piman 2014/09/18 18:11:51 I don't think the RTCVideoEncoderFactory is create
wuchengli 2014/09/19 14:27:24 RTCVideoEncoderFactory is created in PeerConnectio
72 } 79 }
73 80
74 RTCVideoEncoderFactory::~RTCVideoEncoderFactory() {} 81 RTCVideoEncoderFactory::~RTCVideoEncoderFactory() {
82 }
75 83
76 webrtc::VideoEncoder* RTCVideoEncoderFactory::CreateVideoEncoder( 84 webrtc::VideoEncoder* RTCVideoEncoderFactory::CreateVideoEncoder(
77 webrtc::VideoCodecType type) { 85 webrtc::VideoCodecType type) {
78 bool found = false; 86 bool found = false;
79 for (size_t i = 0; i < codecs_.size(); ++i) { 87 for (size_t i = 0; i < codecs_.size(); ++i) {
80 if (codecs_[i].type == type) { 88 if (codecs_[i].type == type) {
81 found = true; 89 found = true;
82 break; 90 break;
83 } 91 }
84 } 92 }
(...skipping 12 matching lines...) Expand all
97 const std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>& 105 const std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>&
98 RTCVideoEncoderFactory::codecs() const { 106 RTCVideoEncoderFactory::codecs() const {
99 return codecs_; 107 return codecs_;
100 } 108 }
101 109
102 void RTCVideoEncoderFactory::DestroyVideoEncoder( 110 void RTCVideoEncoderFactory::DestroyVideoEncoder(
103 webrtc::VideoEncoder* encoder) { 111 webrtc::VideoEncoder* encoder) {
104 delete encoder; 112 delete encoder;
105 } 113 }
106 114
115 void RTCVideoEncoderFactory::GetSupportedCodecs(base::WaitableEvent* waiter) {
116 scoped_ptr<media::VideoEncodeAccelerator> video_encoder =
117 gpu_factories_->CreateVideoEncodeAccelerator();
118 if (video_encoder) {
119 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles =
120 video_encoder->GetSupportedProfiles();
121 for (size_t i = 0; i < profiles.size(); ++i)
122 VEAToWebRTCCodecs(&codecs_, profiles[i]);
123 }
124 waiter->Signal();
125 }
126
107 } // namespace content 127 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698