Commit f80aa521 authored by Dafydd Harries's avatar Dafydd Harries

split out stream/component code into separate files

darcs-hash:20070315122751-c9803-0ac60fd10fd6af57feb61733abecaca6425acfbb.gz
parent eeef472d
......@@ -30,8 +30,12 @@ CLEANFILES += $(BUILT_SOURCES)
libagent_la_SOURCES = \
candidate.h \
candidate.c \
component.h \
component.c \
agent.h \
agent.c \
stream.h \
stream.c \
$(BUILT_SOURCES)
libagent_la_LIBADD = \
......
......@@ -9,108 +9,7 @@
#include "udp.h"
#include "agent.h"
#include "agent-signals-marshal.h"
/*** component ***/
/* (ICE-13 §4.1.1) For RTP-based media streams, the RTP itself has a component
* ID of 1, and RTCP a component ID of 2. If an agent is using RTCP it MUST
* obtain a candidate for it. If an agent is using both RTP and RTCP, it
* would end up with 2*K host candidates if an agent has K interfaces.
*/
typedef enum
{
COMPONENT_TYPE_RTP,
COMPONENT_TYPE_RTCP,
} ComponentType;
typedef struct _Component Component;
struct _Component
{
ComponentType type;
/* the local candidate that last received a valid connectivity check */
NiceCandidate *active_candidate;
/* the remote address that the last connectivity check came from */
NiceAddress peer_addr;
guint id;
NiceComponentState state;
GSList *local_candidates;
GSList *remote_candidates;
};
static Component *
component_new (
G_GNUC_UNUSED
ComponentType type)
{
Component *component;
component = g_slice_new0 (Component);
component->id = 1;
return component;
}
static void
component_free (Component *cmp)
{
GSList *i;
for (i = cmp->local_candidates; i; i = i->next)
{
NiceCandidate *candidate = i->data;
nice_candidate_free (candidate);
}
for (i = cmp->remote_candidates; i; i = i->next)
{
NiceCandidate *candidate = i->data;
nice_candidate_free (candidate);
}
g_slist_free (cmp->local_candidates);
g_slist_free (cmp->remote_candidates);
g_slice_free (Component, cmp);
}
/*** stream ***/
typedef struct _Stream Stream;
struct _Stream
{
guint id;
/* XXX: streams can have multiple components */
Component *component;
};
static Stream *
stream_new (void)
{
Stream *stream;
stream = g_slice_new0 (Stream);
stream->component = component_new (COMPONENT_TYPE_RTP);
return stream;
}
static void
stream_free (Stream *stream)
{
component_free (stream->component);
g_slice_free (Stream, stream);
}
#include "stream.h"
/*** candidate_pair ***/
......
#include "component.h"
Component *
component_new (
G_GNUC_UNUSED
ComponentType type)
{
Component *component;
component = g_slice_new0 (Component);
component->id = 1;
return component;
}
void
component_free (Component *cmp)
{
GSList *i;
for (i = cmp->local_candidates; i; i = i->next)
{
NiceCandidate *candidate = i->data;
nice_candidate_free (candidate);
}
for (i = cmp->remote_candidates; i; i = i->next)
{
NiceCandidate *candidate = i->data;
nice_candidate_free (candidate);
}
g_slist_free (cmp->local_candidates);
g_slist_free (cmp->remote_candidates);
g_slice_free (Component, cmp);
}
#ifndef _NICE_COMPONENT_H
#define _NICE_COMPONENT_H
#include <glib.h>
#include "agent.h"
#include "candidate.h"
G_BEGIN_DECLS
/* (ICE-13 §4.1.1) For RTP-based media streams, the RTP itself has a component
* ID of 1, and RTCP a component ID of 2. If an agent is using RTCP it MUST
* obtain a candidate for it. If an agent is using both RTP and RTCP, it
* would end up with 2*K host candidates if an agent has K interfaces.
*/
typedef enum
{
COMPONENT_TYPE_RTP,
COMPONENT_TYPE_RTCP,
} ComponentType;
typedef struct _Component Component;
struct _Component
{
ComponentType type;
/* the local candidate that last received a valid connectivity check */
NiceCandidate *active_candidate;
/* the remote address that the last connectivity check came from */
NiceAddress peer_addr;
guint id;
NiceComponentState state;
GSList *local_candidates;
GSList *remote_candidates;
GSList *checks;
};
Component *
component_new (
G_GNUC_UNUSED
ComponentType type);
void
component_free (Component *cmp);
G_END_DECLS
#endif /* _NICE_COMPONENT_H */
#include "stream.h"
Stream *
stream_new (void)
{
Stream *stream;
stream = g_slice_new0 (Stream);
stream->component = component_new (COMPONENT_TYPE_RTP);
return stream;
}
void
stream_free (Stream *stream)
{
component_free (stream->component);
g_slice_free (Stream, stream);
}
#ifndef _NICE_STREAM_H
#define _NICE_STREAM_H
#include <glib.h>
#include "component.h"
G_BEGIN_DECLS
typedef struct _Stream Stream;
struct _Stream
{
guint id;
/* XXX: streams can have multiple components */
Component *component;
};
Stream *
stream_new (void);
void
stream_free (Stream *stream);
G_END_DECLS
#endif /* _NICE_STREAM_H */
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