srtobject: distinguish authentication error messages

Use GST_RESOURCE_ERROR_NOT_AUTHORIZED code in posted error messages
related to SRT authentication (e.g. incorrect or missing password) so
that the application can recognize them more easily.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1943>
This commit is contained in:
Jakub Adam 2020-10-16 19:30:59 +02:00 committed by GStreamer Merge Bot
parent ef118f3d0a
commit 6c35222973

View file

@ -1538,12 +1538,20 @@ gst_srt_object_read (GstSRTObject * srtobject,
if (wsocklen == 1 && rsocklen == 1) {
/* Socket reported in wsock AND rsock signifies an error. */
gint reason = srt_getrejectreason (wsock);
gboolean is_auth_error = (reason == SRT_REJ_BADSECRET
|| reason == SRT_REJ_UNSECURE);
if (is_auth_error) {
ELEMENT_WARNING_SRTSOCK_ERROR (NOT_AUTHORIZED, reason);
}
if (connection_mode == GST_SRT_CONNECTION_MODE_LISTENER) {
/* Caller has disappeared. */
return 0;
} else {
ELEMENT_WARNING_SRTSOCK_ERROR (READ, reason);
if (!is_auth_error) {
ELEMENT_WARNING_SRTSOCK_ERROR (READ, reason);
}
gst_srt_object_close (srtobject);
if (!gst_srt_object_open_internal (srtobject, cancellable, error)) {
@ -1767,7 +1775,11 @@ gst_srt_object_write_one (GstSRTObject * srtobject,
/* Socket reported in wsock AND rsock signifies an error. */
gint reason = srt_getrejectreason (wsock);
ELEMENT_WARNING_SRTSOCK_ERROR (WRITE, reason);
if (reason == SRT_REJ_BADSECRET || reason == SRT_REJ_UNSECURE) {
ELEMENT_WARNING_SRTSOCK_ERROR (NOT_AUTHORIZED, reason);
} else {
ELEMENT_WARNING_SRTSOCK_ERROR (WRITE, reason);
}
gst_srt_object_close (srtobject);
if (!gst_srt_object_open_internal (srtobject, cancellable, error)) {