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

#ifndef _AGENT_H
#define _AGENT_H

Dafydd Harries's avatar
Dafydd Harries committed
5 6
typedef enum media_type MediaType;

Dafydd Harries's avatar
Dafydd Harries committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
enum media_type
{
  MEDIA_TYPE_AUDIO,
  MEDIA_TYPE_VIDEO,
};


/*** address ***/


typedef struct _address Address;


Address *
address_new_ipv4_from_string (gchar *str);
gboolean
address_equal (Address *a, Address *b);
void
address_free (Address *addr);


/*** candidate ***/

Dafydd Harries's avatar
Dafydd Harries committed
30
typedef enum candidate_type CandidateType;
Dafydd Harries's avatar
Dafydd Harries committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44

enum candidate_type
{
  CANDIDATE_TYPE_HOST,
  CANDIDATE_TYPE_SERVER_REFLEXIVE,
  CANDIDATE_TYPE_PEER_REFLEXIVE,
  CANDIDATE_TYPE_RELAYED,
};


typedef struct _candidate Candidate;

struct _candidate
{
Dafydd Harries's avatar
Dafydd Harries committed
45
  CandidateType type;
Dafydd Harries's avatar
Dafydd Harries committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
  guint id;
  Address *addr;
  Address *base_addr;
  // guint sock;
  guint16 port;
  guint32 priority;
  // Stream *stream;
  // guint component_id;
  // guint generation;
  // gchar *foundation;
};


/*** event ***/


Dafydd Harries's avatar
Dafydd Harries committed
62 63
typedef enum event_type EventType;

Dafydd Harries's avatar
Dafydd Harries committed
64 65 66 67 68 69 70 71 72 73 74 75 76
enum event_type
{
  EVENT_REQUEST_PORT,
  EVENT_LOCAL_CANDIDATES_READY,
  EVENT_REQUEST_STUN_QUERY,
  EVENT_CANDIDATE_SELECTED,
};


typedef struct _event Event;

struct _event
{
Dafydd Harries's avatar
Dafydd Harries committed
77
  EventType type;
Dafydd Harries's avatar
Dafydd Harries committed
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

  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;
  GSList *local_addresses;
  GSList *local_candidates;
108
  GSList *remote_candidates;
Dafydd Harries's avatar
Dafydd Harries committed
109 110 111 112 113 114 115 116 117 118 119 120
  GSList *streams;
  GSList *events;
};


Agent *
ice_agent_new ();
Event *
ice_agent_pop_event (Agent *agent);
void
ice_agent_add_local_address (Agent *agent, Address *addr);
void
Dafydd Harries's avatar
Dafydd Harries committed
121
ice_agent_add_stream (Agent *agent, MediaType type);
Dafydd Harries's avatar
Dafydd Harries committed
122 123 124 125
void
ice_agent_set_candidate_port (Agent *agent, guint candidate_id, guint port);
void
ice_agent_free (Agent *agent);
126 127 128 129 130 131
void
ice_agent_add_remote_candidate (
  Agent *agent,
  CandidateType type,
  Address *addr,
  guint port);
Dafydd Harries's avatar
Dafydd Harries committed
132 133 134

#endif /* _AGENT_H */