summaryrefslogtreecommitdiff
path: root/farstream/fs-candidate.h
blob: 5abedb9327b9229feedb8f8f1c507d5a00496af4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
 * Farstream - Farstream Candidate
 *
 * Copyright 2007 Collabora Ltd.
 *  @author: Philippe Kalaf <philippe.kalaf@collabora.co.uk>
 * Copyright 2007 Nokia Corp.
 *
 * fs-candidate.h - A Farstream candidate
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 */

#ifndef __FS_CANDIDATE_H__
#define __FS_CANDIDATE_H__

#include <glib.h>
#include <glib-object.h>

G_BEGIN_DECLS

#define FS_TYPE_CANDIDATE \
  (fs_candidate_get_type ())


#define FS_TYPE_CANDIDATE_LIST \
  (fs_candidate_list_get_type ())

/**
 * FsCandidateType:
 * @FS_CANDIDATE_TYPE_HOST: A host candidate (local)
 * @FS_CANDIDATE_TYPE_SRFLX: A server reflexive candidate.
 * @FS_CANDIDATE_TYPE_PRFLX: A peer reflexive candidate
 * @FS_CANDIDATE_TYPE_RELAY: An relay candidate
 * @FS_CANDIDATE_TYPE_MULTICAST: A multicast address
 *
 * An enum for the type of candidate used/reported
 */
typedef enum
{
  FS_CANDIDATE_TYPE_HOST,
  FS_CANDIDATE_TYPE_SRFLX,
  FS_CANDIDATE_TYPE_PRFLX,
  FS_CANDIDATE_TYPE_RELAY,    /* An external stream relay */
  FS_CANDIDATE_TYPE_MULTICAST
} FsCandidateType;

/**
 * FsNetworkProtocol:
 * @FS_NETWORK_PROTOCOL_UDP: A UDP based protocol
 * @FS_NETWORK_PROTOCOL_TCP: A TCP based protocol, will listen for
 * incoming connections
 * @FS_NETWORK_PROTOCOL_TCP_PASSIVE: A TCP based protocol, will listen for
 * incoming connections
 * @FS_NETWORK_PROTOCOL_TCP_ACTIVE: A TCP based protocol, will attempt to
 * open an outbound connection
 * @FS_NETWORK_PROTOCOL_TCP_SO: A TCP based protocol, will listen for
 * incoming connections and attempt an outbound connection at the same time
 * as the peer (Simultanuous-Open)
 *
 * An enum for the base IP protocol
 */
typedef enum
{
  FS_NETWORK_PROTOCOL_UDP,
  FS_NETWORK_PROTOCOL_TCP,
  FS_NETWORK_PROTOCOL_TCP_PASSIVE = FS_NETWORK_PROTOCOL_TCP,
  FS_NETWORK_PROTOCOL_TCP_ACTIVE,
  FS_NETWORK_PROTOCOL_TCP_SO,
} FsNetworkProtocol;

/**
 * FsComponentType:
 * @FS_COMPONENT_NONE: Use this when specifying a component is innapropriate
 * @FS_COMPONENT_RTP: This component is for RTP data
 * @FS_COMPONENT_RTCP: This component is for RTCP control
 *
 * This enum contains the component IDs defined in ICE-19
 */

typedef enum
{
  FS_COMPONENT_NONE = 0,
  FS_COMPONENT_RTP = 1,
  FS_COMPONENT_RTCP = 2
} FsComponentType;


typedef struct _FsCandidate FsCandidate;

/**
 * FsCandidate:
 * @foundation: a string representing the foundation of this candidate (maximum 32 chars)
 * @component_id: value between 1 and 256 indicating which component this candidate represents (1 is RTP, 2 is RTCP, #FsComponentType can be used here)
 * @ip: IP in dotted format
 * @port: Port to use
 * @base_ip: IP of base in dotted format as defined in ICE-19.
 * @base_port: Port of base as defined in ICE-19.
 * @proto: #FsNetworkProtocol for ip protocol to use as candidate
 * @priority: Value between 0 and (2^31 - 1) representing the priority
 * @type: The #FsCandidateType of the candidate
 * @username: Username to use to connect to client if necessary,
 *            NULL otherwise
 * @password: Username to use to connect to client if necessary,
 *            NULL otherwise
 * @ttl: The TTL used when sending Multicast packet (0 = auto)
 *
 * Struct to hold information about ICE-19 compliant candidates
 */
struct _FsCandidate
{
  gchar *foundation;
  guint component_id;
  gchar *ip;
  guint16 port;
  gchar *base_ip;
  guint16 base_port;
  FsNetworkProtocol proto;
  guint32 priority;
  FsCandidateType type;
  gchar *username;
  gchar *password;
  guint ttl;
};

GType fs_candidate_get_type (void);
GType fs_candidate_list_get_type (void);

void fs_candidate_destroy (FsCandidate *cand);

FsCandidate *fs_candidate_copy (const FsCandidate *cand);

void fs_candidate_list_destroy (GList *candidate_list);

GList *fs_candidate_list_copy (const GList *candidate_list);

FsCandidate *fs_candidate_new (
    const gchar *foundation,
    guint component_id,
    FsCandidateType type,
    FsNetworkProtocol proto,
    const gchar *ip,
    guint port);

FsCandidate *fs_candidate_new_full (
  const gchar *foundation,
  guint component_id,
  const gchar *ip,
  guint16 port,
  const gchar *base_ip,
  guint16 base_port,
  FsNetworkProtocol proto,
  guint32 priority,
  FsCandidateType type,
  const gchar *username,
  const gchar *password,
  guint ttl);

void fs_value_set_candidate_list (GValue *value, GList *candidates);


G_END_DECLS
#endif /* __FS_CANDIDATE_H__ */