From 65bfa84d7accd821aa153a2cea821806d22e1967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 1 May 2020 10:42:17 +0300 Subject: [PATCH] rtsp-stream-transport: Fix accidental API/ABI breakage with message_sent callbacks The old API is preserved now and new API was added that provides the additional parameter to the callback. Fixes https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/issues/104 Part-of: --- gst/rtsp-server/rtsp-stream-transport.c | 38 +++++++++++++++++++++++-- gst/rtsp-server/rtsp-stream-transport.h | 24 +++++++++++++--- gst/rtsp-server/rtsp-stream.c | 4 +-- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/gst/rtsp-server/rtsp-stream-transport.c b/gst/rtsp-server/rtsp-stream-transport.c index ac0e2572d5..d293a95138 100644 --- a/gst/rtsp-server/rtsp-stream-transport.c +++ b/gst/rtsp-server/rtsp-stream-transport.c @@ -77,6 +77,10 @@ struct _GstRTSPStreamTransportPrivate gpointer ms_user_data; GDestroyNotify ms_notify; + GstRTSPMessageSentFuncFull message_sent_full; + gpointer msf_user_data; + GDestroyNotify msf_notify; + GstRTSPTransport *transport; GstRTSPUrl *url; @@ -373,6 +377,34 @@ gst_rtsp_stream_transport_set_message_sent (GstRTSPStreamTransport * trans, priv->ms_notify = notify; } +/** + * gst_rtsp_stream_transport_set_message_sent_full: + * @trans: a #GstRTSPStreamTransport + * @message_sent: (scope notified): a callback called when a message has been sent + * @user_data: (closure): user data passed to callback + * @notify: (allow-none): called with the user_data when no longer needed + * + * Install a callback that will be called when a message has been sent on @trans. + * + * Since: 1.18 + */ +void +gst_rtsp_stream_transport_set_message_sent_full (GstRTSPStreamTransport * trans, + GstRTSPMessageSentFuncFull message_sent, gpointer user_data, + GDestroyNotify notify) +{ + GstRTSPStreamTransportPrivate *priv; + + g_return_if_fail (GST_IS_RTSP_STREAM_TRANSPORT (trans)); + + priv = trans->priv; + + priv->message_sent_full = message_sent; + if (priv->msf_notify) + priv->msf_notify (priv->msf_user_data); + priv->msf_user_data = user_data; + priv->msf_notify = notify; +} /** * gst_rtsp_stream_transport_set_transport: @@ -750,7 +782,7 @@ gst_rtsp_stream_transport_keep_alive (GstRTSPStreamTransport * trans) * gst_rtsp_stream_transport_message_sent: * @trans: a #GstRTSPStreamTransport * - * Signal the installed message_sent callback for @trans. + * Signal the installed message_sent / message_sent_full callback for @trans. * * Since: 1.16 */ @@ -761,8 +793,10 @@ gst_rtsp_stream_transport_message_sent (GstRTSPStreamTransport * trans) priv = trans->priv; + if (priv->message_sent_full) + priv->message_sent_full (trans, priv->msf_user_data); if (priv->message_sent) - priv->message_sent (trans, priv->ms_user_data); + priv->message_sent (priv->ms_user_data); } /** diff --git a/gst/rtsp-server/rtsp-stream-transport.h b/gst/rtsp-server/rtsp-stream-transport.h index f878858db1..d8516c027e 100644 --- a/gst/rtsp-server/rtsp-stream-transport.h +++ b/gst/rtsp-server/rtsp-stream-transport.h @@ -89,7 +89,18 @@ typedef void (*GstRTSPKeepAliveFunc) (gpointer user_data); * Function registered with gst_rtsp_stream_transport_set_message_sent() * and called when a message has been sent on the transport. */ -typedef void (*GstRTSPMessageSentFunc) (GstRTSPStreamTransport *trans, gpointer user_data); +typedef void (*GstRTSPMessageSentFunc) (gpointer user_data); + +/** + * GstRTSPMessageSentFuncFull: + * @user_data: user data + * + * Function registered with gst_rtsp_stream_transport_set_message_sent_full() + * and called when a message has been sent on the transport. + * + * Since: 1.18 + */ +typedef void (*GstRTSPMessageSentFuncFull) (GstRTSPStreamTransport *trans, gpointer user_data); /** * GstRTSPStreamTransport: @@ -163,11 +174,16 @@ void gst_rtsp_stream_transport_set_keepalive (GstRTSPStreamT GST_RTSP_SERVER_API void gst_rtsp_stream_transport_set_message_sent (GstRTSPStreamTransport *trans, - GstRTSPMessageSentFunc message_sent, - gpointer user_data, - GDestroyNotify notify); + GstRTSPMessageSentFunc message_sent, + gpointer user_data, + GDestroyNotify notify); GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_message_sent_full (GstRTSPStreamTransport *trans, + GstRTSPMessageSentFuncFull message_sent, + gpointer user_data, + GDestroyNotify notify); +GST_RTSP_SERVER_API void gst_rtsp_stream_transport_keep_alive (GstRTSPStreamTransport *trans); GST_RTSP_SERVER_API diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c index aabb3b0a33..411498061c 100644 --- a/gst/rtsp-server/rtsp-stream.c +++ b/gst/rtsp-server/rtsp-stream.c @@ -4685,8 +4685,8 @@ gst_rtsp_stream_add_transport (GstRTSPStream * stream, g_mutex_lock (&priv->lock); res = update_transport (stream, trans, TRUE); if (res) - gst_rtsp_stream_transport_set_message_sent (trans, on_message_sent, stream, - NULL); + gst_rtsp_stream_transport_set_message_sent_full (trans, on_message_sent, + stream, NULL); g_mutex_unlock (&priv->lock); return res;