agent.h 1.44 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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

  union {
    struct {
      Address *addr;
      guint candidate_id;
    } request_port;
    struct {
      Address *from;
      guint from_port;
      Address *to;
      guint to_port;
    } request_stun_query;
  };
};


void
event_free (Event *ev);


/*** agent ***/


typedef struct _agent Agent;

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 70 71
typedef void (*AgentRecvHandler) (
  Agent *agent, guint stream_id, guint component_id, guint len, gchar *buf);


Dafydd Harries's avatar
Dafydd Harries committed
72
Agent *
73
ice_agent_new (UDPSocketManager *mgr);
Dafydd Harries's avatar
Dafydd Harries committed
74 75 76 77
Event *
ice_agent_pop_event (Agent *agent);
void
ice_agent_add_local_address (Agent *agent, Address *addr);
Dafydd Harries's avatar
Dafydd Harries committed
78
guint
79 80
ice_agent_add_stream (
  Agent *agent,
81
  AgentRecvHandler handle_recv);
Dafydd Harries's avatar
Dafydd Harries committed
82 83
void
ice_agent_free (Agent *agent);
84 85 86 87 88 89
void
ice_agent_add_remote_candidate (
  Agent *agent,
  CandidateType type,
  Address *addr,
  guint port);
Dafydd Harries's avatar
Dafydd Harries committed
90 91 92 93
void
ice_agent_recv (
  Agent *agent,
  guint candidate_id);
94 95 96
const GSList *
ice_agent_get_local_candidates (
  Agent *agent);
Dafydd Harries's avatar
Dafydd Harries committed
97 98 99

#endif /* _AGENT_H */