| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { | 222 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { |
| 223 video_codec.targetBitrate = | 223 video_codec.targetBitrate = |
| 224 config.streams[0].temporal_layer_thresholds_bps[0] / 1000; | 224 config.streams[0].temporal_layer_thresholds_bps[0] / 1000; |
| 225 } | 225 } |
| 226 break; | 226 break; |
| 227 } | 227 } |
| 228 | 228 |
| 229 switch (video_codec.codecType) { | 229 switch (video_codec.codecType) { |
| 230 case kVideoCodecVP8: { | 230 case kVideoCodecVP8: { |
| 231 if (config.encoder_specific_settings) { | 231 if (config.encoder_specific_settings) { |
| 232 video_codec.codecSpecific.VP8 = *reinterpret_cast<const VideoCodecVP8*>( | 232 *(video_codec.VP8()) = *reinterpret_cast<const VideoCodecVP8*>( |
| 233 config.encoder_specific_settings); | 233 config.encoder_specific_settings); |
| 234 } else { | 234 } else { |
| 235 video_codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings(); | 235 *(video_codec.VP8()) = VideoEncoder::GetDefaultVp8Settings(); |
| 236 } | 236 } |
| 237 video_codec.codecSpecific.VP8.numberOfTemporalLayers = | 237 video_codec.VP8()->numberOfTemporalLayers = static_cast<unsigned char>( |
| 238 static_cast<unsigned char>( | 238 streams.back().temporal_layer_thresholds_bps.size() + 1); |
| 239 streams.back().temporal_layer_thresholds_bps.size() + 1); | |
| 240 break; | 239 break; |
| 241 } | 240 } |
| 242 case kVideoCodecVP9: { | 241 case kVideoCodecVP9: { |
| 243 if (config.encoder_specific_settings) { | 242 if (config.encoder_specific_settings) { |
| 244 video_codec.codecSpecific.VP9 = *reinterpret_cast<const VideoCodecVP9*>( | 243 *(video_codec.VP9()) = *reinterpret_cast<const VideoCodecVP9*>( |
| 245 config.encoder_specific_settings); | 244 config.encoder_specific_settings); |
| 246 if (video_codec.mode == kScreensharing) { | 245 if (video_codec.mode == kScreensharing) { |
| 247 video_codec.codecSpecific.VP9.flexibleMode = true; | 246 video_codec.VP9()->flexibleMode = true; |
| 248 // For now VP9 screensharing use 1 temporal and 2 spatial layers. | 247 // For now VP9 screensharing use 1 temporal and 2 spatial layers. |
| 249 RTC_DCHECK_EQ(video_codec.codecSpecific.VP9.numberOfTemporalLayers, | 248 RTC_DCHECK_EQ(video_codec.VP9()->numberOfTemporalLayers, 1); |
| 250 1); | 249 RTC_DCHECK_EQ(video_codec.VP9()->numberOfSpatialLayers, 2); |
| 251 RTC_DCHECK_EQ(video_codec.codecSpecific.VP9.numberOfSpatialLayers, 2); | |
| 252 } | 250 } |
| 253 } else { | 251 } else { |
| 254 video_codec.codecSpecific.VP9 = VideoEncoder::GetDefaultVp9Settings(); | 252 *(video_codec.VP9()) = VideoEncoder::GetDefaultVp9Settings(); |
| 255 } | 253 } |
| 256 video_codec.codecSpecific.VP9.numberOfTemporalLayers = | 254 video_codec.VP9()->numberOfTemporalLayers = static_cast<unsigned char>( |
| 257 static_cast<unsigned char>( | 255 streams.back().temporal_layer_thresholds_bps.size() + 1); |
| 258 streams.back().temporal_layer_thresholds_bps.size() + 1); | |
| 259 break; | 256 break; |
| 260 } | 257 } |
| 261 case kVideoCodecH264: { | 258 case kVideoCodecH264: { |
| 262 if (config.encoder_specific_settings) { | 259 if (config.encoder_specific_settings) { |
| 263 video_codec.codecSpecific.H264 = | 260 *(video_codec.H264()) = *reinterpret_cast<const VideoCodecH264*>( |
| 264 *reinterpret_cast<const VideoCodecH264*>( | 261 config.encoder_specific_settings); |
| 265 config.encoder_specific_settings); | |
| 266 } else { | 262 } else { |
| 267 video_codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings(); | 263 *(video_codec.H264()) = VideoEncoder::GetDefaultH264Settings(); |
| 268 } | 264 } |
| 269 break; | 265 break; |
| 270 } | 266 } |
| 271 default: | 267 default: |
| 272 // TODO(pbos): Support encoder_settings codec-agnostically. | 268 // TODO(pbos): Support encoder_settings codec-agnostically. |
| 273 RTC_DCHECK(!config.encoder_specific_settings) | 269 RTC_DCHECK(!config.encoder_specific_settings) |
| 274 << "Encoder-specific settings for codec type not wired up."; | 270 << "Encoder-specific settings for codec type not wired up."; |
| 275 break; | 271 break; |
| 276 } | 272 } |
| 277 | 273 |
| 278 strncpy(video_codec.plName, payload_name.c_str(), kPayloadNameSize - 1); | 274 strncpy(video_codec.plName, payload_name.c_str(), kPayloadNameSize - 1); |
| 279 video_codec.plName[kPayloadNameSize - 1] = '\0'; | 275 video_codec.plName[kPayloadNameSize - 1] = '\0'; |
| 280 video_codec.plType = payload_type; | 276 video_codec.plType = payload_type; |
| 281 video_codec.numberOfSimulcastStreams = | 277 video_codec.numberOfSimulcastStreams = |
| 282 static_cast<unsigned char>(streams.size()); | 278 static_cast<unsigned char>(streams.size()); |
| 283 video_codec.minBitrate = streams[0].min_bitrate_bps / 1000; | 279 video_codec.minBitrate = streams[0].min_bitrate_bps / 1000; |
| 284 if (video_codec.minBitrate < kEncoderMinBitrateKbps) | 280 if (video_codec.minBitrate < kEncoderMinBitrateKbps) |
| 285 video_codec.minBitrate = kEncoderMinBitrateKbps; | 281 video_codec.minBitrate = kEncoderMinBitrateKbps; |
| 286 RTC_DCHECK_LE(streams.size(), static_cast<size_t>(kMaxSimulcastStreams)); | 282 RTC_DCHECK_LE(streams.size(), static_cast<size_t>(kMaxSimulcastStreams)); |
| 287 if (video_codec.codecType == kVideoCodecVP9) { | 283 if (video_codec.codecType == kVideoCodecVP9) { |
| 288 // If the vector is empty, bitrates will be configured automatically. | 284 // If the vector is empty, bitrates will be configured automatically. |
| 289 RTC_DCHECK(config.spatial_layers.empty() || | 285 RTC_DCHECK(config.spatial_layers.empty() || |
| 290 config.spatial_layers.size() == | 286 config.spatial_layers.size() == |
| 291 video_codec.codecSpecific.VP9.numberOfSpatialLayers); | 287 video_codec.VP9()->numberOfSpatialLayers); |
| 292 RTC_DCHECK_LE(video_codec.codecSpecific.VP9.numberOfSpatialLayers, | 288 RTC_DCHECK_LE(video_codec.VP9()->numberOfSpatialLayers, |
| 293 kMaxSimulcastStreams); | 289 kMaxSimulcastStreams); |
| 294 for (size_t i = 0; i < config.spatial_layers.size(); ++i) | 290 for (size_t i = 0; i < config.spatial_layers.size(); ++i) |
| 295 video_codec.spatialLayers[i] = config.spatial_layers[i]; | 291 video_codec.spatialLayers[i] = config.spatial_layers[i]; |
| 296 } | 292 } |
| 297 for (size_t i = 0; i < streams.size(); ++i) { | 293 for (size_t i = 0; i < streams.size(); ++i) { |
| 298 SimulcastStream* sim_stream = &video_codec.simulcastStream[i]; | 294 SimulcastStream* sim_stream = &video_codec.simulcastStream[i]; |
| 299 RTC_DCHECK_GT(streams[i].width, 0u); | 295 RTC_DCHECK_GT(streams[i].width, 0u); |
| 300 RTC_DCHECK_GT(streams[i].height, 0u); | 296 RTC_DCHECK_GT(streams[i].height, 0u); |
| 301 RTC_DCHECK_GT(streams[i].max_framerate, 0); | 297 RTC_DCHECK_GT(streams[i].max_framerate, 0); |
| 302 // Different framerates not supported per stream at the moment. | 298 // Different framerates not supported per stream at the moment. |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 &module_nack_rate); | 798 &module_nack_rate); |
| 803 *sent_video_rate_bps += module_video_rate; | 799 *sent_video_rate_bps += module_video_rate; |
| 804 *sent_nack_rate_bps += module_nack_rate; | 800 *sent_nack_rate_bps += module_nack_rate; |
| 805 *sent_fec_rate_bps += module_fec_rate; | 801 *sent_fec_rate_bps += module_fec_rate; |
| 806 } | 802 } |
| 807 return 0; | 803 return 0; |
| 808 } | 804 } |
| 809 | 805 |
| 810 } // namespace internal | 806 } // namespace internal |
| 811 } // namespace webrtc | 807 } // namespace webrtc |
| OLD | NEW |