Fix bug where a discovered peer-reflexive pair does not get nominated
[sipe-libnice.git] / agent / agent-priv.h
blob231eda1dfb539ffd97e30c41df5f7d249fa375c5
1 /*
2 * This file is part of the Nice GLib ICE library.
4 * (C) 2006, 2007 Collabora Ltd.
5 * Contact: Dafydd Harries
6 * (C) 2006, 2007 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
17 * License.
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.
24 * Contributors:
25 * Dafydd Harries, Collabora Ltd.
26 * Kai Vehmanen, Nokia
28 * Alternatively, the contents of this file may be used under the terms of the
29 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
30 * case the provisions of LGPL are applicable instead of those above. If you
31 * wish to allow use of your version of this file only under the terms of the
32 * LGPL and not to allow others to use your version of this file under the
33 * MPL, indicate your decision by deleting the provisions above and replace
34 * them with the notice and other provisions required by the LGPL. If you do
35 * not delete the provisions above, a recipient may use your version of this
36 * file under either the MPL or the LGPL.
39 #ifndef _NICE_AGENT_PRIV_H
40 #define _NICE_AGENT_PRIV_H
42 /* note: this is a private header part of agent.h */
44 #include <glib.h>
46 #include "agent.h"
47 #include "socket.h"
48 #include "candidate.h"
49 #include "stream.h"
50 #include "conncheck.h"
51 #include "component.h"
52 #include "stun/stunagent.h"
53 #include "stun/usages/turn.h"
54 #include "stun/usages/ice.h"
56 /* XXX: starting from ICE ID-18, Ta SHOULD now be set according
57 * to session bandwidth -> this is not yet implemented in NICE */
59 #define NICE_AGENT_TIMER_TA_DEFAULT 20 /* timer Ta, msecs (impl. defined) */
60 #define NICE_AGENT_TIMER_TR_DEFAULT 25000 /* timer Tr, msecs (impl. defined) */
61 #define NICE_AGENT_TIMER_TR_MIN 15000 /* timer Tr, msecs (ICE ID-19) */
62 #define NICE_AGENT_MAX_CONNECTIVITY_CHECKS_DEFAULT 100 /* see spec 5.7.3 (ID-19) */
65 /** An upper limit to size of STUN packets handled (based on Ethernet
66 * MTU and estimated typical sizes of ICE STUN packet */
67 #define MAX_STUN_DATAGRAM_PAYLOAD 1300
69 struct _NiceAgent
71 GObject parent; /**< gobject pointer */
73 gboolean full_mode; /**< property: full-mode */
74 GTimeVal next_check_tv; /**< property: next conncheck timestamp */
75 gchar *stun_server_ip; /**< property: STUN server IP */
76 guint stun_server_port; /**< property: STUN server port */
77 gchar *proxy_ip; /**< property: Proxy server IP */
78 guint proxy_port; /**< property: Proxy server port */
79 NiceProxyType proxy_type; /**< property: Proxy type */
80 gchar *proxy_username; /**< property: Proxy username */
81 gchar *proxy_password; /**< property: Proxy password */
82 gboolean controlling_mode; /**< property: controlling-mode */
83 guint timer_ta; /**< property: timer Ta */
84 guint max_conn_checks; /**< property: max connectivity checks */
86 GSList *local_addresses; /**< list of NiceAddresses for local
87 interfaces */
88 GSList *streams; /**< list of Stream objects */
89 GMainContext *main_context; /**< main context pointer */
90 guint next_candidate_id; /**< id of next created candidate */
91 guint next_stream_id; /**< id of next created candidate */
92 NiceRNG *rng; /**< random number generator */
93 GSList *discovery_list; /**< list of CandidateDiscovery items */
94 guint discovery_unsched_items; /**< number of discovery items unscheduled */
95 GSource *discovery_timer_source; /**< source of discovery timer */
96 GSource *conncheck_timer_source; /**< source of conncheck timer */
97 GSource *keepalive_timer_source; /**< source of keepalive timer */
98 GSList *refresh_list; /**< list of CandidateRefresh items */
99 guint64 tie_breaker; /**< tie breaker (ICE sect 5.2
100 "Determining Role" ID-19) */
101 GStaticRecMutex mutex; /* Mutex used for thread-safe lib */
102 NiceCompatibility compatibility; /* property: Compatibility mode */
103 StunAgent stun_agent; /* STUN agent */
104 /* XXX: add pointer to internal data struct for ABI-safe extensions */
107 gboolean
108 agent_find_component (
109 NiceAgent *agent,
110 guint stream_id,
111 guint component_id,
112 Stream **stream,
113 Component **component);
115 Stream *agent_find_stream (NiceAgent *agent, guint stream_id);
117 void agent_gathering_done (NiceAgent *agent);
118 void agent_signal_gathering_done (NiceAgent *agent);
120 void agent_signal_new_selected_pair (
121 NiceAgent *agent,
122 guint stream_id,
123 guint component_id,
124 const gchar *local_foundation,
125 const gchar *remote_foundation);
127 void agent_signal_component_state_change (
128 NiceAgent *agent,
129 guint stream_id,
130 guint component_id,
131 NiceComponentState state);
133 void agent_signal_new_candidate (
134 NiceAgent *agent,
135 NiceCandidate *candidate);
137 void agent_signal_new_remote_candidate (NiceAgent *agent, NiceCandidate *candidate);
139 void agent_signal_initial_binding_request_received (NiceAgent *agent, Stream *stream);
141 guint64 agent_candidate_pair_priority (NiceAgent *agent, NiceCandidate *local, NiceCandidate *remote);
143 GSource *agent_timeout_add_with_context (NiceAgent *agent, guint interval, GSourceFunc function, gpointer data);
145 void agent_attach_stream_component_socket (NiceAgent *agent,
146 Stream *stream,
147 Component *component,
148 NiceSocket *socket);
150 StunUsageIceCompatibility agent_to_ice_compatibility (NiceAgent *agent);
151 StunUsageTurnCompatibility agent_to_turn_compatibility (NiceAgent *agent);
152 NiceTurnSocketCompatibility agent_to_turn_socket_compatibility (NiceAgent *agent);
154 #endif /*_NICE_AGENT_PRIV_H */