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

#ifndef _AGENT_H
#define _AGENT_H

5
#include <arpa/inet.h>
6

7 8 9
#include <glib.h>

#include "udp.h"
10
#include "address.h"
Dafydd Harries's avatar
Dafydd Harries committed
11
#include "candidate.h"
12

Dafydd Harries's avatar
Dafydd Harries committed
13
G_BEGIN_DECLS
14

Dafydd Harries's avatar
Dafydd Harries committed
15 16 17
/*** event ***/


18
typedef enum _EventType EventType;
Dafydd Harries's avatar
Dafydd Harries committed
19

20
enum _EventType
Dafydd Harries's avatar
Dafydd Harries committed
21 22 23 24 25
{
  EVENT_CANDIDATE_SELECTED,
};


26
typedef struct _Event Event;
Dafydd Harries's avatar
Dafydd Harries committed
27

28
struct _Event
Dafydd Harries's avatar
Dafydd Harries committed
29
{
Dafydd Harries's avatar
Dafydd Harries committed
30
  EventType type;
Dafydd Harries's avatar
Dafydd Harries committed
31 32 33

  union {
    struct {
34
      NiceAddress *addr;
Dafydd Harries's avatar
Dafydd Harries committed
35 36 37
      guint candidate_id;
    } request_port;
    struct {
38
      NiceAddress *from;
Dafydd Harries's avatar
Dafydd Harries committed
39
      guint from_port;
40
      NiceAddress *to;
Dafydd Harries's avatar
Dafydd Harries committed
41 42 43 44 45 46 47 48 49 50 51 52 53
      guint to_port;
    } request_stun_query;
  };
};


void
event_free (Event *ev);


/*** agent ***/


54
typedef struct _NiceAgent NiceAgent;
Dafydd Harries's avatar
Dafydd Harries committed
55

56
struct _NiceAgent
Dafydd Harries's avatar
Dafydd Harries committed
57 58
{
  guint next_candidate_id;
Dafydd Harries's avatar
Dafydd Harries committed
59
  guint next_stream_id;
60
  UDPSocketManager *sockmgr;
Dafydd Harries's avatar
Dafydd Harries committed
61 62
  GSList *local_addresses;
  GSList *local_candidates;
63
  GSList *remote_candidates;
Dafydd Harries's avatar
Dafydd Harries committed
64 65 66 67 68
  GSList *streams;
  GSList *events;
};


69 70
typedef void (*NiceAgentRecvHandler) (
  NiceAgent *agent, guint stream_id, guint component_id, guint len,
71
  gchar *buf, gpointer user_data);
72 73


74 75
NiceAgent *
nice_agent_new (UDPSocketManager *mgr);
76

Dafydd Harries's avatar
Dafydd Harries committed
77
Event *
78
nice_agent_pop_event (NiceAgent *agent);
79

Dafydd Harries's avatar
Dafydd Harries committed
80
void
81
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
82

Dafydd Harries's avatar
Dafydd Harries committed
83
guint
84 85
nice_agent_add_stream (
  NiceAgent *agent,
86 87
  NiceAgentRecvHandler handle_recv,
  gpointer handle_recv_data);
88

Dafydd Harries's avatar
Dafydd Harries committed
89
void
90
nice_agent_free (NiceAgent *agent);
91

92
void
93 94
nice_agent_add_remote_candidate (
  NiceAgent *agent,
95 96
  guint stream_id,
  guint component_id,
97 98
  NiceCandidateType type,
  NiceAddress *addr,
99 100 101
  guint port,
  gchar *username,
  gchar *password);
102

Dafydd Harries's avatar
Dafydd Harries committed
103
void
104 105
nice_agent_recv (
  NiceAgent *agent,
Dafydd Harries's avatar
Dafydd Harries committed
106
  guint candidate_id);
107

108
const GSList *
109 110
nice_agent_get_local_candidates (
  NiceAgent *agent);
Dafydd Harries's avatar
Dafydd Harries committed
111

Dafydd Harries's avatar
Dafydd Harries committed
112 113
G_END_DECLS

Dafydd Harries's avatar
Dafydd Harries committed
114 115
#endif /* _AGENT_H */