agent.h   agent.h 
skipping to change at line 56 skipping to change at line 56
* @see_also: #NiceCandidate * @see_also: #NiceCandidate
* @see_also: #NiceAddress * @see_also: #NiceAddress
* @include: agent.h * @include: agent.h
* @stability: Stable * @stability: Stable
* *
* The #NiceAgent is your main object when using libnice. * The #NiceAgent is your main object when using libnice.
* It is the agent that will take care of everything relating to ICE. * It is the agent that will take care of everything relating to ICE.
* It will take care of discovering your local candidates and do * It will take care of discovering your local candidates and do
* connectivity checks to create a stream of data between you and your pee r. * connectivity checks to create a stream of data between you and your pee r.
* *
* Streams and their components are referenced by integer IDs (with respect
to a
* given #NiceAgent). These IDs are guaranteed to be positive (i.e. non-zer
o)
* for valid streams/components.
*
* Each stream can receive data in one of two ways: using
* nice_agent_attach_recv() or nice_agent_recv_messages() (and the derived
* #NiceInputStream and #NiceIOStream classes accessible using
* nice_agent_get_io_stream()). nice_agent_attach_recv() is non-blocking: i
t
* takes a user-provided callback function and attaches the stream’s sock
et to
* the provided #GMainContext, invoking the callback in that context for ev
ery
* packet received. nice_agent_recv_messages() instead blocks on receiving
a
* packet, and writes it directly into a user-provided buffer. This reduces
the
* number of callback invokations and (potentially) buffer copies required
to
* receive packets. nice_agent_recv_messages() (or #NiceInputStream) is des
igned
* to be used in a blocking loop in a separate thread.
*
<example> <example>
<title>Simple example on how to use libnice</title> <title>Simple example on how to use libnice</title>
<programlisting> <programlisting>
guint stream_id; guint stream_id;
gchar buffer[] = "hello world!"; gchar buffer[] = "hello world!";
GSList *lcands = NULL; GSList *lcands = NULL;
// Create a nice agent // Create a nice agent
NiceAgent *agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); NiceAgent *agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245);
skipping to change at line 106 skipping to change at line 122
</programlisting> </programlisting>
</example> </example>
* *
* Refer to the examples in the examples/ subdirectory of the libnice sourc e for * Refer to the examples in the examples/ subdirectory of the libnice sourc e for
* complete examples. * complete examples.
* *
*/ */
#include <glib-object.h> #include <glib-object.h>
#include <gio/gio.h>
/** /**
* NiceAgent: * NiceAgent:
* *
* The #NiceAgent is the main GObject of the libnice library and represents * The #NiceAgent is the main GObject of the libnice library and represents
* the ICE agent. * the ICE agent.
*/ */
typedef struct _NiceAgent NiceAgent; typedef struct _NiceAgent NiceAgent;
#include "address.h" #include "address.h"
#include "candidate.h" #include "candidate.h"
#include "debug.h" #include "debug.h"
G_BEGIN_DECLS G_BEGIN_DECLS
/**
* NiceInputMessage:
* @buffers: (array length=n_buffers): unowned array of #GInputVector buffe
rs to
* store data in for this message
* @n_buffers: number of #GInputVectors in @buffers, or -1 to indicate @buf
fers
* is %NULL-terminated
* @from: (allow-none): return location to store the address of the peer wh
o
* transmitted the message, or %NULL
* @length: total number of valid bytes contiguously stored in @buffers
*
* Represents a single message received off the network. For reliable
* connections, this is essentially just an array of buffers (specifically,
* @from can be ignored). for non-reliable connections, it represents a sin
gle
* packet as received from the OS.
*
* @n_buffers may be -1 to indicate that @buffers is terminated by a
* #GInputVector with a %NULL buffer pointer.
*
* By providing arrays of #NiceInputMessages to functions like
* nice_agent_recv_messages(), multiple messages may be received with a sin
gle
* call, which is more efficient than making multiple calls in a loop. In t
his
* manner, nice_agent_recv_messages() is analogous to recvmmsg(); and
* #NiceInputMessage to struct mmsghdr.
*
* Since: 0.1.5
*/
typedef struct {
GInputVector *buffers;
gint n_buffers; /* may be -1 to indicate @buffers is NULL-terminated */
NiceAddress *from; /* return location for address of message sender */
gsize length; /* sum of the lengths of @buffers */
} NiceInputMessage;
/**
* NiceOutputMessage:
* @buffers: (array length=n_buffers): unowned array of #GOutputVector buff
ers
* which contain data to transmit for this message
* @n_buffers: number of #GOutputVectors in @buffers, or -1 to indicate @bu
ffers
* is %NULL-terminated
*
* Represents a single message to transmit on the network. For
* reliable connections, this is essentially just an array of
* buffer. for non-reliable connections, it represents a single packet
* to send to the OS.
*
* @n_buffers may be -1 to indicate that @buffers is terminated by a
* #GOutputVector with a %NULL buffer pointer.
*
* By providing arrays of #NiceOutputMessages to functions like
* nice_agent_send_messages_nonblocking(), multiple messages may be transmi
tted
* with a single call, which is more efficient than making multiple calls i
n a
* loop. In this manner, nice_agent_send_messages_nonblocking() is analogou
s to
* sendmmsg(); and #NiceOutputMessage to struct mmsghdr.
*
* Since: 0.1.5
*/
typedef struct {
GOutputVector *buffers;
gint n_buffers;
} NiceOutputMessage;
#define NICE_TYPE_AGENT nice_agent_get_type() #define NICE_TYPE_AGENT nice_agent_get_type()
#define NICE_AGENT(obj) \ #define NICE_AGENT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
NICE_TYPE_AGENT, NiceAgent)) NICE_TYPE_AGENT, NiceAgent))
#define NICE_AGENT_CLASS(klass) \ #define NICE_AGENT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \ (G_TYPE_CHECK_CLASS_CAST ((klass), \
NICE_TYPE_AGENT, NiceAgentClass)) NICE_TYPE_AGENT, NiceAgentClass))
skipping to change at line 330 skipping to change at line 408
* Returns: %TRUE on success, %FALSE on fatal (memory allocation) errors * Returns: %TRUE on success, %FALSE on fatal (memory allocation) errors
*/ */
gboolean gboolean
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr); nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
/** /**
* nice_agent_add_stream: * nice_agent_add_stream:
* @agent: The #NiceAgent Object * @agent: The #NiceAgent Object
* @n_components: The number of components to add to the stream * @n_components: The number of components to add to the stream
* *
* Adds a data stream to @agent containing @n_components components. * Adds a data stream to @agent containing @n_components components. The
* returned stream ID is guaranteed to be positive on success.
* *
* Returns: The ID of the new stream, 0 on failure * Returns: The ID of the new stream, 0 on failure
**/ **/
guint guint
nice_agent_add_stream ( nice_agent_add_stream (
NiceAgent *agent, NiceAgent *agent,
guint n_components); guint n_components);
/** /**
* nice_agent_remove_stream: * nice_agent_remove_stream:
skipping to change at line 390 skipping to change at line 469
* @agent: The #NiceAgent Object * @agent: The #NiceAgent Object
* @stream_id: The ID of the stream * @stream_id: The ID of the stream
* @component_id: The ID of the component * @component_id: The ID of the component
* @server_ip: The IP address of the TURN server * @server_ip: The IP address of the TURN server
* @server_port: The port of the TURN server * @server_port: The port of the TURN server
* @username: The TURN username to use for the allocate * @username: The TURN username to use for the allocate
* @password: The TURN password to use for the allocate * @password: The TURN password to use for the allocate
* @type: The type of relay to use * @type: The type of relay to use
* *
* Sets the settings for using a relay server during the candidate discover y. * Sets the settings for using a relay server during the candidate discover y.
* This may be called multiple times to add multiple relay servers to the
* discovery process; one TCP and one UDP, for example.
* *
* Returns: %TRUE if the TURN settings were accepted. * Returns: %TRUE if the TURN settings were accepted.
* %FALSE if the address was invalid. * %FALSE if the address was invalid.
*/ */
gboolean nice_agent_set_relay_info( gboolean nice_agent_set_relay_info(
NiceAgent *agent, NiceAgent *agent,
guint stream_id, guint stream_id,
guint component_id, guint component_id,
const gchar *server_ip, const gchar *server_ip,
guint server_port, guint server_port,
const gchar *username, const gchar *username,
const gchar *password, const gchar *password,
NiceRelayType type); NiceRelayType type);
/** /**
* nice_agent_gather_candidates: * nice_agent_gather_candidates:
* @agent: The #NiceAgent Object * @agent: The #NiceAgent object
* @stream_id: The id of the stream to start * @stream_id: The ID of the stream to start
*
* Allocate and start listening on local candidate ports and start the remo
te
* candidate gathering process.
* Once done, #NiceAgent::candidate-gathering-done is called for the stream
.
* As soon as this function is called, #NiceAgent::new-candidate signals ma
y be
* emitted, even before this function returns.
* *
* Start the candidate gathering process. * nice_agent_get_local_candidates() will only return non-empty results aft
* Once done, #NiceAgent::candidate-gathering-done is called for the stream er
* calling this function.
* *
* <para>See also: nice_agent_add_local_address()</para> * <para>See also: nice_agent_add_local_address()</para>
* <para>See also: nice_agent_set_port_range()</para> * <para>See also: nice_agent_set_port_range()</para>
* *
* Returns: %FALSE if the stream id is invalid or if a host candidate could * Returns: %FALSE if the stream ID is invalid or if a host candidate could
n't be allocated n't
* on the requested interfaces/ports. * be allocated on the requested interfaces/ports; %TRUE otherwise
* *
<note> <note>
<para> <para>
Local addresses can be previously set with nice_agent_add_local_address () Local addresses can be previously set with nice_agent_add_local_address ()
</para> </para>
<para> <para>
Since 0.0.5, If no local address was previously added, then the nice ag ent Since 0.0.5, If no local address was previously added, then the nice ag ent
will automatically detect the local address using will automatically detect the local address using
nice_interfaces_get_local_ips() nice_interfaces_get_local_ips()
</para> </para>
skipping to change at line 463 skipping to change at line 550
gboolean gboolean
nice_agent_set_remote_credentials ( nice_agent_set_remote_credentials (
NiceAgent *agent, NiceAgent *agent,
guint stream_id, guint stream_id,
const gchar *ufrag, const gchar *pwd); const gchar *ufrag, const gchar *pwd);
/** /**
* nice_agent_get_local_credentials: * nice_agent_get_local_credentials:
* @agent: The #NiceAgent Object * @agent: The #NiceAgent Object
* @stream_id: The ID of the stream * @stream_id: The ID of the stream
* @ufrag: a pointer to a NULL-terminated string containing * @ufrag: (out callee-allocates): return location for a nul-terminated str
* an ICE username fragment [OUT]. ing
* This string must be freed with g_free() * containing an ICE username fragment; must be freed with g_free()
* @pwd: a pointer to a NULL-terminated string containing an ICE * @pwd: (out callee-allocates): return location for a nul-terminated strin
* password [OUT] g
* This string must be freed with g_free() * containing an ICE password; must be freed with g_free()
* *
* Gets the local credentials for stream @stream_id. * Gets the local credentials for stream @stream_id. This may be called any
time
* after creating a stream using nice_agent_add_stream().
*
* An error will be returned if this is called for a non-existent stream, o
r if
* either of @ufrag or @pwd are %NULL.
* *
* Returns: %TRUE on success, %FALSE on error. * Returns: %TRUE on success, %FALSE on error.
*/ */
gboolean gboolean
nice_agent_get_local_credentials ( nice_agent_get_local_credentials (
NiceAgent *agent, NiceAgent *agent,
guint stream_id, guint stream_id,
gchar **ufrag, gchar **pwd); gchar **ufrag, gchar **pwd);
/** /**
skipping to change at line 561 skipping to change at line 650
*/ */
gint gint
nice_agent_send ( nice_agent_send (
NiceAgent *agent, NiceAgent *agent,
guint stream_id, guint stream_id,
guint component_id, guint component_id,
guint len, guint len,
const gchar *buf); const gchar *buf);
/** /**
* nice_agent_send_messages_nonblocking:
* @agent: a #NiceAgent
* @stream_id: the ID of the stream to send to
* @component_id: the ID of the component to send to
* @messages: (array length=n_messages): array of messages to send, of at l
east
* @n_messages entries in length
* @n_messages: number of entries in @messages
* @cancellable: (allow-none): a #GCancellable to cancel the operation from
* another thread, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Sends multiple messages on the socket identified by the given
* stream/component pair. Transmission is non-blocking, so a
* %G_IO_ERROR_WOULD_BLOCK error may be returned if the send buffer is full
.
*
* As with nice_agent_send(), the given component must be in
* %NICE_COMPONENT_STATE_READY or, as a special case, in any state if it wa
s
* previously ready and was then restarted.
*
* On success, the number of messages written to the socket will be returne
d,
* which may be less than @n_messages if transmission would have blocked
* part-way through. Zero will be returned if @n_messages is zero, or if
* transmission would have blocked on the first message.
*
* In reliable mode, it is instead recommended to use
* nice_agent_send(). The return value can be less than @n_messages
* or 0 even if it is still possible to send a partial message. In
* this case, "nice-agent-writable" will never be triggered, so the
* application would have to use nice_agent_sent() to fill the buffer or ha
ve
* to retry sending at a later point.
*
* On failure, -1 will be returned and @error will be set. If the #NiceAgen
t is
* reliable and the socket is not yet connected, %G_IO_ERROR_BROKEN_PIPE wi
ll be
* returned; if the write buffer is full, %G_IO_ERROR_WOULD_BLOCK will be
* returned. In both cases, wait for the #NiceAgent::reliable-transport-wri
table
* signal before trying again. If the given @stream_id or @component_id are
* invalid or not yet connected, %G_IO_ERROR_BROKEN_PIPE will be returned.
* %G_IO_ERROR_FAILED will be returned for other errors.
*
* Returns: the number of messages sent (may be zero), or -1 on error
*
* Since: 0.1.5
*/
gint
nice_agent_send_messages_nonblocking (
NiceAgent *agent,
guint stream_id,
guint component_id,
const NiceOutputMessage *messages,
guint n_messages,
GCancellable *cancellable,
GError **error);
/**
* nice_agent_get_local_candidates: * nice_agent_get_local_candidates:
* @agent: The #NiceAgent Object * @agent: The #NiceAgent Object
* @stream_id: The ID of the stream * @stream_id: The ID of the stream
* @component_id: The ID of the component * @component_id: The ID of the component
* *
* Retreive from the agent the list of all local candidates * Retreive from the agent the list of all local candidates
* for a stream's component * for a stream's component
* *
<note> <note>
<para> <para>
skipping to change at line 597 skipping to change at line 740
/** /**
* nice_agent_get_remote_candidates: * nice_agent_get_remote_candidates:
* @agent: The #NiceAgent Object * @agent: The #NiceAgent Object
* @stream_id: The ID of the stream * @stream_id: The ID of the stream
* @component_id: The ID of the component * @component_id: The ID of the component
* *
* Get a list of the remote candidates set on a stream's component * Get a list of the remote candidates set on a stream's component
* *
<note> <note>
<para> <para>
The caller owns the returned GSList but not the candidates The caller owns the returned GSList as well as the candidates containe
contained within it. d
within it.
</para> </para>
<para> <para>
The list of remote candidates can change during processing. The list of remote candidates can change during processing.
The client should register for the #NiceAgent::new-remote-candidate si gnal The client should register for the #NiceAgent::new-remote-candidate si gnal
to get notified of new remote candidates. to get notified of new remote candidates.
</para> </para>
</note> </note>
* *
* Returns: a #GSList of #NiceCandidates objects representing * Returns: a #GSList of #NiceCandidates objects representing
* the remote candidates set on the @agent * the remote candidates set on the @agent
skipping to change at line 644 skipping to change at line 787
* @stream_id: The ID of stream * @stream_id: The ID of stream
* @component_id: The ID of the component * @component_id: The ID of the component
* @ctx: The Glib Mainloop Context to use for listening on the component * @ctx: The Glib Mainloop Context to use for listening on the component
* @func: The callback function to be called when data is received on * @func: The callback function to be called when data is received on
* the stream's component * the stream's component
* @data: user data associated with the callback * @data: user data associated with the callback
* *
* Attaches the stream's component's sockets to the Glib Mainloop Context i n * Attaches the stream's component's sockets to the Glib Mainloop Context i n
* order to be notified whenever data becomes available for a component. * order to be notified whenever data becomes available for a component.
* *
* This must not be used in combination with nice_agent_recv_messages() (or
* #NiceIOStream or #NiceInputStream) on the same stream/component pair.
*
* Calling nice_agent_attach_recv() with a %NULL @func will detach any exis
ting
* callback and cause reception to be paused for the given stream/component
* pair. You must iterate the previously specified #GMainContext sufficient
ly to
* ensure all pending I/O callbacks have been received before calling this
* function to unset @func, otherwise data loss of received packets may occ
ur.
*
* Returns: %TRUE on success, %FALSE if the stream or component IDs are inv alid. * Returns: %TRUE on success, %FALSE if the stream or component IDs are inv alid.
*/ */
gboolean gboolean
nice_agent_attach_recv ( nice_agent_attach_recv (
NiceAgent *agent, NiceAgent *agent,
guint stream_id, guint stream_id,
guint component_id, guint component_id,
GMainContext *ctx, GMainContext *ctx,
NiceAgentRecvFunc func, NiceAgentRecvFunc func,
gpointer data); gpointer data);
/** /**
* nice_agent_recv:
* @agent: a #NiceAgent
* @stream_id: the ID of the stream to receive on
* @component_id: the ID of the component to receive on
* @buf: (array length=buf_len) (out caller-allocates): caller-allocated bu
ffer
* to write the received data into, of length at least @buf_len
* @buf_len: length of @buf
* @cancellable: (allow-none): a #GCancellable to allow the operation to be
* cancelled from another thread, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* A single-message version of nice_agent_recv_messages().
*
* Returns: the number of bytes written to @buf on success (guaranteed to b
e
* greater than 0 unless @buf_len is 0), or -1 on error
*
* Since: 0.1.5
*/
gssize
nice_agent_recv (
NiceAgent *agent,
guint stream_id,
guint component_id,
guint8 *buf,
gsize buf_len,
GCancellable *cancellable,
GError **error);
/**
* nice_agent_recv_messages:
* @agent: a #NiceAgent
* @stream_id: the ID of the stream to receive on
* @component_id: the ID of the component to receive on
* @messages: (array length=n_messages) (out caller-allocates): caller-allo
cated
* array of #NiceInputMessages to write the received messages into, of leng
th at
* least @n_messages
* @n_messages: number of entries in @messages
* @cancellable: (allow-none): a #GCancellable to allow the operation to be
* cancelled from another thread, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Block on receiving data from the given stream/component combination on
* @agent, returning only once exactly @n_messages messages have been recei
ved
* and written into @messages, the stream is closed by the other end or by
* calling nice_agent_remove_stream(), or @cancellable is cancelled.
*
* In the non-error case, in reliable mode, this will block until all buffe
rs in
* all @n_messages have been filled with received data (i.e. @messages is
* treated as a large, flat array of buffers). In non-reliable mode, it wil
l
* block until @n_messages messages have been received, each of which does
not
* have to fill all the buffers in its #NiceInputMessage. In the non-reliab
le
* case, each #NiceInputMessage must have enough buffers to contain an enti
re
* message (65536 bytes), or any excess data may be silently dropped.
*
* For each received message, #NiceInputMessage::length will be set to the
* number of valid bytes stored in the message’s buffers. The bytes are s
tored
* sequentially in the buffers; there are no gaps apart from at the end of
the
* buffer array (in non-reliable mode). If non-%NULL on input,
* #NiceInputMessage::from will have the address of the sending peer stored
in
* it. The base addresses, sizes, and number of buffers in each message wil
l not
* be modified in any case.
*
* This must not be used in combination with nice_agent_attach_recv() on th
e
* same stream/component pair.
*
* If the stream/component pair doesn’t exist, or if a suitable candidate
socket
* hasn’t yet been selected for it, a %G_IO_ERROR_BROKEN_PIPE error will
be
* returned. A %G_IO_ERROR_CANCELLED error will be returned if the operatio
n was
* cancelled. %G_IO_ERROR_FAILED will be returned for other errors.
*
* Returns: the number of valid messages written to @messages on success
* (guaranteed to be greater than 0 unless @n_messages is 0), or -1 on erro
r
*
* Since: 0.1.5
*/
gint
nice_agent_recv_messages (
NiceAgent *agent,
guint stream_id,
guint component_id,
NiceInputMessage *messages,
guint n_messages,
GCancellable *cancellable,
GError **error);
/**
* nice_agent_recv_nonblocking:
* @agent: a #NiceAgent
* @stream_id: the ID of the stream to receive on
* @component_id: the ID of the component to receive on
* @buf: (array length=buf_len) (out caller-allocates): caller-allocated bu
ffer
* to write the received data into, of length at least @buf_len
* @buf_len: length of @buf
* @cancellable: (allow-none): a #GCancellable to allow the operation to be
* cancelled from another thread, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* A single-message version of nice_agent_recv_messages_nonblocking().
*
* Returns: the number of bytes received into @buf on success (guaranteed t
o be
* greater than 0 unless @buf_len is 0), or -1 on error
*
* Since: 0.1.5
*/
gssize
nice_agent_recv_nonblocking (
NiceAgent *agent,
guint stream_id,
guint component_id,
guint8 *buf,
gsize buf_len,
GCancellable *cancellable,
GError **error);
/**
* nice_agent_recv_messages_nonblocking:
* @agent: a #NiceAgent
* @stream_id: the ID of the stream to receive on
* @component_id: the ID of the component to receive on
* @messages: (array length=n_messages) (out caller-allocates): caller-allo
cated
* array of #NiceInputMessages to write the received messages into, of leng
th at
* least @n_messages
* @n_messages: number of entries in @messages
* @cancellable: (allow-none): a #GCancellable to allow the operation to be
* cancelled from another thread, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Try to receive data from the given stream/component combination on @agen
t,
* without blocking. If receiving data would block, -1 is returned and
* %G_IO_ERROR_WOULD_BLOCK is set in @error. If any other error occurs, -1
is
* returned and @error is set accordingly. Otherwise, 0 is returned if (and
only
* if) @n_messages is 0. In all other cases, the number of valid messages s
tored
* in @messages is returned, and will be greater than 0.
*
* This function behaves similarly to nice_agent_recv_messages(), except th
at it
* will not block on filling (in reliable mode) or receiving (in non-reliab
le
* mode) exactly @n_messages messages. In reliable mode, it will receive by
tes
* into @messages until it would block; in non-reliable mode, it will recei
ve
* messages until it would block.
*
* As this function is non-blocking, @cancellable is included only for pari
ty
* with nice_agent_recv_messages(). If @cancellable is cancelled before thi
s
* function is called, a %G_IO_ERROR_CANCELLED error will be returned
* immediately.
*
* This must not be used in combination with nice_agent_attach_recv() on th
e
* same stream/component pair.
*
* Returns: the number of valid messages written to @messages on success
* (guaranteed to be greater than 0 unless @n_messages is 0), or -1 on erro
r
*
* Since: 0.1.5
*/
gint
nice_agent_recv_messages_nonblocking (
NiceAgent *agent,
guint stream_id,
guint component_id,
NiceInputMessage *messages,
guint n_messages,
GCancellable *cancellable,
GError **error);
/**
* nice_agent_set_selected_pair: * nice_agent_set_selected_pair:
* @agent: The #NiceAgent Object * @agent: The #NiceAgent Object
* @stream_id: The ID of the stream * @stream_id: The ID of the stream
* @component_id: The ID of the component * @component_id: The ID of the component
* @lfoundation: The local foundation of the candidate to use * @lfoundation: The local foundation of the candidate to use
* @rfoundation: The remote foundation of the candidate to use * @rfoundation: The remote foundation of the candidate to use
* *
* Sets the selected candidate pair for media transmission * Sets the selected candidate pair for media transmission
* for a given stream's component. Calling this function will * for a given stream's component. Calling this function will
* disable all further ICE processing (connection check, * disable all further ICE processing (connection check,
skipping to change at line 701 skipping to change at line 1017
*/ */
gboolean gboolean
nice_agent_get_selected_pair ( nice_agent_get_selected_pair (
NiceAgent *agent, NiceAgent *agent,
guint stream_id, guint stream_id,
guint component_id, guint component_id,
NiceCandidate **local, NiceCandidate **local,
NiceCandidate **remote); 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 alread
y
* 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.
*
* Users of this method are encouraged to not use a TURN relay or any kind
* of proxy, as in this case, the socket will not be available to the
* application because the packets are encapsulated.
*
* Returns: (transfer full) pointer to the #GSocket, or NULL if there is no
* selected candidate or if the selected candidate is a relayed 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: * nice_agent_set_selected_remote_candidate:
* @agent: The #NiceAgent Object * @agent: The #NiceAgent Object
* @stream_id: The ID of the stream * @stream_id: The ID of the stream
* @component_id: The ID of the component * @component_id: The ID of the component
* @candidate: The #NiceCandidate to select * @candidate: The #NiceCandidate to select
* *
* Sets the selected remote candidate for media transmission * Sets the selected remote candidate for media transmission
* for a given stream's component. This is used to force the selection of * for a given stream's component. This is used to force the selection of
* a specific remote candidate even when connectivity checks are failing * a specific remote candidate even when connectivity checks are failing
* (e.g. non-ICE compatible candidates). * (e.g. non-ICE compatible candidates).
skipping to change at line 1022 skipping to change at line 1368
* Returns: The parsed candidate or %NULL if there was an error. * Returns: The parsed candidate or %NULL if there was an error.
* *
* Since: 0.1.4 * Since: 0.1.4
**/ **/
NiceCandidate * NiceCandidate *
nice_agent_parse_remote_candidate_sdp ( nice_agent_parse_remote_candidate_sdp (
NiceAgent *agent, NiceAgent *agent,
guint stream_id, guint stream_id,
const gchar *sdp); const gchar *sdp);
/**
* nice_agent_get_io_stream:
* @agent: A #NiceAgent
* @stream_id: The ID of the stream to wrap
* @component_id: The ID of the component to wrap
*
* Gets a #GIOStream wrapper around the given stream and component in
* @agent. The I/O stream will be valid for as long as @stream_id is valid.
* The #GInputStream and #GOutputStream implement #GPollableInputStream and
* #GPollableOutputStream.
*
* This function may only be called on reliable #NiceAgents. It is a
* programming error to try and create an I/O stream wrapper for an
* unreliable stream.
*
* Returns: (transfer full): A #GIOStream.
*
* Since: 0.1.5
*/
GIOStream *
nice_agent_get_io_stream (
NiceAgent *agent,
guint stream_id,
guint component_id);
G_END_DECLS G_END_DECLS
#endif /* _AGENT_H */ #endif /* _AGENT_H */
 End of changes. 16 change blocks. 
17 lines changed or deleted 465 lines changed or added


 debug.h   debug.h 
/* /*
* This file is part of the Nice GLib ICE library. * This file is part of the Nice GLib ICE library.
* *
* (C) 2008 Collabora Ltd. * (C) 2008-2009 Collabora Ltd.
* Contact: Youness Alaoui * Contact: Youness Alaoui
* (C) 2008 Nokia Corporation. All rights reserved. * (C) 2007 Nokia Corporation. All rights reserved.
* *
* The contents of this file are subject to the Mozilla Public License Vers ion * The contents of this file are subject to the Mozilla Public License Vers ion
* 1.1 (the "License"); you may not use this file except in compliance with * 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at * the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/ * http://www.mozilla.org/MPL/
* *
* Software distributed under the License is distributed on an "AS IS" basi s, * Software distributed under the License is distributed on an "AS IS" basi s,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the * for the specific language governing rights and limitations under the
* License. * License.
skipping to change at line 37 skipping to change at line 37
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
* case the provisions of LGPL are applicable instead of those above. If yo u * case the provisions of LGPL are applicable instead of those above. If yo u
* wish to allow use of your version of this file only under the terms of t he * wish to allow use of your version of this file only under the terms of t he
* LGPL and not to allow others to use your version of this file under the * LGPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replace * MPL, indicate your decision by deleting the provisions above and replace
* them with the notice and other provisions required by the LGPL. If you d o * them with the notice and other provisions required by the LGPL. If you d o
* not delete the provisions above, a recipient may use your version of thi s * not delete the provisions above, a recipient may use your version of thi s
* file under either the MPL or the LGPL. * file under either the MPL or the LGPL.
*/ */
#ifndef _DEBUG_H #ifndef STUN_DEBUG_H
#define _DEBUG_H #define STUN_DEBUG_H
/** #include <stddef.h>
* SECTION:debug
* @short_description: Debug messages utility functions
* @stability: Unstable
*
* <para>Libnice can output a lot of information when debug messages are en
abled.
* This can significantly help track down problems and/or understand what
* it's doing.</para>
*
* <para>You can enable/disable the debug messages by calling nice_debug_en
able()
* or nice_debug_disable() and choosing whether you want only ICE debug mes
sages
* or also stun debug messages.</para>
*
* <para>By default, the debug messages are disabled, unless the environmen
t
* variable NICE_DEBUG is set, in which case, it must contain a comma separ
ated
* list of flags specifying which debug to enable.</para>
* <para> The currently available flags are "nice", "stun", "pseudotcp",
* "pseudotcp-verbose" or "all" to enable all debug messages.</para>
* <para> If the 'pseudotcp' flag is enabled, then 'pseudotcp-verbose' gets
* automatically disabled. This is to allow the use of the 'all' flag witho
ut
* having verbose messages from pseudotcp. You can enable verbose debug mes
sages
* from the pseudotcp layer by specifying 'pseudotcp-verbose' without the
* 'pseudotcp' flag.</para>
*
*
* <para>This API is unstable and is subject to change at any time...
* More flags are to come and a better API to enable/disable each flag
* should be added.</para>
*/
#include <glib.h>
G_BEGIN_DECLS
/** #ifdef __cplusplus
* nice_debug_init: extern "C" {
* #endif
* Initialize the debugging system. Uses the NICE_DEBUG environment variabl
e
* to set the appropriate debugging flags
*/
void nice_debug_init (void);
/** /**
* nice_debug_enable: * stun_debug_enable:
* @with_stun: Also enable stun debugging messages
* *
* Enables libnice debug output to the terminal * Enable debug messages to stderr
*/ */
void nice_debug_enable (gboolean with_stun); void stun_debug_enable (void);
/** /**
* nice_debug_disable: * stun_debug_disable:
* @with_stun: Also disable stun debugging messages
* *
* Disables libnice debug output to the terminal * Disable debug messages to stderr
*/ */
void nice_debug_disable (gboolean with_stun); void stun_debug_disable (void);
void nice_debug (const char *fmt, ...);
G_END_DECLS #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__
> 4))
void stun_debug (const char *fmt, ...)
__attribute__((__format__ (__printf__, 1, 2)));
#else
void stun_debug (const char *fmt, ...);
#endif
void stun_debug_bytes (const void *data, size_t len);
# ifdef __cplusplus
}
# endif
#endif /* _DEBUG_H */ #endif /* STUN_DEBUG_H */
 End of changes. 13 change blocks. 
