agent.h 5.79 KB
Newer Older
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
/*
 * This file is part of the Nice GLib ICE library.
 *
 * (C) 2006, 2007 Collabora Ltd.
 *  Contact: Dafydd Harries
 * (C) 2006, 2007 Nokia Corporation. All rights reserved.
 *  Contact: Kai Vehmanen
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is the Nice GLib ICE library.
 *
 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
 * Corporation. All Rights Reserved.
 *
 * Contributors:
 *   Dafydd Harries, Collabora Ltd.
26
 *   Kai Vehmanen, Nokia
27
28
29
30
31
32
33
34
35
36
37
 *
 * Alternatively, the contents of this file may be used under the terms of the
 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
 * case the provisions of LGPL are applicable instead of those above. If you
 * wish to allow use of your version of this file only under the terms of the
 * LGPL and not to allow others to use your version of this file under the
 * MPL, indicate your decision by deleting the provisions above and replace
 * them with the notice and other provisions required by the LGPL. If you do
 * not delete the provisions above, a recipient may use your version of this
 * file under either the MPL or the LGPL.
 */
Dafydd Harries's avatar
Dafydd Harries committed
38
39
40
41

#ifndef _AGENT_H
#define _AGENT_H

Dafydd Harries's avatar
Dafydd Harries committed
42
#include <glib-object.h>
43
44

#include "udp.h"
45
#include "address.h"
Dafydd Harries's avatar
Dafydd Harries committed
46
#include "candidate.h"
Dafydd Harries's avatar
Dafydd Harries committed
47
#include "random.h"
48

49

Dafydd Harries's avatar
Dafydd Harries committed
50
G_BEGIN_DECLS
51

Dafydd Harries's avatar
Dafydd Harries committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#define NICE_TYPE_AGENT nice_agent_get_type()

#define NICE_AGENT(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
  NICE_TYPE_AGENT, NiceAgent))

#define NICE_AGENT_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST ((klass), \
  NICE_TYPE_AGENT, NiceAgentClass))

#define NICE_IS_AGENT(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
  NICE_TYPE_AGENT))

#define NICE_IS_AGENT_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
  NICE_TYPE_AGENT))

#define NICE_AGENT_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
  NICE_TYPE_AGENT, NiceAgentClass))

74
75
76
77
78
79
80
/** 
 * A hard limit for number for remote candidates. This
 * limit is enforced to protect against malevolent remote 
 * clients.
 */
#define NICE_AGENT_MAX_REMOTE_CANDIDATES    25

81
82
typedef enum
{
83
84
85
86
87
88
  NICE_COMPONENT_STATE_DISCONNECTED, /* no activity scheduled */
  NICE_COMPONENT_STATE_GATHERING,    /* gathering local candidates */
  NICE_COMPONENT_STATE_CONNECTING,   /* establishing connectivity */
  NICE_COMPONENT_STATE_CONNECTED,    /* at least one working candidate pair */
  NICE_COMPONENT_STATE_READY,        /* ICE concluded, candidate pair
					selection is now final */
Youness Alaoui's avatar
Youness Alaoui committed
89
  NICE_COMPONENT_STATE_FAILED,       /* connectivity checks have been completed,
90
					but connectivity was not established */
Youness Alaoui's avatar
Youness Alaoui committed
91
  NICE_COMPONENT_STATE_LAST
92
93
} NiceComponentState;

94
95
96
97
98
99
typedef enum
{
  NICE_COMPONENT_TYPE_RTP = 1,
  NICE_COMPONENT_TYPE_RTCP = 2
} NiceComponentType;

100
101
typedef enum
{
102
  NICE_COMPATIBILITY_ID19 = 0,
103
104
  NICE_COMPATIBILITY_GOOGLE,
  NICE_COMPATIBILITY_MSN,
105
  NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_MSN
106
107
} NiceCompatibility;

108
typedef struct _NiceAgent NiceAgent;
Dafydd Harries's avatar
Dafydd Harries committed
109

110
111
112
113
typedef void (*NiceAgentRecvFunc) (
  NiceAgent *agent, guint stream_id, guint component_id, guint len,
  gchar *buf, gpointer user_data);

