summaryrefslogtreecommitdiff
path: root/agent/agent.h
blob: 1eb37379c1bcf76d415c8c51407479badef1a857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

#ifndef _AGENT_H
#define _AGENT_H

#include <arpa/inet.h>

#include <glib.h>

#include "udp.h"
#include "address.h"
#include "candidate.h"

G_BEGIN_DECLS

/*** event ***/


typedef enum event_type EventType;

enum event_type
{
  EVENT_CANDIDATE_SELECTED,
};


typedef struct _event Event;

struct _event
{
  EventType type;

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


void
event_free (Event *ev);


/*** agent ***/


typedef struct _agent NiceAgent;

struct _agent
{
  guint next_candidate_id;
  guint next_stream_id;
  UDPSocketManager *sockmgr;
  GSList *local_addresses;
  GSList *local_candidates;
  GSList *remote_candidates;
  GSList *streams;
  GSList *events;
};


typedef void (*NiceAgentRecvHandler) (
  NiceAgent *agent, guint stream_id, guint component_id, guint len,
  gchar *buf, gpointer user_data);


NiceAgent *
nice_agent_new (UDPSocketManager *mgr);
Event *
nice_agent_pop_event (NiceAgent *agent);
void
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
guint
nice_agent_add_stream (
  NiceAgent *agent,
  NiceAgentRecvHandler handle_recv,
  gpointer handle_recv_data);
void
nice_agent_free (NiceAgent *agent);
void
nice_agent_add_remote_candidate (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  NiceCandidateType type,
  NiceAddress *addr,
  guint port,
  gchar *username,
  gchar *password);
void
nice_agent_recv (
  NiceAgent *agent,
  guint candidate_id);
const GSList *
nice_agent_get_local_candidates (
  NiceAgent *agent);

G_END_DECLS

#endif /* _AGENT_H */