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/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 "base/command_line.h" |
8 #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" | 9 #include "content/public/common/content_switches.h" |
10 #include "content/renderer/media/rtc_video_encoder.h" | 10 #include "content/renderer/media/rtc_video_encoder.h" |
11 #include "media/filters/gpu_video_accelerator_factories.h" | 11 #include "media/filters/gpu_video_accelerator_factories.h" |
12 #include "media/video/video_encode_accelerator.h" | 12 #include "media/video/video_encode_accelerator.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Translate from media::VideoEncodeAccelerator::SupportedProfile to | 18 // Translate from media::VideoEncodeAccelerator::SupportedProfile to |
19 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec | 19 // one or more instances of cricket::WebRtcVideoEncoderFactory::VideoCodec |
20 void VEAToWebRTCCodecs( | 20 void VEAToWebRTCCodecs( |
21 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, | 21 std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>* codecs, |
22 const media::VideoEncodeAccelerator::SupportedProfile& profile) { | 22 const media::VideoEncodeAccelerator::SupportedProfile& profile) { |
23 int width = profile.max_resolution.width(); | 23 int width = profile.max_resolution.width(); |
24 int height = profile.max_resolution.height(); | 24 int height = profile.max_resolution.height(); |
25 int fps = profile.max_framerate.numerator; | 25 int fps = profile.max_framerate_numerator; |
26 DCHECK_EQ(profile.max_framerate.denominator, 1U); | 26 DCHECK_EQ(profile.max_framerate_denominator, 1U); |
27 | 27 |
28 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 28 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
29 if (profile.profile >= media::VP8PROFILE_MIN && | 29 if (profile.profile >= media::VP8PROFILE_MIN && |
30 profile.profile <= media::VP8PROFILE_MAX) { | 30 profile.profile <= media::VP8PROFILE_MAX) { |
31 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWVp8Encoding)) { | 31 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWVp8Encoding)) { |
32 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( | 32 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( |
33 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); | 33 webrtc::kVideoCodecVP8, "VP8", width, height, fps)); |
34 } | 34 } |
35 } else if (profile.profile >= media::H264PROFILE_MIN && | 35 } else if (profile.profile >= media::H264PROFILE_MIN && |
36 profile.profile <= media::H264PROFILE_MAX) { | 36 profile.profile <= media::H264PROFILE_MAX) { |
(...skipping 20 matching lines...) Expand all Loading... |
57 default: | 57 default: |
58 return media::VIDEO_CODEC_PROFILE_UNKNOWN; | 58 return media::VIDEO_CODEC_PROFILE_UNKNOWN; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 } // anonymous namespace | 62 } // anonymous namespace |
63 | 63 |
64 RTCVideoEncoderFactory::RTCVideoEncoderFactory( | 64 RTCVideoEncoderFactory::RTCVideoEncoderFactory( |
65 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) | 65 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) |
66 : gpu_factories_(gpu_factories) { | 66 : gpu_factories_(gpu_factories) { |
67 // Query media::VideoEncodeAccelerator (statically) for our supported codecs. | |
68 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles = | 67 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles = |
69 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles(); | 68 gpu_factories_->GetVideoEncodeAcceleratorSupportedProfiles(); |
70 for (size_t i = 0; i < profiles.size(); ++i) | 69 for (size_t i = 0; i < profiles.size(); ++i) |
71 VEAToWebRTCCodecs(&codecs_, profiles[i]); | 70 VEAToWebRTCCodecs(&codecs_, profiles[i]); |
72 } | 71 } |
73 | 72 |
74 RTCVideoEncoderFactory::~RTCVideoEncoderFactory() {} | 73 RTCVideoEncoderFactory::~RTCVideoEncoderFactory() {} |
75 | 74 |
76 webrtc::VideoEncoder* RTCVideoEncoderFactory::CreateVideoEncoder( | 75 webrtc::VideoEncoder* RTCVideoEncoderFactory::CreateVideoEncoder( |
77 webrtc::VideoCodecType type) { | 76 webrtc::VideoCodecType type) { |
78 bool found = false; | 77 bool found = false; |
79 for (size_t i = 0; i < codecs_.size(); ++i) { | 78 for (size_t i = 0; i < codecs_.size(); ++i) { |
(...skipping 18 matching lines...) Expand all Loading... |
98 RTCVideoEncoderFactory::codecs() const { | 97 RTCVideoEncoderFactory::codecs() const { |
99 return codecs_; | 98 return codecs_; |
100 } | 99 } |
101 | 100 |
102 void RTCVideoEncoderFactory::DestroyVideoEncoder( | 101 void RTCVideoEncoderFactory::DestroyVideoEncoder( |
103 webrtc::VideoEncoder* encoder) { | 102 webrtc::VideoEncoder* encoder) { |
104 delete encoder; | 103 delete encoder; |
105 } | 104 } |
106 | 105 |
107 } // namespace content | 106 } // namespace content |
OLD | NEW |