Fork me on GitHub
Data Structures | Macros | Typedefs | Functions | Variables
ice.c File Reference

ICE/STUN/TURN processing. More...

#include <ifaddrs.h>
#include <net/if.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netdb.h>
#include <fcntl.h>
#include <stun/usages/bind.h>
#include <nice/debug.h>
#include "janus.h"
#include "debug.h"
#include "ice.h"
#include "turnrest.h"
#include "dtls.h"
#include "sdp.h"
#include "rtpsrtp.h"
#include "rtcp.h"
#include "apierror.h"
#include "ip-utils.h"
#include "events.h"
Include dependency graph for ice.c:

Data Structures

struct  janus_ice_queued_packet
 

Macros

#define JANUS_ICE_PACKET_AUDIO   0
 
#define JANUS_ICE_PACKET_VIDEO   1
 
#define JANUS_ICE_PACKET_DATA   2
 
#define DEFAULT_NO_MEDIA_TIMER   1
 
#define DEFAULT_MAX_NACK_QUEUE   500
 
#define MAX_NACK_IGNORE   200000
 
#define SEQ_MISSING_WAIT   12000 /* 12ms */
 
#define SEQ_NACKED_WAIT   155000 /* 155ms */
 
#define SLOW_LINK_NACKS_PER_SEC   8
 

Typedefs

typedef struct janus_ice_queued_packet janus_ice_queued_packet
 

Functions

char * janus_ice_get_stun_server (void)
 Method to get the STUN server IP address. More...
 
uint16_t janus_ice_get_stun_port (void)
 Method to get the STUN server port. More...
 
char * janus_ice_get_turn_server (void)
 Method to get the TURN server IP address. More...
 
uint16_t janus_ice_get_turn_port (void)
 Method to get the TURN server port. More...
 
char * janus_ice_get_turn_rest_api (void)
 Method to get the specified TURN REST API backend, if any. More...
 
gboolean janus_ice_is_ice_lite_enabled (void)
 Method to check whether ICE Lite mode is enabled or not (still WIP) More...
 
gboolean janus_ice_is_ice_tcp_enabled (void)
 Method to check whether ICE-TCP support is enabled/supported or not (still WIP) More...
 
gboolean janus_ice_is_ipv6_enabled (void)
 Method to check whether IPv6 candidates are enabled/supported or not (still WIP) More...
 
void janus_ice_force_bundle (gboolean forced)
 Method to set the BUNDLE support mode (true means mandatory, false means optional) More...
 
gboolean janus_ice_is_bundle_forced (void)
 Method to check whether BUNDLE support is forced or not. More...
 
void janus_ice_force_rtcpmux (gboolean forced)
 Method to set the rtcp-mux support mode (true means mandatory, false means optional) More...
 
gint janus_ice_get_rtcpmux_blackhole_port (void)
 Method to get the port that has been assigned for the RTCP component blackhole in case of rtcp-mux. More...
 
gboolean janus_ice_is_rtcpmux_forced (void)
 Method to check whether rtcp-mux support is forced or not. More...
 
