1 /* 2 * Farstream - Farstream Candidate 3 * 4 * Copyright 2007 Collabora Ltd. 5 * @author: Philippe Kalaf <philippe.kalaf@collabora.co.uk> 6 * Copyright 2007 Nokia Corp. 7 * 8 * fs-candidate.h - A Farstream candidate 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef __FS_CANDIDATE_H__ 26 #define __FS_CANDIDATE_H__ 27 28 #include <glib.h> 29 #include <glib-object.h> 30 31 G_BEGIN_DECLS 32 33 #define FS_TYPE_CANDIDATE \ 34 (fs_candidate_get_type ()) 35 36 37 #define FS_TYPE_CANDIDATE_LIST \ 38 (fs_candidate_list_get_type ()) 39 40 /** 41 * FsCandidateType: 42 * @FS_CANDIDATE_TYPE_HOST: A host candidate (local) 43 * @FS_CANDIDATE_TYPE_SRFLX: A server reflexive candidate. 44 * @FS_CANDIDATE_TYPE_PRFLX: A peer reflexive candidate 45 * @FS_CANDIDATE_TYPE_RELAY: An relay candidate 46 * @FS_CANDIDATE_TYPE_MULTICAST: A multicast address 47 * 48 * An enum for the type of candidate used/reported 49 */ 50 typedef enum 51 { 52 FS_CANDIDATE_TYPE_HOST, 53 FS_CANDIDATE_TYPE_SRFLX, 54 FS_CANDIDATE_TYPE_PRFLX, 55 FS_CANDIDATE_TYPE_RELAY, /* An external stream relay */ 56 FS_CANDIDATE_TYPE_MULTICAST 57 } FsCandidateType; 58 59 /** 60 * FsNetworkProtocol: 61 * @FS_NETWORK_PROTOCOL_UDP: A UDP based protocol 62 * @FS_NETWORK_PROTOCOL_TCP: A TCP based protocol, will listen for 63 * incoming connections 64 * @FS_NETWORK_PROTOCOL_TCP_PASSIVE: A TCP based protocol, will listen for 65 * incoming connections 66 * @FS_NETWORK_PROTOCOL_TCP_ACTIVE: A TCP based protocol, will attempt to 67 * open an outbound connection 68 * @FS_NETWORK_PROTOCOL_TCP_SO: A TCP based protocol, will listen for 69 * incoming connections and attempt an outbound connection at the same time 70 * as the peer (Simultanuous-Open) 71 * 72 * An enum for the base IP protocol 73 */ 74 typedef enum 75 { 76 FS_NETWORK_PROTOCOL_UDP, 77 FS_NETWORK_PROTOCOL_TCP, 78 FS_NETWORK_PROTOCOL_TCP_PASSIVE = FS_NETWORK_PROTOCOL_TCP, 79 FS_NETWORK_PROTOCOL_TCP_ACTIVE, 80 FS_NETWORK_PROTOCOL_TCP_SO, 81 } FsNetworkProtocol; 82 83 /** 84 * FsComponentType: 85 * @FS_COMPONENT_NONE: Use this when specifying a component is innapropriate 86 * @FS_COMPONENT_RTP: This component is for RTP data 87 * @FS_COMPONENT_RTCP: This component is for RTCP control 88 * 89 * This enum contains the component IDs defined in ICE-19 90 */ 91 92 typedef enum 93 { 94 FS_COMPONENT_NONE = 0, 95 FS_COMPONENT_RTP = 1, 96 FS_COMPONENT_RTCP = 2 97 } FsComponentType; 98 99 100 typedef struct _FsCandidate FsCandidate; 101 102 /** 103 * FsCandidate: 104 * @foundation: a string representing the foundation of this candidate (maximum 32 chars) 105 * @component_id: value between 1 and 256 indicating which component this candidate represents (1 is RTP, 2 is RTCP, #FsComponentType can be used here) 106 * @ip: IP in dotted format 107 * @port: Port to use 108 * @base_ip: IP of base in dotted format as defined in ICE-19. 109 * @base_port: Port of base as defined in ICE-19. 110 * @proto: #FsNetworkProtocol for ip protocol to use as candidate 111 * @priority: Value between 0 and (2^31 - 1) representing the priority 112 * @type: The #FsCandidateType of the candidate 113 * @username: Username to use to connect to client if necessary, 114 * NULL otherwise 115 * @password: Username to use to connect to client if necessary, 116 * NULL otherwise 117 * @ttl: The TTL used when sending Multicast packet (0 = auto) 118 * 119 * Struct to hold information about ICE-19 compliant candidates 120 */ 121 struct _FsCandidate 122 { 123 gchar *foundation; 124 guint component_id; 125 gchar *ip; 126 guint16 port; 127 gchar *base_ip; 128 guint16 base_port; 129 FsNetworkProtocol proto; 130 guint32 priority; 131 FsCandidateType type; 132 gchar *username; 133 gchar *password; 134 guint ttl; 135 }; 136 137 GType fs_candidate_get_type (void); 138 GType fs_candidate_list_get_type (void); 139 140 void fs_candidate_destroy (FsCandidate *cand); 141 142 FsCandidate *fs_candidate_copy (const FsCandidate *cand); 143 144 void fs_candidate_list_destroy (GList *candidate_list); 145 146 GList *fs_candidate_list_copy (const GList *candidate_list); 147 148 FsCandidate *fs_candidate_new ( 149 const gchar *foundation, 150 guint component_id, 151 FsCandidateType type, 152 FsNetworkProtocol proto, 153 const gchar *ip, 154 guint port); 155 156 FsCandidate *fs_candidate_new_full ( 157 const gchar *foundation, 158 guint component_id, 159 const gchar *ip, 160 guint16 port, 161 const gchar *base_ip, 162 guint16 base_port, 163 FsNetworkProtocol proto, 164 guint32 priority, 165 FsCandidateType type, 166 const gchar *username, 167 const gchar *password, 168 guint ttl); 169 170 void fs_value_set_candidate_list (GValue *value, GList *candidates); 171 172 173 G_END_DECLS 174 #endif /* __FS_CANDIDATE_H__ */ 175