Commit b2541b36 authored by Dafydd Harries's avatar Dafydd Harries

give streams IDs

darcs-hash:20070122122526-c9803-6f4c4ae139a84f9debd0a3c81bb59cf573bac547.gz
parent d4121858
......@@ -9,7 +9,7 @@ libagent_la_SOURCES = agent.h agent.c
libagent_la_LIBADD = $(top_builddir)/udp/libudp.la
check_PROGRAMS = test test-readline test-util
check_PROGRAMS = test test-readline test-util test-add-stream
test_LDADD = libagent.la $(GLIB_LIBS)
......@@ -21,5 +21,7 @@ test_util_SOURCES = test-util.c util.h util.c
test_util_LDADD = libagent.la $(GLIB_LIBS)
TESTS = test test-readline test-util
test_add_stream_LDADD = libagent.la $(GLIB_LIBS)
TESTS = test test-readline test-util test-add-stream
......@@ -190,6 +190,7 @@ typedef struct _stream Stream;
struct _stream
{
MediaType type;
guint id;
/* XXX: streams can have multiple components */
Component *component;
};
......@@ -316,6 +317,7 @@ ice_agent_new (UDPSocketManager *mgr)
agent = g_slice_new0 (Agent);
agent->sockmgr = mgr;
agent->next_candidate_id = 1;
agent->next_stream_id = 1;
return agent;
}
......@@ -369,13 +371,14 @@ ice_agent_add_local_host_candidate (
}
void
guint
ice_agent_add_stream (Agent *agent, MediaType type)
{
Stream *stream;
GSList *i;
stream = stream_new (type);
stream->id = agent->next_stream_id++;
agent->streams = g_slist_append (agent->streams, stream);
/* generate a local host candidate for each local address */
......@@ -389,6 +392,8 @@ ice_agent_add_stream (Agent *agent, MediaType type)
/* XXX: need to check for redundant candidates? */
/* later: send STUN requests to obtain server-reflexive candidates */
}
return stream->id;
}
......
......@@ -129,6 +129,7 @@ typedef struct _agent Agent;
struct _agent
{
guint next_candidate_id;
guint next_stream_id;
UDPSocketManager *sockmgr;
GSList *local_addresses;
GSList *local_candidates;
......@@ -144,7 +145,7 @@ Event *
ice_agent_pop_event (Agent *agent);
void
ice_agent_add_local_address (Agent *agent, Address *addr);
void
guint
ice_agent_add_stream (Agent *agent, MediaType type);
void
ice_agent_free (Agent *agent);
......
#include <arpa/inet.h>
#include <glib.h>
#include <udp.h>
#include <agent.h>
int
main (void)
{
Agent *agent;
agent = ice_agent_new (NULL);
g_assert (ice_agent_add_stream (agent, MEDIA_TYPE_AUDIO) == 1);
g_assert (ice_agent_add_stream (agent, MEDIA_TYPE_AUDIO) == 2);
g_assert (ice_agent_add_stream (agent, MEDIA_TYPE_AUDIO) == 3);
ice_agent_free (agent);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment