srt: don't pass SRT socket ID to "caller-added,removed" signals

The caller's IP and port is enough for unique identification. Don't leak
the socket handle since using it in unadvised libsrt calls from the
application could break the SRT element.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1772>
This commit is contained in:
Jakub Adam 2020-12-14 20:34:15 +01:00 committed by GStreamer Merge Bot
parent 4a58af4352
commit 327ad84e35
3 changed files with 16 additions and 20 deletions

View file

@ -126,7 +126,7 @@ srt_caller_signal_removed (SRTCaller * caller, GstSRTObject * srtobject)
* socket. Deliver the stats to the app before we throw them away. */ * socket. Deliver the stats to the app before we throw them away. */
gst_structure_free (stats); gst_structure_free (stats);
g_signal_emit_by_name (srtobject->element, "caller-removed", caller->sock, g_signal_emit_by_name (srtobject->element, "caller-removed",
caller->sockaddr); caller->sockaddr);
} }
@ -990,7 +990,7 @@ thread_func (gpointer data)
g_mutex_unlock (&srtobject->sock_lock); g_mutex_unlock (&srtobject->sock_lock);
/* notifying caller-added */ /* notifying caller-added */
g_signal_emit_by_name (srtobject->element, "caller-added", caller->sock, g_signal_emit_by_name (srtobject->element, "caller-added",
caller->sockaddr); caller->sockaddr);
if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (srtobject->element)) == if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (srtobject->element)) ==

View file

@ -305,29 +305,27 @@ gst_srt_sink_class_init (GstSRTSinkClass * klass)
/** /**
* GstSRTSink::caller-added: * GstSRTSink::caller-added:
* @gstsrtsink: the srtsink element that emitted this signal * @gstsrtsink: the srtsink element that emitted this signal
* @sock: the client socket descriptor that was added to srtsink * @addr: the #GSocketAddress of the new caller
* @addr: the #GSocketAddress that describes the @sock *
* * A new caller has connected to @gstsrtsink.
* The given socket descriptor was added to srtsink.
*/ */
signals[SIG_CALLER_ADDED] = signals[SIG_CALLER_ADDED] =
g_signal_new ("caller-added", G_TYPE_FROM_CLASS (klass), g_signal_new ("caller-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSRTSinkClass, caller_added), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSRTSinkClass, caller_added),
NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_SOCKET_ADDRESS); NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_SOCKET_ADDRESS);
/** /**
* GstSRTSink::caller-removed: * GstSRTSink::caller-removed:
* @gstsrtsink: the srtsink element that emitted this signal * @gstsrtsink: the srtsink element that emitted this signal
* @sock: the client socket descriptor that was added to srtsink * @addr: the #GSocketAddress of the caller
* @addr: the #GSocketAddress that describes the @sock
* *
* The given socket descriptor was removed from srtsink. * The given caller has disconnected.
*/ */
signals[SIG_CALLER_REMOVED] = signals[SIG_CALLER_REMOVED] =
g_signal_new ("caller-removed", G_TYPE_FROM_CLASS (klass), g_signal_new ("caller-removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSRTSinkClass, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSRTSinkClass,
caller_added), NULL, NULL, NULL, G_TYPE_NONE, caller_added), NULL, NULL, NULL, G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_SOCKET_ADDRESS); 1, G_TYPE_SOCKET_ADDRESS);
/** /**
* GstSRTSink::caller-rejected: * GstSRTSink::caller-rejected:

View file

@ -362,29 +362,27 @@ gst_srt_src_class_init (GstSRTSrcClass * klass)
/** /**
* GstSRTSrc::caller-added: * GstSRTSrc::caller-added:
* @gstsrtsrc: the srtsrc element that emitted this signal * @gstsrtsrc: the srtsrc element that emitted this signal
* @sock: the client socket descriptor that was added to srtsrc * @addr: the #GSocketAddress of the new caller
* @addr: the #GSocketAddress that describes the @sock *
* * A new caller has connected to srtsrc.
* The given socket descriptor was added to srtsink.
*/ */
signals[SIG_CALLER_ADDED] = signals[SIG_CALLER_ADDED] =
g_signal_new ("caller-added", G_TYPE_FROM_CLASS (klass), g_signal_new ("caller-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSRTSrcClass, caller_added), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSRTSrcClass, caller_added),
NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_SOCKET_ADDRESS); NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_SOCKET_ADDRESS);
/** /**
* GstSRTSrc::caller-removed: * GstSRTSrc::caller-removed:
* @gstsrtsrc: the srtsrc element that emitted this signal * @gstsrtsrc: the srtsrc element that emitted this signal
* @sock: the client socket descriptor that was added to srtsrc * @addr: the #GSocketAddress of the caller
* @addr: the #GSocketAddress that describes the @sock
* *
* The given socket descriptor was removed from srtsrc. * The given caller has disconnected.
*/ */
signals[SIG_CALLER_REMOVED] = signals[SIG_CALLER_REMOVED] =
g_signal_new ("caller-removed", G_TYPE_FROM_CLASS (klass), g_signal_new ("caller-removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSRTSrcClass, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSRTSrcClass,
caller_added), NULL, NULL, NULL, G_TYPE_NONE, caller_added), NULL, NULL, NULL, G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_SOCKET_ADDRESS); 1, G_TYPE_SOCKET_ADDRESS);
/** /**
* GstSRTSrc::caller-rejected: * GstSRTSrc::caller-rejected: