Skip to content

Commit

Permalink
Cherry-pick 261954@main (2a1e995). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=254163

    [GStreamer][WebRTC] webrtc/libwebrtc/setLocalDescriptionCrash.html fails
    https://bugs.webkit.org/show_bug.cgi?id=254163

    Reviewed by Xabier Rodriguez-Calvar.

    Detect SDP messages without version attribute and fail accordingly.

    * LayoutTests/platform/glib/TestExpectations:
    * Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp:
    (WebCore::GStreamerMediaEndpoint::doSetLocalDescription):
    (WebCore::GStreamerMediaEndpoint::setDescription):

    Canonical link: https://commits.webkit.org/261954@main
  • Loading branch information
philn authored and aperezdc committed Apr 13, 2023
1 parent 251a050 commit 2467638
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion LayoutTests/platform/glib/TestExpectations
Expand Up @@ -1729,7 +1729,6 @@ webkit.org/b/235885 webrtc/audio-video-element-playing.html [ Timeout ]
webkit.org/b/235885 webrtc/candidate-stats.html [ Failure ]
webkit.org/b/235885 webrtc/ephemeral-certificates-and-cnames.html [ Failure ]
webkit.org/b/235885 webrtc/filtering-ice-candidate-after-reload.html [ Failure ]
webkit.org/b/235885 webrtc/libwebrtc/setLocalDescriptionCrash.html [ Failure ]
webkit.org/b/235885 webrtc/peer-connection-track-end.html [ Failure ]
webkit.org/b/235885 webrtc/peerconnection-page-cache-long.html [ Timeout ]
webkit.org/b/235885 webrtc/peerconnection-page-cache.html [ Timeout ]
Expand Down
Expand Up @@ -12,7 +12,7 @@ FAIL pc.remoteDescription should throw an exception. Was null.
PASS pc.signalingState is "have-local-offer"
PASS pc.setLocalDescription(sessionDescription).then(finishIfSucceeded, requestFailed1); did not throw exception.
PASS setLocalDescription failed.
FAIL errorReason.name should be InvalidSessionDescriptionError. Was InvalidStateError.
FAIL errorReason.name should be InvalidSessionDescriptionError. Was OperationError.
PASS pc.localDescription.type is "offer"
PASS pc.localDescription.sdp is "local"
FAIL pc.remoteDescription should throw an exception. Was null.
Expand Down
Expand Up @@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS pc.signalingState is "stable"
PASS pc.setLocalDescription(sessionDescription).then(finishIfSucceeded, requestFailed1); did not throw exception.
PASS setLocalDescription failed.
FAIL errorReason.name should be InvalidSessionDescriptionError. Was InvalidStateError.
FAIL errorReason.name should be InvalidSessionDescriptionError. Was OperationError.
FAIL pc.localDescription should throw an exception. Was null.
FAIL pc.remoteDescription should throw an exception. Was null.
PASS pc.signalingState is "stable"
Expand Down
Expand Up @@ -395,9 +395,13 @@ void GStreamerMediaEndpoint::doSetLocalDescription(const RTCSessionDescription*
}, [protectedThis = Ref(*this), this](const GError* error) {
if (protectedThis->isStopped())
return;
if (error && error->code == GST_WEBRTC_ERROR_INVALID_STATE)
m_peerConnectionBackend.setLocalDescriptionFailed(Exception { InvalidStateError, "Failed to set local answer sdp: no pending remote description."_s });
else
if (error) {
if (error->code == GST_WEBRTC_ERROR_INVALID_STATE) {
m_peerConnectionBackend.setLocalDescriptionFailed(Exception { InvalidStateError, "Failed to set local answer sdp: no pending remote description."_s });
return;
}
m_peerConnectionBackend.setLocalDescriptionFailed(Exception { OperationError, String::fromUTF8(error->message) });
} else
m_peerConnectionBackend.setLocalDescriptionFailed(Exception { OperationError, "Unable to apply session local description"_s });
});
}
Expand Down Expand Up @@ -500,6 +504,13 @@ void GStreamerMediaEndpoint::setDescription(const RTCSessionDescription* descrip
return;
}
sdpType = description->type();
if (descriptionType == DescriptionType::Local && sdpType == RTCSdpType::Answer && !gst_sdp_message_get_version(message.get())) {
GError error;
GUniquePtr<char> errorMessage(g_strdup("Expect line: v="));
error.message = errorMessage.get();
failureCallback(&error);
return;
}
preProcessCallback(*message.get());
} else if (gst_sdp_message_new(&message.outPtr()) != GST_SDP_OK) {
failureCallback(nullptr);
Expand Down

0 comments on commit 2467638

Please sign in to comment.