Commit df972e33 authored by Dafydd Harries's avatar Dafydd Harries

add gst/ directory and basic nicesrc element

darcs-hash:20070207202611-c9803-6f19990a3e9e7bc483f0aa9754567e9d643c6232.gz
parent bfb9f532
......@@ -9,7 +9,8 @@ SUBDIRS = \
udp \
random \
agent \
nice
nice \
gst
EXTRA_DIST = scripts common.mk
......@@ -15,6 +15,7 @@ AC_CONFIG_FILES([
nice/Makefile
nice/libnice.pc
random/Makefile
gst/Makefile
])
# Checks for programs.
......@@ -29,5 +30,10 @@ PKG_CHECK_MODULES(GLIB, [dnl
gobject-2.0 >= 2.10 dnl
])
PKG_CHECK_MODULES(GST, [
gstreamer-0.10 >= 0.10.0
gstreamer-base-0.10 >= 0.10.0
])
AC_OUTPUT
AM_CFLAGS = -Wall -Werror \
$(GST_CFLAGS) \
-I $(top_srcdir) \
-I $(top_srcdir)/udp \
-I $(top_srcdir)/agent \
-I $(top_srcdir)/random \
-I $(top_srcdir)/address
COMMON_LDADD = \
$(GST_LIBS) \
$(top_builddir)/nice/libnice.la
# libgstnice
lib_LTLIBRARIES = libgstnice.la
libgstnice_la_SOURCES = \
gstnicesrc.h \
gstnicesrc.c
libgstnice_la_LIBADD = $(COMMON_LDADD)
libgstnice_la_LDFLAGS = -module -avoid-version
#include <string.h>
#include "config.h"
#include "gstnicesrc.h"
static GstFlowReturn
gst_nice_src_create (
GstBaseSrc *basesrc, guint64 offset, guint length, GstBuffer **buffer);
static void
gst_nice_src_set_property (
GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void
gst_nice_src_get_property (
GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static const GstElementDetails gst_nice_src_details =
GST_ELEMENT_DETAILS (
"ICE source",
"Source",
"Automagic UDP connectivity establishment",
"Dafydd Harries <dafydd.harries@collabora.co.uk>");
static GstStaticPadTemplate gst_nice_src_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (NULL));
GST_BOILERPLATE (GstNiceSrc, gst_nice_src, GstBaseSrc, GST_TYPE_BASE_SRC);
static gboolean
plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "nicesrc", GST_RANK_NONE,
GST_TYPE_NICE_SRC);
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"nicesrc",
"Interactive UDP connectivity establishment",
plugin_init, VERSION, "LGPL", PACKAGE_NAME,
"http://telepathy.freedesktop.org/wiki/");
enum
{
PROP_AGENT = 1,
PROP_STREAM,
PROP_COMPONENT
};
static void
gst_nice_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_nice_src_src_template));
gst_element_class_set_details (element_class, &gst_nice_src_details);
}
static void
gst_nice_src_class_init (GstNiceSrcClass *klass)
{
GstBaseSrcClass *gstbasesrc_class;
GObjectClass *gobject_class;
gstbasesrc_class = (GstBaseSrcClass *) klass;
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_nice_src_create);
gobject_class = (GObjectClass *) klass;
gobject_class->set_property = gst_nice_src_set_property;
gobject_class->get_property = gst_nice_src_get_property;
g_object_class_install_property (gobject_class, PROP_AGENT,
g_param_spec_pointer (
"agent",
"Agent",
"The NiceAgent this source is bound to",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class, PROP_STREAM,
g_param_spec_uint (
"stream",
"Stream ID",
"The ID of the stream to read from",
0,
G_MAXUINT,
0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class, PROP_COMPONENT,
g_param_spec_uint (
"component",
"Component ID",
"The ID of the component to read from",
0,
G_MAXUINT,
0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class)
{
}
static GstFlowReturn
gst_nice_src_create (GstBaseSrc *basesrc, guint64 offset, guint length,
GstBuffer **buffer)
{
GstFlowReturn res;
GstBuffer *buf;
GstNiceSrc *nicesrc;
guint len;
nicesrc = GST_NICE_SRC (basesrc);
res = gst_pad_alloc_buffer (basesrc->srcpad, offset, 1024, GST_PAD_CAPS
(basesrc->srcpad), &buf);
if (res != GST_FLOW_OK)
return res;
len = nice_agent_component_recv (nicesrc->agent, nicesrc->stream_id,
nicesrc->component_id, 1024, (gchar *) buf->data);
g_assert (len);
buf->size = len;
*buffer = buf;
return GST_FLOW_OK;
}
static void
gst_nice_src_set_property (
GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GstNiceSrc *src = GST_NICE_SRC (object);
switch (prop_id)
{
case PROP_AGENT:
src->agent = g_value_get_pointer (value);
break;
case PROP_STREAM:
src->stream_id = g_value_get_uint (value);
break;
case PROP_COMPONENT:
src->component_id = g_value_get_uint (value);
break;
}
}
static void
gst_nice_src_get_property (
GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GstNiceSrc *src = GST_NICE_SRC (object);
switch (prop_id)
{
case PROP_AGENT:
g_value_set_pointer (value, src->agent);
break;
case PROP_STREAM:
g_value_set_uint (value, src->stream_id);
break;
case PROP_COMPONENT:
g_value_set_uint (value, src->component_id);
break;
}
}
#ifndef _GSTNICE_H
#define _GSTNICE_H
#include <gst/gst.h>
#include <gst/base/gstbasesrc.h>
#include <nice/nice.h>
G_BEGIN_DECLS
#define GST_TYPE_NICE_SRC \
(gst_nice_src_get_type())
#define GST_NICE_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_NICE_SRC,GstNiceSrc))
#define GST_NICE_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_NICE_SRC,GstNiceSrcClass))
#define GST_IS_NICE_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_NICE_SRC))
#define GST_IS_NICE_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_NICE_SRC))
typedef struct _GstNiceSrc GstNiceSrc;
struct _GstNiceSrc
{
GstBaseSrc parent;
GstPad *srcpad;
NiceAgent *agent;
guint stream_id;
guint component_id;
};
typedef struct _GstNiceSrcClass GstNiceSrcClass;
struct _GstNiceSrcClass
{
GstBaseSrcClass parent_class;
};
GType gst_nice_src_get_type (void);
G_END_DECLS
#endif // _GSTNICE_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