summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorDafydd Harries <dafydd.harries@collabora.co.uk>2007-02-08 17:10:00 +0000
committerDafydd Harries <dafydd.harries@collabora.co.uk>2007-02-08 17:10:00 +0000
commit94afcb3f636c0a54859a02fc21472f6b265aab29 (patch)
treeafeb8fb1ad630f977ea8288770f04a215965b25f /gst
parent8349861676415a71309eeb70480b52b2af452028 (diff)
downloadlibnice-94afcb3f636c0a54859a02fc21472f6b265aab29.tar.gz
add GStreamer sink
darcs-hash:20070208171033-c9803-a4c5644aa41618d48c57c65261a72d0b1951a068.gz
Diffstat (limited to 'gst')
-rw-r--r--gst/Makefile.am3
-rw-r--r--gst/gstnice.c12
-rw-r--r--gst/gstnice.h4
-rw-r--r--gst/gstnicesink.c153
-rw-r--r--gst/gstnicesink.h45
5 files changed, 215 insertions, 2 deletions
diff --git a/gst/Makefile.am b/gst/Makefile.am
index 42dca10..f07cf10 100644
--- a/gst/Makefile.am
+++ b/gst/Makefile.am
@@ -18,6 +18,9 @@ lib_LTLIBRARIES = libgstnice.la
libgstnice_la_SOURCES = \
gstnicesrc.h \
gstnicesrc.c \
+ gstnicesink.h \
+ gstnicesink.c \
+ gstnice.h \
gstnice.c
libgstnice_la_LIBADD = $(COMMON_LDADD)
diff --git a/gst/gstnice.c b/gst/gstnice.c
index 03c4c59..41bc88f 100644
--- a/gst/gstnice.c
+++ b/gst/gstnice.c
@@ -1,12 +1,20 @@
#include "config.h"
#include "gstnicesrc.h"
+#include "gstnicesink.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "nicesrc", GST_RANK_NONE,
- GST_TYPE_NICE_SRC);
+ if (!gst_element_register (plugin, "nicesrc",
+ GST_RANK_NONE, GST_TYPE_NICE_SRC))
+ return FALSE;
+
+ if (!gst_element_register (plugin, "nicesink",
+ GST_RANK_NONE, GST_TYPE_NICE_SINK))
+ return FALSE;
+
+ return TRUE;
}
GST_PLUGIN_DEFINE (
diff --git a/gst/gstnice.h b/gst/gstnice.h
new file mode 100644
index 0000000..dfb5ef6
--- /dev/null
+++ b/gst/gstnice.h
@@ -0,0 +1,4 @@
+
+#include "gstnicesrc.h"
+#include "gstnicesink.h"
+
diff --git a/gst/gstnicesink.c b/gst/gstnicesink.c
new file mode 100644
index 0000000..408ee20
--- /dev/null
+++ b/gst/gstnicesink.c
@@ -0,0 +1,153 @@
+
+#include "config.h"
+#include "gstnicesink.h"
+
+static GstFlowReturn
+gst_nice_sink_render (
+ GstBaseSink *basesink, GstBuffer *buffer);
+
+static void
+gst_nice_sink_set_property (
+ GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+
+static void
+gst_nice_sink_get_property (
+ GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+
+static const GstElementDetails gst_nice_sink_details =
+GST_ELEMENT_DETAILS (
+ "ICE sink",
+ "Sink",
+ "Interactive UDP connectivity establishment",
+ "Dafydd Harries <dafydd.harries@collabora.co.uk>");
+
+static GstStaticPadTemplate gst_nice_sink_sink_template =
+GST_STATIC_PAD_TEMPLATE (
+ "sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+GST_BOILERPLATE (GstNiceSink, gst_nice_sink, GstBaseSink, GST_TYPE_BASE_SINK);
+
+enum
+{
+ PROP_AGENT = 1,
+ PROP_STREAM,
+ PROP_COMPONENT
+};
+
+static void
+gst_nice_sink_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_sink_sink_template));
+ gst_element_class_set_details (element_class, &gst_nice_sink_details);
+}
+
+static void
+gst_nice_sink_class_init (GstNiceSinkClass *klass)
+{
+ GstBaseSinkClass *gstbasesink_class;
+ GObjectClass *gobject_class;
+
+ gstbasesink_class = (GstBaseSinkClass *) klass;
+ gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_nice_sink_render);
+
+ gobject_class = (GObjectClass *) klass;
+ gobject_class->set_property = gst_nice_sink_set_property;
+ gobject_class->get_property = gst_nice_sink_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_sink_init (GstNiceSink *sink, GstNiceSinkClass *g_class)
+{
+}
+
+static GstFlowReturn
+gst_nice_sink_render (
+ GstBaseSink *basesink, GstBuffer *buffer)
+{
+ GstNiceSink *nicesink;
+
+ nicesink = GST_NICE_SINK (basesink);
+ nice_agent_send (nicesink->agent, nicesink->stream_id,
+ nicesink->component_id, GST_BUFFER_SIZE (buffer),
+ (gchar *) GST_BUFFER_DATA (buffer));
+
+ return GST_FLOW_OK;
+}
+
+static void
+gst_nice_sink_set_property (
+ GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ GstNiceSink *sink = GST_NICE_SINK (object);
+
+ switch (prop_id)
+ {
+ case PROP_AGENT:
+ sink->agent = g_value_get_pointer (value);
+ break;
+
+ case PROP_STREAM:
+ sink->stream_id = g_value_get_uint (value);
+ break;
+
+ case PROP_COMPONENT:
+ sink->component_id = g_value_get_uint (value);
+ break;
+ }
+}
+
+static void
+gst_nice_sink_get_property (
+ GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ GstNiceSink *sink = GST_NICE_SINK (object);
+
+ switch (prop_id)
+ {
+ case PROP_AGENT:
+ g_value_set_pointer (value, sink->agent);
+ break;
+
+ case PROP_STREAM:
+ g_value_set_uint (value, sink->stream_id);
+ break;
+
+ case PROP_COMPONENT:
+ g_value_set_uint (value, sink->component_id);
+ break;
+ }
+}
+
diff --git a/gst/gstnicesink.h b/gst/gstnicesink.h
new file mode 100644
index 0000000..5f28457
--- /dev/null
+++ b/gst/gstnicesink.h
@@ -0,0 +1,45 @@
+
+#ifndef _GST_NICE_SINK_H
+#define _GST_NICE_SINK_H
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesink.h>
+
+#include <nice/nice.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_NICE_SINK \
+ (gst_nice_sink_get_type())
+#define GST_NICE_SINK(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_NICE_SINK,GstNiceSink))
+#define GST_NICE_SINK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_NICE_SINK,GstNiceSinkClass))
+#define GST_IS_NICE_SINK(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_NICE_SINK))
+#define GST_IS_NICE_SINK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_NICE_SINK))
+
+typedef struct _GstNiceSink GstNiceSink;
+
+struct _GstNiceSink
+{
+ GstBaseSink parent;
+ GstPad *sinkpad;
+ NiceAgent *agent;
+ guint stream_id;
+ guint component_id;
+};
+
+typedef struct _GstNiceSinkClass GstNiceSinkClass;
+
+struct _GstNiceSinkClass
+{
+ GstBaseSinkClass parent_class;
+};
+
+GType gst_nice_sink_get_type (void);
+
+G_END_DECLS
+
+#endif