agent.h 2.38 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
typedef struct _NiceAgent NiceAgent;
Dafydd Harries's avatar
Dafydd Harries committed
36

37 38 39 40
typedef void (*NiceAgentRecvFunc) (
  NiceAgent *agent, guint stream_id, guint component_id, guint len,
  gchar *buf, gpointer user_data);

41
struct _NiceAgent
Dafydd Harries's avatar
Dafydd Harries committed
42
{
Dafydd Harries's avatar
Dafydd Harries committed
43
  GObject parent;
Dafydd Harries's avatar
Dafydd Harries committed
44
  guint next_candidate_id;
Dafydd Harries's avatar
Dafydd Harries committed
45
  guint next_stream_id;
Dafydd Harries's avatar
Dafydd Harries committed
46
  NiceUDPSocketFactory *socket_factory;
Dafydd Harries's avatar
Dafydd Harries committed
47 48
  GSList *local_addresses;
  GSList *local_candidates;
49
  GSList *remote_candidates;
Dafydd Harries's avatar
Dafydd Harries committed
50
  GSList *streams;
51 52 53 54
  gboolean main_context_set;
  GMainContext *main_context;
  NiceAgentRecvFunc read_func;
  gpointer read_func_data;
Dafydd Harries's avatar
Dafydd Harries committed
55 56
};

Dafydd Harries's avatar
Dafydd Harries committed
57 58 59 60 61 62 63 64 65
typedef struct _NiceAgentClass NiceAgentClass;

struct _NiceAgentClass
{
  GObjectClass parent_class;
};

GType nice_agent_get_type (void);

66
NiceAgent *
Dafydd Harries's avatar
Dafydd Harries committed
67
nice_agent_new (NiceUDPSocketFactory *factory);
68

Dafydd Harries's avatar
Dafydd Harries committed
69
void
70
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
71

Dafydd Harries's avatar
Dafydd Harries committed
72
guint
73 74
nice_agent_add_stream (
  NiceAgent *agent,
75
  guint n_components);
76

Dafydd Harries's avatar
Dafydd Harries committed
77 78 79 80 81
void
nice_agent_remove_stream (
  NiceAgent *agent,
  guint stream_id);

82
void
83 84
nice_agent_add_remote_candidate (
  NiceAgent *agent,
85 86
  guint stream_id,
  guint component_id,
87 88
  NiceCandidateType type,
  NiceAddress *addr,
89 90
  const gchar *username,
  const gchar *password);
91

Dafydd Harries's avatar
Dafydd Harries committed
92
guint
93
nice_agent_recv (
Dafydd Harries's avatar
Dafydd Harries committed
94 95 96 97 98 99
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  guint buf_len,
  gchar *buf);

Dafydd Harries's avatar
Dafydd Harries committed
100 101 102
GSList *
nice_agent_poll_read (
  NiceAgent *agent,
103 104 105
  GSList *other_fds,
  NiceAgentRecvFunc func,
  gpointer data);
Dafydd Harries's avatar
Dafydd Harries committed
106

Dafydd Harries's avatar
Dafydd Harries committed
107 108 109 110 111 112
void
nice_agent_send (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  guint len,
113
  const gchar *buf);
Dafydd Harries's avatar
Dafydd Harries committed
114

115
const GSList *
116 117
nice_agent_get_local_candidates (
  NiceAgent *agent);
Dafydd Harries's avatar
Dafydd Harries committed
118

119 120 121 122 123 124 125
gboolean
nice_agent_main_context_attach (
  NiceAgent *agent,
  GMainContext *ctx,
  NiceAgentRecvFunc func,
  gpointer data);

Dafydd Harries's avatar
Dafydd Harries committed
126 127
G_END_DECLS

Dafydd Harries's avatar
Dafydd Harries committed
128 129
#endif /* _AGENT_H */