media/mtransport/third_party/nICEr/src/ice/ice_candidate.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2 Copyright (c) 2007, Adobe Systems, Incorporated
     3 All rights reserved.
     5 Redistribution and use in source and binary forms, with or without
     6 modification, are permitted provided that the following conditions are
     7 met:
     9 * Redistributions of source code must retain the above copyright
    10   notice, this list of conditions and the following disclaimer.
    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.
    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.
    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 */
    35 #ifndef _ice_candidate_h
    36 #define _ice_candidate_h
    37 #ifdef __cplusplus
    38 using namespace std;
    39 extern "C" {
    40 #endif /* __cplusplus */
    42 typedef enum {HOST=1, SERVER_REFLEXIVE, PEER_REFLEXIVE, RELAYED, CTYPE_MAX} nr_ice_candidate_type;
    44 struct nr_ice_candidate_ {
    45   char *label;
    46   char codeword[5];
    47   int state;
    48 #define NR_ICE_CAND_STATE_CREATED          1
    49 #define NR_ICE_CAND_STATE_INITIALIZING     2
    50 #define NR_ICE_CAND_STATE_INITIALIZED      3
    51 #define NR_ICE_CAND_STATE_FAILED           4
    52 #define NR_ICE_CAND_PEER_CANDIDATE_UNPAIRED 9
    53 #define NR_ICE_CAND_PEER_CANDIDATE_PAIRED   10
    54   struct nr_ice_ctx_ *ctx;
    55   nr_ice_socket *isock;               /* The socket to read from
    56                                          (it contains all other candidates
    57                                          on this socket) */
    58   nr_socket *osock;                   /* The socket to write to */
    59   nr_ice_media_stream *stream;        /* The media stream this is associated with */
    60   nr_ice_component *component;        /* The component this is associated with */
    61   nr_ice_candidate_type type;         /* The type of the candidate (S 4.1.1) */
    62   UCHAR component_id;                 /* The component id (S 4.1.2.1) */
    63   nr_transport_addr addr;             /* The advertised address;
    64                                          JDR calls this the candidate */
    65   nr_transport_addr base;             /* The base address (S 2.1)*/
    66   char *foundation;                   /* Foundation for the candidate (S 4) */
    67   UINT4 priority;                     /* The priority value (S 5.4 */
    68   nr_ice_stun_server *stun_server;
    69   nr_transport_addr stun_server_addr; /* Resolved STUN server address */
    70   void *delay_timer;
    71   void *resolver_handle;
    73   /* Holding data for STUN and TURN */
    74   union {
    75     struct {
    76       nr_stun_client_ctx *stun;
    77       void *stun_handle;
    78     } srvrflx;
    79     struct {
    80       nr_turn_client_ctx *turn;
    81       nr_ice_turn_server *server;
    82       nr_ice_candidate *srvflx_candidate;
    83       nr_socket *turn_sock;
    84       void *turn_handle;
    85     } relayed;
    86   } u;
    88   NR_async_cb done_cb;
    89   void *cb_arg;
    91   NR_async_cb ready_cb;
    92   void *ready_cb_arg;
    93   void *ready_cb_timer;
    95   TAILQ_ENTRY(nr_ice_candidate_) entry_sock;
    96   TAILQ_ENTRY(nr_ice_candidate_) entry_comp;
    97 };
    99 extern char *nr_ice_candidate_type_names[];
   102 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);
   103 int nr_ice_candidate_initialize(nr_ice_candidate *cand, NR_async_cb ready_cb, void *cb_arg);
   104 void nr_ice_candidate_compute_codeword(nr_ice_candidate *cand);
   105 int nr_ice_candidate_process_stun(nr_ice_candidate *cand, UCHAR *msg, int len, nr_transport_addr *faddr);
   106 int nr_ice_candidate_destroy(nr_ice_candidate **candp);
   107 void nr_ice_candidate_destroy_cb(NR_SOCKET s, int h, void *cb_arg);
   108 int nr_ice_format_candidate_attribute(nr_ice_candidate *cand, char *attr, int maxlen);
   109 int nr_ice_peer_candidate_from_attribute(nr_ice_ctx *ctx,char *attr,nr_ice_media_stream *stream,nr_ice_candidate **candp);
   110 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);
   111 int nr_ice_candidate_compute_priority(nr_ice_candidate *cand);
   113 #ifdef __cplusplus
   114 }
   115 #endif /* __cplusplus */
   116 #endif

mercurial