agent.h 1.57 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 13


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


Dafydd Harries's avatar
Dafydd Harries committed
17 18
typedef enum event_type EventType;

Dafydd Harries's avatar
Dafydd Harries committed
19 20 21 22 23 24 25 26 27 28
enum event_type
{
  EVENT_CANDIDATE_SELECTED,
};


typedef struct _event Event;

struct _event
{
Dafydd Harries's avatar
Dafydd Harries committed
29
  EventType type;
Dafydd Harries's avatar
Dafydd Harries committed
30 31 32

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


void
event_free (Event *ev);


/*** agent ***/


53
typedef struct _agent NiceAgent;
Dafydd Harries's avatar
Dafydd Harries committed
54 55 56 57

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


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


73 74
NiceAgent *
nice_agent_new (UDPSocketManager *mgr);
Dafydd Harries's avatar
Dafydd Harries committed
75
Event *
76
nice_agent_pop_event (NiceAgent *agent);
Dafydd Harries's avatar
Dafydd Harries committed
77
void
78
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
Dafydd Harries's avatar
Dafydd Harries committed
79
guint
80 81
nice_agent_add_stream (
  NiceAgent *agent,
82 83
  NiceAgentRecvHandler handle_recv,
  gpointer handle_recv_data);
Dafydd Harries's avatar
Dafydd Harries committed
84
void
85
nice_agent_free (NiceAgent *agent);
86
void
87 88 89 90
nice_agent_add_remote_candidate (
  NiceAgent *agent,
  NiceCandidateType type,
  NiceAddress *addr,
91
  guint port);
Dafydd Harries's avatar
Dafydd Harries committed
92
void
93 94
nice_agent_recv (
  NiceAgent *agent,
Dafydd Harries's avatar
Dafydd Harries committed
95
  guint candidate_id);
96
const GSList *
97 98
nice_agent_get_local_candidates (
  NiceAgent *agent);
Dafydd Harries's avatar
Dafydd Harries committed
99 100 101

#endif /* _AGENT_H */