[Nice] [nice/master] Add function to copy candidates

Olivier Crête olivier.crete at collabora.co.uk
Wed Nov 5 14:01:11 PST 2008


---
 agent/candidate.c |   18 ++++++++++++++++++
 agent/candidate.h |    3 +++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/agent/candidate.c b/agent/candidate.c
index 4ebd866..4598cc6 100644
--- a/agent/candidate.c
+++ b/agent/candidate.c
@@ -45,6 +45,8 @@
 # include <config.h>
 #endif
 
+#include <string.h>
+
 #include "agent.h"
 #include "component.h"
 
@@ -165,3 +167,19 @@ nice_candidate_pair_priority (guint32 o_prio, guint32 a_prio)
 
   return ((guint64)1 << 32) * min + 2 * max + (o_prio > a_prio ? 1 : 0);
 }
+
+/**
+ * Copies a candidate
+ */
+NICEAPI_EXPORT NiceCandidate *
+nice_candidate_copy (const NiceCandidate *candidate)
+{
+  NiceCandidate *copy = nice_candidate_new (candidate->type);
+
+  memcpy (copy, candidate, sizeof(NiceCandidate));
+
+  copy->username = g_strdup (copy->username);
+  copy->password = g_strdup (copy->password);
+
+  return copy;
+}
diff --git a/agent/candidate.h b/agent/candidate.h
index 4c89851..08c5c82 100644
--- a/agent/candidate.h
+++ b/agent/candidate.h
@@ -103,6 +103,9 @@ nice_candidate_ice_priority (const NiceCandidate *candidate);
 guint64
 nice_candidate_pair_priority (guint32 o_prio, guint32 a_prio);
 
+NiceCandidate *
+nice_candidate_copy (const NiceCandidate *candidate);
+
 G_END_DECLS
 
 #endif /* _CANDIDATE_H */
-- 
1.5.6.5




More information about the Nice mailing list