1
/* $Id: transport_ice.h 4350 2013-02-15 03:57:31Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PJMEDIA_TRANSPORT_ICE_H__
21
#define __PJMEDIA_TRANSPORT_ICE_H__
25
* @file transport_ice.h
26
* @brief ICE capable media transport.
29
#include <pjmedia/stream.h>
30
#include <pjnath/ice_strans.h>
34
* @defgroup PJMEDIA_TRANSPORT_ICE ICE Media Transport
35
* @ingroup PJMEDIA_TRANSPORT
36
* @brief Interactive Connectivity Establishment (ICE) transport
39
* This describes the implementation of media transport using
40
* Interactive Connectivity Establishment (ICE) protocol.
47
* Structure containing callbacks to receive ICE notifications.
49
typedef struct pjmedia_ice_cb
52
* This callback will be called when ICE negotiation completes.
54
* @param tp PJMEDIA ICE transport.
55
* @param op The operation
56
* @param status Operation status.
58
void (*on_ice_complete)(pjmedia_transport *tp,
66
* This structure specifies ICE transport specific info. This structure
67
* will be filled in media transport specific info.
69
typedef struct pjmedia_ice_transport_info
72
* Specifies whether ICE is used, i.e. SDP offer and answer indicates
73
* that both parties support ICE and ICE should be used for the session.
80
pj_ice_strans_state sess_state;
85
pj_ice_sess_role role;
88
* Number of components in the component array. Before ICE negotiation
89
* is complete, the number represents the number of components of the
90
* local agent. After ICE negotiation has been completed successfully,
91
* the number represents the number of common components between local
97
* Array of ICE components. Typically the first element denotes RTP and
98
* second element denotes RTCP.
103
* Local candidate type.
105
pj_ice_cand_type lcand_type;
110
pj_sockaddr lcand_addr;
113
* Remote candidate type.
115
pj_ice_cand_type rcand_type;
120
pj_sockaddr rcand_addr;
124
} pjmedia_ice_transport_info;
128
* Options that can be specified when creating ICE transport.
130
enum pjmedia_transport_ice_options
133
* Normally when remote doesn't use ICE, the ICE transport will
134
* continuously check the source address of incoming packets to see
135
* if it is different than the configured remote address, and switch
136
* the remote address to the source address of the packet if they
137
* are different after several packets are received.
138
* Specifying this option will disable this feature.
140
PJMEDIA_ICE_NO_SRC_ADDR_CHECKING = 1
145
* Create the Interactive Connectivity Establishment (ICE) media transport
146
* using the specified configuration. When STUN or TURN (or both) is used,
147
* the creation operation will complete asynchronously, when STUN resolution
148
* and TURN allocation completes. When the initialization completes, the
149
* \a on_ice_complete() complete will be called with \a op parameter equal
150
* to PJ_ICE_STRANS_OP_INIT.
152
* In addition, this transport will also notify the application about the
153
* result of ICE negotiation, also in \a on_ice_complete() callback. In this
154
* case the callback will be called with \a op parameter equal to
155
* PJ_ICE_STRANS_OP_NEGOTIATION.
157
* Other than this, application should use the \ref PJMEDIA_TRANSPORT API
158
* to manipulate this media transport.
160
* @param endpt The media endpoint.
161
* @param name Optional name to identify this ICE media transport
162
* for logging purposes.
163
* @param comp_cnt Number of components to be created.
164
* @param cfg Pointer to configuration settings.
165
* @param cb Optional structure containing ICE specific callbacks.
166
* @param p_tp Pointer to receive the media transport instance.
168
* @return PJ_SUCCESS on success, or the appropriate error code.
170
PJ_DECL(pj_status_t) pjmedia_ice_create(pjmedia_endpt *endpt,
173
const pj_ice_strans_cfg *cfg,
174
const pjmedia_ice_cb *cb,
175
pjmedia_transport **p_tp);
179
* The same as #pjmedia_ice_create() with additional \a options param.
181
* @param endpt The media endpoint.
182
* @param name Optional name to identify this ICE media transport
183
* for logging purposes.
184
* @param comp_cnt Number of components to be created.
185
* @param cfg Pointer to configuration settings.
186
* @param cb Optional structure containing ICE specific callbacks.
187
* @param options Options, see #pjmedia_transport_ice_options.
188
* @param p_tp Pointer to receive the media transport instance.
190
* @return PJ_SUCCESS on success, or the appropriate error code.
192
PJ_DECL(pj_status_t) pjmedia_ice_create2(pjmedia_endpt *endpt,
195
const pj_ice_strans_cfg *cfg,
196
const pjmedia_ice_cb *cb,
198
pjmedia_transport **p_tp);
201
* The same as #pjmedia_ice_create2() with additional \a user_data param.
203
* @param endpt The media endpoint.
204
* @param name Optional name to identify this ICE media transport
205
* for logging purposes.
206
* @param comp_cnt Number of components to be created.
207
* @param cfg Pointer to configuration settings.
208
* @param cb Optional structure containing ICE specific callbacks.
209
* @param options Options, see #pjmedia_transport_ice_options.
210
* @param user_data User data to be attached to the transport.
211
* @param p_tp Pointer to receive the media transport instance.
213
* @return PJ_SUCCESS on success, or the appropriate error code.
215
PJ_DECL(pj_status_t) pjmedia_ice_create3(pjmedia_endpt *endpt,
218
const pj_ice_strans_cfg *cfg,
219
const pjmedia_ice_cb *cb,
222
pjmedia_transport **p_tp);
232
#endif /* __PJMEDIA_TRANSPORT_ICE_H__ */