1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 1.4 +/* 1.5 +Copyright (c) 2007, Adobe Systems, Incorporated 1.6 +All rights reserved. 1.7 + 1.8 +Redistribution and use in source and binary forms, with or without 1.9 +modification, are permitted provided that the following conditions are 1.10 +met: 1.11 + 1.12 +* Redistributions of source code must retain the above copyright 1.13 + notice, this list of conditions and the following disclaimer. 1.14 + 1.15 +* Redistributions in binary form must reproduce the above copyright 1.16 + notice, this list of conditions and the following disclaimer in the 1.17 + documentation and/or other materials provided with the distribution. 1.18 + 1.19 +* Neither the name of Adobe Systems, Network Resonance nor the names of its 1.20 + contributors may be used to endorse or promote products derived from 1.21 + this software without specific prior written permission. 1.22 + 1.23 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.24 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.25 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.26 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.27 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.28 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.29 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.30 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.31 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.32 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.33 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.34 +*/ 1.35 + 1.36 + 1.37 + 1.38 +#ifndef _ice_candidate_h 1.39 +#define _ice_candidate_h 1.40 +#ifdef __cplusplus 1.41 +using namespace std; 1.42 +extern "C" { 1.43 +#endif /* __cplusplus */ 1.44 + 1.45 +typedef enum {HOST=1, SERVER_REFLEXIVE, PEER_REFLEXIVE, RELAYED, CTYPE_MAX} nr_ice_candidate_type; 1.46 + 1.47 +struct nr_ice_candidate_ { 1.48 + char *label; 1.49 + char codeword[5]; 1.50 + int state; 1.51 +#define NR_ICE_CAND_STATE_CREATED 1 1.52 +#define NR_ICE_CAND_STATE_INITIALIZING 2 1.53 +#define NR_ICE_CAND_STATE_INITIALIZED 3 1.54 +#define NR_ICE_CAND_STATE_FAILED 4 1.55 +#define NR_ICE_CAND_PEER_CANDIDATE_UNPAIRED 9 1.56 +#define NR_ICE_CAND_PEER_CANDIDATE_PAIRED 10 1.57 + struct nr_ice_ctx_ *ctx; 1.58 + nr_ice_socket *isock; /* The socket to read from 1.59 + (it contains all other candidates 1.60 + on this socket) */ 1.61 + nr_socket *osock; /* The socket to write to */ 1.62 + nr_ice_media_stream *stream; /* The media stream this is associated with */ 1.63 + nr_ice_component *component; /* The component this is associated with */ 1.64 + nr_ice_candidate_type type; /* The type of the candidate (S 4.1.1) */ 1.65 + UCHAR component_id; /* The component id (S 4.1.2.1) */ 1.66 + nr_transport_addr addr; /* The advertised address; 1.67 + JDR calls this the candidate */ 1.68 + nr_transport_addr base; /* The base address (S 2.1)*/ 1.69 + char *foundation; /* Foundation for the candidate (S 4) */ 1.70 + UINT4 priority; /* The priority value (S 5.4 */ 1.71 + nr_ice_stun_server *stun_server; 1.72 + nr_transport_addr stun_server_addr; /* Resolved STUN server address */ 1.73 + void *delay_timer; 1.74 + void *resolver_handle; 1.75 + 1.76 + /* Holding data for STUN and TURN */ 1.77 + union { 1.78 + struct { 1.79 + nr_stun_client_ctx *stun; 1.80 + void *stun_handle; 1.81 + } srvrflx; 1.82 + struct { 1.83 + nr_turn_client_ctx *turn; 1.84 + nr_ice_turn_server *server; 1.85 + nr_ice_candidate *srvflx_candidate; 1.86 + nr_socket *turn_sock; 1.87 + void *turn_handle; 1.88 + } relayed; 1.89 + } u; 1.90 + 1.91 + NR_async_cb done_cb; 1.92 + void *cb_arg; 1.93 + 1.94 + NR_async_cb ready_cb; 1.95 + void *ready_cb_arg; 1.96 + void *ready_cb_timer; 1.97 + 1.98 + TAILQ_ENTRY(nr_ice_candidate_) entry_sock; 1.99 + TAILQ_ENTRY(nr_ice_candidate_) entry_comp; 1.100 +}; 1.101 + 1.102 +extern char *nr_ice_candidate_type_names[]; 1.103 + 1.104 + 1.105 +int nr_ice_candidate_create(struct nr_ice_ctx_ *ctx,nr_ice_component *component, nr_ice_socket *isock, nr_socket *osock, nr_ice_candidate_type ctype, nr_ice_stun_server *stun_server, UCHAR component_id, nr_ice_candidate **candp); 1.106 +int nr_ice_candidate_initialize(nr_ice_candidate *cand, NR_async_cb ready_cb, void *cb_arg); 1.107 +void nr_ice_candidate_compute_codeword(nr_ice_candidate *cand); 1.108 +int nr_ice_candidate_process_stun(nr_ice_candidate *cand, UCHAR *msg, int len, nr_transport_addr *faddr); 1.109 +int nr_ice_candidate_destroy(nr_ice_candidate **candp); 1.110 +void nr_ice_candidate_destroy_cb(NR_SOCKET s, int h, void *cb_arg); 1.111 +int nr_ice_format_candidate_attribute(nr_ice_candidate *cand, char *attr, int maxlen); 1.112 +int nr_ice_peer_candidate_from_attribute(nr_ice_ctx *ctx,char *attr,nr_ice_media_stream *stream,nr_ice_candidate **candp); 1.113 +int nr_ice_peer_peer_rflx_candidate_create(nr_ice_ctx *ctx,char *label, nr_ice_component *comp,nr_transport_addr *addr, nr_ice_candidate **candp); 1.114 +int nr_ice_candidate_compute_priority(nr_ice_candidate *cand); 1.115 + 1.116 +#ifdef __cplusplus 1.117 +} 1.118 +#endif /* __cplusplus */ 1.119 +#endif 1.120 +