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: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/116>
This commit is contained in:
Sebastian Dröge 2020-05-01 10:42:17 +03:00
parent e7802c1be7
commit 65bfa84d7a
3 changed files with 58 additions and 8 deletions

View file

@ -77,6 +77,10 @@ struct _GstRTSPStreamTransportPrivate
gpointer ms_user_data; gpointer ms_user_data;
GDestroyNotify ms_notify; GDestroyNotify ms_notify;
GstRTSPMessageSentFuncFull message_sent_full;
gpointer msf_user_data;
GDestroyNotify msf_notify;
GstRTSPTransport *transport; GstRTSPTransport *transport;
GstRTSPUrl *url; GstRTSPUrl *url;
@ -373,6 +377,34 @@ gst_rtsp_stream_transport_set_message_sent (GstRTSPStreamTransport * trans,
priv->ms_notify = notify; 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: * gst_rtsp_stream_transport_set_transport:
@ -750,7 +782,7 @@ gst_rtsp_stream_transport_keep_alive (GstRTSPStreamTransport * trans)
* gst_rtsp_stream_transport_message_sent: * gst_rtsp_stream_transport_message_sent:
* @trans: a #GstRTSPStreamTransport * @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 * Since: 1.16
*/ */
@ -761,8 +793,10 @@ gst_rtsp_stream_transport_message_sent (GstRTSPStreamTransport * trans)
priv = trans->priv; priv = trans->priv;
if (priv->message_sent_full)
priv->message_sent_full (trans, priv->msf_user_data);
if (priv->message_sent) if (priv->message_sent)
priv->message_sent (trans, priv->ms_user_data); priv->message_sent (priv->ms_user_data);
} }
/** /**

View file

@ -89,7 +89,18 @@ typedef void (*GstRTSPKeepAliveFunc) (gpointer user_data);
* Function registered with gst_rtsp_stream_transport_set_message_sent() * Function registered with gst_rtsp_stream_transport_set_message_sent()
* and called when a message has been sent on the transport. * 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: * GstRTSPStreamTransport:
@ -163,11 +174,16 @@ void gst_rtsp_stream_transport_set_keepalive (GstRTSPStreamT
GST_RTSP_SERVER_API GST_RTSP_SERVER_API
void gst_rtsp_stream_transport_set_message_sent (GstRTSPStreamTransport *trans, void gst_rtsp_stream_transport_set_message_sent (GstRTSPStreamTransport *trans,
GstRTSPMessageSentFunc message_sent, GstRTSPMessageSentFunc message_sent,
gpointer user_data, gpointer user_data,
GDestroyNotify notify); GDestroyNotify notify);
GST_RTSP_SERVER_API 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); void gst_rtsp_stream_transport_keep_alive (GstRTSPStreamTransport *trans);
GST_RTSP_SERVER_API GST_RTSP_SERVER_API

View file

@ -4685,8 +4685,8 @@ gst_rtsp_stream_add_transport (GstRTSPStream * stream,
g_mutex_lock (&priv->lock); g_mutex_lock (&priv->lock);
res = update_transport (stream, trans, TRUE); res = update_transport (stream, trans, TRUE);
if (res) if (res)
gst_rtsp_stream_transport_set_message_sent (trans, on_message_sent, stream, gst_rtsp_stream_transport_set_message_sent_full (trans, on_message_sent,
NULL); stream, NULL);
g_mutex_unlock (&priv->lock); g_mutex_unlock (&priv->lock);
return res; return res;