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" |
(...skipping 26 matching lines...) Expand all Loading... |
37 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWH264Encoding)) { | 37 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWH264Encoding)) { |
38 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( | 38 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( |
39 webrtc::kVideoCodecH264, "H264", width, height, fps)); | 39 webrtc::kVideoCodecH264, "H264", width, height, fps)); |
40 } | 40 } |
41 // TODO(hshi): remove the generic codec type after CASTv1 deprecation. | 41 // TODO(hshi): remove the generic codec type after CASTv1 deprecation. |
42 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( | 42 codecs->push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( |
43 webrtc::kVideoCodecGeneric, "CAST1", width, height, fps)); | 43 webrtc::kVideoCodecGeneric, "CAST1", width, height, fps)); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 // Translate from cricket::WebRtcVideoEncoderFactory::VideoCodec to | |
48 // media::VideoCodecProfile. Pick a default profile for each codec type. | |
49 media::VideoCodecProfile WebRTCCodecToVideoCodecProfile( | |
50 webrtc::VideoCodecType type) { | |
51 switch (type) { | |
52 case webrtc::kVideoCodecVP8: | |
53 return media::VP8PROFILE_ANY; | |
54 case webrtc::kVideoCodecH264: | |
55 case webrtc::kVideoCodecGeneric: | |
56 return media::H264PROFILE_MAIN; | |
57 default: | |
58 return media::VIDEO_CODEC_PROFILE_UNKNOWN; | |
59 } | |
60 } | |
61 | |
62 } // anonymous namespace | 47 } // anonymous namespace |
63 | 48 |
64 RTCVideoEncoderFactory::RTCVideoEncoderFactory( | 49 RTCVideoEncoderFactory::RTCVideoEncoderFactory( |
65 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) | 50 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) |
66 : gpu_factories_(gpu_factories) { | 51 : gpu_factories_(gpu_factories) { |
67 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles = | 52 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles = |
68 gpu_factories_->GetVideoEncodeAcceleratorSupportedProfiles(); | 53 gpu_factories_->GetVideoEncodeAcceleratorSupportedProfiles(); |
69 for (size_t i = 0; i < profiles.size(); ++i) | 54 for (size_t i = 0; i < profiles.size(); ++i) |
70 VEAToWebRTCCodecs(&codecs_, profiles[i]); | 55 VEAToWebRTCCodecs(&codecs_, profiles[i]); |
71 } | 56 } |
72 | 57 |
73 RTCVideoEncoderFactory::~RTCVideoEncoderFactory() {} | 58 RTCVideoEncoderFactory::~RTCVideoEncoderFactory() {} |
74 | 59 |
75 webrtc::VideoEncoder* RTCVideoEncoderFactory::CreateVideoEncoder( | 60 webrtc::VideoEncoder* RTCVideoEncoderFactory::CreateVideoEncoder( |
76 webrtc::VideoCodecType type) { | 61 webrtc::VideoCodecType type) { |
77 bool found = false; | 62 bool found = false; |
78 for (size_t i = 0; i < codecs_.size(); ++i) { | 63 for (size_t i = 0; i < codecs_.size(); ++i) { |
79 if (codecs_[i].type == type) { | 64 if (codecs_[i].type == type) { |
80 found = true; | 65 found = true; |
81 break; | 66 break; |
82 } | 67 } |
83 } | 68 } |
84 if (!found) | 69 if (!found) |
85 return NULL; | 70 return NULL; |
86 return new RTCVideoEncoder( | 71 return new RTCVideoEncoder(type, gpu_factories_); |
87 type, WebRTCCodecToVideoCodecProfile(type), gpu_factories_); | |
88 } | 72 } |
89 | 73 |
90 const std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>& | 74 const std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>& |
91 RTCVideoEncoderFactory::codecs() const { | 75 RTCVideoEncoderFactory::codecs() const { |
92 return codecs_; | 76 return codecs_; |
93 } | 77 } |
94 | 78 |
95 void RTCVideoEncoderFactory::DestroyVideoEncoder( | 79 void RTCVideoEncoderFactory::DestroyVideoEncoder( |
96 webrtc::VideoEncoder* encoder) { | 80 webrtc::VideoEncoder* encoder) { |
97 delete encoder; | 81 delete encoder; |
98 } | 82 } |
99 | 83 |
100 } // namespace content | 84 } // namespace content |
OLD | NEW |