gboolean janus_ice_is_ice_debugging_enabled (void)
 Method to check whether libnice debugging has been enabled (http://nice.freedesktop.org/libnice/libnice-Debug-messages.html) More...
 
void janus_ice_debugging_enable (void)
 Method to enable libnice debugging (http://nice.freedesktop.org/libnice/libnice-Debug-messages.html) More...
 
void janus_ice_debugging_disable (void)
 Method to disable libnice debugging (the default) More...
 
void janus_ice_enable_nat_1_1 (void)
 Helper method to force Janus to overwrite all host candidates with the public IP. More...
 
void janus_ice_enforce_interface (const char *ip)
 Method to add an interface/IP to the enforce list for ICE (that is, only gather candidates from these and ignore the others) More...
 
gboolean janus_ice_is_enforced (const char *ip)
 Method to check whether an interface is currently in the enforce list for ICE (that is, won't have candidates) More...
 
void janus_ice_ignore_interface (const char *ip)
 Method to add an interface/IP to the ignore list for ICE (that is, don't gather candidates) More...
 
gboolean janus_ice_is_ignored (const char *ip)
 Method to check whether an interface/IP is currently in the ignore list for ICE (that is, won't have candidates) More...
 
void janus_ice_set_event_stats_period (int period)
 Method to modify the event handler statistics period (i.e., the number of seconds that should pass before Janus notifies event handlers about media statistics for a PeerConnection) More...
 
int janus_ice_get_event_stats_period (void)
 Method to get the current event handler statistics period (see above) More...
 
void janus_set_no_media_timer (uint timer)
 Method to modify the no-media event timer (i.e., the number of seconds where no media arrives before Janus notifies this) More...
 
uint janus_get_no_media_timer (void)
 Method to get the current no-media event timer (see above) More...
 
void janus_set_max_nack_queue (uint mnq)
 Method to modify the max NACK value (i.e., the number of packets per handle to store for retransmissions) More...
 
uint janus_get_max_nack_queue (void)
 Method to get the current max NACK value (i.e., the number of packets per handle to store for retransmissions) More...
 
void janus_ice_relay_rtcp_internal (janus_ice_handle *handle, int video, char *buf, int len, gboolean filter_rtcp)
 
gboolean janus_plugin_session_is_alive (janus_plugin_session *plugin_session)
 Quick helper method to check if a plugin session associated with a Janus handle is still valid. More...
 
void janus_ice_notify_hangup (janus_ice_handle *handle, const char *reason)
 Quick helper method to notify a WebRTC hangup through the Janus API. More...
 
janus_ice_tricklejanus_ice_trickle_new (janus_ice_handle *handle, const char *transaction, json_t *candidate)
 Helper method to allocate a janus_ice_trickle instance. More...
 
gint janus_ice_trickle_parse (janus_ice_handle *handle, json_t *candidate, const char **error)
 Helper method to parse trickle candidates. More...
 
void janus_ice_trickle_destroy (janus_ice_trickle *trickle)
 Helper method to destroy a janus_ice_trickle instance. More...
 
void janus_ice_init (gboolean ice_lite, gboolean ice_tcp, gboolean ipv6, uint16_t rtp_min_port, uint16_t rtp_max_port)
 ICE stuff initialization. More...
 
void janus_ice_deinit (void)
 ICE stuff de-initialization. More...
 
int janus_ice_set_stun_server (gchar *stun_server, uint16_t stun_port)
 Method to force Janus to use a STUN server when gathering candidates. More...
 
int janus_ice_set_turn_server (gchar *turn_server, uint16_t turn_port, gchar *turn_type, gchar *turn_user, gchar *turn_pwd)
 Method to force Janus to use a TURN server when gathering candidates. More...
 
int janus_ice_set_turn_rest_api (gchar *api_server, gchar *api_key, gchar *api_method)
 Method to force Janus to contact a TURN REST API server to get a TURN service to use when gathering candidates. The TURN REST API takes precedence over any static credential passed via janus_ice_set_turn_server. More...
 
const gchar * janus_get_ice_state_name (gint state)
 Helper method to get a string representation of a libnice ICE state. More...
 
janus_ice_handlejanus_ice_handle_create (void *gateway_session, const char *opaque_id)
 Method to create a new Janus ICE handle. More...
 
janus_ice_handlejanus_ice_handle_find (void *gateway_session, guint64 handle_id)
 Method to find an existing Janus ICE handle from its ID. More...
 
gint janus_ice_handle_attach_plugin (void *gateway_session, guint64 handle_id, janus_plugin *plugin)
 Method to attach a Janus ICE handle to a plugin. More...
 
gint janus_ice_handle_destroy (void *gateway_session, guint64 handle_id)
 Method to destroy a Janus ICE handle. More...
 
void janus_ice_free (janus_ice_handle *handle)
 Method to actually free the resources allocated by a Janus ICE handle. More...
 
void janus_ice_webrtc_hangup (janus_ice_handle *handle, const char *reason)
 Method to only hangup (e.g., DTLS alert) the WebRTC PeerConnection allocated by a Janus ICE handle. More...
 
void janus_ice_webrtc_free (janus_ice_handle *handle)
 Method to only free the WebRTC related resources allocated by a Janus ICE handle. More...
 
void janus_ice_stream_free (GHashTable *streams, janus_ice_stream *stream)
 Method to only free resources related to a specific ICE stream allocated by a Janus ICE handle. More...
 
void janus_ice_component_free (GHashTable *components, janus_ice_component *component)
 Method to only free resources related to a specific ICE component allocated by a Janus ICE handle. More...
 
void janus_ice_incoming_data (janus_ice_handle *handle, char *buffer, int length)
 Plugin SCTP/DataChannel callback, called by the SCTP stack when when there's data for a plugin. More...
 
void * janus_ice_thread (void *data)
 Janus ICE handle thread. More...
 
void janus_ice_candidates_to_sdp (janus_ice_handle *handle, janus_sdp_mline *mline, guint stream_id, guint component_id)
 Method to add local candidates to a janus_sdp SDP object representation. More...
 
void janus_ice_setup_remote_candidates (janus_ice_handle *handle, guint stream_id, guint component_id)
 Method to handle remote candidates and start the connectivity checks. More...
 
int janus_ice_setup_local (janus_ice_handle *handle, int offer, int audio, int video, int data, int bundle, int rtcpmux, int trickle)
 Method to locally set up the ICE candidates (initialization and gathering) More...
 
void * janus_ice_send_thread (void *data)
 Janus ICE thread for sending outgoing packets. More...
 
void janus_ice_relay_rtp (janus_ice_handle *handle, int video, char *buf, int len)
 Gateway RTP callback, called when a plugin has an RTP packet to send to a peer. More...
 
void janus_ice_relay_rtcp (janus_ice_handle *handle, int video, char *buf, int len)
 Gateway RTCP callback, called when a plugin has an RTCP message to send to a peer. More...
 
void janus_ice_dtls_handshake_done (janus_ice_handle *handle, janus_ice_component *component)
 Callback to be notified when the DTLS handshake for a specific component has been completed. More...
 

Variables

GList * janus_ice_enforce_list = NULL
 
GList * janus_ice_ignore_list = NULL
 
janus_mutex ice_list_mutex
 
uint16_t rtp_range_min = 0
 
uint16_t rtp_range_max = 0
 
GMainLoop * handles_watchdog_loop = NULL
 
GThread * handles_watchdog = NULL
 

Detailed Description

ICE/STUN/TURN processing.

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Implementation (based on libnice) of the ICE process. The code handles the whole ICE process, from the gathering of candidates to the final setup of a virtual channel RTP and RTCP can be transported on. Incoming RTP and RTCP packets from peers are relayed to the associated plugins by means of the incoming_rtp and incoming_rtcp callbacks. Packets to be sent to peers are relayed by peers invoking the relay_rtp and relay_rtcp gateway callbacks instead.

Protocols

Macro Definition Documentation

◆ DEFAULT_MAX_NACK_QUEUE

#define DEFAULT_MAX_NACK_QUEUE   500

◆ DEFAULT_NO_MEDIA_TIMER

#define DEFAULT_NO_MEDIA_TIMER   1

◆ JANUS_ICE_PACKET_AUDIO

#define JANUS_ICE_PACKET_AUDIO   0

◆ JANUS_ICE_PACKET_DATA

#define JANUS_ICE_PACKET_DATA   2

◆ JANUS_ICE_PACKET_VIDEO

#define JANUS_ICE_PACKET_VIDEO   1

◆ MAX_NACK_IGNORE

#define MAX_NACK_IGNORE   200000

◆ SEQ_MISSING_WAIT

#define SEQ_MISSING_WAIT   12000 /* 12ms */

◆ SEQ_NACKED_WAIT

#define SEQ_NACKED_WAIT   155000 /* 155ms */

◆ SLOW_LINK_NACKS_PER_SEC

#define SLOW_LINK_NACKS_PER_SEC   8

Typedef Documentation

◆ janus_ice_queued_packet

Function Documentation

◆ janus_get_ice_state_name()

const gchar* janus_get_ice_state_name ( gint  state)

Helper method to get a string representation of a libnice ICE state.

Parameters
[in]stateThe libnice ICE state
Returns
A string representation of the libnice ICE state

◆ janus_get_max_nack_queue()

uint janus_get_max_nack_queue ( void  )

Method to get the current max NACK value (i.e., the number of packets per handle to store for retransmissions)

Returns
The current max NACK value

◆ janus_get_no_media_timer()

uint janus_get_no_media_timer ( void  )

Method to get the current no-media event timer (see above)

Returns
The current no-media event timer

◆ janus_ice_candidates_to_sdp()

void janus_ice_candidates_to_sdp ( janus_ice_handle handle,
janus_sdp_mline mline,
guint  stream_id,
guint  component_id 
)

Method to add local candidates to a janus_sdp SDP object representation.

Parameters
[in]handleThe Janus ICE handle this method refers to
[in]mlineThe Janus SDP m-line object to add candidates to
[in]stream_idThe stream ID of the candidate to add to the SDP
[in]component_idThe component ID of the candidate to add to the SDP

◆ janus_ice_component_free()

void janus_ice_component_free ( GHashTable *  container,
janus_ice_component component 
)

Method to only free resources related to a specific ICE component allocated by a Janus ICE handle.

Parameters
[in]containerThe map containing the list of all components for the stream
[in]componentThe Janus ICE component instance to free

◆ janus_ice_debugging_disable()

void janus_ice_debugging_disable ( void  )

Method to disable libnice debugging (the default)

◆ janus_ice_debugging_enable()

void janus_ice_debugging_enable ( void  )

◆ janus_ice_deinit()

void janus_ice_deinit ( void  )

ICE stuff de-initialization.

◆ janus_ice_dtls_handshake_done()

void janus_ice_dtls_handshake_done ( janus_ice_handle handle,
janus_ice_component component 
)

Callback to be notified when the DTLS handshake for a specific component has been completed.

This method also decides when to notify attached plugins about the availability of a reliable PeerConnection

Parameters
[in]handleThe Janus ICE handle this callback refers to
[in]componentThe Janus ICE component that is now ready to be used

◆ janus_ice_enable_nat_1_1()

void janus_ice_enable_nat_1_1 ( void  )

Helper method to force Janus to overwrite all host candidates with the public IP.

◆ janus_ice_enforce_interface()

void janus_ice_enforce_interface ( const char *  ip)

Method to add an interface/IP to the enforce list for ICE (that is, only gather candidates from these and ignore the others)

Note
This method is especially useful to speed up the ICE gathering process on the gateway: in fact, if you know in advance which interface must be used (e.g., the main interface connected to the internet), adding it to the enforce list will prevent libnice from gathering candidates from other interfaces. If you're interested in excluding interfaces explicitly, instead, check janus_ice_ignore_interface.
Parameters
[in]ipInterface/IP to enforce (e.g., 192.168. or eth0)

◆ janus_ice_force_bundle()

void janus_ice_force_bundle ( gboolean  forced)

Method to set the BUNDLE support mode (true means mandatory, false means optional)

Parameters
forcedwhether BUNDLE support must be forced or not (default is false)

◆ janus_ice_force_rtcpmux()

void janus_ice_force_rtcpmux ( gboolean  forced)

Method to set the rtcp-mux support mode (true means mandatory, false means optional)

Parameters
forcedwhether rtcp-mux support must be forced or not (default is false)

◆ janus_ice_free()

void janus_ice_free ( janus_ice_handle handle)

Method to actually free the resources allocated by a Janus ICE handle.

Parameters
[in]handleThe Janus ICE handle instance to free

◆ janus_ice_get_event_stats_period()

int janus_ice_get_event_stats_period ( void  )

Method to get the current event handler statistics period (see above)

Returns
The current event handler stats period

◆ janus_ice_get_rtcpmux_blackhole_port()

gint janus_ice_get_rtcpmux_blackhole_port ( void  )

Method to get the port that has been assigned for the RTCP component blackhole in case of rtcp-mux.

Returns
The blackhole port

◆ janus_ice_get_stun_port()

uint16_t janus_ice_get_stun_port ( void  )

Method to get the STUN server port.

Returns
The currently used STUN server port, if available, or 0 if not

◆ janus_ice_get_stun_server()

char* janus_ice_get_stun_server ( void  )

Method to get the STUN server IP address.

Returns
The currently used STUN server IP address, if available, or NULL if not

◆ janus_ice_get_turn_port()

uint16_t janus_ice_get_turn_port ( void  )

Method to get the TURN server port.

Returns
The currently used TURN server port, if available, or 0 if not

◆ janus_ice_get_turn_rest_api()

char* janus_ice_get_turn_rest_api ( void  )

Method to get the specified TURN REST API backend, if any.

Returns
The currently specified TURN REST API backend, if available, or NULL if not

◆ janus_ice_get_turn_server()

char* janus_ice_get_turn_server ( void  )

Method to get the TURN server IP address.

Returns
The currently used TURN server IP address, if available, or NULL if not

◆ janus_ice_handle_attach_plugin()

gint janus_ice_handle_attach_plugin ( void *  gateway_session,
guint64  handle_id,
janus_plugin plugin 
)

Method to attach a Janus ICE handle to a plugin.

This method is very important, as it allows plugins to send/receive media (RTP/RTCP) to/from a WebRTC peer.

Parameters
[in]gateway_sessionThe gateway/peer session this ICE handle belongs to
[in]handle_idThe Janus ICE handle ID
[in]pluginThe plugin the ICE handle needs to be attached to
Returns
0 in case of success, a negative integer otherwise

◆ janus_ice_handle_create()

janus_ice_handle* janus_ice_handle_create ( void *  gateway_session,
const char *  opaque_id 
)

Method to create a new Janus ICE handle.

Parameters
[in]gateway_sessionThe gateway/peer session this ICE handle will belong to
[in]opaque_idThe opaque identifier provided by the creator, if any (optional)
Returns
The created Janus ICE handle if successful, NULL otherwise

◆ janus_ice_handle_destroy()

gint janus_ice_handle_destroy ( void *  gateway_session,
guint64  handle_id 
)

Method to destroy a Janus ICE handle.

Parameters
[in]gateway_sessionThe gateway/peer session this ICE handle belongs to
[in]handle_idThe Janus ICE handle ID to destroy
Returns
0 in case of success, a negative integer otherwise

◆ janus_ice_handle_find()

janus_ice_handle* janus_ice_handle_find ( void *  gateway_session,
guint64  handle_id 
)

Method to find an existing Janus ICE handle from its ID.

Parameters
[in]gateway_sessionThe gateway/peer session this ICE handle belongs to
[in]handle_idThe Janus ICE handle ID
Returns
The created Janus ICE handle if successful, NULL otherwise

◆ janus_ice_ignore_interface()

void janus_ice_ignore_interface ( const char *  ip)

Method to add an interface/IP to the ignore list for ICE (that is, don't gather candidates)

Note
This method is especially useful to speed up the ICE gathering process on the gateway: in fact, if you know in advance an interface is not going to be used (e.g., one of those created by VMware), adding it to the ignore list will prevent libnice from gathering a candidate for it. Unlike the enforce list, the ignore list also accepts IP addresses, partial or complete. If you're interested in only using specific interfaces, instead, check janus_ice_enforce_interface.
Parameters
[in]ipInterface/IP to ignore (e.g., 192.168. or eth1)

◆ janus_ice_incoming_data()

void janus_ice_incoming_data ( janus_ice_handle handle,
char *  buffer,
int  length 
)

Plugin SCTP/DataChannel callback, called by the SCTP stack when when there's data for a plugin.

Parameters
[in]handleThe Janus ICE handle associated with the peer
[in]bufferThe message data (buffer)
[in]lengthThe buffer lenght

◆ janus_ice_init()

void janus_ice_init ( gboolean  ice_lite,
gboolean  ice_tcp,
gboolean  ipv6,
uint16_t  rtp_min_port,
uint16_t  rtp_max_port 
)

ICE stuff initialization.

Parameters
[in]ice_liteWhether the ICE Lite mode should be enabled or not
[in]ice_tcpWhether ICE-TCP support should be enabled or not (only libnice >= 0.1.8, currently broken)
[in]ipv6Whether IPv6 candidates must be negotiated or not
[in]rtp_min_portMinimum port to use for RTP/RTCP, if a range is to be used
[in]rtp_max_portMaximum port to use for RTP/RTCP, if a range is to be used
Note
The RTP/RTCP port range configuration may be just a placeholder: for instance, libnice supports this since 0.1.0, but the 0.1.3 on Fedora fails when linking with an undefined reference to nice_agent_set_port_range so this is checked by the install.sh script in advance.

◆ janus_ice_is_bundle_forced()

gboolean janus_ice_is_bundle_forced ( void  )

Method to check whether BUNDLE support is forced or not.

Returns
true if BUNDLE is mandatory, false otherwise

◆ janus_ice_is_enforced()

gboolean janus_ice_is_enforced ( const char *  ip)

Method to check whether an interface is currently in the enforce list for ICE (that is, won't have candidates)

Parameters
[in]ipInterface/IP to check (e.g., 192.168.244.1 or eth1)
Returns
true if the interface/IP is in the enforce list, false otherwise

◆ janus_ice_is_ice_debugging_enabled()

gboolean janus_ice_is_ice_debugging_enabled ( void  )

Method to check whether libnice debugging has been enabled (http://nice.freedesktop.org/libnice/libnice-Debug-messages.html)

Returns
True if libnice debugging is enabled, FALSE otherwise

◆ janus_ice_is_ice_lite_enabled()

gboolean janus_ice_is_ice_lite_enabled ( void  )

Method to check whether ICE Lite mode is enabled or not (still WIP)

Returns
true if ICE-TCP support is enabled/supported, false otherwise

◆ janus_ice_is_ice_tcp_enabled()

gboolean janus_ice_is_ice_tcp_enabled ( void  )

Method to check whether ICE-TCP support is enabled/supported or not (still WIP)

Returns
true if ICE-TCP support is enabled/supported, false otherwise

◆ janus_ice_is_ignored()

gboolean janus_ice_is_ignored ( const char *  ip)

Method to check whether an interface/IP is currently in the ignore list for ICE (that is, won't have candidates)

Parameters
[in]ipInterface/IP to check (e.g., 192.168.244.1 or eth1)
Returns
true if the interface/IP is in the ignore list, false otherwise

◆ janus_ice_is_ipv6_enabled()

gboolean janus_ice_is_ipv6_enabled ( void  )

Method to check whether IPv6 candidates are enabled/supported or not (still WIP)

Returns
true if IPv6 candidates are enabled/supported, false otherwise

◆ janus_ice_is_rtcpmux_forced()

gboolean janus_ice_is_rtcpmux_forced ( void  )

Method to check whether rtcp-mux support is forced or not.

Returns
true if rtcp-mux is mandatory, false otherwise

◆ janus_ice_notify_hangup()

void janus_ice_notify_hangup ( janus_ice_handle handle,
const char *  reason 
)

Quick helper method to notify a WebRTC hangup through the Janus API.

Parameters
handleThe janus_ice_handle instance this event refers to
reasonA description of why this happened

◆ janus_ice_relay_rtcp()

void janus_ice_relay_rtcp ( janus_ice_handle handle,
int  video,
char *  buf,
int  len 
)

Gateway RTCP callback, called when a plugin has an RTCP message to send to a peer.

Parameters
[in]handleThe Janus ICE handle associated with the peer
[in]videoWhether this is related to an audio or a video stream
[in]bufThe message data (buffer)
[in]lenThe buffer lenght

◆ janus_ice_relay_rtcp_internal()

void janus_ice_relay_rtcp_internal ( janus_ice_handle handle,
int  video,
char *  buf,
int  len,
gboolean  filter_rtcp 
)

◆ janus_ice_relay_rtp()

void janus_ice_relay_rtp ( janus_ice_handle handle,
int  video,
char *  buf,
int  len 
)

Gateway RTP callback, called when a plugin has an RTP packet to send to a peer.

Parameters
[in]handleThe Janus ICE handle associated with the peer
[in]videoWhether this is an audio or a video frame
[in]bufThe packet data (buffer)
[in]lenThe buffer lenght

◆ janus_ice_send_thread()

void* janus_ice_send_thread ( void *  data)

Janus ICE thread for sending outgoing packets.

◆ janus_ice_set_event_stats_period()

void janus_ice_set_event_stats_period ( int  period)

Method to modify the event handler statistics period (i.e., the number of seconds that should pass before Janus notifies event handlers about media statistics for a PeerConnection)

Parameters
[in]timerThe new timer value, in seconds

◆ janus_ice_set_stun_server()

int janus_ice_set_stun_server ( gchar *  stun_server,
uint16_t  stun_port 
)

Method to force Janus to use a STUN server when gathering candidates.

Parameters
[in]stun_serverSTUN server address to use
[in]stun_portSTUN port to use
Returns
0 in case of success, a negative integer on errors

◆ janus_ice_set_turn_rest_api()

int janus_ice_set_turn_rest_api ( gchar *  api_server,
gchar *  api_key,
gchar *  api_method 
)

Method to force Janus to contact a TURN REST API server to get a TURN service to use when gathering candidates. The TURN REST API takes precedence over any static credential passed via janus_ice_set_turn_server.

Note
Requires libcurl to be available, and a working TURN REST API backend (see turnrest.h)
Parameters
[in]api_serverTURN REST API backend (NULL to disable the API)
[in]api_keyAPI key to use, if required
[in]api_methodHTTP method to use (POST by default)
Returns
0 in case of success, a negative integer on errors

◆ janus_ice_set_turn_server()

int janus_ice_set_turn_server ( gchar *  turn_server,
uint16_t  turn_port,
gchar *  turn_type,
gchar *  turn_user,
gchar *  turn_pwd 
)

Method to force Janus to use a TURN server when gathering candidates.

Parameters
[in]turn_serverTURN server address to use
[in]turn_portTURN port to use
[in]turn_typeRelay type (udp, tcp or tls)
[in]turn_userTURN username, if needed
[in]turn_pwdTURN password, if needed
Returns
0 in case of success, a negative integer on errors

◆ janus_ice_setup_local()

int janus_ice_setup_local ( janus_ice_handle handle,
int  offer,
int  audio,
int  video,
int  data,
int  bundle,
int  rtcpmux,
int  trickle 
)

Method to locally set up the ICE candidates (initialization and gathering)

Parameters
[in]handleThe Janus ICE handle this method refers to
[in]offerWhether this is for an OFFER or an ANSWER
[in]audioWhether audio is enabled
[in]videoWhether video is enabled
[in]dataWhether SCTP data channels are enabled
[in]bundleWhether BUNDLE is supported or not
[in]rtcpmuxWhether rtcp-mux is supported or not
[in]trickleWhether ICE trickling is supported or not
Returns
0 in case of success, a negative integer otherwise

◆ janus_ice_setup_remote_candidates()

void janus_ice_setup_remote_candidates ( janus_ice_handle handle,
guint  stream_id,
guint  component_id 
)

Method to handle remote candidates and start the connectivity checks.

Parameters
[in]handleThe Janus ICE handle this method refers to
[in]stream_idThe stream ID of the candidate to add to the SDP
[in]component_idThe component ID of the candidate to add to the SDP

◆ janus_ice_stream_free()

void janus_ice_stream_free ( GHashTable *  container,
janus_ice_stream stream 
)

Method to only free resources related to a specific ICE stream allocated by a Janus ICE handle.

Parameters
[in]containerThe map containing the list of all streams for the handle
[in]streamThe Janus ICE stream instance to free

◆ janus_ice_thread()

void* janus_ice_thread ( void *  data)

Janus ICE handle thread.

◆ janus_ice_trickle_destroy()

void janus_ice_trickle_destroy ( janus_ice_trickle trickle)

Helper method to destroy a janus_ice_trickle instance.

Parameters
[in]trickleThe janus_ice_trickle instance to destroy

◆ janus_ice_trickle_new()

janus_ice_trickle* janus_ice_trickle_new ( janus_ice_handle handle,
const char *  transaction,
json_t candidate 
)

Helper method to allocate a janus_ice_trickle instance.

Parameters
[in]handleThe Janus ICE handle this trickle candidate belongs to
[in]transactionThe Janus API ID of the original trickle request
[in]candidateThe trickle candidate, as a Jansson object
Returns
a pointer to the new instance, if successful, NULL otherwise

◆ janus_ice_trickle_parse()

gint janus_ice_trickle_parse ( janus_ice_handle handle,
json_t candidate,
const char **  error 
)

Helper method to parse trickle candidates.

Parameters
[in]handleThe Janus ICE handle this candidate belongs to
[in]candidateThe trickle candidate to parse, as a Jansson object
[in,out]errorError string describing the failure, if any
Returns
0 in case of success, any code from apierror.h in case of failure

◆ janus_ice_webrtc_free()

void janus_ice_webrtc_free ( janus_ice_handle handle)

Method to only free the WebRTC related resources allocated by a Janus ICE handle.

Parameters
[in]handleThe Janus ICE handle instance managing the WebRTC resources to free

◆ janus_ice_webrtc_hangup()

void janus_ice_webrtc_hangup ( janus_ice_handle handle,
const char *  reason 
)

Method to only hangup (e.g., DTLS alert) the WebRTC PeerConnection allocated by a Janus ICE handle.

Parameters
[in]handleThe Janus ICE handle instance managing the WebRTC PeerConnection to hangup
[in]reasonA description of why this happened

◆ janus_plugin_session_is_alive()

gboolean janus_plugin_session_is_alive ( janus_plugin_session plugin_session)

Quick helper method to check if a plugin session associated with a Janus handle is still valid.

Parameters
plugin_sessionThe janus_plugin_session instance to validate
Returns
true if the plugin session is valid, false otherwise

◆ janus_set_max_nack_queue()

void janus_set_max_nack_queue ( uint  mnq)

Method to modify the max NACK value (i.e., the number of packets per handle to store for retransmissions)

Parameters
[in]mnqThe new max NACK value

◆ janus_set_no_media_timer()

void janus_set_no_media_timer ( uint  timer)

Method to modify the no-media event timer (i.e., the number of seconds where no media arrives before Janus notifies this)

Parameters
[in]timerThe new timer value, in seconds

Variable Documentation

◆ handles_watchdog

GThread* handles_watchdog = NULL

◆ handles_watchdog_loop

GMainLoop* handles_watchdog_loop = NULL

◆ ice_list_mutex

janus_mutex ice_list_mutex

◆ janus_ice_enforce_list

GList* janus_ice_enforce_list = NULL

◆ janus_ice_ignore_list

GList * janus_ice_ignore_list = NULL

◆ rtp_range_max

uint16_t rtp_range_max = 0

◆ rtp_range_min

uint16_t rtp_range_min = 0