agent.h 2.74 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 61
};

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

struct _NiceAgentClass
{
  GObjectClass parent_class;
};

GType nice_agent_get_type (void);

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

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

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

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

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

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

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

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

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

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

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

Dafydd Harries's avatar
Dafydd Harries committed
148 149
G_END_DECLS

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