agent.h 2.79 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"
Dafydd Harries's avatar
Dafydd Harries committed
10
#include "random.h"
11

Dafydd Harries's avatar
Dafydd Harries committed
12
G_BEGIN_DECLS
13

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

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

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

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

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

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

struct _NiceAgentClass
{
  GObjectClass parent_class;
};

GType nice_agent_get_type (void);

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

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

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

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

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

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

Dafydd Harries's avatar
Dafydd Harries committed
108 109 110 111 112 113 114 115 116
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
117 118 119
GSList *
nice_agent_poll_read (
  NiceAgent *agent,
120 121 122
  GSList *other_fds,
  NiceAgentRecvFunc func,
  gpointer data);
Dafydd Harries's avatar
Dafydd Harries committed
123

Dafydd Harries's avatar
Dafydd Harries committed
124 125 126 127 128 129
void
nice_agent_send (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  guint len,
130
  const gchar *buf);
Dafydd Harries's avatar
Dafydd Harries committed
131

132
GSList *
133
nice_agent_get_local_candidates (
134 135 136
  NiceAgent *agent,
  guint stream_id,
  guint component_id);
Dafydd Harries's avatar
Dafydd Harries committed
137

138 139 140 141 142 143
GSList *
nice_agent_get_remote_candidates (
  NiceAgent *agent,
  guint stream_id,
  guint component_id);

144 145 146 147 148 149 150
gboolean
nice_agent_main_context_attach (
  NiceAgent *agent,
  GMainContext *ctx,
  NiceAgentRecvFunc func,
  gpointer data);

Dafydd Harries's avatar
Dafydd Harries committed
151 152
G_END_DECLS

Dafydd Harries's avatar
Dafydd Harries committed
153 154
#endif /* _AGENT_H */