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 20 matching lines...) Expand all Loading... |
31 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { | 31 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { |
32 *codec = | 32 *codec = |
33 VideoEncoderConfigToVideoCodec(config, streams, settings.payload_name, | 33 VideoEncoderConfigToVideoCodec(config, streams, settings.payload_name, |
34 settings.payload_type, nack_enabled); | 34 settings.payload_type, nack_enabled); |
35 | 35 |
36 std::unique_ptr<TemporalLayersFactory> tl_factory; | 36 std::unique_ptr<TemporalLayersFactory> tl_factory; |
37 switch (codec->codecType) { | 37 switch (codec->codecType) { |
38 case kVideoCodecVP8: { | 38 case kVideoCodecVP8: { |
39 if (!codec->VP8()->tl_factory) { | 39 if (!codec->VP8()->tl_factory) { |
40 if (codec->mode == kScreensharing && | 40 if (codec->mode == kScreensharing && |
41 codec->numberOfSimulcastStreams == 1 && | 41 (codec->numberOfSimulcastStreams > 1 || |
42 codec->VP8()->numberOfTemporalLayers == 2) { | 42 (codec->numberOfSimulcastStreams == 1 && |
| 43 codec->VP8()->numberOfTemporalLayers == 2))) { |
43 // Conference mode temporal layering for screen content. | 44 // Conference mode temporal layering for screen content. |
44 tl_factory.reset(new ScreenshareTemporalLayersFactory()); | 45 tl_factory.reset(new ScreenshareTemporalLayersFactory()); |
45 } else { | 46 } else { |
46 // Standard video temporal layers. | 47 // Standard video temporal layers. |
47 tl_factory.reset(new TemporalLayersFactory()); | 48 tl_factory.reset(new TemporalLayersFactory()); |
48 } | 49 } |
49 codec->VP8()->tl_factory = tl_factory.get(); | 50 codec->VP8()->tl_factory = tl_factory.get(); |
50 } | 51 } |
51 break; | 52 break; |
52 } | 53 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 memset(&video_codec, 0, sizeof(video_codec)); | 96 memset(&video_codec, 0, sizeof(video_codec)); |
96 video_codec.codecType = PayloadNameToCodecType(payload_name) | 97 video_codec.codecType = PayloadNameToCodecType(payload_name) |
97 .value_or(VideoCodecType::kVideoCodecGeneric); | 98 .value_or(VideoCodecType::kVideoCodecGeneric); |
98 | 99 |
99 switch (config.content_type) { | 100 switch (config.content_type) { |
100 case VideoEncoderConfig::ContentType::kRealtimeVideo: | 101 case VideoEncoderConfig::ContentType::kRealtimeVideo: |
101 video_codec.mode = kRealtimeVideo; | 102 video_codec.mode = kRealtimeVideo; |
102 break; | 103 break; |
103 case VideoEncoderConfig::ContentType::kScreen: | 104 case VideoEncoderConfig::ContentType::kScreen: |
104 video_codec.mode = kScreensharing; | 105 video_codec.mode = kScreensharing; |
105 if (streams.size() == 1 && | 106 if (streams.size() >= 1 && |
106 streams[0].temporal_layer_thresholds_bps.size() == 1) { | 107 streams[0].temporal_layer_thresholds_bps.size() == 1) { |
107 video_codec.targetBitrate = | 108 video_codec.targetBitrate = |
108 streams[0].temporal_layer_thresholds_bps[0] / 1000; | 109 streams[0].temporal_layer_thresholds_bps[0] / 1000; |
109 } | 110 } |
110 break; | 111 break; |
111 } | 112 } |
112 | 113 |
113 if (config.encoder_specific_settings) | 114 if (config.encoder_specific_settings) |
114 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec); | 115 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec); |
115 | 116 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 RTC_DCHECK_LE(video_codec.VP9()->numberOfSpatialLayers, | 174 RTC_DCHECK_LE(video_codec.VP9()->numberOfSpatialLayers, |
174 kMaxSimulcastStreams); | 175 kMaxSimulcastStreams); |
175 for (size_t i = 0; i < config.spatial_layers.size(); ++i) | 176 for (size_t i = 0; i < config.spatial_layers.size(); ++i) |
176 video_codec.spatialLayers[i] = config.spatial_layers[i]; | 177 video_codec.spatialLayers[i] = config.spatial_layers[i]; |
177 } | 178 } |
178 for (size_t i = 0; i < streams.size(); ++i) { | 179 for (size_t i = 0; i < streams.size(); ++i) { |
179 SimulcastStream* sim_stream = &video_codec.simulcastStream[i]; | 180 SimulcastStream* sim_stream = &video_codec.simulcastStream[i]; |
180 RTC_DCHECK_GT(streams[i].width, 0); | 181 RTC_DCHECK_GT(streams[i].width, 0); |
181 RTC_DCHECK_GT(streams[i].height, 0); | 182 RTC_DCHECK_GT(streams[i].height, 0); |
182 RTC_DCHECK_GT(streams[i].max_framerate, 0); | 183 RTC_DCHECK_GT(streams[i].max_framerate, 0); |
183 // Different framerates not supported per stream at the moment. | 184 // Different framerates not supported per stream at the moment, unless it's |
184 RTC_DCHECK_EQ(streams[i].max_framerate, streams[0].max_framerate); | 185 // screenshare where there is an exception and a simulcast encoder adapter, |
| 186 // which supports different framerates, is used instead. |
| 187 if (config.content_type != VideoEncoderConfig::ContentType::kScreen) { |
| 188 RTC_DCHECK_EQ(streams[i].max_framerate, streams[0].max_framerate); |
| 189 } |
185 RTC_DCHECK_GE(streams[i].min_bitrate_bps, 0); | 190 RTC_DCHECK_GE(streams[i].min_bitrate_bps, 0); |
186 RTC_DCHECK_GE(streams[i].target_bitrate_bps, streams[i].min_bitrate_bps); | 191 RTC_DCHECK_GE(streams[i].target_bitrate_bps, streams[i].min_bitrate_bps); |
187 RTC_DCHECK_GE(streams[i].max_bitrate_bps, streams[i].target_bitrate_bps); | 192 RTC_DCHECK_GE(streams[i].max_bitrate_bps, streams[i].target_bitrate_bps); |
188 RTC_DCHECK_GE(streams[i].max_qp, 0); | 193 RTC_DCHECK_GE(streams[i].max_qp, 0); |
189 | 194 |
190 sim_stream->width = static_cast<uint16_t>(streams[i].width); | 195 sim_stream->width = static_cast<uint16_t>(streams[i].width); |
191 sim_stream->height = static_cast<uint16_t>(streams[i].height); | 196 sim_stream->height = static_cast<uint16_t>(streams[i].height); |
192 sim_stream->minBitrate = streams[i].min_bitrate_bps / 1000; | 197 sim_stream->minBitrate = streams[i].min_bitrate_bps / 1000; |
193 sim_stream->targetBitrate = streams[i].target_bitrate_bps / 1000; | 198 sim_stream->targetBitrate = streams[i].target_bitrate_bps / 1000; |
194 sim_stream->maxBitrate = streams[i].max_bitrate_bps / 1000; | 199 sim_stream->maxBitrate = streams[i].max_bitrate_bps / 1000; |
(...skipping 21 matching lines...) Expand all Loading... |
216 } | 221 } |
217 if (video_codec.maxBitrate < kEncoderMinBitrateKbps) | 222 if (video_codec.maxBitrate < kEncoderMinBitrateKbps) |
218 video_codec.maxBitrate = kEncoderMinBitrateKbps; | 223 video_codec.maxBitrate = kEncoderMinBitrateKbps; |
219 | 224 |
220 RTC_DCHECK_GT(streams[0].max_framerate, 0); | 225 RTC_DCHECK_GT(streams[0].max_framerate, 0); |
221 video_codec.maxFramerate = streams[0].max_framerate; | 226 video_codec.maxFramerate = streams[0].max_framerate; |
222 return video_codec; | 227 return video_codec; |
223 } | 228 } |
224 | 229 |
225 } // namespace webrtc | 230 } // namespace webrtc |
OLD | NEW |