Commit 19679283 authored by Bryce Allen's avatar Bryce Allen Committed by Olivier Crête

agent: Add API to retrieve the selected GSocket

This should be used only when the protocol has it's own keepalive mechanism
parent 54577177
......@@ -2889,6 +2889,33 @@ nice_agent_get_selected_pair (NiceAgent *agent, guint stream_id,
return ret;
}
NICEAPI_EXPORT GSocket *
nice_agent_get_selected_socket (NiceAgent *agent, guint stream_id,
guint component_id)
{
Component *component;
Stream *stream;
NiceSocket *nice_socket;
GSocket *g_socket = NULL;
agent_lock();
/* step: check that params specify an existing pair */
if (!agent_find_component (agent, stream_id, component_id,
&stream, &component))
goto done;
if (component->selected_pair.local && component->selected_pair.remote) {
nice_socket = (NiceSocket *)component->selected_pair.local->sockptr;
g_socket = nice_socket->fileno;
}
done:
agent_unlock();
return g_socket;
}
GSource* agent_timeout_add_with_context (NiceAgent *agent, guint interval,
GSourceFunc function, gpointer data)
{
......
......@@ -104,6 +104,7 @@
#include <glib-object.h>
#include <gio/gio.h>
/**
* NiceAgent:
......@@ -714,6 +715,30 @@ nice_agent_get_selected_pair (
NiceCandidate **local,
NiceCandidate **remote);
/**
* nice_agent_get_selected_socket:
* @agent: The #NiceAgent Object
* @stream_id: The ID of the stream
* @component_id: The ID of the component
*
* Retreive the local socket associated with the selected candidate pair
* for media transmission for a given stream's component.
*
* This is useful for adding ICE support to legacy applications that already
* have a protocol that maintains a connection. If the socket is duplicated
* before unrefing the agent, the application can take over and continue to use
* it. New applications are encouraged to use the built in libnice stream
* handling instead and let libnice handle the connection maintenance.
*
* Returns: pointer to the socket, or NULL if there is no selected candidate
* Since: 0.1.5
*/
GSocket *
nice_agent_get_selected_socket (
NiceAgent *agent,
guint stream_id,
guint component_id);
/**
* nice_agent_set_selected_remote_candidate:
* @agent: The #NiceAgent Object
......
......@@ -26,6 +26,7 @@ nice_agent_get_local_candidates
nice_agent_get_local_credentials
nice_agent_get_remote_candidates
nice_agent_get_selected_pair
nice_agent_get_selected_socket
nice_agent_get_stream_name
nice_agent_get_type
nice_agent_new
......
......@@ -30,6 +30,7 @@ nice_agent_get_local_candidates
nice_agent_get_local_credentials
nice_agent_get_remote_candidates
nice_agent_get_selected_pair
nice_agent_get_selected_socket
nice_agent_get_stream_name
nice_agent_get_type
nice_agent_new
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment