Make requested_resolution throw on invalid dimensions.
As mandated by the scaleResolutionDownTo spec. Bug: chromium:363544347 Change-Id: Ic78cad708a271bbd6a1980c08430dbb8ae07663a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/362980 Auto-Submit: Henrik Boström <hbos@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43058}
This commit is contained in:
parent
3aa47cfd30
commit
f566dee902
@ -186,6 +186,11 @@ webrtc::RTCError CheckRtpParametersValues(
|
||||
|
||||
if (rtp_parameters.encodings[i].requested_resolution.has_value()) {
|
||||
has_requested_resolution = true;
|
||||
if (rtp_parameters.encodings[i].requested_resolution->width <= 0 ||
|
||||
rtp_parameters.encodings[i].requested_resolution->height <= 0) {
|
||||
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_MODIFICATION,
|
||||
"The resolution dimensions must be positive.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!field_trials.IsEnabled("WebRTC-MixedCodecSimulcast")) {
|
||||
|
||||
@ -2134,6 +2134,15 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
|
||||
EXPECT_EQ(transceiver_or_error.error().type(),
|
||||
RTCErrorType::UNSUPPORTED_OPERATION);
|
||||
|
||||
// AddTransceiver: Width and height must not be zero.
|
||||
init.send_encodings[0].requested_resolution = {.width = 1280, .height = 0};
|
||||
init.send_encodings[1].requested_resolution = {.width = 0, .height = 720};
|
||||
transceiver_or_error =
|
||||
pc_wrapper->pc()->AddTransceiver(cricket::MEDIA_TYPE_VIDEO, init);
|
||||
EXPECT_FALSE(transceiver_or_error.ok());
|
||||
EXPECT_EQ(transceiver_or_error.error().type(),
|
||||
RTCErrorType::UNSUPPORTED_OPERATION);
|
||||
|
||||
// AddTransceiver: Specifying both `requested_resolution` and
|
||||
// `scale_resolution_down_by` is allowed (the latter is ignored).
|
||||
init.send_encodings[0].requested_resolution = {.width = 640, .height = 480};
|
||||
@ -2154,6 +2163,15 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
|
||||
EXPECT_FALSE(error.ok());
|
||||
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
|
||||
|
||||
// SetParameters: Width and height must not be zero.
|
||||
sender = transceiver_or_error.value()->sender();
|
||||
parameters = sender->GetParameters();
|
||||
parameters.encodings[0].requested_resolution = {.width = 1280, .height = 0};
|
||||
parameters.encodings[1].requested_resolution = {.width = 0, .height = 720};
|
||||
error = sender->SetParameters(parameters);
|
||||
EXPECT_FALSE(error.ok());
|
||||
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
|
||||
|
||||
// SetParameters: Specifying both `requested_resolution` and
|
||||
// `scale_resolution_down_by` is allowed (the latter is ignored).
|
||||
parameters = sender->GetParameters();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user