agent.h 1.67 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 ***/


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

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


typedef struct _event Event;

struct _event
{
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 _agent NiceAgent;
Dafydd Harries's avatar
Dafydd Harries committed
55 56 57 58

struct _agent
{
  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);
Dafydd Harries's avatar
Dafydd Harries committed
76
Event *
77
nice_agent_pop_event (NiceAgent *agent);
Dafydd Harries's avatar
Dafydd Harries committed
78
void
79
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
Dafydd Harries's avatar
Dafydd Harries committed
80
guint
81 82
nice_agent_add_stream (
  NiceAgent *agent,
83 84
  NiceAgentRecvHandler handle_recv,
  gpointer handle_recv_data);
Dafydd Harries's avatar
Dafydd Harries committed
85
void
86
nice_agent_free (NiceAgent *agent);
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 96
  guint port,
  gchar *username,
  gchar *password);
Dafydd Harries's avatar
Dafydd Harries committed
97
void
98 99
nice_agent_recv (
  NiceAgent *agent,
Dafydd Harries's avatar
Dafydd Harries committed
100
  guint candidate_id);
101
const GSList *
102 103
nice_agent_get_local_candidates (
  NiceAgent *agent);
Dafydd Harries's avatar
Dafydd Harries committed
104

Dafydd Harries's avatar
Dafydd Harries committed
105 106
G_END_DECLS

Dafydd Harries's avatar
Dafydd Harries committed
107 108
#endif /* _AGENT_H */