Dafydd Harries's avatar
Dafydd Harries committed
114

Dafydd Harries's avatar
Dafydd Harries committed
115
116
117
118
119
120
121
typedef struct _NiceAgentClass NiceAgentClass;

struct _NiceAgentClass
{
  GObjectClass parent_class;
};

Youness Alaoui's avatar
Youness Alaoui committed
122

Dafydd Harries's avatar
Dafydd Harries committed
123
124
GType nice_agent_get_type (void);

125
NiceAgent *
126
127
nice_agent_new (NiceUDPSocketFactory *factory,
    GMainContext *ctx, NiceCompatibility compat);
128

129
gboolean
130
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
131

Dafydd Harries's avatar
Dafydd Harries committed
132
guint
133
134
nice_agent_add_stream (
  NiceAgent *agent,
135
  guint n_components);
136

Dafydd Harries's avatar
Dafydd Harries committed
137
138
139
140
141
void
nice_agent_remove_stream (
  NiceAgent *agent,
  guint stream_id);

142
143
144
145
146
void
nice_agent_gather_candidates (
  NiceAgent *agent,
  guint stream_id);

147
148
149
150
151
152
153
154
155
156
157
158
gboolean
nice_agent_set_remote_credentials (
  NiceAgent *agent,
  guint stream_id,
  const gchar *ufrag, const gchar *pwd);

gboolean
nice_agent_get_local_credentials (
  NiceAgent *agent,
  guint stream_id,
  const gchar **ufrag, const gchar **pwd);

159
gboolean
160
161
nice_agent_add_remote_candidate (
  NiceAgent *agent,
162
163
  guint stream_id,
  guint component_id,
164
165
  NiceCandidateType type,
  NiceAddress *addr,
166
167
  const gchar *username,
  const gchar *password);
168

169
int
170
171
172
173
nice_agent_set_remote_candidates (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
174
  const GSList *candidates);
175

Dafydd Harries's avatar
Dafydd Harries committed
176
guint
177
nice_agent_recv (
Dafydd Harries's avatar
Dafydd Harries committed
178
179
180
181
182
183
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  guint buf_len,
  gchar *buf);

Dafydd Harries's avatar
Dafydd Harries committed
184
185
186
187
188
189
190
191
192
guint
nice_agent_recv_sock (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  guint sock,
  guint buf_len,
  gchar *buf);

Dafydd Harries's avatar
Dafydd Harries committed
193
194
195
GSList *
nice_agent_poll_read (
  NiceAgent *agent,
196
197
198
  GSList *other_fds,
  NiceAgentRecvFunc func,
  gpointer data);
Dafydd Harries's avatar
Dafydd Harries committed
199

200
gint
Dafydd Harries's avatar
Dafydd Harries committed
201
202
203
204
205
nice_agent_send (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  guint len,
206
  const gchar *buf);
Dafydd Harries's avatar
Dafydd Harries committed
207

208
GSList *
209
nice_agent_get_local_candidates (
210
211
212
  NiceAgent *agent,
  guint stream_id,
  guint component_id);
Dafydd Harries's avatar
Dafydd Harries committed
213

214
215
216
217
218
219
GSList *
nice_agent_get_remote_candidates (
  NiceAgent *agent,
  guint stream_id,
  guint component_id);

220
221
222
223
gboolean 
nice_agent_restart (
  NiceAgent *agent);

224
gboolean
225
nice_agent_attach_recv (
226
  NiceAgent *agent,
227
228
  guint stream_id,
  guint component_id,
229
230
231
232
  GMainContext *ctx,
  NiceAgentRecvFunc func,
  gpointer data);

233
234
235
236
237
238
239
240
gboolean 
nice_agent_set_selected_pair (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  const gchar *lfoundation,
  const gchar *rfoundation);

241
242
243
244
245
246
247
248

gboolean
nice_agent_set_selected_remote_candidate (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  NiceCandidate *candidate);

Dafydd Harries's avatar
Dafydd Harries committed
249
250
G_END_DECLS

Dafydd Harries's avatar
Dafydd Harries committed
251
252
#endif /* _AGENT_H */