63 lines changed or deleted 26 lines changed or added


 pseudotcp.h   pseudotcp.h 
skipping to change at line 67 skipping to change at line 67
#include <glib-object.h> #include <glib-object.h>
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
# include <winsock2.h> # include <winsock2.h>
# define ECONNABORTED WSAECONNABORTED # define ECONNABORTED WSAECONNABORTED
# define ENOTCONN WSAENOTCONN # define ENOTCONN WSAENOTCONN
# define EWOULDBLOCK WSAEWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK
# define ECONNRESET WSAECONNRESET # define ECONNRESET WSAECONNRESET
#endif #endif
#include "agent.h"
G_BEGIN_DECLS G_BEGIN_DECLS
/** /**
* PseudoTcpSocket: * PseudoTcpSocket:
* *
* The #PseudoTcpSocket is the GObject implementing the Pseudo TCP Socket * The #PseudoTcpSocket is the GObject implementing the Pseudo TCP Socket
* *
* Since: 0.0.11 * Since: 0.0.11
*/ */
typedef struct _PseudoTcpSocket PseudoTcpSocket; typedef struct _PseudoTcpSocket PseudoTcpSocket;
skipping to change at line 394 skipping to change at line 396
* Notify the #PseudoTcpSocket when a new packet arrives * Notify the #PseudoTcpSocket when a new packet arrives
* *
* Returns: %TRUE if the packet was processed successfully, %FALSE otherwis e * Returns: %TRUE if the packet was processed successfully, %FALSE otherwis e
* *
* Since: 0.0.11 * Since: 0.0.11
*/ */
gboolean pseudo_tcp_socket_notify_packet(PseudoTcpSocket *self, gboolean pseudo_tcp_socket_notify_packet(PseudoTcpSocket *self,
const gchar * buffer, guint32 len); const gchar * buffer, guint32 len);
/** /**
* pseudo_tcp_socket_notify_message:
* @self: The #PseudoTcpSocket object.
* @message: A #NiceInputMessage containing the received data.
*
* Notify the #PseudoTcpSocket that a new message has arrived, and enqueue
the
* data in its buffers to the #PseudoTcpSocket’s receive buffer.
*
* Returns: %TRUE if the packet was processed successfully, %FALSE otherwis
e
*
* Since: 0.1.5
*/
gboolean pseudo_tcp_socket_notify_message (PseudoTcpSocket *self,
NiceInputMessage *message);
/**
* pseudo_tcp_set_debug_level: * pseudo_tcp_set_debug_level:
* @level: The level of debug to set * @level: The level of debug to set
* *
* Sets the debug level to enable/disable normal/verbose debug messages. * Sets the debug level to enable/disable normal/verbose debug messages.
* *
* Since: 0.0.11 * Since: 0.0.11
*/ */
void pseudo_tcp_set_debug_level (PseudoTcpDebugLevel level); void pseudo_tcp_set_debug_level (PseudoTcpDebugLevel level);
/**
* pseudo_tcp_socket_get_available_bytes:
* @self: The #PseudoTcpSocket object.
*
* Gets the number of bytes of data in the buffer that can be read without
* receiving more packets from the network.
*
* Returns: The number of bytes or -1 if the connection is not established
*
* Since: 0.1.5
*/
gint pseudo_tcp_socket_get_available_bytes (PseudoTcpSocket *self);
/**
* pseudo_tcp_socket_can_send:
* @self: The #PseudoTcpSocket object.
*
* Returns if there is space in the send buffer to send any data.
*
* Returns: %TRUE if data can be sent, %FALSE otherwise
*
* Since: 0.1.5
*/
gboolean pseudo_tcp_socket_can_send (PseudoTcpSocket *self);
/**
* pseudo_tcp_socket_get_available_send_space:
* @self: The #PseudoTcpSocket object.
*
* Gets the number of bytes of space available in the transmission buffer.
*
* Returns: The numbero f bytes, or 0 if the connection is not established.
*
* Since: 0.1.5
*/
gsize pseudo_tcp_socket_get_available_send_space (PseudoTcpSocket *self);
G_END_DECLS G_END_DECLS
#endif /* _PSEUDOTCP_H */ #endif /* _PSEUDOTCP_H */
 End of changes. 3 change blocks. 
