1
/* $Id: transport_ice.h 3872 2011-10-28 04:27:41Z bennylp $ */
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
74
pj_ice_strans_state sess_state;
79
pj_ice_sess_role role;
82
* Number of components in the component array. Before ICE negotiation
83
* is complete, the number represents the number of components of the
84
* local agent. After ICE negotiation has been completed successfully,
85
* the number represents the number of common components between local
91
* Array of ICE components. Typically the first element denotes RTP and
92
* second element denotes RTCP.
97
* Local candidate type.
99
pj_ice_cand_type lcand_type;
104
pj_sockaddr lcand_addr;
107
* Remote candidate type.
109
pj_ice_cand_type rcand_type;
114
pj_sockaddr rcand_addr;
118
} pjmedia_ice_transport_info;
122
* Options that can be specified when creating ICE transport.
124
enum pjmedia_transport_ice_options
127
* Normally when remote doesn't use ICE, the ICE transport will
128
* continuously check the source address of incoming packets to see
129
* if it is different than the configured remote address, and switch
130
* the remote address to the source address of the packet if they
131
* are different after several packets are received.
132
* Specifying this option will disable this feature.
134
PJMEDIA_ICE_NO_SRC_ADDR_CHECKING = 1
139
* Create the Interactive Connectivity Establishment (ICE) media transport
140
* using the specified configuration. When STUN or TURN (or both) is used,
141
* the creation operation will complete asynchronously, when STUN resolution
142
* and TURN allocation completes. When the initialization completes, the
143
* \a on_ice_complete() complete will be called with \a op parameter equal
144
* to PJ_ICE_STRANS_OP_INIT.
146
* In addition, this transport will also notify the application about the
147
* result of ICE negotiation, also in \a on_ice_complete() callback. In this
148
* case the callback will be called with \a op parameter equal to
149
* PJ_ICE_STRANS_OP_NEGOTIATION.
151
* Other than this, application should use the \ref PJMEDIA_TRANSPORT API
152
* to manipulate this media transport.
154
* @param endpt The media endpoint.
155
* @param name Optional name to identify this ICE media transport
156
* for logging purposes.
157
* @param comp_cnt Number of components to be created.
158
* @param cfg Pointer to configuration settings.
159
* @param cb Optional structure containing ICE specific callbacks.
160
* @param p_tp Pointer to receive the media transport instance.
162
* @return PJ_SUCCESS on success, or the appropriate error code.
164
PJ_DECL(pj_status_t) pjmedia_ice_create(pjmedia_endpt *endpt,
167
const pj_ice_strans_cfg *cfg,
168
const pjmedia_ice_cb *cb,
169
pjmedia_transport **p_tp);
173
* The same as #pjmedia_ice_create() with additional \a options param.
175
* @param endpt The media endpoint.
176
* @param name Optional name to identify this ICE media transport
177
* for logging purposes.
178
* @param comp_cnt Number of components to be created.
179
* @param cfg Pointer to configuration settings.
180
* @param cb Optional structure containing ICE specific callbacks.
181
* @param options Options, see #pjmedia_transport_ice_options.
182
* @param p_tp Pointer to receive the media transport instance.
184
* @return PJ_SUCCESS on success, or the appropriate error code.
186
PJ_DECL(pj_status_t) pjmedia_ice_create2(pjmedia_endpt *endpt,
189
const pj_ice_strans_cfg *cfg,
190
const pjmedia_ice_cb *cb,
192
pjmedia_transport **p_tp);
195
* The same as #pjmedia_ice_create2() with additional \a user_data param.
197
* @param endpt The media endpoint.
198
* @param name Optional name to identify this ICE media transport
199
* for logging purposes.
200
* @param comp_cnt Number of components to be created.
201
* @param cfg Pointer to configuration settings.
202
* @param cb Optional structure containing ICE specific callbacks.
203
* @param options Options, see #pjmedia_transport_ice_options.
204
* @param user_data User data to be attached to the transport.
205
* @param p_tp Pointer to receive the media transport instance.
207
* @return PJ_SUCCESS on success, or the appropriate error code.
209
PJ_DECL(pj_status_t) pjmedia_ice_create3(pjmedia_endpt *endpt,
212
const pj_ice_strans_cfg *cfg,
213
const pjmedia_ice_cb *cb,
216
pjmedia_transport **p_tp);
226
#endif /* __PJMEDIA_TRANSPORT_ICE_H__ */