webrtc: Refactor ICECandidateStats freeing logic to a dedicated function

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998>
This commit is contained in:
Philippe Normand 2022-03-26 12:36:46 +00:00 committed by GStreamer Marge Bot
parent dce8a7750d
commit c19319c777
3 changed files with 16 additions and 9 deletions

View file

@ -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)
{

View file

@ -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__ */

View file

@ -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);