michael@0: /* michael@0: Copyright (c) 2007, Adobe Systems, Incorporated michael@0: All rights reserved. michael@0: michael@0: Redistribution and use in source and binary forms, with or without michael@0: modification, are permitted provided that the following conditions are michael@0: met: michael@0: michael@0: * Redistributions of source code must retain the above copyright michael@0: notice, this list of conditions and the following disclaimer. michael@0: michael@0: * Redistributions in binary form must reproduce the above copyright michael@0: notice, this list of conditions and the following disclaimer in the michael@0: documentation and/or other materials provided with the distribution. michael@0: michael@0: * Neither the name of Adobe Systems, Network Resonance nor the names of its michael@0: contributors may be used to endorse or promote products derived from michael@0: this software without specific prior written permission. michael@0: michael@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT michael@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, michael@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY michael@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: michael@0: michael@0: michael@0: #ifndef _ice_component_h michael@0: #define _ice_component_h michael@0: #ifdef __cplusplus michael@0: using namespace std; michael@0: extern "C" { michael@0: #endif /* __cplusplus */ michael@0: michael@0: typedef struct nr_ice_pre_answer_request_ { michael@0: nr_stun_server_request req; michael@0: char *username; michael@0: nr_transport_addr local_addr; michael@0: michael@0: STAILQ_ENTRY(nr_ice_pre_answer_request_) entry; michael@0: } nr_ice_pre_answer_request; michael@0: michael@0: typedef STAILQ_HEAD(nr_ice_pre_answer_request_head_, nr_ice_pre_answer_request_) nr_ice_pre_answer_request_head; michael@0: michael@0: struct nr_ice_component_ { michael@0: int state; michael@0: #define NR_ICE_COMPONENT_UNPAIRED 0 michael@0: #define NR_ICE_COMPONENT_RUNNING 1 michael@0: #define NR_ICE_COMPONENT_NOMINATED 2 michael@0: #define NR_ICE_COMPONENT_FAILED 3 michael@0: #define NR_ICE_COMPONENT_DISABLED 4 michael@0: struct nr_ice_ctx_ *ctx; michael@0: struct nr_ice_media_stream_ *stream; michael@0: nr_ice_component *local_component; michael@0: michael@0: int component_id; michael@0: nr_ice_socket_head sockets; michael@0: nr_ice_candidate_head candidates; michael@0: int candidate_ct; michael@0: nr_ice_pre_answer_request_head pre_answer_reqs; michael@0: michael@0: int valid_pairs; michael@0: struct nr_ice_cand_pair_ *nominated; /* Highest priority nomninated pair */ michael@0: struct nr_ice_cand_pair_ *active; michael@0: michael@0: int keepalive_needed; michael@0: void *keepalive_timer; michael@0: nr_stun_client_ctx *keepalive_ctx; michael@0: michael@0: STAILQ_ENTRY(nr_ice_component_)entry; michael@0: }; michael@0: michael@0: typedef STAILQ_HEAD(nr_ice_component_head_,nr_ice_component_) nr_ice_component_head; michael@0: michael@0: int nr_ice_component_create(struct nr_ice_media_stream_ *stream, int component_id, nr_ice_component **componentp); michael@0: int nr_ice_component_destroy(nr_ice_component **componentp); michael@0: int nr_ice_component_initialize(struct nr_ice_ctx_ *ctx,nr_ice_component *component); michael@0: int nr_ice_component_maybe_prune_candidate(nr_ice_ctx *ctx, nr_ice_component *comp, nr_ice_candidate *c1, int *was_pruned); michael@0: int nr_ice_component_pair_candidate(nr_ice_peer_ctx *pctx, nr_ice_component *pcomp, nr_ice_candidate *lcand, int pair_all_remote); michael@0: int nr_ice_component_pair_candidates(nr_ice_peer_ctx *pctx, nr_ice_component *lcomp, nr_ice_component *pcomp); michael@0: int nr_ice_component_service_pre_answer_requests(nr_ice_peer_ctx *pctx, nr_ice_component *pcomp, char *username, int *serviced); michael@0: int nr_ice_component_nominated_pair(nr_ice_component *comp, nr_ice_cand_pair *pair); michael@0: int nr_ice_component_failed_pair(nr_ice_component *comp, nr_ice_cand_pair *pair); michael@0: int nr_ice_component_select_pair(nr_ice_peer_ctx *pctx, nr_ice_component *comp); michael@0: int nr_ice_component_set_failed(nr_ice_component *comp); michael@0: int nr_ice_component_finalize(nr_ice_component *lcomp, nr_ice_component *rcomp); michael@0: int nr_ice_component_insert_pair(nr_ice_component *pcomp, nr_ice_cand_pair *pair); michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif /* __cplusplus */ michael@0: #endif