webrtc: nice: Add niceutils

The gst_webrtc_nice_get_candidate_server_url() function is going to be used for
stats generation purposes and also from the upcoming get_selected_candidate_pair
implementation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8698>
This commit is contained in:
Philippe Normand 2025-02-15 11:41:57 +00:00 committed by GStreamer Marge Bot
parent 19dea1507e
commit b088d53970
2 changed files with 35 additions and 6 deletions

View File

@ -23,6 +23,7 @@
#include "nice.h"
#include "nicestream.h"
#include "niceutils.h"
/* libnice */
#include <agent.h>
@ -1021,8 +1022,8 @@ gst_webrtc_nice_set_tos (GstWebRTCICE * ice, GstWebRTCICEStream * stream,
nice_agent_set_stream_tos (nice->priv->nice_agent, item->nice_stream_id, tos);
}
static const gchar *
_relay_type_to_string (GstUri * turn_server)
const gchar *
gst_webrtc_nice_get_candidate_relay_protocol (GstUri * turn_server)
{
const gchar *scheme;
const gchar *transport;
@ -1045,8 +1046,9 @@ _relay_type_to_string (GstUri * turn_server)
return "none";
}
static gchar *
_get_server_url (GstWebRTCNice * ice, NiceCandidate * cand)
gchar *
gst_webrtc_nice_get_candidate_server_url (GstWebRTCNice * ice,
NiceCandidate * cand)
{
switch (cand->type) {
case NICE_CANDIDATE_TYPE_RELAYED:{
@ -1091,8 +1093,8 @@ _populate_candidate_stats (GstWebRTCNice * ice, NiceCandidate * cand,
cand->transport == NICE_CANDIDATE_TRANSPORT_UDP ? "udp" : "tcp";
if (is_local) {
if (cand->type == NICE_CANDIDATE_TYPE_RELAYED)
stats->relay_proto = _relay_type_to_string (ice->priv->turn_server);
stats->url = _get_server_url (ice, cand);
stats->relay_proto = gst_webrtc_nice_get_candidate_relay_protocol (ice->priv->turn_server);
stats->url = gst_webrtc_nice_get_candidate_server_url (ice, cand);
}
}

View File

@ -0,0 +1,27 @@
/* GStreamer
* Copyright (C) 2022 Sherrill Lin <lshuying@amazon.com>
* Copyright (C) 2022 Philippe Normand <philn@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib.h>
#include "nice.h"
gchar *gst_webrtc_nice_get_candidate_server_url(GstWebRTCNice * ice, NiceCandidate * cand);
const gchar *gst_webrtc_nice_get_candidate_relay_protocol(GstUri * turn_server);