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
_clear_ice_stream (struct NiceStreamItem *item)
{
GWeakRef ice_weak;
GstWebRTCNice *ice;
GstWebRTCNice *ice = NULL;
if (!item)
return;
if (item->stream) {
g_object_get (GST_WEBRTC_NICE_STREAM (item->stream), "ice", &ice_weak,
NULL);
ice = g_weak_ref_get (&ice_weak);
g_object_get (item->stream, "ice", &ice, NULL);
if (ice != NULL) {
g_signal_handlers_disconnect_by_data (ice->priv->nice_agent,

View file

@ -179,9 +179,15 @@ weak_free (GWeakRef * weak)
static void
gst_webrtc_nice_stream_constructed (GObject * object)
{
GstWebRTCNiceStream *stream = GST_WEBRTC_NICE_STREAM (object);
GstWebRTCNiceStream *stream;
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_object_get (ice, "agent", &agent, NULL);
@ -191,8 +197,6 @@ gst_webrtc_nice_stream_constructed (GObject * object)
g_object_unref (agent);
gst_object_unref (ice);
G_OBJECT_CLASS (parent_class)->constructed (object);
}
static gboolean

View file

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