From 2caa6721f9bad0144fdb4060e2700702ff04b147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Vel=C3=A1zquez-Garc=C3=ADa?= Date: Wed, 9 Oct 2024 12:08:10 -0400 Subject: [PATCH] srtsink: Register SRT listen callback before binding socket This change https://github.com/Haivision/srt/pull/2683 forces us to call `srt_listen_callback` before `srt_listen`. Part-of: --- .../gst-plugins-bad/ext/srt/gstsrtobject.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/srt/gstsrtobject.c b/subprojects/gst-plugins-bad/ext/srt/gstsrtobject.c index ce15c0b022..986c643a40 100644 --- a/subprojects/gst-plugins-bad/ext/srt/gstsrtobject.c +++ b/subprojects/gst-plugins-bad/ext/srt/gstsrtobject.c @@ -1198,19 +1198,22 @@ gst_srt_object_wait_connect (GstSRTObject * srtobject, gpointer sa, } poll_added = TRUE; - GST_DEBUG_OBJECT (srtobject->element, "Starting to listen on bind socket"); - if (srt_listen (sock, 1) == SRT_ERROR) { - g_set_error (error, GST_RESOURCE_ERROR, - GST_RESOURCE_ERROR_OPEN_READ_WRITE, "Cannot listen on bind socket: %s", - srt_getlasterror_str ()); - goto failed; - } - srtobject->sock = sock; /* Register the SRT listen callback */ if (srt_listen_callback (srtobject->sock, (srt_listen_callback_fn *) srt_listen_callback_func, srtobject)) { + g_set_error (error, GST_RESOURCE_ERROR, + GST_RESOURCE_ERROR_OPEN_READ_WRITE, + "Failed to register SRT listen callback: %s", srt_getlasterror_str ()); + goto failed; + } + + GST_DEBUG_OBJECT (srtobject->element, "Starting to listen on bind socket"); + if (srt_listen (sock, 1) == SRT_ERROR) { + g_set_error (error, GST_RESOURCE_ERROR, + GST_RESOURCE_ERROR_OPEN_READ_WRITE, "Cannot listen on bind socket: %s", + srt_getlasterror_str ()); goto failed; }