agent.h 2.76 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 *streams;
56 57 58 59
  gboolean main_context_set;
  GMainContext *main_context;
  NiceAgentRecvFunc read_func;
  gpointer read_func_data;
Dafydd Harries's avatar
Dafydd Harries committed
60
  gchar *stun_server;
Dafydd Harries's avatar
Dafydd Harries committed
61 62
};

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

struct _NiceAgentClass
{
  GObjectClass parent_class;
};

GType nice_agent_get_type (void);

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

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

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

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

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

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

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

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

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

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

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

Dafydd Harries's avatar
Dafydd Harries committed
149 150
G_END_DECLS

Dafydd Harries's avatar
Dafydd Harries committed
151 152
#endif /* _AGENT_H */