From c19319c7774d701b5c7ae23ac15f3c1dea3d4c0d Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Sat, 26 Mar 2022 12:36:46 +0000 Subject: [PATCH] webrtc: Refactor ICECandidateStats freeing logic to a dedicated function Part-of: --- subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c | 11 +++++++++++ subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.h | 3 +++ subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c | 11 ++--------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c index 8b1ce70..5e796e1 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c @@ -1006,6 +1006,17 @@ gst_webrtc_ice_get_selected_pair (GstWebRTCICE * ice, return FALSE; } +void +gst_webrtc_ice_candidate_stats_free (GstWebRTCICECandidateStats * stats) +{ + if (stats) { + g_free (stats->ipaddr); + g_free (stats->url); + } + + g_free (stats); +} + static void _clear_ice_stream (struct NiceStreamItem *item) { diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.h b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.h index 831ca1c..7e20902 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.h +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.h @@ -128,6 +128,9 @@ gboolean gst_webrtc_ice_get_selected_pair (GstWebRTCIC GstWebRTCICEStream * stream, GstWebRTCICECandidateStats ** local_stats, GstWebRTCICECandidateStats ** remote_stats); + +void gst_webrtc_ice_candidate_stats_free (GstWebRTCICECandidateStats * stats); + G_END_DECLS #endif /* __GST_WEBRTC_ICE_H__ */ diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c index da3a4a6..c628fc1 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c @@ -711,15 +711,8 @@ _get_stats_from_ice_transport (GstWebRTCBin * webrtc, g_free (local_cand_id); g_free (remote_cand_id); - if (local_cand) { - g_free (local_cand->ipaddr); - g_free (local_cand->url); - } - if (remote_cand) - g_free (remote_cand->ipaddr); - - g_free (local_cand); - g_free (remote_cand); + gst_webrtc_ice_candidate_stats_free (local_cand); + gst_webrtc_ice_candidate_stats_free (remote_cand); gst_structure_free (stats); -- 2.7.4