/* * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
if (send_codecs.empty()) { // This is an audio sender or an extra check in the stack where the codec // list is not available and we can't check the scalability_mode values. return webrtc::RTCError::OK();
}
for (size_t i = 0; i < rtp_parameters.encodings.size(); ++i) { if (rtp_parameters.encodings[i].codec) { bool codecFound = false; for (const cricket::Codec& codec : send_codecs) { if (IsSameRtpCodec(codec, *rtp_parameters.encodings[i].codec) &&
SupportsMode(codec, rtp_parameters.encodings[i].scalability_mode)) {
codecFound = true;
send_codec = codec; break;
}
} if (!codecFound) {
LOG_AND_RETURN_ERROR(
RTCErrorType::INVALID_MODIFICATION, "Attempted to use an unsupported codec for layer " +
std::to_string(i));
}
} if (rtp_parameters.encodings[i].scalability_mode) { if (!send_codec) { bool scalabilityModeFound = false; for (const cricket::Codec& codec : send_codecs) { for (constauto& scalability_mode : codec.scalability_modes) { if (ScalabilityModeToString(scalability_mode) ==
*rtp_parameters.encodings[i].scalability_mode) {
scalabilityModeFound = true; break;
}
} if (scalabilityModeFound) break;
}
if (!scalabilityModeFound) {
LOG_AND_RETURN_ERROR(
RTCErrorType::INVALID_MODIFICATION, "Attempted to set RtpParameters scalabilityMode " "to an unsupported value for the current codecs.");
}
} else { bool scalabilityModeFound = false; for (constauto& scalability_mode : send_codec->scalability_modes) { if (ScalabilityModeToString(scalability_mode) ==
*rtp_parameters.encodings[i].scalability_mode) {
scalabilityModeFound = true; break;
}
} if (!scalabilityModeFound) {
LOG_AND_RETURN_ERROR(
RTCErrorType::INVALID_MODIFICATION, "Attempted to set RtpParameters scalabilityMode " "to an unsupported value for the current codecs.");
}
}
}
}
bool has_scale_resolution_down_to = false; for (size_t i = 0; i < rtp_parameters.encodings.size(); ++i) { if (rtp_parameters.encodings[i].bitrate_priority <= 0) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_RANGE, "Attempted to set RtpParameters bitrate_priority to " "an invalid number. bitrate_priority must be > 0.");
} if (rtp_parameters.encodings[i].scale_resolution_down_by &&
*rtp_parameters.encodings[i].scale_resolution_down_by < 1.0) {
LOG_AND_RETURN_ERROR(
RTCErrorType::INVALID_RANGE, "Attempted to set RtpParameters scale_resolution_down_by to an " "invalid value. scale_resolution_down_by must be >= 1.0");
} if (rtp_parameters.encodings[i].max_framerate &&
*rtp_parameters.encodings[i].max_framerate < 0.0) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_RANGE, "Attempted to set RtpParameters max_framerate to an " "invalid value. max_framerate must be >= 0.0");
} if (rtp_parameters.encodings[i].min_bitrate_bps &&
rtp_parameters.encodings[i].max_bitrate_bps) { if (*rtp_parameters.encodings[i].max_bitrate_bps <
*rtp_parameters.encodings[i].min_bitrate_bps) {
LOG_AND_RETURN_ERROR(webrtc::RTCErrorType::INVALID_RANGE, "Attempted to set RtpParameters min bitrate " "larger than max bitrate.");
}
} if (rtp_parameters.encodings[i].num_temporal_layers) { if (*rtp_parameters.encodings[i].num_temporal_layers < 1 ||
*rtp_parameters.encodings[i].num_temporal_layers >
webrtc::kMaxTemporalStreams) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_RANGE, "Attempted to set RtpParameters " "num_temporal_layers to an invalid number.");
}
}
if (rtp_parameters.encodings[i].scale_resolution_down_to.has_value()) {
has_scale_resolution_down_to = true; if (rtp_parameters.encodings[i].scale_resolution_down_to->width <= 0 ||
rtp_parameters.encodings[i].scale_resolution_down_to->height <= 0) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_MODIFICATION, "The resolution dimensions must be positive.");
}
}
if (!field_trials.IsEnabled("WebRTC-MixedCodecSimulcast")) { if (i > 0 && rtp_parameters.encodings[i - 1].codec !=
rtp_parameters.encodings[i].codec) {
LOG_AND_RETURN_ERROR(RTCErrorType::UNSUPPORTED_OPERATION, "Attempted to use different codec values for " "different encodings.");
}
}
}
if (has_scale_resolution_down_to &&
absl::c_any_of(rtp_parameters.encodings,
[](const webrtc::RtpEncodingParameters& encoding) { return encoding.active &&
!encoding.scale_resolution_down_to.has_value();
})) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_MODIFICATION, "If a resolution is specified on any encoding then " "it must be specified on all encodings.");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.