2 * This file is part of the Nice GLib ICE library.
4 * (C) 2006-2010 Collabora Ltd.
5 * Contact: Youness Alaoui
6 * (C) 2006-2010 Nokia Corporation. All rights reserved.
7 * Contact: Kai Vehmanen
9 * The contents of this file are subject to the Mozilla Public License Version
10 * 1.1 (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 * http://www.mozilla.org/MPL/
14 * Software distributed under the License is distributed on an "AS IS" basis,
15 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
16 * for the specific language governing rights and limitations under the
19 * The Original Code is the Nice GLib ICE library.
21 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
22 * Corporation. All Rights Reserved.
25 * Dafydd Harries, Collabora Ltd.
26 * Youness Alaoui, Collabora Ltd.
29 * Alternatively, the contents of this file may be used under the terms of the
30 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
31 * case the provisions of LGPL are applicable instead of those above. If you
32 * wish to allow use of your version of this file only under the terms of the
33 * LGPL and not to allow others to use your version of this file under the
34 * MPL, indicate your decision by deleting the provisions above and replace
35 * them with the notice and other provisions required by the LGPL. If you do
36 * not delete the provisions above, a recipient may use your version of this
37 * file under either the MPL or the LGPL.
40 #ifndef __LIBNICE_AGENT_H__
41 #define __LIBNICE_AGENT_H__
45 * @short_description: ICE agent API implementation
46 * @see_also: #NiceCandidate, #NiceAddress
50 * The #NiceAgent is your main object when using libnice.
51 * It is the agent that will take care of everything relating to ICE.
52 * It will take care of discovering your local candidates and do
53 * connectivity checks to create a stream of data between you and your peer.
55 * A #NiceAgent must always be used with a #GMainLoop running the #GMainContext
56 * passed into nice_agent_new() (or nice_agent_new_reliable()). Without the
57 * #GMainContext being iterated, the agent’s timers will not fire, etc.
59 * Streams and their components are referenced by integer IDs (with respect to a
60 * given #NiceAgent). These IDs are guaranteed to be positive (i.e. non-zero)
61 * for valid streams/components.
63 * To complete the ICE connectivity checks, the user must either register
64 * an I/O callback (with nice_agent_attach_recv()) or call nice_agent_recv_messages()
65 * in a loop on a dedicated thread.
66 * Technically, #NiceAgent does not poll the streams on its own, since
67 * user data could arrive at any time; to receive STUN packets
68 * required for establishing ICE connectivity, it is backpiggying
69 * on the facility chosen by the user. #NiceAgent will handle all STUN
70 * packets internally; they're never actually passed to the I/O callback
71 * or returned from nice_agent_recv_messages() and related functions.
73 * Each stream can receive data in one of two ways: using
74 * nice_agent_attach_recv() or nice_agent_recv_messages() (and the derived
75 * #NiceInputStream and #NiceIOStream classes accessible using
76 * nice_agent_get_io_stream()). nice_agent_attach_recv() is non-blocking: it
77 * takes a user-provided callback function and attaches the stream’s socket to
78 * the provided #GMainContext, invoking the callback in that context for every
79 * packet received. nice_agent_recv_messages() instead blocks on receiving a
80 * packet, and writes it directly into a user-provided buffer. This reduces the
81 * number of callback invokations and (potentially) buffer copies required to
82 * receive packets. nice_agent_recv_messages() (or #NiceInputStream) is designed
83 * to be used in a blocking loop in a separate thread.
86 * <title>Simple example on how to use libnice</title>
89 * gchar buffer[] = "hello world!";
90 * gchar *ufrag = NULL, *pwd = NULL;
91 * gchar *remote_ufrag, *remote_pwd;
92 * GSList *lcands = NULL;
94 * // Create a nice agent, passing in the global default GMainContext.
95 * NiceAgent *agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245);
96 * spawn_thread_to_run_main_loop (g_main_loop_new (NULL, FALSE));
98 * // Connect the signals
99 * g_signal_connect (G_OBJECT (agent), "candidate-gathering-done",
100 * G_CALLBACK (cb_candidate_gathering_done), NULL);
101 * g_signal_connect (G_OBJECT (agent), "component-state-changed",
102 * G_CALLBACK (cb_component_state_changed), NULL);
103 * g_signal_connect (G_OBJECT (agent), "new-selected-pair",
104 * G_CALLBACK (cb_new_selected_pair), NULL);
106 * // Create a new stream with one component and start gathering candidates
107 * stream_id = nice_agent_add_stream (agent, 1);
108 * nice_agent_gather_candidates (agent, stream_id);
110 * // Attach I/O callback the component to ensure that:
111 * // 1) agent gets its STUN packets (not delivered to cb_nice_recv)
112 * // 2) you get your own data
113 * nice_agent_attach_recv (agent, stream_id, 1, NULL,
114 * cb_nice_recv, NULL);
116 * // ... Wait until the signal candidate-gathering-done is fired ...
117 * lcands = nice_agent_get_local_candidates(agent, stream_id, 1);
119 * nice_agent_get_local_credentials(agent, stream_id, &ufrag, &pwd);
121 * // ... Send local candidates and credentials to the peer
123 * // Set the peer's remote credentials and remote candidates
124 * nice_agent_set_remote_credentials (agent, stream_id, remote_ufrag, remote_pwd);
125 * nice_agent_set_remote_candidates (agent, stream_id, 1, rcands);
127 * // ... Wait until the signal new-selected-pair is fired ...
128 * // Send our message!
129 * nice_agent_send (agent, stream_id, 1, sizeof(buffer), buffer);
131 * // Anything received will be received through the cb_nice_recv callback.
132 * // You must be running a GMainLoop on the global default GMainContext in
133 * // another thread for this to work.
135 * // Destroy the object
136 * g_object_unref(agent);
141 * Refer to the examples in the examples/ subdirectory of the libnice source for
142 * more complete examples.
147 #include <glib-object.h>
153 * The #NiceAgent is the main GObject of the libnice library and represents
156 typedef struct _NiceAgent NiceAgent;
159 #include "candidate.h"
167 * @buffers: (array length=n_buffers): unowned array of #GInputVector buffers to
168 * store data in for this message
169 * @n_buffers: number of #GInputVectors in @buffers, or -1 to indicate @buffers
170 * is %NULL-terminated
171 * @from: (allow-none): return location to store the address of the peer who
172 * transmitted the message, or %NULL
173 * @length: total number of valid bytes contiguously stored in @buffers
175 * Represents a single message received off the network. For reliable
176 * connections, this is essentially just an array of buffers (specifically,
177 * @from can be ignored). for non-reliable connections, it represents a single
178 * packet as received from the OS.
180 * @n_buffers may be -1 to indicate that @buffers is terminated by a
181 * #GInputVector with a %NULL buffer pointer.
183 * By providing arrays of #NiceInputMessages to functions like
184 * nice_agent_recv_messages(), multiple messages may be received with a single
185 * call, which is more efficient than making multiple calls in a loop. In this
186 * manner, nice_agent_recv_messages() is analogous to recvmmsg(); and
187 * #NiceInputMessage to struct mmsghdr.
192 GInputVector *buffers;
193 gint n_buffers; /* may be -1 to indicate @buffers is NULL-terminated */
194 NiceAddress *from; /* return location for address of message sender */
195 gsize length; /* sum of the lengths of @buffers */
200 * @buffers: (array length=n_buffers): unowned array of #GOutputVector buffers
201 * which contain data to transmit for this message
202 * @n_buffers: number of #GOutputVectors in @buffers, or -1 to indicate @buffers
203 * is %NULL-terminated
205 * Represents a single message to transmit on the network. For
206 * reliable connections, this is essentially just an array of
207 * buffer. for non-reliable connections, it represents a single packet
210 * @n_buffers may be -1 to indicate that @buffers is terminated by a
211 * #GOutputVector with a %NULL buffer pointer.
213 * By providing arrays of #NiceOutputMessages to functions like
214 * nice_agent_send_messages_nonblocking(), multiple messages may be transmitted
215 * with a single call, which is more efficient than making multiple calls in a
216 * loop. In this manner, nice_agent_send_messages_nonblocking() is analogous to
217 * sendmmsg(); and #NiceOutputMessage to struct mmsghdr.
222 GOutputVector *buffers;
227 #define NICE_TYPE_AGENT nice_agent_get_type()
229 #define NICE_AGENT(obj) \
230 (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
231 NICE_TYPE_AGENT, NiceAgent))
233 #define NICE_AGENT_CLASS(klass) \
234 (G_TYPE_CHECK_CLASS_CAST ((klass), \
235 NICE_TYPE_AGENT, NiceAgentClass))
237 #define NICE_IS_AGENT(obj) \
238 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
241 #define NICE_IS_AGENT_CLASS(klass) \
242 (G_TYPE_CHECK_CLASS_TYPE ((klass), \
245 #define NICE_AGENT_GET_CLASS(obj) \
246 (G_TYPE_INSTANCE_GET_CLASS ((obj), \
247 NICE_TYPE_AGENT, NiceAgentClass))
249 typedef struct _NiceAgentClass NiceAgentClass;
251 struct _NiceAgentClass
253 GObjectClass parent_class;
257 GType nice_agent_get_type (void);
261 * NICE_AGENT_MAX_REMOTE_CANDIDATES:
263 * A hard limit for the number of remote candidates. This
264 * limit is enforced to protect against malevolent remote
267 #define NICE_AGENT_MAX_REMOTE_CANDIDATES 25
270 * NiceComponentState:
271 * @NICE_COMPONENT_STATE_DISCONNECTED: No activity scheduled
272 * @NICE_COMPONENT_STATE_GATHERING: Gathering local candidates
273 * @NICE_COMPONENT_STATE_CONNECTING: Establishing connectivity
274 * @NICE_COMPONENT_STATE_CONNECTED: At least one working candidate pair
275 * @NICE_COMPONENT_STATE_READY: ICE concluded, candidate pair selection
277 * @NICE_COMPONENT_STATE_FAILED: Connectivity checks have been completed,
278 * but connectivity was not established
279 * @NICE_COMPONENT_STATE_LAST: Dummy state
281 * An enum representing the state of a component.
282 * <para> See also: #NiceAgent::component-state-changed </para>
286 NICE_COMPONENT_STATE_DISCONNECTED,
287 NICE_COMPONENT_STATE_GATHERING,
288 NICE_COMPONENT_STATE_CONNECTING,
289 NICE_COMPONENT_STATE_CONNECTED,
290 NICE_COMPONENT_STATE_READY,
291 NICE_COMPONENT_STATE_FAILED,
292 NICE_COMPONENT_STATE_LAST
293 } NiceComponentState;
298 * @NICE_COMPONENT_TYPE_RTP: RTP Component type
299 * @NICE_COMPONENT_TYPE_RTCP: RTCP Component type
301 * Convenience enum representing the type of a component for use as the
302 * component_id for RTP/RTCP usages.
304 <title>Example of use.</title>
306 nice_agent_send (agent, stream_id, NICE_COMPONENT_TYPE_RTP, len, buf);
312 NICE_COMPONENT_TYPE_RTP = 1,
313 NICE_COMPONENT_TYPE_RTCP = 2
319 * @NICE_COMPATIBILITY_RFC5245: Use compatibility with the RFC5245 ICE-UDP specs
320 * and RFC6544 ICE-TCP specs
321 * @NICE_COMPATIBILITY_GOOGLE: Use compatibility for Google Talk specs
322 * @NICE_COMPATIBILITY_MSN: Use compatibility for MSN Messenger specs
323 * @NICE_COMPATIBILITY_WLM2009: Use compatibility with Windows Live Messenger
325 * @NICE_COMPATIBILITY_OC2007: Use compatibility with Microsoft Office Communicator 2007
326 * @NICE_COMPATIBILITY_OC2007R2: Use compatibility with Microsoft Office Communicator 2007 R2
327 * @NICE_COMPATIBILITY_DRAFT19: Use compatibility for ICE Draft 19 specs
328 * @NICE_COMPATIBILITY_LAST: Dummy last compatibility mode
330 * An enum to specify which compatible specifications the #NiceAgent should use.
331 * Use with nice_agent_new()
333 * <warning>@NICE_COMPATIBILITY_DRAFT19 is deprecated and should not be used
334 * in newly-written code. It is kept for compatibility reasons and
335 * represents the same compatibility as @NICE_COMPATIBILITY_RFC5245 </warning>
338 If @NICE_COMPATIBILITY_RFC5245 compatibility mode is used for a non-reliable
339 agent, then ICE-UDP will be used with higher priority and ICE-TCP will also
340 be used when the UDP connectivity fails. If it is used with a reliable agent,
341 then ICE-UDP will be used with the TCP-Over-UDP (#PseudoTcpSocket) if ICE-TCP
342 fails and ICE-UDP succeeds.
349 NICE_COMPATIBILITY_RFC5245 = 0,
350 NICE_COMPATIBILITY_DRAFT19 = NICE_COMPATIBILITY_RFC5245,
351 NICE_COMPATIBILITY_GOOGLE,
352 NICE_COMPATIBILITY_MSN,
353 NICE_COMPATIBILITY_WLM2009,
354 NICE_COMPATIBILITY_OC2007,
355 NICE_COMPATIBILITY_OC2007R2,
356 NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_OC2007R2,
361 * @NICE_PROXY_TYPE_NONE: Do not use a proxy
362 * @NICE_PROXY_TYPE_SOCKS5: Use a SOCKS5 proxy
363 * @NICE_PROXY_TYPE_HTTP: Use an HTTP proxy
364 * @NICE_PROXY_TYPE_LAST: Dummy last proxy type
366 * An enum to specify which proxy type to use for relaying.
367 * Note that the proxies will only be used with TCP TURN relaying.
368 * <para> See also: #NiceAgent:proxy-type </para>
374 NICE_PROXY_TYPE_NONE = 0,
375 NICE_PROXY_TYPE_SOCKS5,
376 NICE_PROXY_TYPE_HTTP,
377 NICE_PROXY_TYPE_LAST = NICE_PROXY_TYPE_HTTP,
381 * NiceNominationMode:
382 * @NICE_NOMINATION_MODE_AGGRESSIVE: Aggressive nomination mode
383 * @NICE_NOMINATION_MODE_REGULAR: Regular nomination mode
385 * An enum to specity the kind of nomination mode to use by
386 * the agent, as described in RFC 5245. Two modes exists,
387 * regular and aggressive. They differ by the way the controlling
388 * agent chooses to put the USE-CANDIDATE attribute in its STUN
389 * messages. The aggressive mode is supposed to nominate a pair
390 * faster, than the regular mode, potentially causing the nominated
391 * pair to change until the connection check completes.
397 NICE_NOMINATION_MODE_REGULAR = 0,
398 NICE_NOMINATION_MODE_AGGRESSIVE,
399 } NiceNominationMode;
403 * @NICE_AGENT_OPTION_REGULAR_NOMINATION: Enables regular nomination, default
404 * is aggrssive mode (see #NiceNominationMode).
405 * @NICE_AGENT_OPTION_RELIABLE: Enables reliable mode, possibly using PseudoTCP, * see nice_agent_new_reliable().
406 * @NICE_AGENT_OPTION_LITE_MODE: Enable lite mode
407 * @NICE_AGENT_OPTION_ICE_TRICKLE: Enable ICE trickle mode
408 * @NICE_AGENT_OPTION_SUPPORT_RENOMINATION: Enable renomination triggered by NOMINATION STUN attribute
409 * proposed here: https://tools.ietf.org/html/draft-thatcher-ice-renomination-00
411 * These are options that can be passed to nice_agent_new_full(). They set
412 * various properties on the agent. Not including them sets the property to
418 NICE_AGENT_OPTION_REGULAR_NOMINATION = 1 << 0,
419 NICE_AGENT_OPTION_RELIABLE = 1 << 1,
420 NICE_AGENT_OPTION_LITE_MODE = 1 << 2,
421 NICE_AGENT_OPTION_ICE_TRICKLE = 1 << 3,
422 NICE_AGENT_OPTION_SUPPORT_RENOMINATION = 1 << 4,
427 * @agent: The #NiceAgent Object
428 * @stream_id: The id of the stream
429 * @component_id: The id of the component of the stream
430 * which received the data
431 * @len: The length of the data
432 * @buf: The buffer containing the data received
433 * @user_data: The user data set in nice_agent_attach_recv()
435 * Callback function when data is received on a component
438 typedef void (*NiceAgentRecvFunc) (
439 NiceAgent *agent, guint stream_id, guint component_id, guint len,
440 gchar *buf, gpointer user_data);
445 * @ctx: The Glib Mainloop Context to use for timers
446 * @compat: The compatibility mode of the agent
448 * Create a new #NiceAgent.
449 * The returned object must be freed with g_object_unref()
451 * Returns: The new agent GObject
454 nice_agent_new (GMainContext *ctx, NiceCompatibility compat);
458 * nice_agent_new_reliable:
459 * @ctx: The Glib Mainloop Context to use for timers
460 * @compat: The compatibility mode of the agent
462 * Create a new #NiceAgent in reliable mode. If the connectivity is established
463 * through ICE-UDP, then a #PseudoTcpSocket will be transparently used to
464 * ensure reliability of the messages.
465 * The returned object must be freed with g_object_unref()
466 * <para> See also: #NiceAgent::reliable-transport-writable </para>
470 * Returns: The new agent GObject
473 nice_agent_new_reliable (GMainContext *ctx, NiceCompatibility compat);
476 * nice_agent_new_full:
477 * @ctx: The Glib Mainloop Context to use for timers
478 * @compat: The compatibility mode of the agent
479 * @flags: Flags to set the properties
481 * Create a new #NiceAgent with parameters that must be be defined at
483 * The returned object must be freed with g_object_unref()
484 * <para> See also: #NiceNominationMode and #NiceAgentOption</para>
488 * Returns: The new agent GObject
491 nice_agent_new_full (GMainContext *ctx,
492 NiceCompatibility compat,
493 NiceAgentOption flags);
496 * nice_agent_add_local_address:
497 * @agent: The #NiceAgent Object
498 * @addr: The address to listen to
499 * If the port is 0, then a random port will be chosen by the system
501 * Add a local address from which to derive local host candidates for
502 * candidate gathering.
504 * Since 0.0.5, if this method is not called, libnice will automatically
505 * discover the local addresses available
508 * See also: nice_agent_gather_candidates()
509 * Returns: %TRUE on success, %FALSE on fatal (memory allocation) errors
512 nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
515 * nice_agent_add_stream:
516 * @agent: The #NiceAgent Object
517 * @n_components: The number of components to add to the stream
519 * Adds a data stream to @agent containing @n_components components. The
520 * returned stream ID is guaranteed to be positive on success.
522 * Returns: The ID of the new stream, 0 on failure
525 nice_agent_add_stream (
530 * nice_agent_remove_stream:
531 * @agent: The #NiceAgent Object
532 * @stream_id: The ID of the stream to remove
534 * Remove and free a previously created data stream from @agent. If any I/O
535 * streams have been created using nice_agent_get_io_stream(), they should be
536 * closed completely using g_io_stream_close() before this is called, or they
537 * will get broken pipe errors.
541 nice_agent_remove_stream (
547 * nice_agent_set_port_range:
548 * @agent: The #NiceAgent Object
549 * @stream_id: The ID of the stream
550 * @component_id: The ID of the component
551 * @min_port: The minimum port to use
552 * @max_port: The maximum port to use
554 * Sets a preferred port range for allocating host candidates.
556 * If a local host candidate cannot be created on that port
557 * range, then the nice_agent_gather_candidates() call will fail.
560 * This MUST be called before nice_agent_gather_candidates()
565 nice_agent_set_port_range (
573 * nice_agent_set_relay_info:
574 * @agent: The #NiceAgent Object
575 * @stream_id: The ID of the stream
576 * @component_id: The ID of the component
577 * @server_ip: The IP address of the TURN server
578 * @server_port: The port of the TURN server
579 * @username: The TURN username to use for the allocate
580 * @password: The TURN password to use for the allocate
581 * @type: The type of relay to use
583 * Sets the settings for using a relay server during the candidate discovery.
584 * This may be called multiple times to add multiple relay servers to the
585 * discovery process; one TCP and one UDP, for example.
587 * Returns: %TRUE if the TURN settings were accepted.
588 * %FALSE if the address was invalid.
590 gboolean nice_agent_set_relay_info(
594 const gchar *server_ip,
596 const gchar *username,
597 const gchar *password,
601 * nice_agent_gather_candidates:
602 * @agent: The #NiceAgent object
603 * @stream_id: The ID of the stream to start
605 * Allocate and start listening on local candidate ports and start the remote
606 * candidate gathering process.
607 * Once done, #NiceAgent::candidate-gathering-done is called for the stream.
608 * As soon as this function is called, #NiceAgent::new-candidate signals may be
609 * emitted, even before this function returns.
611 * nice_agent_get_local_candidates() will only return non-empty results after
612 * calling this function.
614 * <para>See also: nice_agent_add_local_address()</para>
615 * <para>See also: nice_agent_set_port_range()</para>
617 * Returns: %FALSE if the stream ID is invalid or if a host candidate couldn't
618 * be allocated on the requested interfaces/ports; %TRUE otherwise
622 Local addresses can be previously set with nice_agent_add_local_address()
625 Since 0.0.5, If no local address was previously added, then the nice agent
626 will automatically detect the local address using
627 nice_interfaces_get_local_ips()
632 nice_agent_gather_candidates (
637 * nice_agent_set_remote_credentials:
638 * @agent: The #NiceAgent Object
639 * @stream_id: The ID of the stream
640 * @ufrag: nul-terminated string containing an ICE username fragment
641 * (length must be between 22 and 256 chars)
642 * @pwd: nul-terminated string containing an ICE password
643 * (length must be between 4 and 256 chars)
645 * Sets the remote credentials for stream @stream_id.
649 Stream credentials do not override per-candidate credentials if set
652 Due to the native of peer-reflexive candidates, any agent using a per-stream
653 credentials (RFC5245, WLM2009, OC2007R2 and DRAFT19) instead of
654 per-candidate credentials (GOOGLE, MSN, OC2007), must
655 use the nice_agent_set_remote_credentials() API instead of setting the
656 username and password on the candidates.
660 * Returns: %TRUE on success, %FALSE on error.
663 nice_agent_set_remote_credentials (
666 const gchar *ufrag, const gchar *pwd);
670 * nice_agent_set_local_credentials:
671 * @agent: The #NiceAgent Object
672 * @stream_id: The ID of the stream
673 * @ufrag: nul-terminated string containing an ICE username fragment
674 * (length must be between 22 and 256 chars)
675 * @pwd: nul-terminated string containing an ICE password
676 * (length must be between 4 and 256 chars)
678 * Sets the local credentials for stream @stream_id.
682 This is only effective before ICE negotiation has started.
687 * Returns: %TRUE on success, %FALSE on error.
690 nice_agent_set_local_credentials (
698 * nice_agent_get_local_credentials:
699 * @agent: The #NiceAgent Object
700 * @stream_id: The ID of the stream
701 * @ufrag: (out callee-allocates): return location for a nul-terminated string
702 * containing an ICE username fragment; must be freed with g_free()
703 * @pwd: (out callee-allocates): return location for a nul-terminated string
704 * containing an ICE password; must be freed with g_free()
706 * Gets the local credentials for stream @stream_id. This may be called any time
707 * after creating a stream using nice_agent_add_stream().
709 * An error will be returned if this is called for a non-existent stream, or if
710 * either of @ufrag or @pwd are %NULL.
712 * Returns: %TRUE on success, %FALSE on error.
715 nice_agent_get_local_credentials (
718 gchar **ufrag, gchar **pwd);
721 * nice_agent_set_remote_candidates:
722 * @agent: The #NiceAgent Object
723 * @stream_id: The ID of the stream the candidates are for
724 * @component_id: The ID of the component the candidates are for
725 * @candidates: (element-type NiceCandidate) (transfer none): a #GSList of
726 * #NiceCandidate items describing each candidate to add
728 * Sets, adds or updates the remote candidates for a component of a stream.
732 NICE_AGENT_MAX_REMOTE_CANDIDATES is the absolute maximum limit
733 for remote candidates.
736 You must first call nice_agent_gather_candidates() and wait for the
737 #NiceAgent::candidate-gathering-done signale before
738 calling nice_agent_set_remote_candidates()
741 Since 0.1.3, there is no need to wait for the candidate-gathering-done signal.
742 Remote candidates can be set even while gathering local candidates.
743 Newly discovered local candidates will automatically be paired with
744 existing remote candidates.
748 * Returns: The number of candidates added, negative on errors (memory
749 * allocation error or invalid component)
752 nice_agent_set_remote_candidates (
756 const GSList *candidates);
761 * @agent: The #NiceAgent Object
762 * @stream_id: The ID of the stream to send to
763 * @component_id: The ID of the component to send to
764 * @len: The length of the buffer to send
765 * @buf: The buffer of data to send
767 * Sends a data payload over a stream's component.
771 Component state MUST be NICE_COMPONENT_STATE_READY, or as a special case,
772 in any state if component was in READY state before and was then restarted
775 In reliable mode, the -1 error value means either that you are not yet
776 connected or that the send buffer is full (equivalent to EWOULDBLOCK).
777 In both cases, you simply need to wait for the
778 #NiceAgent::reliable-transport-writable signal to be fired before resending
782 In non-reliable mode, it will virtually never happen with UDP sockets, but
783 it might happen if the active candidate is a TURN-TCP connection that got
787 In both reliable and non-reliable mode, a -1 error code could also mean that
788 the stream_id and/or component_id are invalid.
792 * Returns: The number of bytes sent, or negative error code
803 * nice_agent_send_messages_nonblocking:
804 * @agent: a #NiceAgent
805 * @stream_id: the ID of the stream to send to
806 * @component_id: the ID of the component to send to
807 * @messages: (array length=n_messages): array of messages to send, of at least
808 * @n_messages entries in length
809 * @n_messages: number of entries in @messages
810 * @cancellable: (allow-none): a #GCancellable to cancel the operation from
811 * another thread, or %NULL
812 * @error: (allow-none): return location for a #GError, or %NULL
814 * Sends multiple messages on the socket identified by the given
815 * stream/component pair. Transmission is non-blocking, so a
816 * %G_IO_ERROR_WOULD_BLOCK error may be returned if the send buffer is full.
818 * As with nice_agent_send(), the given component must be in
819 * %NICE_COMPONENT_STATE_READY or, as a special case, in any state if it was
820 * previously ready and was then restarted.
822 * On success, the number of messages written to the socket will be returned,
823 * which may be less than @n_messages if transmission would have blocked
824 * part-way through. Zero will be returned if @n_messages is zero, or if
825 * transmission would have blocked on the first message.
827 * In reliable mode, it is instead recommended to use
828 * nice_agent_send(). The return value can be less than @n_messages
829 * or 0 even if it is still possible to send a partial message. In
830 * this case, "nice-agent-writable" will never be triggered, so the
831 * application would have to use nice_agent_sent() to fill the buffer or have
832 * to retry sending at a later point.
834 * On failure, -1 will be returned and @error will be set. If the #NiceAgent is
835 * reliable and the socket is not yet connected, %G_IO_ERROR_BROKEN_PIPE will be
836 * returned; if the write buffer is full, %G_IO_ERROR_WOULD_BLOCK will be
837 * returned. In both cases, wait for the #NiceAgent::reliable-transport-writable
838 * signal before trying again. If the given @stream_id or @component_id are
839 * invalid or not yet connected, %G_IO_ERROR_BROKEN_PIPE will be returned.
840 * %G_IO_ERROR_FAILED will be returned for other errors.
842 * Returns: the number of messages sent (may be zero), or -1 on error
847 nice_agent_send_messages_nonblocking (
851 const NiceOutputMessage *messages,
853 GCancellable *cancellable,
857 * nice_agent_get_local_candidates:
858 * @agent: The #NiceAgent Object
859 * @stream_id: The ID of the stream
860 * @component_id: The ID of the component
862 * Retrieve from the agent the list of all local candidates
863 * for a stream's component
867 The caller owns the returned GSList as well as the candidates contained
869 To get full results, the client should wait for the
870 #NiceAgent::candidate-gathering-done signal.
874 * Returns: (element-type NiceCandidate) (transfer full): a #GSList of
875 * #NiceCandidate objects representing the local candidates of @agent
878 nice_agent_get_local_candidates (
885 * nice_agent_get_remote_candidates:
886 * @agent: The #NiceAgent Object
887 * @stream_id: The ID of the stream
888 * @component_id: The ID of the component
890 * Get a list of the remote candidates set on a stream's component
894 The caller owns the returned GSList as well as the candidates contained
898 The list of remote candidates can change during processing.
899 The client should register for the #NiceAgent::new-remote-candidate signal
900 to get notified of new remote candidates.
904 * Returns: (element-type NiceCandidate) (transfer full): a #GSList of
905 * #NiceCandidates objects representing the remote candidates set on the @agent
908 nice_agent_get_remote_candidates (
914 * nice_agent_restart:
915 * @agent: The #NiceAgent Object
917 * Restarts the session as defined in ICE draft 19. This function
918 * needs to be called both when initiating (ICE spec section 9.1.1.1.
919 * "ICE Restarts"), as well as when reacting (spec section 9.2.1.1.
920 * "Detecting ICE Restart") to a restart.
922 * Returns: %TRUE on success %FALSE on error
929 * nice_agent_restart_stream:
930 * @agent: The #NiceAgent Object
931 * @stream_id: The ID of the stream
933 * Restarts a single stream as defined in RFC 5245. This function
934 * needs to be called both when initiating (ICE spec section 9.1.1.1.
935 * "ICE Restarts"), as well as when reacting (spec section 9.2.1.1.
936 * "Detecting ICE Restart") to a restart.
938 * Unlike nice_agent_restart(), this applies to a single stream. It also
939 * does not generate a new tie breaker.
941 * Returns: %TRUE on success %FALSE on error
946 nice_agent_restart_stream (
952 * nice_agent_attach_recv: (skip)
953 * @agent: The #NiceAgent Object
954 * @stream_id: The ID of stream
955 * @component_id: The ID of the component
956 * @ctx: The Glib Mainloop Context to use for listening on the component
957 * @func: The callback function to be called when data is received on
958 * the stream's component (will not be called for STUN messages that
959 * should be handled by #NiceAgent itself)
960 * @data: user data associated with the callback
962 * Attaches the stream's component's sockets to the Glib Mainloop Context in
963 * order to be notified whenever data becomes available for a component,
964 * and to enable #NiceAgent to receive STUN messages (during the
965 * establishment of ICE connectivity).
967 * This must not be used in combination with nice_agent_recv_messages() (or
968 * #NiceIOStream or #NiceInputStream) on the same stream/component pair.
970 * Calling nice_agent_attach_recv() with a %NULL @func will detach any existing
971 * callback and cause reception to be paused for the given stream/component
972 * pair. You must iterate the previously specified #GMainContext sufficiently to
973 * ensure all pending I/O callbacks have been received before calling this
974 * function to unset @func, otherwise data loss of received packets may occur.
976 * Returns: %TRUE on success, %FALSE if the stream or component IDs are invalid.
979 nice_agent_attach_recv (
984 NiceAgentRecvFunc func,
989 * @agent: a #NiceAgent
990 * @stream_id: the ID of the stream to receive on
991 * @component_id: the ID of the component to receive on
992 * @buf: (array length=buf_len) (out caller-allocates): caller-allocated buffer
993 * to write the received data into, of length at least @buf_len
994 * @buf_len: length of @buf
995 * @cancellable: (allow-none): a #GCancellable to allow the operation to be
996 * cancelled from another thread, or %NULL
997 * @error: (allow-none): return location for a #GError, or %NULL
999 * A single-message version of nice_agent_recv_messages().
1001 * Returns: the number of bytes written to @buf on success (guaranteed to be
1002 * greater than 0 unless @buf_len is 0), 0 if in reliable mode and the remote
1003 * peer closed the stream, or -1 on error
1014 GCancellable *cancellable,
1018 * nice_agent_recv_messages:
1019 * @agent: a #NiceAgent
1020 * @stream_id: the ID of the stream to receive on
1021 * @component_id: the ID of the component to receive on
1022 * @messages: (array length=n_messages) (out caller-allocates): caller-allocated
1023 * array of #NiceInputMessages to write the received messages into, of length at
1025 * @n_messages: number of entries in @messages
1026 * @cancellable: (allow-none): a #GCancellable to allow the operation to be
1027 * cancelled from another thread, or %NULL
1028 * @error: (allow-none): return location for a #GError, or %NULL
1030 * Block on receiving data from the given stream/component combination on
1031 * @agent, returning only once exactly @n_messages messages have been received
1032 * and written into @messages, the stream is closed by the other end or by
1033 * calling nice_agent_remove_stream(), or @cancellable is cancelled.
1035 * Any STUN packets received will not be added to @messages; instead,
1036 * they'll be passed for processing to #NiceAgent itself. Since #NiceAgent
1037 * does not poll for messages on its own, it's therefore essential to keep
1038 * calling this function for ICE connection establishment to work.
1040 * In the non-error case, in reliable mode, this will block until all buffers in
1041 * all @n_messages have been filled with received data (i.e. @messages is
1042 * treated as a large, flat array of buffers). In non-reliable mode, it will
1043 * block until @n_messages messages have been received, each of which does not
1044 * have to fill all the buffers in its #NiceInputMessage. In the non-reliable
1045 * case, each #NiceInputMessage must have enough buffers to contain an entire
1046 * message (65536 bytes), or any excess data may be silently dropped.
1048 * For each received message, #NiceInputMessage::length will be set to the
1049 * number of valid bytes stored in the message’s buffers. The bytes are stored
1050 * sequentially in the buffers; there are no gaps apart from at the end of the
1051 * buffer array (in non-reliable mode). If non-%NULL on input,
1052 * #NiceInputMessage::from will have the address of the sending peer stored in
1053 * it. The base addresses, sizes, and number of buffers in each message will not
1054 * be modified in any case.
1056 * This must not be used in combination with nice_agent_attach_recv() on the
1057 * same stream/component pair.
1059 * If the stream/component pair doesn’t exist, or if a suitable candidate socket
1060 * hasn’t yet been selected for it, a %G_IO_ERROR_BROKEN_PIPE error will be
1061 * returned. A %G_IO_ERROR_CANCELLED error will be returned if the operation was
1062 * cancelled. %G_IO_ERROR_FAILED will be returned for other errors.
1064 * Returns: the number of valid messages written to @messages on success
1065 * (guaranteed to be greater than 0 unless @n_messages is 0), 0 if the remote
1066 * peer closed the stream, or -1 on error
1071 nice_agent_recv_messages (
1075 NiceInputMessage *messages,
1077 GCancellable *cancellable,
1081 * nice_agent_recv_nonblocking:
1082 * @agent: a #NiceAgent
1083 * @stream_id: the ID of the stream to receive on
1084 * @component_id: the ID of the component to receive on
1085 * @buf: (array length=buf_len) (out caller-allocates): caller-allocated buffer
1086 * to write the received data into, of length at least @buf_len
1087 * @buf_len: length of @buf
1088 * @cancellable: (allow-none): a #GCancellable to allow the operation to be
1089 * cancelled from another thread, or %NULL
1090 * @error: (allow-none): return location for a #GError, or %NULL
1092 * A single-message version of nice_agent_recv_messages_nonblocking().
1094 * Returns: the number of bytes received into @buf on success (guaranteed to be
1095 * greater than 0 unless @buf_len is 0), 0 if in reliable mode and the remote
1096 * peer closed the stream, or -1 on error
1101 nice_agent_recv_nonblocking (
1107 GCancellable *cancellable,
1111 * nice_agent_recv_messages_nonblocking:
1112 * @agent: a #NiceAgent
1113 * @stream_id: the ID of the stream to receive on
1114 * @component_id: the ID of the component to receive on
1115 * @messages: (array length=n_messages) (out caller-allocates): caller-allocated
1116 * array of #NiceInputMessages to write the received messages into, of length at
1118 * @n_messages: number of entries in @messages
1119 * @cancellable: (allow-none): a #GCancellable to allow the operation to be
1120 * cancelled from another thread, or %NULL
1121 * @error: (allow-none): return location for a #GError, or %NULL
1123 * Try to receive data from the given stream/component combination on @agent,
1124 * without blocking. If receiving data would block, -1 is returned and
1125 * %G_IO_ERROR_WOULD_BLOCK is set in @error. If any other error occurs, -1 is
1126 * returned and @error is set accordingly. Otherwise, 0 is returned if (and only
1127 * if) @n_messages is 0. In all other cases, the number of valid messages stored
1128 * in @messages is returned, and will be greater than 0.
1130 * This function behaves similarly to nice_agent_recv_messages(), except that it
1131 * will not block on filling (in reliable mode) or receiving (in non-reliable
1132 * mode) exactly @n_messages messages. In reliable mode, it will receive bytes
1133 * into @messages until it would block; in non-reliable mode, it will receive
1134 * messages until it would block.
1136 * Any STUN packets received will not be added to @messages; instead,
1137 * they'll be passed for processing to #NiceAgent itself. Since #NiceAgent
1138 * does not poll for messages on its own, it's therefore essential to keep
1139 * calling this function for ICE connection establishment to work.
1141 * As this function is non-blocking, @cancellable is included only for parity
1142 * with nice_agent_recv_messages(). If @cancellable is cancelled before this
1143 * function is called, a %G_IO_ERROR_CANCELLED error will be returned
1146 * This must not be used in combination with nice_agent_attach_recv() on the
1147 * same stream/component pair.
1149 * Returns: the number of valid messages written to @messages on success
1150 * (guaranteed to be greater than 0 unless @n_messages is 0), 0 if in reliable
1151 * mode and the remote peer closed the stream, or -1 on error
1156 nice_agent_recv_messages_nonblocking (
1160 NiceInputMessage *messages,
1162 GCancellable *cancellable,
1166 * nice_agent_set_selected_pair:
1167 * @agent: The #NiceAgent Object
1168 * @stream_id: The ID of the stream
1169 * @component_id: The ID of the component
1170 * @lfoundation: The local foundation of the candidate to use
1171 * @rfoundation: The remote foundation of the candidate to use
1173 * Sets the selected candidate pair for media transmission
1174 * for a given stream's component. Calling this function will
1175 * disable all further ICE processing (connection check,
1176 * state machine updates, etc). Note that keepalives will
1177 * continue to be sent.
1179 * Returns: %TRUE on success, %FALSE if the candidate pair cannot be found
1182 nice_agent_set_selected_pair (
1186 const gchar *lfoundation,
1187 const gchar *rfoundation);
1190 * nice_agent_get_selected_pair:
1191 * @agent: The #NiceAgent Object
1192 * @stream_id: The ID of the stream
1193 * @component_id: The ID of the component
1194 * @local: The local selected candidate
1195 * @remote: The remote selected candidate
1197 * Retreive the selected candidate pair for media transmission
1198 * for a given stream's component.
1200 * Returns: %TRUE on success, %FALSE if there is no selected candidate pair
1203 nice_agent_get_selected_pair (
1207 NiceCandidate **local,
1208 NiceCandidate **remote);
1211 * nice_agent_get_selected_socket:
1212 * @agent: The #NiceAgent Object
1213 * @stream_id: The ID of the stream
1214 * @component_id: The ID of the component
1216 * Retreive the local socket associated with the selected candidate pair
1217 * for media transmission for a given stream's component.
1219 * This is useful for adding ICE support to legacy applications that already
1220 * have a protocol that maintains a connection. If the socket is duplicated
1221 * before unrefing the agent, the application can take over and continue to use
1222 * it. New applications are encouraged to use the built in libnice stream
1223 * handling instead and let libnice handle the connection maintenance.
1225 * Users of this method are encouraged to not use a TURN relay or any kind
1226 * of proxy, as in this case, the socket will not be available to the
1227 * application because the packets are encapsulated.
1229 * Returns: (transfer full) (nullable): pointer to the #GSocket, or %NULL if
1230 * there is no selected candidate or if the selected candidate is a relayed
1236 nice_agent_get_selected_socket (
1239 guint component_id);
1242 * nice_agent_set_selected_remote_candidate:
1243 * @agent: The #NiceAgent Object
1244 * @stream_id: The ID of the stream
1245 * @component_id: The ID of the component
1246 * @candidate: The #NiceCandidate to select
1248 * Sets the selected remote candidate for media transmission
1249 * for a given stream's component. This is used to force the selection of
1250 * a specific remote candidate even when connectivity checks are failing
1251 * (e.g. non-ICE compatible candidates).
1252 * Calling this function will disable all further ICE processing
1253 * (connection check, state machine updates, etc). Note that keepalives will
1254 * continue to be sent.
1256 * Returns: %TRUE on success, %FALSE on failure
1259 nice_agent_set_selected_remote_candidate (
1263 NiceCandidate *candidate);
1267 * nice_agent_set_stream_tos:
1268 * @agent: The #NiceAgent Object
1269 * @stream_id: The ID of the stream
1270 * @tos: The ToS to set
1272 * Sets the IP_TOS and/or IPV6_TCLASS field on the stream's sockets' options
1276 void nice_agent_set_stream_tos (
1284 * nice_agent_set_software:
1285 * @agent: The #NiceAgent Object
1286 * @software: The value of the SOFTWARE attribute to add.
1288 * This function will set the value of the SOFTWARE attribute to be added to
1289 * STUN requests, responses and error responses sent during connectivity checks.
1291 * The SOFTWARE attribute will only be added in the #NICE_COMPATIBILITY_RFC5245
1292 * and #NICE_COMPATIBILITY_WLM2009 compatibility modes.
1297 The @software argument will be appended with the libnice version before
1301 The @software argument must be in UTF-8 encoding and only the first
1302 128 characters will be sent.
1309 void nice_agent_set_software (
1311 const gchar *software);
1314 * nice_agent_set_stream_name:
1315 * @agent: The #NiceAgent Object
1316 * @stream_id: The ID of the stream to change
1317 * @name: The new name of the stream or %NULL
1319 * This function will assign a media type to a stream. The only values
1320 * that can be used to produce a valid SDP are: "audio", "video",
1321 * "text", "application", "image" and "message".
1323 * This is only useful when parsing and generating an SDP of the
1326 * <para>See also: nice_agent_generate_local_sdp()</para>
1327 * <para>See also: nice_agent_parse_remote_sdp()</para>
1328 * <para>See also: nice_agent_get_stream_name()</para>
1330 * Returns: %TRUE if the name has been set. %FALSE in case of error
1331 * (invalid stream or duplicate name).
1334 gboolean nice_agent_set_stream_name (
1340 * nice_agent_get_stream_name:
1341 * @agent: The #NiceAgent Object
1342 * @stream_id: The ID of the stream to change
1344 * This function will return the name assigned to a stream.
1346 * <para>See also: nice_agent_set_stream_name()</para>
1348 * Returns: The name of the stream. The name is only valid while the stream
1349 * exists or until it changes through a call to nice_agent_set_stream_name().
1354 const gchar *nice_agent_get_stream_name (
1359 * nice_agent_get_default_local_candidate:
1360 * @agent: The #NiceAgent Object
1361 * @stream_id: The ID of the stream
1362 * @component_id: The ID of the component
1364 * This helper function will return the recommended default candidate to be
1365 * used for non-ICE compatible clients. This will usually be the candidate
1366 * with the lowest priority, since it will be the longest path but the one with
1367 * the most chances of success.
1370 This function is only useful in order to manually generate the
1375 * Returns: The candidate to be used as the default candidate, or %NULL in case
1376 * of error. Must be freed with nice_candidate_free() once done.
1380 nice_agent_get_default_local_candidate (
1383 guint component_id);
1386 * nice_agent_generate_local_sdp:
1387 * @agent: The #NiceAgent Object
1389 * Generate an SDP string containing the local candidates and credentials for
1390 * all streams and components in the agent.
1394 The SDP will not contain any codec lines and the 'm' line will not list
1398 It is highly recommended to set names on the streams prior to calling this
1399 function. Unnamed streams will show up as '-' in the 'm' line, but the SDP
1400 will not be parseable with nice_agent_parse_remote_sdp() if a stream is
1404 The default candidate in the SDP will be selected based on the lowest
1405 priority candidate for the first component.
1409 * <para>See also: nice_agent_set_stream_name() </para>
1410 * <para>See also: nice_agent_parse_remote_sdp() </para>
1411 * <para>See also: nice_agent_generate_local_stream_sdp() </para>
1412 * <para>See also: nice_agent_generate_local_candidate_sdp() </para>
1413 * <para>See also: nice_agent_get_default_local_candidate() </para>
1415 * Returns: A string representing the local SDP. Must be freed with g_free()
1421 nice_agent_generate_local_sdp (
1425 * nice_agent_generate_local_stream_sdp:
1426 * @agent: The #NiceAgent Object
1427 * @stream_id: The ID of the stream
1428 * @include_non_ice: Whether or not to include non ICE specific lines
1429 * (m=, c= and a=rtcp: lines)
1431 * Generate an SDP string containing the local candidates and credentials
1436 The SDP will not contain any codec lines and the 'm' line will not list
1440 It is highly recommended to set the name of the stream prior to calling this
1441 function. Unnamed streams will show up as '-' in the 'm' line.
1444 The default candidate in the SDP will be selected based on the lowest
1449 * <para>See also: nice_agent_set_stream_name() </para>
1450 * <para>See also: nice_agent_parse_remote_stream_sdp() </para>
1451 * <para>See also: nice_agent_generate_local_sdp() </para>
1452 * <para>See also: nice_agent_generate_local_candidate_sdp() </para>
1453 * <para>See also: nice_agent_get_default_local_candidate() </para>
1455 * Returns: A string representing the local SDP for the stream. Must be freed
1456 * with g_free() once done.
1461 nice_agent_generate_local_stream_sdp (
1464 gboolean include_non_ice);
1467 * nice_agent_generate_local_candidate_sdp:
1468 * @agent: The #NiceAgent Object
1469 * @candidate: The candidate to generate
1471 * Generate an SDP string representing a local candidate.
1473 * <para>See also: nice_agent_parse_remote_candidate_sdp() </para>
1474 * <para>See also: nice_agent_generate_local_sdp() </para>
1475 * <para>See also: nice_agent_generate_local_stream_sdp() </para>
1477 * Returns: A string representing the SDP for the candidate. Must be freed
1478 * with g_free() once done.
1483 nice_agent_generate_local_candidate_sdp (
1485 NiceCandidate *candidate);
1488 * nice_agent_parse_remote_sdp:
1489 * @agent: The #NiceAgent Object
1490 * @sdp: The remote SDP to parse
1492 * Parse an SDP string and extracts candidates and credentials from it and sets
1493 * them on the agent.
1495 * <para>See also: nice_agent_set_stream_name() </para>
1496 * <para>See also: nice_agent_generate_local_sdp() </para>
1497 * <para>See also: nice_agent_parse_remote_stream_sdp() </para>
1498 * <para>See also: nice_agent_parse_remote_candidate_sdp() </para>
1500 * Returns: The number of candidates added, negative on errors
1505 nice_agent_parse_remote_sdp (
1511 * nice_agent_parse_remote_stream_sdp:
1512 * @agent: The #NiceAgent Object
1513 * @stream_id: The ID of the stream to parse
1514 * @sdp: The remote SDP to parse
1515 * @ufrag: Pointer to store the ice ufrag if non %NULL. Must be freed with
1516 * g_free() after use
1517 * @pwd: Pointer to store the ice password if non %NULL. Must be freed with
1518 * g_free() after use
1520 * Parse an SDP string representing a single stream and extracts candidates
1521 * and credentials from it.
1523 * <para>See also: nice_agent_generate_local_stream_sdp() </para>
1524 * <para>See also: nice_agent_parse_remote_sdp() </para>
1525 * <para>See also: nice_agent_parse_remote_candidate_sdp() </para>
1527 * Returns: (element-type NiceCandidate) (transfer full): A #GSList of
1528 * candidates parsed from the SDP, or %NULL in case of errors
1533 nice_agent_parse_remote_stream_sdp (
1542 * nice_agent_parse_remote_candidate_sdp:
1543 * @agent: The #NiceAgent Object
1544 * @stream_id: The ID of the stream the candidate belongs to
1545 * @sdp: The remote SDP to parse
1547 * Parse an SDP string and extracts the candidate from it.
1549 * <para>See also: nice_agent_generate_local_candidate_sdp() </para>
1550 * <para>See also: nice_agent_parse_remote_sdp() </para>
1551 * <para>See also: nice_agent_parse_remote_stream_sdp() </para>
1553 * Returns: The parsed candidate or %NULL if there was an error.
1558 nice_agent_parse_remote_candidate_sdp (
1564 * nice_agent_get_io_stream:
1565 * @agent: A #NiceAgent
1566 * @stream_id: The ID of the stream to wrap
1567 * @component_id: The ID of the component to wrap
1569 * Gets a #GIOStream wrapper around the given stream and component in
1570 * @agent. The I/O stream will be valid for as long as @stream_id is valid.
1571 * The #GInputStream and #GOutputStream implement #GPollableInputStream and
1572 * #GPollableOutputStream.
1574 * This function may only be called on reliable #NiceAgents. It is a
1575 * programming error to try and create an I/O stream wrapper for an
1576 * unreliable stream.
1578 * Returns: (transfer full): A #GIOStream.
1583 nice_agent_get_io_stream (
1586 guint component_id);
1589 * nice_component_state_to_string:
1590 * @state: a #NiceComponentState
1592 * Returns a string representation of the state, generally to use in debug
1595 * Returns: (transfer none): a string representation of @state
1599 nice_component_state_to_string (NiceComponentState state);
1602 * nice_agent_forget_relays:
1603 * @agent: The #NiceAgent Object
1604 * @stream_id: The ID of the stream
1605 * @component_id: The ID of the component
1607 * Forget all the relay servers previously added using
1608 * nice_agent_set_relay_info(). Currently connected streams will keep
1609 * using the relay as long as they have not been restarted and haven't
1610 * succesfully negotiated a different path.
1612 * Returns: %FALSE if the component could not be found, %TRUE otherwise
1617 nice_agent_forget_relays (NiceAgent *agent,
1619 guint component_id);
1622 * nice_agent_get_component_state:
1623 * @agent: The #NiceAgent Object
1624 * @stream_id: The ID of the stream
1625 * @component_id: The ID of the component
1627 * Retrieves the current state of a component.
1629 * Returns: the #NiceComponentState of the component and
1630 * %NICE_COMPONENT_STATE_FAILED if the component was invalid.
1635 nice_agent_get_component_state (NiceAgent *agent,
1637 guint component_id);
1640 * nice_agent_peer_candidate_gathering_done:
1641 * @agent: The #NiceAgent Object
1642 * @stream_id: The ID of the stream
1644 * Notifies the agent that the remote peer has concluded candidate gathering and
1645 * thus no more remote candidates are expected to arrive for @stream_id.
1647 * This will allow the stream components without a successful connectivity check
1648 * to stop waiting for more candidates to come and finally transit into
1649 * %NICE_COMPONENT_STATE_FAILED.
1651 * Calling the function has an effect only when #NiceAgent:trickle-ice is %TRUE.
1653 * Returns: %FALSE if the stream could not be found, %TRUE otherwise
1658 nice_agent_peer_candidate_gathering_done (
1663 * nice_agent_close_async:
1664 * @agent: The #NiceAgent object
1665 * @callback: (nullable): A callback that will be called when the closing is
1667 * @callback_data: (nullable): A pointer that will be passed to the callback
1669 * Asynchronously closes resources the agent has allocated on remote servers.
1671 * The agent will call the callback in the current #GMainContext in
1672 * which this function is called. The #GAsyncResult in the callback
1673 * can be ignored as this operation never fails.
1675 * Calling this function before freeing the agent makes sure the allocated relay
1676 * ports aren't left behind on TURN server but properly removed.
1681 nice_agent_close_async (NiceAgent *agent, GAsyncReadyCallback callback,
1682 gpointer callback_data);
1685 * nice_agent_get_sockets:
1686 * @agent: The #NiceAgent Object
1687 * @stream_id: The ID of the stream
1688 * @component_id: The ID of the component
1690 * Each component can have multiple sockets, this is an API to retrieve them all
1691 * to be able to set properties. Most of the sockets for a component are created when
1692 * calling nice_agent_gather_candidates(), so this API should be called right after to
1693 * able to set properties on the sockets before they are used.
1695 * These sockets can be a mix of UDP & TCP sockets depending on the compatibility mode
1696 * and options that have been set.
1698 * Returns: (element-type GSocket) (transfer full): An array
1699 * containing all of the sockets for this component. Free with
1700 * g_ptr_array_unref() when done.
1705 nice_agent_get_sockets (NiceAgent *agent, guint stream_id, guint component_id);
1709 #endif /* __LIBNICE_AGENT_H__ */