|
1 /* |
|
2 Copyright (c) 2007, Adobe Systems, Incorporated |
|
3 All rights reserved. |
|
4 |
|
5 Redistribution and use in source and binary forms, with or without |
|
6 modification, are permitted provided that the following conditions are |
|
7 met: |
|
8 |
|
9 * Redistributions of source code must retain the above copyright |
|
10 notice, this list of conditions and the following disclaimer. |
|
11 |
|
12 * Redistributions in binary form must reproduce the above copyright |
|
13 notice, this list of conditions and the following disclaimer in the |
|
14 documentation and/or other materials provided with the distribution. |
|
15 |
|
16 * Neither the name of Adobe Systems, Network Resonance nor the names of its |
|
17 contributors may be used to endorse or promote products derived from |
|
18 this software without specific prior written permission. |
|
19 |
|
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
31 */ |
|
32 |
|
33 |
|
34 |
|
35 #ifndef _ice_component_h |
|
36 #define _ice_component_h |
|
37 #ifdef __cplusplus |
|
38 using namespace std; |
|
39 extern "C" { |
|
40 #endif /* __cplusplus */ |
|
41 |
|
42 typedef struct nr_ice_pre_answer_request_ { |
|
43 nr_stun_server_request req; |
|
44 char *username; |
|
45 nr_transport_addr local_addr; |
|
46 |
|
47 STAILQ_ENTRY(nr_ice_pre_answer_request_) entry; |
|
48 } nr_ice_pre_answer_request; |
|
49 |
|
50 typedef STAILQ_HEAD(nr_ice_pre_answer_request_head_, nr_ice_pre_answer_request_) nr_ice_pre_answer_request_head; |
|
51 |
|
52 struct nr_ice_component_ { |
|
53 int state; |
|
54 #define NR_ICE_COMPONENT_UNPAIRED 0 |
|
55 #define NR_ICE_COMPONENT_RUNNING 1 |
|
56 #define NR_ICE_COMPONENT_NOMINATED 2 |
|
57 #define NR_ICE_COMPONENT_FAILED 3 |
|
58 #define NR_ICE_COMPONENT_DISABLED 4 |
|
59 struct nr_ice_ctx_ *ctx; |
|
60 struct nr_ice_media_stream_ *stream; |
|
61 nr_ice_component *local_component; |
|
62 |
|
63 int component_id; |
|
64 nr_ice_socket_head sockets; |
|
65 nr_ice_candidate_head candidates; |
|
66 int candidate_ct; |
|
67 nr_ice_pre_answer_request_head pre_answer_reqs; |
|
68 |
|
69 int valid_pairs; |
|
70 struct nr_ice_cand_pair_ *nominated; /* Highest priority nomninated pair */ |
|
71 struct nr_ice_cand_pair_ *active; |
|
72 |
|
73 int keepalive_needed; |
|
74 void *keepalive_timer; |
|
75 nr_stun_client_ctx *keepalive_ctx; |
|
76 |
|
77 STAILQ_ENTRY(nr_ice_component_)entry; |
|
78 }; |
|
79 |
|
80 typedef STAILQ_HEAD(nr_ice_component_head_,nr_ice_component_) nr_ice_component_head; |
|
81 |
|
82 int nr_ice_component_create(struct nr_ice_media_stream_ *stream, int component_id, nr_ice_component **componentp); |
|
83 int nr_ice_component_destroy(nr_ice_component **componentp); |
|
84 int nr_ice_component_initialize(struct nr_ice_ctx_ *ctx,nr_ice_component *component); |
|
85 int nr_ice_component_maybe_prune_candidate(nr_ice_ctx *ctx, nr_ice_component *comp, nr_ice_candidate *c1, int *was_pruned); |
|
86 int nr_ice_component_pair_candidate(nr_ice_peer_ctx *pctx, nr_ice_component *pcomp, nr_ice_candidate *lcand, int pair_all_remote); |
|
87 int nr_ice_component_pair_candidates(nr_ice_peer_ctx *pctx, nr_ice_component *lcomp, nr_ice_component *pcomp); |
|
88 int nr_ice_component_service_pre_answer_requests(nr_ice_peer_ctx *pctx, nr_ice_component *pcomp, char *username, int *serviced); |
|
89 int nr_ice_component_nominated_pair(nr_ice_component *comp, nr_ice_cand_pair *pair); |
|
90 int nr_ice_component_failed_pair(nr_ice_component *comp, nr_ice_cand_pair *pair); |
|
91 int nr_ice_component_select_pair(nr_ice_peer_ctx *pctx, nr_ice_component *comp); |
|
92 int nr_ice_component_set_failed(nr_ice_component *comp); |
|
93 int nr_ice_component_finalize(nr_ice_component *lcomp, nr_ice_component *rcomp); |
|
94 int nr_ice_component_insert_pair(nr_ice_component *pcomp, nr_ice_cand_pair *pair); |
|
95 |
|
96 #ifdef __cplusplus |
|
97 } |
|
98 #endif /* __cplusplus */ |
|
99 #endif |