webrtc: nice: WeakRef access fixes

The GstWebRTCNiceStream::ice property getter already hands-off a full reference,
so there is no need to call g_weak_ref_get() in call sites.

Fixes #1350

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2819>
This commit is contained in:
Philippe Normand 2022-07-30 17:28:41 +01:00 committed by GStreamer Marge Bot
parent 3bdf3455a0
commit 4bf62c788c
3 changed files with 26 additions and 27 deletions

View file

@ -1257,15 +1257,13 @@ gst_webrtc_nice_get_selected_pair (GstWebRTCICE * ice,
static void static void
_clear_ice_stream (struct NiceStreamItem *item) _clear_ice_stream (struct NiceStreamItem *item)
{ {
GWeakRef ice_weak; GstWebRTCNice *ice = NULL;
GstWebRTCNice *ice;
if (!item) if (!item)
return; return;
if (item->stream) { if (item->stream) {
g_object_get (GST_WEBRTC_NICE_STREAM (item->stream), "ice", &ice_weak, g_object_get (item->stream, "ice", &ice, NULL);
NULL);
ice = g_weak_ref_get (&ice_weak);
if (ice != NULL) { if (ice != NULL) {
g_signal_handlers_disconnect_by_data (ice->priv->nice_agent, g_signal_handlers_disconnect_by_data (ice->priv->nice_agent,

View file

@ -179,9 +179,15 @@ weak_free (GWeakRef * weak)
static void static void
gst_webrtc_nice_stream_constructed (GObject * object) gst_webrtc_nice_stream_constructed (GObject * object)
{ {
GstWebRTCNiceStream *stream = GST_WEBRTC_NICE_STREAM (object); GstWebRTCNiceStream *stream;
NiceAgent *agent; NiceAgent *agent;
GstWebRTCNice *ice = g_weak_ref_get (&stream->priv->ice_weak); GstWebRTCNice *ice;
G_OBJECT_CLASS (parent_class)->constructed (object);
stream = GST_WEBRTC_NICE_STREAM (object);
ice = g_weak_ref_get (&stream->priv->ice_weak);
g_assert (ice != NULL); g_assert (ice != NULL);
g_object_get (ice, "agent", &agent, NULL); g_object_get (ice, "agent", &agent, NULL);
@ -191,8 +197,6 @@ gst_webrtc_nice_stream_constructed (GObject * object)
g_object_unref (agent); g_object_unref (agent);
gst_object_unref (ice); gst_object_unref (ice);
G_OBJECT_CLASS (parent_class)->constructed (object);
} }
static gboolean static gboolean

View file

@ -163,11 +163,9 @@ gst_webrtc_nice_transport_finalize (GObject * object)
{ {
GstWebRTCNiceTransport *nice = GST_WEBRTC_NICE_TRANSPORT (object); GstWebRTCNiceTransport *nice = GST_WEBRTC_NICE_TRANSPORT (object);
NiceAgent *agent; NiceAgent *agent;
GstWebRTCNice *webrtc_ice; GstWebRTCNice *webrtc_ice = NULL;
GWeakRef ice_weak; g_object_get (nice->stream, "ice", &webrtc_ice, NULL);
g_object_get (GST_WEBRTC_NICE_STREAM (nice->stream), "ice", &ice_weak, NULL);
webrtc_ice = g_weak_ref_get (&ice_weak);
if (webrtc_ice) { if (webrtc_ice) {
g_object_get (webrtc_ice, "agent", &agent, NULL); g_object_get (webrtc_ice, "agent", &agent, NULL);
@ -196,11 +194,9 @@ gst_webrtc_nice_transport_update_buffer_size (GstWebRTCNiceTransport * nice)
NiceAgent *agent = NULL; NiceAgent *agent = NULL;
GPtrArray *sockets; GPtrArray *sockets;
guint i; guint i;
GstWebRTCNice *webrtc_ice; GstWebRTCNice *webrtc_ice = NULL;
GWeakRef ice_weak; g_object_get (nice->stream, "ice", &webrtc_ice, NULL);
g_object_get (GST_WEBRTC_NICE_STREAM (nice->stream), "ice", &ice_weak, NULL);
webrtc_ice = g_weak_ref_get (&ice_weak);
g_assert (webrtc_ice != NULL); g_assert (webrtc_ice != NULL);
@ -322,20 +318,23 @@ weak_free (GWeakRef * weak)
static void static void
gst_webrtc_nice_transport_constructed (GObject * object) gst_webrtc_nice_transport_constructed (GObject * object)
{ {
GstWebRTCNiceTransport *nice = GST_WEBRTC_NICE_TRANSPORT (object); GstWebRTCNiceTransport *nice;
GstWebRTCICETransport *ice = GST_WEBRTC_ICE_TRANSPORT (object); GstWebRTCICETransport *ice;
NiceComponentType component = _gst_component_to_nice (ice->component); NiceComponentType component;
gboolean controlling_mode; gboolean controlling_mode;
guint our_stream_id; guint our_stream_id;
NiceAgent *agent; NiceAgent *agent;
GstWebRTCNice *webrtc_ice; GstWebRTCNice *webrtc_ice = NULL;
GWeakRef ice_weak; G_OBJECT_CLASS (parent_class)->constructed (object);
g_object_get (GST_WEBRTC_NICE_STREAM (nice->stream), "ice", &ice_weak, NULL);
webrtc_ice = g_weak_ref_get (&ice_weak);
nice = GST_WEBRTC_NICE_TRANSPORT (object);
ice = GST_WEBRTC_ICE_TRANSPORT (object);
component = _gst_component_to_nice (ice->component);
g_object_get (nice->stream, "ice", &webrtc_ice, "stream-id", &our_stream_id,
NULL);
g_assert (webrtc_ice != NULL); g_assert (webrtc_ice != NULL);
g_object_get (nice->stream, "stream-id", &our_stream_id, NULL);
g_object_get (webrtc_ice, "agent", &agent, NULL); g_object_get (webrtc_ice, "agent", &agent, NULL);
g_object_get (agent, "controlling-mode", &controlling_mode, NULL); g_object_get (agent, "controlling-mode", &controlling_mode, NULL);
@ -364,8 +363,6 @@ gst_webrtc_nice_transport_constructed (GObject * object)
g_object_unref (agent); g_object_unref (agent);
gst_object_unref (webrtc_ice); gst_object_unref (webrtc_ice);
G_OBJECT_CLASS (parent_class)->constructed (object);
} }
static void static void