0 lines changed or deleted 58 lines changed or added


 stunmessage.h   stunmessage.h 
skipping to change at line 872 skipping to change at line 872
* provide us with the length of the STUN message. * provide us with the length of the STUN message.
* *
* Returns: The length of the valid STUN message in the buffer. * Returns: The length of the valid STUN message in the buffer.
* <para> See also: #STUN_MESSAGE_BUFFER_INCOMPLETE </para> * <para> See also: #STUN_MESSAGE_BUFFER_INCOMPLETE </para>
* <para> See also: #STUN_MESSAGE_BUFFER_INVALID </para> * <para> See also: #STUN_MESSAGE_BUFFER_INVALID </para>
*/ */
int stun_message_validate_buffer_length (const uint8_t *msg, size_t length, int stun_message_validate_buffer_length (const uint8_t *msg, size_t length,
bool has_padding); bool has_padding);
/** /**
* StunInputVector:
* @buffer: a buffer containing already-received binary data
* @size: length of @buffer, in bytes
*
* Container for a single buffer which also stores its length. This is desi
gned
* for vectored I/O: typically an array of #StunInputVectors is passed to
* functions, providing multiple buffers which store logically contiguous
* received data.
*
* This is guaranteed to be layed out identically in memory to #GInputVecto
r.
*
* Since: 0.1.5
*/
typedef struct {
const uint8_t *buffer;
size_t size;
} StunInputVector;
/**
* stun_message_validate_buffer_length_fast:
* @buffers: (array length=n_buffers) (in caller-allocated): array of conti
guous
* #StunInputVectors containing already-received message data
* @n_buffers: number of entries in @buffers
* @total_length: total number of valid bytes stored consecutively in @buff
ers
* @has_padding: %TRUE if attributes should be padded to 4-byte boundaries
*
* Quickly validate whether the message in the given @buffers is potentiall
y a
* valid STUN message, an incomplete STUN message, or if it’s definitely
not one
* at all.
*
* This is designed as a first-pass validation only, and does not check the
* message’s attributes for validity. If this function returns success, t
he
* buffers can be compacted and a more thorough validation can be performed
* using stun_message_validate_buffer_length(). If it fails, the buffers
* definitely do not contain a complete, valid STUN message.
*
* Returns: The length of the valid STUN message in the buffer, or zero or
-1 on
* failure
* <para> See also: #STUN_MESSAGE_BUFFER_INCOMPLETE </para>
* <para> See also: #STUN_MESSAGE_BUFFER_INVALID </para>
*
* Since: 0.1.5
*/
ssize_t stun_message_validate_buffer_length_fast (StunInputVector *buffers,
unsigned int n_buffers, size_t total_length, bool has_padding);
/**
* stun_message_id: * stun_message_id:
* @msg: The #StunMessage * @msg: The #StunMessage
* @id: The #StunTransactionId to fill * @id: The #StunTransactionId to fill
* *
* Retreive the STUN transaction id from a STUN message * Retreive the STUN transaction id from a STUN message
*/ */
void stun_message_id (const StunMessage *msg, StunTransactionId id); void stun_message_id (const StunMessage *msg, StunTransactionId id);
/** /**
* stun_message_get_class: * stun_message_get_class:
 End of changes. 1 change blocks. 
0 lines changed or deleted 55 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/