webrtc: Make GstWebRTCIceCandidateStats a Boxed type
authorThibault Saunier <tsaunier@igalia.com>
Mon, 15 Aug 2022 15:36:25 +0000 (11:36 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 18 Aug 2022 08:34:36 +0000 (08:34 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2891>

subprojects/gst-plugins-bad/gst-libs/gst/webrtc/ice.c
subprojects/gst-plugins-bad/gst-libs/gst/webrtc/ice.h

index a3a4205..d197f19 100644 (file)
@@ -281,7 +281,7 @@ gst_webrtc_ice_get_remote_candidates (GstWebRTCICE * ice,
  * @stream: The #GstWebRTCICEStream
  * @local_stats: A pointer to #GstWebRTCICECandidateStats for local candidate
  * @remote_stats: A pointer to #GstWebRTCICECandidateStats for remote candidate
- * 
+ *
  * Returns: FALSE on failure, otherwise @local_stats @remote_stats will be set
  * Since: 1.22
  */
@@ -300,7 +300,7 @@ gst_webrtc_ice_get_selected_pair (GstWebRTCICE * ice,
 /**
  * gst_webrtc_ice_candidate_stats_free:
  * @stats: The #GstWebRTCICECandidateStats to be free'd
- * 
+ *
  * Helper function to free #GstWebRTCICECandidateStats
  * Since: 1.22
  */
@@ -316,6 +316,31 @@ gst_webrtc_ice_candidate_stats_free (GstWebRTCICECandidateStats * stats)
 }
 
 /**
+ * gst_webrtc_ice_candidate_stats_copy:
+ * @stats: The #GstWebRTCICE
+ *
+ * Returns: (transfer full): A copy of @stats
+ * Since: 1.22
+ */
+GstWebRTCICECandidateStats *
+gst_webrtc_ice_candidate_stats_copy (GstWebRTCICECandidateStats * stats)
+{
+  GstWebRTCICECandidateStats *copy =
+      g_malloc (sizeof (GstWebRTCICECandidateStats));
+
+  *copy = *stats;
+
+  copy->ipaddr = g_strdup (stats->ipaddr);
+  copy->url = g_strdup (stats->url);
+
+  return copy;
+}
+
+G_DEFINE_BOXED_TYPE (GstWebRTCICECandidateStats, gst_webrtc_ice_candidate_stats,
+    (GBoxedCopyFunc) gst_webrtc_ice_candidate_stats_copy,
+    (GBoxedFreeFunc) gst_webrtc_ice_candidate_stats_free);
+
+/**
  * gst_webrtc_ice_set_on_ice_candidate:
  * @ice: The #GstWebRTCICE
  * @func: The #GstWebRTCICEOnCandidateFunc callback function
index a39c5a6..ea16441 100644 (file)
@@ -212,8 +212,14 @@ gboolean                    gst_webrtc_ice_get_selected_pair        (GstWebRTCIC
 GST_WEBRTC_API
 void                        gst_webrtc_ice_candidate_stats_free     (GstWebRTCICECandidateStats * stats);
 
+GST_WEBRTC_API
+GType                       gst_webrtc_ice_candidate_stats_get_type (void);
+
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstWebRTCICE, gst_object_unref)
 
+GST_WEBRTC_API
+GstWebRTCICECandidateStats * gst_webrtc_ice_candidate_stats_copy (GstWebRTCICECandidateStats *stats);
+
 G_END_DECLS
 
 #endif /* __GST_WEBRTC_ICE_H__ */