agent.h 2.55 KB
Newer Older
Dafydd Harries's avatar
Dafydd Harries committed
1
2
3
4

#ifndef _AGENT_H
#define _AGENT_H

Dafydd Harries's avatar
Dafydd Harries committed
5
#include <glib-object.h>
6
7

#include "udp.h"
8
#include "address.h"
Dafydd Harries's avatar
Dafydd Harries committed
9
#include "candidate.h"
10

Dafydd Harries's avatar
Dafydd Harries committed
11
G_BEGIN_DECLS
12

Dafydd Harries's avatar
Dafydd Harries committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#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))

35
36
37
38
39
40
41
typedef enum
{
  NICE_COMPONENT_STATE_DISCONNECTED,
  NICE_COMPONENT_STATE_CONNECTING,
  NICE_COMPONENT_STATE_CONNECTED,
} NiceComponentState;

42
typedef struct _NiceAgent NiceAgent;
Dafydd Harries's avatar
Dafydd Harries committed
43

44
45
46
47
typedef void (*NiceAgentRecvFunc) (
  NiceAgent *agent, guint stream_id, guint component_id, guint len,
  gchar *buf, gpointer user_data);

48
struct _NiceAgent
Dafydd Harries's avatar
Dafydd Harries committed
49
{
Dafydd Harries's avatar
Dafydd Harries committed
50
  GObject parent;
Dafydd Harries's avatar
Dafydd Harries committed
51
  guint next_candidate_id;
Dafydd Harries's avatar
Dafydd Harries committed
52
  guint next_stream_id;
Dafydd Harries's avatar
Dafydd Harries committed
53
  NiceUDPSocketFactory *socket_factory;
Dafydd Harries's avatar
Dafydd Harries committed
54
55
  GSList *local_addresses;
  GSList *local_candidates;
56
  GSList *remote_candidates;
Dafydd Harries's avatar
Dafydd Harries committed
57
  GSList *streams;
58
59
60
61
  gboolean main_context_set;
  GMainContext *main_context;
  NiceAgentRecvFunc read_func;
  gpointer read_func_data;
Dafydd Harries's avatar
Dafydd Harries committed
62
63
};

Dafydd Harries's avatar
Dafydd Harries committed
64
65
66
67
68
69
70
71
72
typedef struct _NiceAgentClass NiceAgentClass;

struct _NiceAgentClass
{
  GObjectClass parent_class;
};

GType nice_agent_get_type (void);

73
NiceAgent *
Dafydd Harries's avatar
Dafydd Harries committed
74
nice_agent_new (NiceUDPSocketFactory *factory);
75

Dafydd Harries's avatar
Dafydd Harries committed
76
void
77
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
78

Dafydd Harries's avatar
Dafydd Harries committed
79
guint
80
81
nice_agent_add_stream (
  NiceAgent *agent,
82
  guint n_components);
83

Dafydd Harries's avatar
Dafydd Harries committed
84
85
86
87
88
void
nice_agent_remove_stream (
  NiceAgent *agent,
  guint stream_id);

89
void
90
91
nice_agent_add_remote_candidate (
  NiceAgent *agent,
92
93
  guint stream_id,
  guint component_id,
94
95
  NiceCandidateType type,
  NiceAddress *addr,
96
97
  const gchar *username,
  const gchar *password);
98

Dafydd Harries's avatar
Dafydd Harries committed
99
guint
100
nice_agent_recv (
Dafydd Harries's avatar
Dafydd Harries committed
101
102
103
104
105
106
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  guint buf_len,
  gchar *buf);

Dafydd Harries's avatar
Dafydd Harries committed
107
108
109
GSList *
nice_agent_poll_read (
  NiceAgent *agent,
110
111
112
  GSList *other_fds,
  NiceAgentRecvFunc func,
  gpointer data);
Dafydd Harries's avatar
Dafydd Harries committed
113

Dafydd Harries's avatar
Dafydd Harries committed
114
115
116
117
118
119
void
nice_agent_send (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  guint len,
120
  const gchar *buf);
Dafydd Harries's avatar
Dafydd Harries committed
121

122
GSList *
123
nice_agent_get_local_candidates (
124
125
126
  NiceAgent *agent,
  guint stream_id,
  guint component_id);
Dafydd Harries's avatar
Dafydd Harries committed
127

128
129
130
131
132
133
134
gboolean
nice_agent_main_context_attach (
  NiceAgent *agent,
  GMainContext *ctx,
  NiceAgentRecvFunc func,
  gpointer data);

Dafydd Harries's avatar
Dafydd Harries committed
135
136
G_END_DECLS

Dafydd Harries's avatar
Dafydd Harries committed
137
138
#endif /* _AGENT_H */