mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
obs-webrtc: Avoid crashing on invalid answer
PeerConnection::setRemoteDescription validates the input SDP, throwing an exception whenever it is invalid. Currently, instead of handling the exception, we just crash. Instead, add an exception handler which logs a short description of the issue as well as the error message from the exception.
This commit is contained in:
parent
e4ec414690
commit
4953c5d517
@ -401,7 +401,21 @@ bool WHIPOutput::Connect()
|
||||
response.erase(0, response.find("v=0"));
|
||||
|
||||
rtc::Description answer(response, "answer");
|
||||
peer_connection->setRemoteDescription(answer);
|
||||
try {
|
||||
peer_connection->setRemoteDescription(answer);
|
||||
} catch (const std::invalid_argument &err) {
|
||||
do_log(LOG_ERROR, "WHIP server responded with invalid SDP: %s",
|
||||
err.what());
|
||||
cleanup();
|
||||
obs_output_signal_stop(output, OBS_OUTPUT_CONNECT_FAILED);
|
||||
return false;
|
||||
} catch (const std::exception &err) {
|
||||
do_log(LOG_ERROR, "Failed to set remote description: %s",
|
||||
err.what());
|
||||
cleanup();
|
||||
obs_output_signal_stop(output, OBS_OUTPUT_CONNECT_FAILED);
|
||||
return false;
|
||||
}
|
||||
cleanup();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user