Skip to content

Commit

Permalink
obs-webrtc: Add additional error messaging for WHIP output
Browse files Browse the repository at this point in the history
Adding to the previous commit, let's also use obs_output_set_last_error
to provide localized error messages to the user if we run into these
failure cases.
  • Loading branch information
RytoEX committed Mar 9, 2024
1 parent c3a20bd commit d25042a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/obs-webrtc/data/locale/en-US.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Output.Name="WHIP Output"
Service.Name="WHIP Service"
Service.BearerToken="Bearer Token"

Error.InvalidSDP="WHIP server responded with invalid SDP: %1"
Error.NoRemoteDescription="Failed to set remote description: %1"
12 changes: 12 additions & 0 deletions plugins/obs-webrtc/whip-output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,24 @@ bool WHIPOutput::Connect()
do_log(LOG_ERROR, "WHIP server responded with invalid SDP: %s",
err.what());
cleanup();
struct dstr error_message;
dstr_init_copy(&error_message,
obs_module_text("Error.InvalidSDP"));
dstr_replace(&error_message, "%1", err.what());
obs_output_set_last_error(output, error_message.array);
dstr_free(&error_message);
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();
struct dstr error_message;
dstr_init_copy(&error_message,
obs_module_text("Error.NoRemoteDescription"));
dstr_replace(&error_message, "%1", err.what());
obs_output_set_last_error(output, error_message.array);
dstr_free(&error_message);
obs_output_signal_stop(output, OBS_OUTPUT_CONNECT_FAILED);
return false;
}
Expand Down

0 comments on commit d25042a

Please sign in to comment.