OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace webrtc { | 24 namespace webrtc { |
25 | 25 |
26 bool VideoCodecInitializer::SetupCodec( | 26 bool VideoCodecInitializer::SetupCodec( |
27 const VideoEncoderConfig& config, | 27 const VideoEncoderConfig& config, |
28 const VideoSendStream::Config::EncoderSettings settings, | 28 const VideoSendStream::Config::EncoderSettings settings, |
29 const std::vector<VideoStream>& streams, | 29 const std::vector<VideoStream>& streams, |
30 bool nack_enabled, | 30 bool nack_enabled, |
31 VideoCodec* codec, | 31 VideoCodec* codec, |
32 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { | 32 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { |
33 *codec = | 33 *codec = VideoEncoderConfigToVideoCodec( |
34 VideoEncoderConfigToVideoCodec(config, streams, settings.payload_name, | 34 config, streams, settings.payload_name, settings.payload_type, |
35 settings.payload_type, nack_enabled); | 35 settings.stereo_associated_payload_name, nack_enabled); |
36 | 36 |
37 std::unique_ptr<TemporalLayersFactory> tl_factory; | 37 std::unique_ptr<TemporalLayersFactory> tl_factory; |
38 switch (codec->codecType) { | 38 switch (codec->codecType) { |
39 case kVideoCodecVP8: { | 39 case kVideoCodecVP8: { |
40 if (!codec->VP8()->tl_factory) { | 40 if (!codec->VP8()->tl_factory) { |
41 if (codec->mode == kScreensharing && | 41 if (codec->mode == kScreensharing && |
42 (codec->numberOfSimulcastStreams > 1 || | 42 (codec->numberOfSimulcastStreams > 1 || |
43 (codec->numberOfSimulcastStreams == 1 && | 43 (codec->numberOfSimulcastStreams == 1 && |
44 codec->VP8()->numberOfTemporalLayers == 2))) { | 44 codec->VP8()->numberOfTemporalLayers == 2))) { |
45 // Conference mode temporal layering for screen content. | 45 // Conference mode temporal layering for screen content. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 return rate_allocator; | 82 return rate_allocator; |
83 } | 83 } |
84 | 84 |
85 // TODO(sprang): Split this up and separate the codec specific parts. | 85 // TODO(sprang): Split this up and separate the codec specific parts. |
86 VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec( | 86 VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec( |
87 const VideoEncoderConfig& config, | 87 const VideoEncoderConfig& config, |
88 const std::vector<VideoStream>& streams, | 88 const std::vector<VideoStream>& streams, |
89 const std::string& payload_name, | 89 const std::string& payload_name, |
90 int payload_type, | 90 int payload_type, |
| 91 const std::string& stereo_associated_payload_name, |
91 bool nack_enabled) { | 92 bool nack_enabled) { |
92 static const int kEncoderMinBitrateKbps = 30; | 93 static const int kEncoderMinBitrateKbps = 30; |
93 RTC_DCHECK(!streams.empty()); | 94 RTC_DCHECK(!streams.empty()); |
94 RTC_DCHECK_GE(config.min_transmit_bitrate_bps, 0); | 95 RTC_DCHECK_GE(config.min_transmit_bitrate_bps, 0); |
95 | 96 |
96 VideoCodec video_codec; | 97 VideoCodec video_codec; |
97 memset(&video_codec, 0, sizeof(video_codec)); | 98 memset(&video_codec, 0, sizeof(video_codec)); |
98 video_codec.codecType = PayloadNameToCodecType(payload_name) | 99 video_codec.codecType = PayloadNameToCodecType(payload_name) |
99 .value_or(VideoCodecType::kVideoCodecGeneric); | 100 .value_or(VideoCodecType::kVideoCodecGeneric); |
100 | 101 |
| 102 const bool is_stereo_codec = video_codec.codecType == kVideoCodecStereo; |
| 103 if (is_stereo_codec) { |
| 104 video_codec.codecType = |
| 105 PayloadNameToCodecType(stereo_associated_payload_name) |
| 106 .value_or(VideoCodecType::kVideoCodecGeneric); |
| 107 } |
| 108 |
101 switch (config.content_type) { | 109 switch (config.content_type) { |
102 case VideoEncoderConfig::ContentType::kRealtimeVideo: | 110 case VideoEncoderConfig::ContentType::kRealtimeVideo: |
103 video_codec.mode = kRealtimeVideo; | 111 video_codec.mode = kRealtimeVideo; |
104 break; | 112 break; |
105 case VideoEncoderConfig::ContentType::kScreen: | 113 case VideoEncoderConfig::ContentType::kScreen: |
106 video_codec.mode = kScreensharing; | 114 video_codec.mode = kScreensharing; |
107 if (!streams.empty() && | 115 if (!streams.empty() && |
108 streams[0].temporal_layer_thresholds_bps.size() == 1) { | 116 streams[0].temporal_layer_thresholds_bps.size() == 1) { |
109 video_codec.targetBitrate = | 117 video_codec.targetBitrate = |
110 streams[0].temporal_layer_thresholds_bps[0] / 1000; | 118 streams[0].temporal_layer_thresholds_bps[0] / 1000; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // Unset max bitrate -> cap to one bit per pixel. | 228 // Unset max bitrate -> cap to one bit per pixel. |
221 video_codec.maxBitrate = | 229 video_codec.maxBitrate = |
222 (video_codec.width * video_codec.height * video_codec.maxFramerate) / | 230 (video_codec.width * video_codec.height * video_codec.maxFramerate) / |
223 1000; | 231 1000; |
224 } | 232 } |
225 if (video_codec.maxBitrate < kEncoderMinBitrateKbps) | 233 if (video_codec.maxBitrate < kEncoderMinBitrateKbps) |
226 video_codec.maxBitrate = kEncoderMinBitrateKbps; | 234 video_codec.maxBitrate = kEncoderMinBitrateKbps; |
227 | 235 |
228 RTC_DCHECK_GT(streams[0].max_framerate, 0); | 236 RTC_DCHECK_GT(streams[0].max_framerate, 0); |
229 video_codec.maxFramerate = streams[0].max_framerate; | 237 video_codec.maxFramerate = streams[0].max_framerate; |
| 238 |
| 239 if (is_stereo_codec) |
| 240 video_codec.codecType = kVideoCodecStereo; |
| 241 |
230 return video_codec; | 242 return video_codec; |
231 } | 243 } |
232 | 244 |
233 } // namespace webrtc | 245 } // namespace webrtc |
OLD | NEW |