From 1e9e28dbc98b4f6a7cf4bda0ca73b5abc2735ddc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Tue, 4 Apr 2017 14:41:51 -0400 Subject: [PATCH] candidate: Add equality check function Add a function that can check if two candidates point to the same place. https://phabricator.freedesktop.org/T104 Reviewed-by: Philip Withnall Differential Revision: https://phabricator.freedesktop.org/D1715 --- agent/candidate.c | 11 +++++++++++ agent/candidate.h | 18 +++++++++++++++++- docs/reference/libnice/libnice-docs.xml | 4 ++++ docs/reference/libnice/libnice-sections.txt | 1 + nice/libnice.sym | 1 + 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/agent/candidate.c b/agent/candidate.c index 27966ef..85f8f65 100644 --- a/agent/candidate.c +++ b/agent/candidate.c @@ -360,3 +360,14 @@ nice_candidate_copy (const NiceCandidate *candidate) return copy; } + +NICEAPI_EXPORT gboolean +nice_candidate_equal_target (const NiceCandidate *candidate1, + const NiceCandidate *candidate2) +{ + g_return_val_if_fail (candidate1 != NULL, FALSE); + g_return_val_if_fail (candidate2 != NULL, FALSE); + + return (candidate1->transport == candidate2->transport && + nice_address_equal (&candidate1->addr, &candidate2->addr)); +} diff --git a/agent/candidate.h b/agent/candidate.h index fadfce3..e556c16 100644 --- a/agent/candidate.h +++ b/agent/candidate.h @@ -230,7 +230,23 @@ nice_candidate_free (NiceCandidate *candidate); NiceCandidate * nice_candidate_copy (const NiceCandidate *candidate); -GType nice_candidate_get_type (void); +/** + * nice_candidate_equal_target: + * @candidate1: A candidate + * @candidate2: A candidate + * + * Verifies that the candidates point to the same place, meaning they have + * the same transport and the same address. It ignores all other aspects. + * + * Returns: %TRUE if the candidates point to the same place + * + * Since: 0.1.15 + */ +gboolean +nice_candidate_equal_target (const NiceCandidate *candidate1, + const NiceCandidate *candidate2); + + GType nice_candidate_get_type (void); /** * NICE_TYPE_CANDIDATE: diff --git a/docs/reference/libnice/libnice-docs.xml b/docs/reference/libnice/libnice-docs.xml index 53487bc..391be1a 100644 --- a/docs/reference/libnice/libnice-docs.xml +++ b/docs/reference/libnice/libnice-docs.xml @@ -105,6 +105,10 @@ Index of new symbols in 0.1.14 + + Index of new symbols in 0.1.15 + + diff --git a/docs/reference/libnice/libnice-sections.txt b/docs/reference/libnice/libnice-sections.txt index d377257..88a6cd2 100644 --- a/docs/reference/libnice/libnice-sections.txt +++ b/docs/reference/libnice/libnice-sections.txt @@ -76,6 +76,7 @@ NICE_CANDIDATE_MAX_FOUNDATION nice_candidate_new nice_candidate_free nice_candidate_copy +nice_candidate_equal_target NICE_TYPE_CANDIDATE nice_candidate_get_type diff --git a/nice/libnice.sym b/nice/libnice.sym index b04bb95..1e522ad 100644 --- a/nice/libnice.sym +++ b/nice/libnice.sym @@ -58,6 +58,7 @@ nice_agent_set_software nice_agent_set_stream_name nice_agent_set_stream_tos nice_candidate_copy +nice_candidate_equal_target nice_candidate_free nice_candidate_new nice_component_state_to_string -- 2.7.4