summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2006-08-21 19:02:13 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2006-08-21 19:02:13 +0000
commit5fc2b326081d07e12c128896667829c45aeb7ea0 (patch)
tree80a9a5c2a93401f6452df3d2cc165994fd9278f4
parent930762e6bdd2246add6e20fa4cd8741e0764836f (diff)
downloadgst-plugins-bad-5fc2b326081d07e12c128896667829c45aeb7ea0.tar.gz
gst-plugins-bad-5fc2b326081d07e12c128896667829c45aeb7ea0.tar.bz2
gst-plugins-bad-5fc2b326081d07e12c128896667829c45aeb7ea0.zip
move gdp plugin to good.
Original commit message from CVS: * configure.ac: * docs/plugins/Makefile.am: * docs/plugins/gst-plugins-bad-plugins-docs.sgml: * docs/plugins/gst-plugins-bad-plugins-sections.txt: * gst/gdp/Makefile.am: * gst/gdp/gstgdp.c: * gst/gdp/gstgdpdepay.c: * gst/gdp/gstgdpdepay.h: * gst/gdp/gstgdppay.c: * gst/gdp/gstgdppay.h: * tests/check/Makefile.am: * tests/check/elements/gdpdepay.c: * tests/check/elements/gdppay.c: move gdp plugin to good.
-rw-r--r--ChangeLog17
-rw-r--r--configure.ac2
-rw-r--r--docs/plugins/Makefile.am2
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-docs.sgml3
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-sections.txt16
-rw-r--r--gst/gdp/Makefile.am14
-rw-r--r--gst/gdp/gstgdp.c46
-rw-r--r--gst/gdp/gstgdpdepay.c457
-rw-r--r--gst/gdp/gstgdpdepay.h75
-rw-r--r--gst/gdp/gstgdppay.c802
-rw-r--r--gst/gdp/gstgdppay.h74
-rw-r--r--tests/check/Makefile.am5
-rw-r--r--tests/check/elements/gdpdepay.c413
-rw-r--r--tests/check/elements/gdppay.c571
14 files changed, 17 insertions, 2480 deletions
diff --git a/ChangeLog b/ChangeLog
index 202ee26a..5d69ac40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2006-08-21 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * configure.ac:
+ * docs/plugins/Makefile.am:
+ * docs/plugins/gst-plugins-bad-plugins-docs.sgml:
+ * docs/plugins/gst-plugins-bad-plugins-sections.txt:
+ * gst/gdp/Makefile.am:
+ * gst/gdp/gstgdp.c:
+ * gst/gdp/gstgdpdepay.c:
+ * gst/gdp/gstgdpdepay.h:
+ * gst/gdp/gstgdppay.c:
+ * gst/gdp/gstgdppay.h:
+ * tests/check/Makefile.am:
+ * tests/check/elements/gdpdepay.c:
+ * tests/check/elements/gdppay.c:
+ move gdp plugin to good.
+
2006-08-21 Wim Taymans <wim@fluendo.com>
* gst/qtdemux/qtdemux.c: (gst_qtdemux_add_stream), (qtdemux_parse),
diff --git a/configure.ac b/configure.ac
index a955e1a5..b10be5c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,6 @@ GST_PLUGINS_ALL="\
cdxaparse \
filter \
freeze \
- gdp \
h264parse \
modplug \
nsf \
@@ -841,7 +840,6 @@ gst/Makefile
gst/cdxaparse/Makefile
gst/filter/Makefile
gst/freeze/Makefile
-gst/gdp/Makefile
gst/h264parse/Makefile
gst/modplug/Makefile
gst/modplug/libmodplug/Makefile
diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am
index a94cafe2..28ce1435 100644
--- a/docs/plugins/Makefile.am
+++ b/docs/plugins/Makefile.am
@@ -86,8 +86,6 @@ EXAMPLE_CFILES = \
$(top_srcdir)/ext/directfb/dfb-example.c
EXTRA_HFILES = \
- $(top_srcdir)/gst/gdp/gstgdpdepay.h \
- $(top_srcdir)/gst/gdp/gstgdppay.h \
$(top_srcdir)/ext/directfb/dfbvideosink.h \
$(top_srcdir)/ext/musicbrainz/gsttrm.h
diff --git a/docs/plugins/gst-plugins-bad-plugins-docs.sgml b/docs/plugins/gst-plugins-bad-plugins-docs.sgml
index 0063bce3..d4ae3d01 100644
--- a/docs/plugins/gst-plugins-bad-plugins-docs.sgml
+++ b/docs/plugins/gst-plugins-bad-plugins-docs.sgml
@@ -14,8 +14,6 @@
<title>gst-plugins-bad Elements</title>
<xi:include href="xml/element-dfbvideosink.xml" />
- <xi:include href="xml/element-gdppay.xml" />
- <xi:include href="xml/element-gdpdepay.xml" />
<xi:include href="xml/element-trm.xml" />
</chapter>
@@ -27,7 +25,6 @@
<xi:include href="xml/plugin-dfbvideosink.xml" />
<xi:include href="xml/plugin-faad.xml" />
<xi:include href="xml/plugin-freeze.xml" />
- <xi:include href="xml/plugin-gdp.xml" />
<xi:include href="xml/plugin-glimagesink.xml" />
<xi:include href="xml/plugin-gsm.xml" />
<xi:include href="xml/plugin-h264parse.xml" />
diff --git a/docs/plugins/gst-plugins-bad-plugins-sections.txt b/docs/plugins/gst-plugins-bad-plugins-sections.txt
index 1166bd99..ed069cab 100644
--- a/docs/plugins/gst-plugins-bad-plugins-sections.txt
+++ b/docs/plugins/gst-plugins-bad-plugins-sections.txt
@@ -1,20 +1,4 @@
<SECTION>
-<FILE>element-gdpdepay</FILE>
-GstGDPDepay
-<TITLE>gdpdepay</TITLE>
-<SUBSECTION Standard>
-GstGDPDepayClass
-</SECTION>
-
-<SECTION>
-<FILE>element-gdppay</FILE>
-GstGDPPay
-<TITLE>gdppay</TITLE>
-<SUBSECTION Standard>
-GstGDPPayClass
-</SECTION>
-
-<SECTION>
<FILE>element-dfbvideosink</FILE>
GstDfbVideoSink
<TITLE>dfbvideosink</TITLE>
diff --git a/gst/gdp/Makefile.am b/gst/gdp/Makefile.am
deleted file mode 100644
index f9caf266..00000000
--- a/gst/gdp/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
-plugin_LTLIBRARIES = libgstgdp.la
-
-libgstgdp_la_SOURCES = \
- gstgdp.c \
- gstgdppay.c \
- gstgdpdepay.c
-
-libgstgdp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-libgstgdp_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_GDP_LIBS)
-libgstgdp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-noinst_HEADERS = \
- gstgdppay.h \
- gstgdpdepay.h
diff --git a/gst/gdp/gstgdp.c b/gst/gdp/gstgdp.c
deleted file mode 100644
index 31d32598..00000000
--- a/gst/gdp/gstgdp.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* GStreamer
- * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gst/dataprotocol/dataprotocol.h>
-
-#include "gstgdppay.h"
-#include "gstgdpdepay.h"
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- gst_dp_init ();
-
- if (!gst_gdp_depay_plugin_init (plugin))
- return FALSE;
-
- if (!gst_gdp_pay_plugin_init (plugin))
- return FALSE;
-
- return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR,
- "gdp",
- "Payload/depayload GDP packets", plugin_init,
- VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/gst/gdp/gstgdpdepay.c b/gst/gdp/gstgdpdepay.c
deleted file mode 100644
index 98d584c4..00000000
--- a/gst/gdp/gstgdpdepay.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/* GStreamer
- * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-gdpdepay
- * @see_also: gdppay
- *
- * <refsect2>
- * <para>
- * This element depayloads GStreamer Data Protocol buffers back to deserialized
- * buffers and events.
- * </para>
- * <para>
- * <programlisting>
- * gst-launch -v -m filesrc location=test.gdp ! gdpdepay ! xvimagesink
- * </programlisting>
- * This pipeline plays back a serialized video stream as created in the
- * example for gdppay.
- * </para>
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include <gst/dataprotocol/dataprotocol.h>
-
-#include "gstgdpdepay.h"
-
-/* elementfactory information */
-static const GstElementDetails gdp_depay_details =
-GST_ELEMENT_DETAILS ("GDP Depayloader",
- "GDP/Depayloader",
- "Depayloads GStreamer Data Protocol buffers",
- "Thomas Vander Stichele <thomas at apestaart dot org>");
-
-enum
-{
- PROP_0,
-};
-
-static GstStaticPadTemplate gdp_depay_sink_template =
-GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-gdp"));
-
-static GstStaticPadTemplate gdp_depay_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
-
-GST_DEBUG_CATEGORY_STATIC (gst_gdp_depay_debug);
-#define GST_CAT_DEFAULT gst_gdp_depay_debug
-
-#define _do_init(x) \
- GST_DEBUG_CATEGORY_INIT (gst_gdp_depay_debug, "gdpdepay", 0, \
- "GDP depayloader");
-
-GST_BOILERPLATE_FULL (GstGDPDepay, gst_gdp_depay, GstElement,
- GST_TYPE_ELEMENT, _do_init);
-
-static gboolean gst_gdp_depay_sink_event (GstPad * pad, GstEvent * event);
-static gboolean gst_gdp_depay_src_event (GstPad * pad, GstEvent * event);
-
-static GstFlowReturn gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer);
-
-static GstStateChangeReturn gst_gdp_depay_change_state (GstElement *
- element, GstStateChange transition);
-
-static void gst_gdp_depay_finalize (GObject * object);
-
-static void
-gst_gdp_depay_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details (element_class, &gdp_depay_details);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gdp_depay_sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gdp_depay_src_template));
-}
-
-static void
-gst_gdp_depay_class_init (GstGDPDepayClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
-
- gstelement_class->change_state =
- GST_DEBUG_FUNCPTR (gst_gdp_depay_change_state);
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_gdp_depay_finalize);
-}
-
-static void
-gst_gdp_depay_init (GstGDPDepay * gdpdepay, GstGDPDepayClass * g_class)
-{
- gdpdepay->sinkpad =
- gst_pad_new_from_static_template (&gdp_depay_sink_template, "sink");
- gst_pad_set_chain_function (gdpdepay->sinkpad,
- GST_DEBUG_FUNCPTR (gst_gdp_depay_chain));
- gst_pad_set_event_function (gdpdepay->sinkpad,
- GST_DEBUG_FUNCPTR (gst_gdp_depay_sink_event));
- gst_element_add_pad (GST_ELEMENT (gdpdepay), gdpdepay->sinkpad);
-
- gdpdepay->srcpad =
- gst_pad_new_from_static_template (&gdp_depay_src_template, "src");
- gst_pad_set_event_function (gdpdepay->srcpad,
- GST_DEBUG_FUNCPTR (gst_gdp_depay_src_event));
- /* our caps will always be decided by the incoming GDP caps buffers */
- gst_pad_use_fixed_caps (gdpdepay->srcpad);
- gst_element_add_pad (GST_ELEMENT (gdpdepay), gdpdepay->srcpad);
-
- gdpdepay->adapter = gst_adapter_new ();
-}
-
-static void
-gst_gdp_depay_finalize (GObject * gobject)
-{
- GstGDPDepay *this;
-
- this = GST_GDP_DEPAY (gobject);
- if (this->caps)
- gst_caps_unref (this->caps);
- g_free (this->header);
- gst_adapter_clear (this->adapter);
- g_object_unref (this->adapter);
-
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (gobject));
-}
-
-static gboolean
-gst_gdp_depay_sink_event (GstPad * pad, GstEvent * event)
-{
- GstGDPDepay *this;
- gboolean res = TRUE;
-
- this = GST_GDP_DEPAY (gst_pad_get_parent (pad));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_FLUSH_START:
- case GST_EVENT_FLUSH_STOP:
- /* forward flush start and stop */
- res = gst_pad_push_event (this->srcpad, event);
- break;
- case GST_EVENT_EOS:
- /* after EOS, we don't expect to output anything anymore */
- res = gst_pad_push_event (this->srcpad, event);
- break;
- case GST_EVENT_NEWSEGMENT:
- case GST_EVENT_TAG:
- case GST_EVENT_BUFFERSIZE:
- default:
- /* we unref most events as we take them from the datastream */
- gst_event_unref (event);
- break;
- }
- gst_object_unref (this);
-
- return res;
-}
-
-static gboolean
-gst_gdp_depay_src_event (GstPad * pad, GstEvent * event)
-{
- GstGDPDepay *this;
- gboolean res = TRUE;
-
- this = GST_GDP_DEPAY (gst_pad_get_parent (pad));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_SEEK:
- /* we refuse seek for now. */
- gst_event_unref (event);
- res = FALSE;
- break;
- case GST_EVENT_QOS:
- case GST_EVENT_NAVIGATION:
- default:
- /* everything else is passed */
- res = gst_pad_push_event (this->sinkpad, event);
- break;
- }
- gst_object_unref (this);
-
- return res;
-}
-
-static GstFlowReturn
-gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
-{
- GstGDPDepay *this;
- GstFlowReturn ret = GST_FLOW_OK;
- GstCaps *caps;
- GstBuffer *buf;
- GstEvent *event;
- guint available;
-
- this = GST_GDP_DEPAY (gst_pad_get_parent (pad));
-
- /* On DISCONT, get rid of accumulated data. We assume a buffer after the
- * DISCONT contains (part of) a new valid header, if not we error because we
- * lost sync */
- if (GST_BUFFER_IS_DISCONT (buffer)) {
- gst_adapter_clear (this->adapter);
- this->state = GST_GDP_DEPAY_STATE_HEADER;
- }
- gst_adapter_push (this->adapter, buffer);
-
- while (TRUE) {
- switch (this->state) {
- case GST_GDP_DEPAY_STATE_HEADER:
- {
- guint8 *header;
-
- /* collect a complete header, validate and store the header. Figure out
- * the payload length and switch to the PAYLOAD state */
- available = gst_adapter_available (this->adapter);
- if (available < GST_DP_HEADER_LENGTH)
- goto done;
-
- GST_LOG_OBJECT (this, "reading GDP header from adapter");
- header = gst_adapter_take (this->adapter, GST_DP_HEADER_LENGTH);
- if (!gst_dp_validate_header (GST_DP_HEADER_LENGTH, header)) {
- g_free (header);
- goto header_validate_error;
- }
-
- /* store types and payload length. Also store the header, which we need
- * to make the payload. */
- this->payload_length = gst_dp_header_payload_length (header);
- this->payload_type = gst_dp_header_payload_type (header);
- /* free previous header and store new one. */
- g_free (this->header);
- this->header = header;
-
- GST_LOG_OBJECT (this,
- "read GDP header, payload size %d, switching to state PAYLOAD",
- this->payload_length);
- this->state = GST_GDP_DEPAY_STATE_PAYLOAD;
- break;
- }
- case GST_GDP_DEPAY_STATE_PAYLOAD:
- {
- /* in this state we wait for all the payload data to be available in the
- * adapter. Then we switch to the state where we actually process the
- * payload. */
- available = gst_adapter_available (this->adapter);
- if (available < this->payload_length)
- goto done;
-
- /* change state based on type */
- if (this->payload_type == GST_DP_PAYLOAD_BUFFER) {
- GST_LOG_OBJECT (this, "switching to state BUFFER");
- this->state = GST_GDP_DEPAY_STATE_BUFFER;
- } else if (this->payload_type == GST_DP_PAYLOAD_CAPS) {
- GST_LOG_OBJECT (this, "switching to state CAPS");
- this->state = GST_GDP_DEPAY_STATE_CAPS;
- } else if (this->payload_type >= GST_DP_PAYLOAD_EVENT_NONE) {
- GST_LOG_OBJECT (this, "switching to state EVENT");
- this->state = GST_GDP_DEPAY_STATE_EVENT;
- } else {
- goto wrong_type;
- }
- break;
- }
- case GST_GDP_DEPAY_STATE_BUFFER:
- {
-
- /* if we receive a buffer without caps first, we error out */
- if (!this->caps)
- goto no_caps;
-
- GST_LOG_OBJECT (this, "reading GDP buffer from adapter");
- buf = gst_dp_buffer_from_header (GST_DP_HEADER_LENGTH, this->header);
- if (!buf)
- goto buffer_failed;
-
- /* now take the payload if there is any */
- if (this->payload_length > 0) {
- guint8 *payload;
-
- payload = gst_adapter_take (this->adapter, this->payload_length);
- memcpy (GST_BUFFER_DATA (buf), payload, this->payload_length);
- g_free (payload);
- }
-
- /* set caps and push */
- gst_buffer_set_caps (buf, this->caps);
- ret = gst_pad_push (this->srcpad, buf);
- if (ret != GST_FLOW_OK)
- goto push_error;
-
- GST_LOG_OBJECT (this, "switching to state HEADER");
- this->state = GST_GDP_DEPAY_STATE_HEADER;
- break;
- }
- case GST_GDP_DEPAY_STATE_CAPS:
- {
- guint8 *payload;
-
- /* take the payload of the caps */
- GST_LOG_OBJECT (this, "reading GDP caps from adapter");
- payload = gst_adapter_take (this->adapter, this->payload_length);
- caps = gst_dp_caps_from_packet (GST_DP_HEADER_LENGTH, this->header,
- payload);
- g_free (payload);
- if (!caps)
- goto caps_failed;
-
- GST_DEBUG_OBJECT (this, "read caps %" GST_PTR_FORMAT, caps);
- gst_caps_replace (&(this->caps), caps);
- gst_pad_set_caps (this->srcpad, caps);
- /* drop the creation ref we still have */
- gst_caps_unref (caps);
-
- GST_LOG_OBJECT (this, "switching to state HEADER");
- this->state = GST_GDP_DEPAY_STATE_HEADER;
- break;
- }
- case GST_GDP_DEPAY_STATE_EVENT:
- {
- guint8 *payload;
-
- GST_LOG_OBJECT (this, "reading GDP event from adapter");
-
- /* adapter doesn't like 0 length payload */
- if (this->payload_length > 0)
- payload = gst_adapter_take (this->adapter, this->payload_length);
- else
- payload = NULL;
- event = gst_dp_event_from_packet (GST_DP_HEADER_LENGTH, this->header,
- payload);
- g_free (payload);
- if (!event)
- goto event_failed;
-
- GST_DEBUG_OBJECT (this, "sending deserialized event %p of type %s",
- event, gst_event_type_get_name (event->type));
- gst_pad_push_event (this->srcpad, event);
-
- GST_LOG_OBJECT (this, "switching to state HEADER");
- this->state = GST_GDP_DEPAY_STATE_HEADER;
- break;
- }
- }
- }
-
-done:
- gst_object_unref (this);
- return ret;
-
- /* ERRORS */
-header_validate_error:
- {
- GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL),
- ("GDP packet header does not validate"));
- ret = GST_FLOW_ERROR;
- goto done;
- }
-wrong_type:
- {
- GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL),
- ("GDP packet header is of wrong type"));
- ret = GST_FLOW_ERROR;
- goto done;
- }
-no_caps:
- {
- GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL),
- ("Received a buffer without first receiving caps"));
- ret = GST_FLOW_NOT_NEGOTIATED;
- goto done;
- }
-buffer_failed:
- {
- GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL),
- ("could not create buffer from GDP packet"));
- ret = GST_FLOW_ERROR;
- goto done;
- }
-push_error:
- {
- GST_WARNING_OBJECT (this, "pushing depayloaded buffer returned %d", ret);
- goto done;
- }
-caps_failed:
- {
- GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL),
- ("could not create caps from GDP packet"));
- ret = GST_FLOW_ERROR;
- goto done;
- }
-event_failed:
- {
- GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL),
- ("could not create event from GDP packet"));
- ret = GST_FLOW_ERROR;
- goto done;
- }
-}
-
-static GstStateChangeReturn
-gst_gdp_depay_change_state (GstElement * element, GstStateChange transition)
-{
- GstStateChangeReturn ret;
- GstGDPDepay *this = GST_GDP_DEPAY (element);
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-
- switch (transition) {
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- if (this->caps) {
- gst_caps_unref (this->caps);
- this->caps = NULL;
- }
- break;
- default:
- break;
- }
- return ret;
-}
-
-gboolean
-gst_gdp_depay_plugin_init (GstPlugin * plugin)
-{
- if (!gst_element_register (plugin, "gdpdepay", GST_RANK_NONE,
- GST_TYPE_GDP_DEPAY))
- return FALSE;
-
- return TRUE;
-}
diff --git a/gst/gdp/gstgdpdepay.h b/gst/gdp/gstgdpdepay.h
deleted file mode 100644
index 2d6d39ae..00000000
--- a/gst/gdp/gstgdpdepay.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* GStreamer
- * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GDP_DEPAY_H__
-#define __GST_GDP_DEPAY_H__
-
-#include <gst/gst.h>
-#include <gst/base/gstadapter.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GDP_DEPAY \
- (gst_gdp_depay_get_type())
-#define GST_GDP_DEPAY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GDP_DEPAY,GstGDPDepay))
-#define GST_GDP_DEPAY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GDP_DEPAY,GstGDPDepayClass))
-#define GST_IS_GDP_DEPAY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDP_DEPAY))
-#define GST_IS_GDP_DEPAY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDP_DEPAY))
-
-typedef enum {
- GST_GDP_DEPAY_STATE_HEADER = 0,
- GST_GDP_DEPAY_STATE_PAYLOAD,
- GST_GDP_DEPAY_STATE_BUFFER,
- GST_GDP_DEPAY_STATE_CAPS,
- GST_GDP_DEPAY_STATE_EVENT,
-} GstGDPDepayState;
-
-
-typedef struct _GstGDPDepay GstGDPDepay;
-typedef struct _GstGDPDepayClass GstGDPDepayClass;
-
-struct _GstGDPDepay
-{
- GstElement element;
- GstPad *sinkpad;
- GstPad *srcpad;
-
- GstAdapter *adapter;
- GstGDPDepayState state;
- GstCaps *caps;
-
- guint8 *header;
- guint32 payload_length;
- GstDPPayloadType payload_type;
-};
-
-struct _GstGDPDepayClass
-{
- GstElementClass parent_class;
-};
-
-gboolean gst_gdp_depay_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_GDP_DEPAY_H__ */
diff --git a/gst/gdp/gstgdppay.c b/gst/gdp/gstgdppay.c
deleted file mode 100644
index e164b503..00000000
--- a/gst/gdp/gstgdppay.c
+++ /dev/null
@@ -1,802 +0,0 @@
-/* GStreamer
- * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-gdppay
- * @see_also: gdpdepay
- *
- * <refsect2>
- * <para>
- * This element payloads GStreamer buffers and events using the
- * GStreamer Data Protocol.
- * </para>
- * <para>
- * <programlisting>
- * gst-launch -v -m videotestsrc num-buffers=50 ! gdppay ! filesink location=test.gdp
- * </programlisting>
- * This pipeline creates a serialized video stream that can be played back
- * with the example shown in gdpdepay.
- * </para>
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/dataprotocol/dataprotocol.h>
-
-#include "gstgdppay.h"
-
-/* elementfactory information */
-static const GstElementDetails gdp_pay_details =
-GST_ELEMENT_DETAILS ("GDP Payloader",
- "GDP/Payloader",
- "Payloads GStreamer Data Protocol buffers",
- "Thomas Vander Stichele <thomas at apestaart dot org>");
-
-static GstStaticPadTemplate gdp_pay_sink_template =
-GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
-
-static GstStaticPadTemplate gdp_pay_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-gdp"));
-
-GST_DEBUG_CATEGORY_STATIC (gst_gdp_pay_debug);
-#define GST_CAT_DEFAULT gst_gdp_pay_debug
-
-#define DEFAULT_CRC_HEADER TRUE
-#define DEFAULT_CRC_PAYLOAD FALSE
-#define DEFAULT_VERSION GST_DP_VERSION_1_0
-
-enum
-{
- PROP_0,
- PROP_CRC_HEADER,
- PROP_CRC_PAYLOAD,
- PROP_VERSION,
-};
-
-#define _do_init(x) \
- GST_DEBUG_CATEGORY_INIT (gst_gdp_pay_debug, "gdppay", 0, \
- "GDP payloader");
-
-GST_BOILERPLATE_FULL (GstGDPPay, gst_gdp_pay, GstElement,
- GST_TYPE_ELEMENT, _do_init);
-
-static void gst_gdp_pay_reset (GstGDPPay * this);
-static GstFlowReturn gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer);
-
-static gboolean gst_gdp_pay_src_event (GstPad * pad, GstEvent * event);
-static gboolean gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event);
-
-static GstStateChangeReturn gst_gdp_pay_change_state (GstElement *
- element, GstStateChange transition);
-
-static void gst_gdp_pay_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gdp_pay_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static void gst_gdp_pay_finalize (GObject * gobject);
-
-static void
-gst_gdp_pay_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details (element_class, &gdp_pay_details);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gdp_pay_sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gdp_pay_src_template));
-}
-
-static void
-gst_gdp_pay_class_init (GstGDPPayClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
-
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_gdp_pay_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_gdp_pay_get_property);
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_gdp_pay_finalize);
-
- g_object_class_install_property (gobject_class, PROP_CRC_HEADER,
- g_param_spec_boolean ("crc-header", "CRC Header",
- "Calculate and store a CRC checksum on the header",
- DEFAULT_CRC_HEADER, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_CRC_PAYLOAD,
- g_param_spec_boolean ("crc-payload", "CRC Payload",
- "Calculate and store a CRC checksum on the payload",
- DEFAULT_CRC_PAYLOAD, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_VERSION,
- g_param_spec_enum ("version", "Version",
- "Version of the GStreamer Data Protocol",
- GST_TYPE_DP_VERSION, DEFAULT_VERSION, G_PARAM_READWRITE));
-
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_gdp_pay_change_state);
-}
-
-static void
-gst_gdp_pay_init (GstGDPPay * gdppay, GstGDPPayClass * g_class)
-{
- gdppay->sinkpad =
- gst_pad_new_from_static_template (&gdp_pay_sink_template, "sink");
- gst_pad_set_chain_function (gdppay->sinkpad,
- GST_DEBUG_FUNCPTR (gst_gdp_pay_chain));
- gst_pad_set_event_function (gdppay->sinkpad,
- GST_DEBUG_FUNCPTR (gst_gdp_pay_sink_event));
- gst_element_add_pad (GST_ELEMENT (gdppay), gdppay->sinkpad);
-
- gdppay->srcpad =
- gst_pad_new_from_static_template (&gdp_pay_src_template, "src");
- gst_pad_set_event_function (gdppay->srcpad,
- GST_DEBUG_FUNCPTR (gst_gdp_pay_src_event));
- gst_element_add_pad (GST_ELEMENT (gdppay), gdppay->srcpad);
-
- gdppay->crc_header = DEFAULT_CRC_HEADER;
- gdppay->crc_payload = DEFAULT_CRC_PAYLOAD;
- gdppay->header_flag = gdppay->crc_header | gdppay->crc_payload;
- gdppay->version = DEFAULT_VERSION;
- gdppay->offset = 0;
-
- gdppay->packetizer = gst_dp_packetizer_new (gdppay->version);
-}
-
-static void
-gst_gdp_pay_finalize (GObject * gobject)
-{
- GstGDPPay *this = GST_GDP_PAY (gobject);
-
- gst_gdp_pay_reset (this);
- gst_dp_packetizer_free (this->packetizer);
-
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (gobject));
-}
-
-static void
-gst_gdp_pay_reset (GstGDPPay * this)
-{
- /* clear the queued buffers */
- while (this->queue) {
- GstBuffer *buffer;
-
- buffer = GST_BUFFER_CAST (this->queue->data);
- GST_DEBUG_OBJECT (this, "Pushing queued GDP buffer %p", buffer);
-
- /* delete buffer from queue now */
- this->queue = g_list_delete_link (this->queue, this->queue);
- }
- if (this->caps) {
- gst_caps_unref (this->caps);
- this->caps = NULL;
- }
- if (this->caps_buf) {
- gst_buffer_unref (this->caps_buf);
- this->caps_buf = NULL;
- }
- if (this->tag_buf) {
- gst_buffer_unref (this->tag_buf);
- this->tag_buf = NULL;
- }
- if (this->new_segment_buf) {
- gst_buffer_unref (this->new_segment_buf);
- this->new_segment_buf = NULL;
- }
- this->sent_streamheader = FALSE;
- this->offset = 0;
-}
-
-/* set OFFSET and OFFSET_END with running count */
-static void
-gst_gdp_stamp_buffer (GstGDPPay * this, GstBuffer * buffer)
-{
- GST_BUFFER_OFFSET (buffer) = this->offset;
- GST_BUFFER_OFFSET_END (buffer) = this->offset + GST_BUFFER_SIZE (buffer);
- this->offset = GST_BUFFER_OFFSET_END (buffer);
-}
-
-static GstBuffer *
-gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps)
-{
- GstBuffer *headerbuf;
- GstBuffer *payloadbuf;
- guint8 *header, *payload;
- guint len;
-
- if (!this->packetizer->packet_from_caps (caps, this->header_flag, &len,
- &header, &payload))
- goto packet_failed;
-
- GST_LOG_OBJECT (this, "creating GDP header and payload buffer from caps");
- headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
-
- payloadbuf = gst_buffer_new ();
- gst_buffer_set_data (payloadbuf, payload,
- gst_dp_header_payload_length (header));
- GST_BUFFER_MALLOCDATA (payloadbuf) = payload;
-
- return gst_buffer_join (headerbuf, payloadbuf);
-
- /* ERRORS */
-packet_failed:
- {
- GST_WARNING_OBJECT (this, "could not create GDP header from caps");
- return NULL;
- }
-}
-
-static GstBuffer *
-gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer)
-{
- GstBuffer *headerbuf;
- guint8 *header;
- guint len;
-
- if (!this->packetizer->header_from_buffer (buffer, this->header_flag, &len,
- &header))
- goto no_buffer;
-
- GST_LOG_OBJECT (this, "creating GDP header and payload buffer from buffer");
- headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
-
- /* we do not want to lose the ref on the incoming buffer */
- gst_buffer_ref (buffer);
-
- return gst_buffer_join (headerbuf, buffer);
-
- /* ERRORS */
-no_buffer:
- {
- GST_WARNING_OBJECT (this, "could not create GDP header from buffer");
- return NULL;
- }
-}
-
-static GstBuffer *
-gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
-{
- GstBuffer *headerbuf;
- GstBuffer *payloadbuf;
- guint8 *header, *payload;
- guint len;
- gboolean ret;
-
- ret =
- this->packetizer->packet_from_event (event, this->header_flag, &len,
- &header, &payload);
- if (!ret)
- goto no_event;
-
- GST_LOG_OBJECT (this, "creating GDP header and payload buffer from event");
- headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
-
- payloadbuf = gst_buffer_new ();
- gst_buffer_set_data (payloadbuf, payload,
- gst_dp_header_payload_length (header));
- GST_BUFFER_MALLOCDATA (payloadbuf) = payload;
-
- return gst_buffer_join (headerbuf, payloadbuf);
-
- /* ERRORS */
-no_event:
- {
- GST_WARNING_OBJECT (this, "could not create GDP header from event %s (%d)",
- gst_event_type_get_name (event->type), event->type);
- return NULL;
- }
-}
-
-
-/* set our caps with streamheader, based on the latest newsegment and caps,
- * and (possibly) GDP-serialized buffers of the streamheaders on the src pad */
-static GstFlowReturn
-gst_gdp_pay_reset_streamheader (GstGDPPay * this)
-{
- GstCaps *caps;
- GstStructure *structure;
- GstBuffer *new_segment_buf = NULL, *caps_buf, *tag_buf = NULL;
- GstFlowReturn r = GST_FLOW_OK;
- gboolean version_one_zero = TRUE;
-
- GValue array = { 0 };
- GValue value = { 0 };
-
- /* In version 0.2, we didn't need or send new segment or tags */
- if (this->version == GST_DP_VERSION_0_2)
- version_one_zero = FALSE;
-
- if (version_one_zero) {
- if (!this->new_segment_buf || !this->caps_buf)
- return GST_FLOW_OK;
- } else {
- if (!this->caps_buf)
- return GST_FLOW_OK;
- }
-
- /* put copies of the buffers in a fixed list */
- g_value_init (&array, GST_TYPE_ARRAY);
-
- if (version_one_zero) {
- new_segment_buf = gst_buffer_copy (this->new_segment_buf);
- g_value_init (&value, GST_TYPE_BUFFER);
- gst_value_set_buffer (&value, new_segment_buf);
- gst_value_array_append_value (&array, &value);
- g_value_unset (&value);
-
- if (this->tag_buf) {
- tag_buf = gst_buffer_copy (this->tag_buf);
- g_value_init (&value, GST_TYPE_BUFFER);
- gst_value_set_buffer (&value, tag_buf);
- gst_value_array_append_value (&array, &value);
- g_value_unset (&value);
- }
- }
-
- caps_buf = gst_buffer_copy (this->caps_buf);
- g_value_init (&value, GST_TYPE_BUFFER);
- gst_value_set_buffer (&value, caps_buf);
- gst_value_array_append_value (&array, &value);
- g_value_unset (&value);
-
- /* we also need to add GDP serializations of the streamheaders of the
- * incoming caps */
- structure = gst_caps_get_structure (this->caps, 0);
- if (gst_structure_has_field (structure, "streamheader")) {
- const GValue *sh;
- GArray *buffers;
- GstBuffer *buffer;
- int i;
-
- sh = gst_structure_get_value (structure, "streamheader");
- buffers = g_value_peek_pointer (sh);
- GST_DEBUG_OBJECT (this,
- "Need to serialize %d incoming streamheader buffers on ours",
- buffers->len);
- for (i = 0; i < buffers->len; ++i) {
- GValue *bufval;
- GstBuffer *outbuffer;
-
- bufval = &g_array_index (buffers, GValue, i);
- buffer = g_value_peek_pointer (bufval);
- outbuffer = gst_gdp_pay_buffer_from_buffer (this, buffer);
- if (!outbuffer)
- goto no_buffer;
-
- g_value_init (&value, GST_TYPE_BUFFER);
- gst_value_set_buffer (&value, outbuffer);
- gst_value_array_append_value (&array, &value);
- g_value_unset (&value);
- }
- }
-
- caps = gst_caps_from_string ("application/x-gdp");
- structure = gst_caps_get_structure (caps, 0);
-
- gst_structure_set_value (structure, "streamheader", &array);
- g_value_unset (&array);
-
- /* Unref our copies */
- if (new_segment_buf)
- gst_buffer_unref (new_segment_buf);
- gst_buffer_unref (caps_buf);
-
- GST_DEBUG_OBJECT (this, "Setting caps on src pad %" GST_PTR_FORMAT, caps);
- gst_pad_set_caps (this->srcpad, caps);
- gst_buffer_set_caps (this->caps_buf, caps);
- gst_buffer_set_caps (this->new_segment_buf, caps);
-
- /* if these are our first ever buffers, send out new_segment first */
- if (!this->sent_streamheader) {
- GstEvent *event =
- gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0);
- GST_DEBUG_OBJECT (this, "Sending out new_segment event %p", event);
- if (!gst_pad_push_event (this->srcpad, event)) {
- GST_WARNING_OBJECT (this, "pushing new segment failed");
- return GST_FLOW_ERROR;
- }
- }
-
- /* push out these streamheader buffers, then flush our internal queue */
- GST_DEBUG_OBJECT (this, "Pushing GDP new_segment buffer %p",
- this->new_segment_buf);
- /* we stored these bufs with refcount 1, so make sure we keep a ref */
- r = gst_pad_push (this->srcpad, gst_buffer_ref (this->new_segment_buf));
- if (r != GST_FLOW_OK) {
- GST_WARNING_OBJECT (this, "pushing GDP newsegment buffer returned %d", r);
- return r;
- }
- if (this->tag_buf) {
- GST_DEBUG_OBJECT (this, "Pushing GDP tag buffer %p", this->tag_buf);
- /* we stored these bufs with refcount 1, so make sure we keep a ref */
- r = gst_pad_push (this->srcpad, gst_buffer_ref (this->tag_buf));
- if (r != GST_FLOW_OK) {
- GST_WARNING_OBJECT (this, "pushing GDP tag buffer returned %d", r);
- return r;
- }
- }
- GST_DEBUG_OBJECT (this, "Pushing GDP caps buffer %p", this->new_segment_buf);
- r = gst_pad_push (this->srcpad, gst_buffer_ref (this->caps_buf));
- if (r != GST_FLOW_OK) {
- GST_WARNING_OBJECT (this, "pushing GDP caps buffer returned %d", r);
- return r;
- }
- this->sent_streamheader = TRUE;
- GST_DEBUG_OBJECT (this, "need to push %d queued buffers",
- g_list_length (this->queue));
- while (this->queue) {
- GstBuffer *buffer;
-
- buffer = GST_BUFFER_CAST (this->queue->data);
- GST_DEBUG_OBJECT (this, "Pushing queued GDP buffer %p", buffer);
-
- /* delete buffer from queue now */
- this->queue = g_list_delete_link (this->queue, this->queue);
-
- /* set caps en push */
- gst_buffer_set_caps (buffer, caps);
- r = gst_pad_push (this->srcpad, buffer);
- if (r != GST_FLOW_OK) {
- GST_WARNING_OBJECT (this, "pushing queued GDP buffer returned %d", r);
- return r;
- }
- }
- return r;
-
- /* ERRORS */
-no_buffer:
- {
- GST_ELEMENT_ERROR (this, STREAM, FORMAT, (NULL),
- ("failed to create GDP buffer from streamheader"));
- return GST_FLOW_ERROR;
- }
-}
-
-/* queue a buffer internally if we haven't sent streamheader buffers yet;
- * otherwise, just push on, this takes ownership of the buffer. */
-static GstFlowReturn
-gst_gdp_queue_buffer (GstGDPPay * this, GstBuffer * buffer)
-{
- if (this->sent_streamheader) {
- GST_LOG_OBJECT (this, "Pushing GDP buffer %p, caps %" GST_PTR_FORMAT,
- buffer, this->caps);
- return gst_pad_push (this->srcpad, buffer);
- }
-
- /* store it on an internal queue. buffer remains reffed. */
- this->queue = g_list_append (this->queue, buffer);
- GST_DEBUG_OBJECT (this, "queued buffer %p, now %d buffers queued",
- buffer, g_list_length (this->queue));
-
- return GST_FLOW_OK;
-}
-
-static GstFlowReturn
-gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer)
-{
- GstGDPPay *this;
- GstCaps *caps;
- GstBuffer *outbuffer;
- GstFlowReturn ret;
-
- this = GST_GDP_PAY (gst_pad_get_parent (pad));
-
- /* we should have received a new_segment before, otherwise it's a bug.
- * fake one in that case */
- if (!this->new_segment_buf) {
- GstEvent *event;
-
- GST_WARNING_OBJECT (this,
- "did not receive new-segment before first buffer");
- event = gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0);
- outbuffer = gst_gdp_buffer_from_event (this, event);
- gst_event_unref (event);
-
- /* GDP 0.2 doesn't know about new-segment, so this is not fatal */
- if (!outbuffer) {
- GST_ELEMENT_WARNING (this, STREAM, ENCODE, (NULL),
- ("Could not create GDP buffer from new segment event"));
- } else {
- gst_gdp_stamp_buffer (this, outbuffer);
- GST_BUFFER_TIMESTAMP (outbuffer) = GST_BUFFER_TIMESTAMP (buffer);
- GST_BUFFER_DURATION (outbuffer) = 0;
- GST_DEBUG_OBJECT (this, "Storing buffer %p as new_segment_buf",
- outbuffer);
- this->new_segment_buf = outbuffer;
- }
- }
-
- /* make sure we've received caps before */
- caps = gst_buffer_get_caps (buffer);
- if (!this->caps && !caps)
- goto no_caps;
-
- /* if the caps have changed, process caps first */
- if (caps && !gst_caps_is_equal (this->caps, caps)) {
- GST_LOG_OBJECT (this, "caps changed to %p, %" GST_PTR_FORMAT, caps, caps);
- gst_caps_replace (&(this->caps), caps);
- outbuffer = gst_gdp_buffer_from_caps (this, caps);
- if (!outbuffer)
- goto no_caps_buffer;
-
- gst_gdp_stamp_buffer (this, outbuffer);
- GST_BUFFER_TIMESTAMP (outbuffer) = GST_BUFFER_TIMESTAMP (buffer);
- GST_BUFFER_DURATION (outbuffer) = 0;
- GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS);
- this->caps_buf = outbuffer;
- gst_gdp_pay_reset_streamheader (this);
- }
-
- /* create a GDP header packet,
- * then create a GST buffer of the header packet and the buffer contents */
- outbuffer = gst_gdp_pay_buffer_from_buffer (this, buffer);
- if (!outbuffer)
- goto no_buffer;
-
- gst_gdp_stamp_buffer (this, outbuffer);
- GST_BUFFER_TIMESTAMP (outbuffer) = GST_BUFFER_TIMESTAMP (buffer);
- GST_BUFFER_DURATION (outbuffer) = GST_BUFFER_DURATION (buffer);
-
- ret = gst_gdp_queue_buffer (this, outbuffer);
-
-done:
- gst_buffer_unref (buffer);
- gst_object_unref (this);
- return ret;
-
- /* ERRORS */
-no_caps:
- {
- /* when returning a fatal error as a GstFlowReturn we must post an error
- * message */
- GST_ELEMENT_ERROR (this, STREAM, FORMAT, (NULL),
- ("first received buffer does not have caps set"));
- if (caps)
- gst_caps_unref (caps);
- ret = GST_FLOW_NOT_NEGOTIATED;
- goto done;
- }
-no_caps_buffer:
- {
- GST_ELEMENT_ERROR (this, STREAM, ENCODE, (NULL),
- ("Could not create GDP buffer from caps %" GST_PTR_FORMAT, caps));
- gst_caps_unref (caps);
- ret = GST_FLOW_ERROR;
- goto done;
- }
-no_buffer:
- {
- GST_ELEMENT_ERROR (this, STREAM, ENCODE, (NULL),
- ("Could not create GDP buffer from buffer"));
- ret = GST_FLOW_ERROR;
- goto done;
- }
-}
-
-static gboolean
-gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event)
-{
- GstBuffer *outbuffer;
- GstGDPPay *this = GST_GDP_PAY (gst_pad_get_parent (pad));
- GstFlowReturn flowret;
- gboolean ret = TRUE;
-
- GST_DEBUG_OBJECT (this, "received event %p of type %s (%d)",
- event, gst_event_type_get_name (event->type), event->type);
-
- /* now turn the event into a buffer */
- outbuffer = gst_gdp_buffer_from_event (this, event);
- if (!outbuffer)
- goto no_outbuffer;
-
- gst_gdp_stamp_buffer (this, outbuffer);
- GST_BUFFER_TIMESTAMP (outbuffer) = GST_EVENT_TIMESTAMP (event);
- GST_BUFFER_DURATION (outbuffer) = 0;
-
- /* if we got a new segment, we should put it on our streamheader,
- * and not send it on */
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:
- GST_DEBUG_OBJECT (this, "Storing buffer %p as new_segment_buf",
- outbuffer);
-
- if (this->new_segment_buf)
- gst_buffer_unref (this->new_segment_buf);
- this->new_segment_buf = outbuffer;
-
- gst_gdp_pay_reset_streamheader (this);
- break;
- case GST_EVENT_TAG:
- GST_DEBUG_OBJECT (this, "Storing buffer %p as tag_buf", outbuffer);
-
- if (this->tag_buf)
- gst_buffer_unref (this->tag_buf);
- this->tag_buf = outbuffer;
-
- gst_gdp_pay_reset_streamheader (this);
- break;
- default:
- GST_DEBUG_OBJECT (this, "queuing GDP buffer %p of event %p", outbuffer,
- event);
- flowret = gst_gdp_queue_buffer (this, outbuffer);
- if (flowret != GST_FLOW_OK)
- goto push_error;
- break;
- }
-
- /* if we have EOS, we should send on EOS ourselves */
- if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
- GST_DEBUG_OBJECT (this, "Sending on EOS event %p", event);
- /* ref, we unref later again */
- ret = gst_pad_push_event (this->srcpad, gst_event_ref (event));
- }
-
-done:
- gst_event_unref (event);
- gst_object_unref (this);
-
- return ret;
-
- /* ERRORS */
-no_outbuffer:
- {
- GST_ELEMENT_WARNING (this, STREAM, ENCODE, (NULL),
- ("Could not create GDP buffer from received event (type %s)",
- gst_event_type_get_name (event->type)));
- ret = FALSE;
- goto done;
- }
-push_error:
- {
- GST_WARNING_OBJECT (this, "queueing GDP event buffer returned %d", flowret);
- ret = FALSE;
- goto done;
- }
-}
-
-static gboolean
-gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
-{
- GstGDPPay *this;
- gboolean res = TRUE;
-
- this = GST_GDP_PAY (gst_pad_get_parent (pad));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_SEEK:
- /* we refuse seek for now. */
- gst_event_unref (event);
- res = FALSE;
- break;
- case GST_EVENT_QOS:
- case GST_EVENT_NAVIGATION:
- default:
- /* everything else is passed */
- res = gst_pad_push_event (this->sinkpad, event);
- break;
- }
- gst_object_unref (this);
-
- return res;
-}
-
-static void
-gst_gdp_pay_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstGDPPay *this;
-
- g_return_if_fail (GST_IS_GDP_PAY (object));
- this = GST_GDP_PAY (object);
-
- switch (prop_id) {
- case PROP_CRC_HEADER:
- this->crc_header =
- g_value_get_boolean (value) ? GST_DP_HEADER_FLAG_CRC_HEADER : 0;
- this->header_flag = this->crc_header | this->crc_payload;
- break;
- case PROP_CRC_PAYLOAD:
- this->crc_payload =
- g_value_get_boolean (value) ? GST_DP_HEADER_FLAG_CRC_PAYLOAD : 0;
- this->header_flag = this->crc_header | this->crc_payload;
- break;
- case PROP_VERSION:
- this->version = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gdp_pay_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstGDPPay *this;
-
- g_return_if_fail (GST_IS_GDP_PAY (object));
- this = GST_GDP_PAY (object);
-
- switch (prop_id) {
- case PROP_CRC_HEADER:
- g_value_set_boolean (value, this->crc_header);
- break;
- case PROP_CRC_PAYLOAD:
- g_value_set_boolean (value, this->crc_payload);
- break;
- case PROP_VERSION:
- g_value_set_enum (value, this->version);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GstStateChangeReturn
-gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
-{
- GstStateChangeReturn ret;
- GstGDPPay *this = GST_GDP_PAY (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-
- switch (transition) {
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- gst_gdp_pay_reset (this);
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-gboolean
-gst_gdp_pay_plugin_init (GstPlugin * plugin)
-{
- if (!gst_element_register (plugin, "gdppay", GST_RANK_NONE, GST_TYPE_GDP_PAY))
- return FALSE;
-
- return TRUE;
-}
diff --git a/gst/gdp/gstgdppay.h b/gst/gdp/gstgdppay.h
deleted file mode 100644
index 22bbcd29..00000000
--- a/gst/gdp/gstgdppay.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* GStreamer
- * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GDP_PAY_H__
-#define __GST_GDP_PAY_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GDP_PAY \
- (gst_gdp_pay_get_type())
-#define GST_GDP_PAY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GDP_PAY,GstGDPPay))
-#define GST_GDP_PAY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GDP_PAY,GstGDPPayClass))
-#define GST_IS_GDP_PAY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDP_PAY))
-#define GST_IS_GDP_PAY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDP_PAY))
-
-typedef struct _GstGDPPay GstGDPPay;
-typedef struct _GstGDPPayClass GstGDPPayClass;
-
-struct _GstGDPPay
-{
- GstElement element;
-
- GstPad *sinkpad;
- GstPad *srcpad;
-
- GstCaps *caps; /* incoming caps */
-
- GstBuffer *caps_buf;
- GstBuffer *new_segment_buf;
- GstBuffer *tag_buf;
-
- gboolean sent_streamheader; /* TRUE after the first streamheaders are sent */
- GList *queue; /* list of queued buffers before streamheaders are sent */
- guint64 offset;
-
- gboolean crc_header;
- gboolean crc_payload;
- GstDPHeaderFlag header_flag;
- GstDPVersion version;
- GstDPPacketizer *packetizer;
-};
-
-struct _GstGDPPayClass
-{
- GstElementClass parent_class;
-};
-
-gboolean gst_gdp_pay_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_GDP_PAY_H__ */
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index d5d5ac47..6ebe6997 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -33,14 +33,9 @@ check_mpeg2enc =
endif
check_PROGRAMS = \
- elements/gdppay \
- elements/gdpdepay \
$(check_mpeg2enc)
TESTS = $(check_PROGRAMS)
AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS)
LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS)
-
-elements_gdpdepay_LDFLAGS = $(LDADD) $(GST_GDP_LIBS)
-elements_gdppay_LDFLAGS = $(LDADD) $(GST_GDP_LIBS)
diff --git a/tests/check/elements/gdpdepay.c b/tests/check/elements/gdpdepay.c
deleted file mode 100644
index 74277cdf..00000000
--- a/tests/check/elements/gdpdepay.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-#include <string.h>
-#include <unistd.h>
-
-#include <gst/check/gstcheck.h>
-#include <gst/dataprotocol/dataprotocol.h>
-
-gboolean have_eos = FALSE;
-
-/* For ease of programming we use globals to keep refs for our floating
- * src and sink pads we create; otherwise we always have to do get_pad,
- * get_peer, and then remove references in every test function */
-GstPad *mysrcpad, *mysinkpad, *myshsinkpad;
-
-#define AUDIO_CAPS_TEMPLATE_STRING \
- "audio/x-raw-int, " \
- "rate = (int) [ 1, MAX ], " \
- "channels = (int) [ 1, 8 ], " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) {8, 16}, " \
- "depth = (int) {8, 16}, " \
- "signed = (boolean) true"
-
-#define AUDIO_CAPS_STRING \
- "audio/x-raw-int, " \
- "rate = (int) 1000, " \
- "channels = (int) 2, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (boolean) true"
-
-
-static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (AUDIO_CAPS_TEMPLATE_STRING)
- );
-static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-gdp")
- );
-
-/* takes over reference for outcaps */
-GstElement *
-setup_gdpdepay ()
-{
- GstElement *gdpdepay;
-
- GST_DEBUG ("setup_gdpdepay");
- gdpdepay = gst_check_setup_element ("gdpdepay");
- mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (gdpdepay, &sinktemplate, NULL);
-
- return gdpdepay;
-}
-
-void
-cleanup_gdpdepay (GstElement * gdpdepay)
-{
- GST_DEBUG ("cleanup_gdpdepay");
-
- gst_check_teardown_src_pad (gdpdepay);
- gst_check_teardown_sink_pad (gdpdepay);
- gst_check_teardown_element (gdpdepay);
-}
-
-static void
-gdpdepay_push_per_byte (gchar * reason, guint8 * bytes, guint length)
-{
- int i;
- GstBuffer *inbuffer;
-
- for (i = 0; i < length; ++i) {
- inbuffer = gst_buffer_new_and_alloc (1);
- GST_BUFFER_DATA (inbuffer)[0] = bytes[i];
- fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK,
- "%s: failed pushing byte buffer", reason);
- }
-}
-
-GST_START_TEST (test_audio_per_byte)
-{
- GstCaps *caps;
- GstPad *srcpad;
- GstElement *gdpdepay;
- GstBuffer *buffer, *inbuffer, *outbuffer;
- gint length;
- guint8 *header, *payload;
- guint len;
- guint i;
-
- gdpdepay = setup_gdpdepay ();
- srcpad = gst_element_get_pad (gdpdepay, "src");
-
- fail_unless (gst_element_set_state (gdpdepay,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
-
- caps = gst_pad_get_caps (srcpad);
- fail_unless (gst_caps_is_any (caps));
- gst_caps_unref (caps);
- fail_if (gst_pad_get_negotiated_caps (srcpad));
-
- /* create caps and buffer packets and push them */
- caps = gst_caps_from_string (AUDIO_CAPS_STRING);
- fail_unless (gst_dp_packet_from_caps (caps, 0, &len, &header, &payload));
- gst_caps_unref (caps);
- gdpdepay_push_per_byte ("caps header", header, len);
- fail_unless_equals_int (g_list_length (buffers), 0);
- gdpdepay_push_per_byte ("caps payload", payload,
- gst_dp_header_payload_length (header));
- fail_unless_equals_int (g_list_length (buffers), 0);
- caps = gst_pad_get_caps (srcpad);
- fail_if (gst_caps_is_any (caps));
- gst_caps_unref (caps);
-
- g_free (header);
- g_free (payload);
-
- buffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
- GST_BUFFER_TIMESTAMP (buffer) = GST_SECOND;
- GST_BUFFER_DURATION (buffer) = GST_SECOND / 10;
- fail_unless (gst_dp_header_from_buffer (buffer, 0, &len, &header));
- gdpdepay_push_per_byte ("buffer header", header, len);
- fail_unless_equals_int (g_list_length (buffers), 0);
- gdpdepay_push_per_byte ("buffer payload", GST_BUFFER_DATA (buffer),
- gst_dp_header_payload_length (header));
- g_free (header);
- gst_buffer_unref (buffer);
-
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (outbuffer), GST_SECOND);
- fail_unless_equals_uint64 (GST_BUFFER_DURATION (outbuffer), GST_SECOND / 10);
-
- buffers = g_list_remove (buffers, outbuffer);
- gst_buffer_unref (outbuffer);
-
- fail_unless (gst_element_set_state (gdpdepay,
- GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
-
- ASSERT_OBJECT_REFCOUNT (gdpdepay, "gdpdepay", 1);
- g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
- g_list_free (buffers);
- buffers = NULL;
- gst_object_unref (srcpad);
- cleanup_gdpdepay (gdpdepay);
-}
-
-GST_END_TEST;
-
-GST_START_TEST (test_audio_in_one_buffer)
-{
- GstCaps *caps;
- GstPad *srcpad;
- GstElement *gdpdepay;
- GstBuffer *buffer, *inbuffer, *outbuffer;
- gint length;
- guint8 *caps_header, *caps_payload, *buf_header, *buf_payload;
- guint header_len, payload_len;
- guint i;
-
- gdpdepay = setup_gdpdepay ();
- srcpad = gst_element_get_pad (gdpdepay, "src");
-
- fail_unless (gst_element_set_state (gdpdepay,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
-
- /* make sure no caps are set yet */
- caps = gst_pad_get_caps (srcpad);
- fail_unless (gst_caps_is_any (caps));
- gst_caps_unref (caps);
- fail_if (gst_pad_get_negotiated_caps (srcpad));
-
- /* create caps and buffer packets and push them as one buffer */
- caps = gst_caps_from_string (AUDIO_CAPS_STRING);
- fail_unless (gst_dp_packet_from_caps (caps, 0, &header_len, &caps_header,
- &caps_payload));
-
- buffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
- fail_unless (gst_dp_header_from_buffer (buffer, 0, &header_len, &buf_header));
-
- payload_len = gst_dp_header_payload_length (caps_header);
-
- inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
- payload_len + GST_BUFFER_SIZE (buffer));
- memcpy (GST_BUFFER_DATA (inbuffer), caps_header, GST_DP_HEADER_LENGTH);
- i = GST_DP_HEADER_LENGTH;
- memcpy (GST_BUFFER_DATA (inbuffer) + i, caps_payload, payload_len);
- i += payload_len;
- memcpy (GST_BUFFER_DATA (inbuffer) + i, buf_header, GST_DP_HEADER_LENGTH);
- i += GST_DP_HEADER_LENGTH;
- memcpy (GST_BUFFER_DATA (inbuffer) + i, GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
-
- gst_caps_unref (caps);
- gst_buffer_unref (buffer);
-
- g_free (caps_header);
- g_free (caps_payload);
- g_free (buf_header);
-
- /* now push it */
- gst_pad_push (mysrcpad, inbuffer);
-
- /* the buffer is still queued */
- fail_unless_equals_int (g_list_length (buffers), 1);
-
- fail_unless (gst_element_set_state (gdpdepay,
- GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
-
- gst_object_unref (srcpad);
- g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
- g_list_free (buffers);
- buffers = NULL;
- ASSERT_OBJECT_REFCOUNT (gdpdepay, "gdpdepay", 1);
- cleanup_gdpdepay (gdpdepay);
-}
-
-GST_END_TEST;
-
-static GstStaticPadTemplate shsinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-gst-test-streamheader")
- );
-
-GstElement *
-setup_gdpdepay_streamheader ()
-{
- GstElement *gdpdepay;
-
- GST_DEBUG ("setup_gdpdepay");
- gdpdepay = gst_check_setup_element ("gdpdepay");
- mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate, NULL);
- myshsinkpad = gst_check_setup_sink_pad (gdpdepay, &shsinktemplate, NULL);
-
- return gdpdepay;
-}
-
-#ifndef HAVE_CPU_PPC64 /* Test known to fail on PPC64. See #348114 */
-
-/* this tests deserialization of a GDP stream where the serialized caps
- * have a streamheader set */
-GST_START_TEST (test_streamheader)
-{
- GstCaps *caps, *padcaps;
- GstPad *srcpad;
- GstElement *gdpdepay;
- GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer;
- gint length;
- guint8 *caps_header, *caps_payload, *buf_header, *buf_payload;
- guint header_len, payload_len;
- guint i;
- GstStructure *structure;
- GValue array = { 0 };
- GValue value = { 0 };
-
- gdpdepay = setup_gdpdepay_streamheader ();
- srcpad = gst_element_get_pad (gdpdepay, "src");
- ASSERT_OBJECT_REFCOUNT (gdpdepay, "gdpdepay", 1);
-
- fail_unless (gst_element_set_state (gdpdepay,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
-
- /* make sure no caps are set yet */
- caps = gst_pad_get_caps (srcpad);
- fail_unless (gst_caps_is_any (caps));
- gst_caps_unref (caps);
- fail_if (gst_pad_get_negotiated_caps (srcpad));
-
- /* create a streamheader buffer and the caps containing it */
- caps = gst_caps_from_string ("application/x-gst-test-streamheader");
- structure = gst_caps_get_structure (caps, 0);
- buffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
- GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
- g_value_init (&array, GST_TYPE_ARRAY);
- g_value_init (&value, GST_TYPE_BUFFER);
- shbuffer = gst_buffer_copy (buffer);
- gst_value_set_buffer (&value, shbuffer);
- gst_buffer_unref (shbuffer);
- gst_value_array_append_value (&array, &value);
- g_value_unset (&value);
- gst_structure_set_value (structure, "streamheader", &array);
- g_value_unset (&array);
-
- gst_buffer_set_caps (buffer, caps);
-
- /* create GDP packets for the caps and the buffer, and put them in one
- * GDP buffer */
- fail_unless (gst_dp_packet_from_caps (caps, 0, &header_len, &caps_header,
- &caps_payload));
-
- fail_unless (gst_dp_header_from_buffer (buffer, 0, &header_len, &buf_header));
-
- payload_len = gst_dp_header_payload_length (caps_header);
-
- inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
- payload_len + GST_BUFFER_SIZE (buffer));
- memcpy (GST_BUFFER_DATA (inbuffer), caps_header, GST_DP_HEADER_LENGTH);
- i = GST_DP_HEADER_LENGTH;
- memcpy (GST_BUFFER_DATA (inbuffer) + i, caps_payload, payload_len);
- i += payload_len;
- memcpy (GST_BUFFER_DATA (inbuffer) + i, buf_header, GST_DP_HEADER_LENGTH);
- i += GST_DP_HEADER_LENGTH;
- memcpy (GST_BUFFER_DATA (inbuffer) + i, GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
-
- gst_caps_unref (caps);
- gst_buffer_unref (buffer);
-
- g_free (caps_header);
- g_free (caps_payload);
- g_free (buf_header);
-
- /* now push it */
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
- gst_pad_push (mysrcpad, inbuffer);
-
- /* our only output buffer is the streamheader buffer */
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
- fail_unless (GST_BUFFER_FLAG_IS_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS));
-
- padcaps = gst_pad_get_negotiated_caps (myshsinkpad);
- caps = gst_buffer_get_caps (outbuffer);
- fail_if (caps == NULL);
- fail_if (padcaps == NULL);
- GST_DEBUG ("caps: %" GST_PTR_FORMAT ", padcaps: %" GST_PTR_FORMAT, caps,
- padcaps);
- fail_unless (gst_caps_is_equal (padcaps, caps));
-
- /* FIXME: get streamheader, compare data with buffer */
- gst_buffer_unref (outbuffer);
- gst_caps_unref (padcaps);
- gst_caps_unref (caps);
-
- /* clean up */
- fail_unless (gst_element_set_state (gdpdepay,
- GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
-
- gst_object_unref (srcpad);
- g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
- g_list_free (buffers);
- buffers = NULL;
- ASSERT_OBJECT_REFCOUNT (gdpdepay, "gdpdepay", 1);
- cleanup_gdpdepay (gdpdepay);
-}
-
-GST_END_TEST;
-
-#endif /* ifndef HAVE_CPU_PPC64 */
-
-Suite *
-gdpdepay_suite (void)
-{
- Suite *s = suite_create ("gdpdepay");
- TCase *tc_chain = tcase_create ("general");
-
- suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_audio_per_byte);
- tcase_add_test (tc_chain, test_audio_in_one_buffer);
-#ifndef HAVE_CPU_PPC64 /* Test known to fail on PPC64. See #348114 */
- tcase_add_test (tc_chain, test_streamheader);
-#endif
- return s;
-}
-
-int
-main (int argc, char **argv)
-{
- int nf;
-
- Suite *s = gdpdepay_suite ();
- SRunner *sr = srunner_create (s);
-
- gst_check_init (&argc, &argv);
-
- srunner_run_all (sr, CK_NORMAL);
- nf = srunner_ntests_failed (sr);
- srunner_free (sr);
-
- return nf;
-}
diff --git a/tests/check/elements/gdppay.c b/tests/check/elements/gdppay.c
deleted file mode 100644
index a89792e3..00000000
--- a/tests/check/elements/gdppay.c
+++ /dev/null
@@ -1,571 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <string.h>
-#include <unistd.h>
-
-#include <gst/check/gstcheck.h>
-#include <gst/dataprotocol/dataprotocol.h>
-
-gboolean have_eos = FALSE;
-
-/* For ease of programming we use globals to keep refs for our floating
- * src and sink pads we create; otherwise we always have to do get_pad,
- * get_peer, and then remove references in every test function */
-GstPad *mysrcpad, *myshsrcpad, *mysinkpad;
-
-#define AUDIO_CAPS_TEMPLATE_STRING \
- "audio/x-raw-int, " \
- "rate = (int) [ 1, MAX ], " \
- "channels = (int) [ 1, 8 ], " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) {8, 16}, " \
- "depth = (int) {8, 16}, " \
- "signed = (boolean) true"
-
-#define AUDIO_CAPS_STRING \
- "audio/x-raw-int, " \
- "rate = (int) 1000, " \
- "channels = (int) 2, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (boolean) true"
-
-
-static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-gdp")
- );
-static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (AUDIO_CAPS_TEMPLATE_STRING)
- );
-
-/* takes over reference for outcaps */
-GstElement *
-setup_gdppay ()
-{
- GstElement *gdppay;
-
- GST_DEBUG ("setup_gdppay");
- gdppay = gst_check_setup_element ("gdppay");
- mysrcpad = gst_check_setup_src_pad (gdppay, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate, NULL);
-
- return gdppay;
-}
-
-void
-cleanup_gdppay (GstElement * gdppay)
-{
- GST_DEBUG ("cleanup_gdppay");
-
- gst_check_teardown_src_pad (gdppay);
- gst_check_teardown_sink_pad (gdppay);
- gst_check_teardown_element (gdppay);
-}
-
-GST_START_TEST (test_audio)
-{
- GstCaps *caps;
- GstElement *gdppay;
- GstBuffer *inbuffer, *outbuffer;
- GstEvent *event;
- gchar *caps_string;
- gint length;
-
- gdppay = setup_gdppay ();
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
-
- GST_DEBUG ("new segment");
- event =
- gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0);
- fail_unless (gst_pad_push_event (mysrcpad, event));
-
- /* no buffer should be pushed yet, waiting for caps */
- fail_unless_equals_int (g_list_length (buffers), 0);
-
- GST_DEBUG ("first buffer");
- inbuffer = gst_buffer_new_and_alloc (4);
- caps = gst_caps_from_string (AUDIO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
- caps_string = gst_caps_to_string (caps);
-
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing gives away my reference */
- fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
-
- /* we should have three buffers now */
- fail_unless_equals_int (g_list_length (buffers), 3);
-
- /* first buffer is the serialized new_segment event;
- * the element also holds a ref to it */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
- gst_buffer_unref (outbuffer);
-
- /* second buffer is the serialized caps;
- * the element also holds a ref to it */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
- length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
- /* the third buffer is the GDP buffer for our pushed buffer */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
- length = GST_DP_HEADER_LENGTH + 4;
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
- /* second buffer */
- GST_DEBUG ("second buffer");
- inbuffer = gst_buffer_new_and_alloc (4);
- gst_buffer_set_caps (inbuffer, caps);
-
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing gives away my reference */
- fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
-
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
-
- /* the third output buffer is data */
- length = GST_DP_HEADER_LENGTH + 4;
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
- /* a third buffer without caps set explicitly; should work */
- GST_DEBUG ("Creating third buffer, no caps set");
- inbuffer = gst_buffer_new_and_alloc (4);
-
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing gives away my reference */
- fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
-
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
-
- /* the fourth output buffer is data */
- length = GST_DP_HEADER_LENGTH + 4;
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
-
- gst_caps_unref (caps);
- g_free (caps_string);
- g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
- g_list_free (buffers);
- buffers = NULL;
- ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1);
- gst_object_unref (gdppay);
-}
-
-GST_END_TEST;
-
-static GstStaticPadTemplate shsrctemplate = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-gst-test-streamheader")
- );
-
-
-GstElement *
-setup_gdppay_streamheader ()
-{
- GstElement *gdppay;
-
- GST_DEBUG ("setup_gdppay");
- gdppay = gst_check_setup_element ("gdppay");
- myshsrcpad = gst_check_setup_src_pad (gdppay, &shsrctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate, NULL);
-
- return gdppay;
-}
-
-/* this test serializes a stream that already has a streamheader of its own.
- * the streamheader should then be serialized and put on the GDP stream's
- * streamheader */
-GST_START_TEST (test_streamheader)
-{
- GstCaps *caps, *sinkcaps;
- GstElement *gdppay;
- GstBuffer *inbuffer, *outbuffer, *shbuffer;
- GstEvent *event;
- gchar *caps_string;
- gint length;
- GstStructure *structure;
- GValue array = { 0 };
- GValue value = { 0 };
- const GValue *sh;
- GArray *shbuffers;
-
-
- gdppay = setup_gdppay_streamheader ();
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
-
- GST_DEBUG ("new segment");
- event =
- gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0);
- fail_unless (gst_pad_push_event (myshsrcpad, event));
-
- /* no buffer should be pushed yet, still waiting for caps */
- fail_unless_equals_int (g_list_length (buffers), 0);
-
- GST_DEBUG ("first buffer");
- inbuffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (inbuffer), "head", 4);
- caps = gst_caps_from_string ("application/x-gst-test-streamheader");
- structure = gst_caps_get_structure (caps, 0);
- GST_BUFFER_FLAG_SET (inbuffer, GST_BUFFER_FLAG_IN_CAPS);
- g_value_init (&array, GST_TYPE_ARRAY);
- g_value_init (&value, GST_TYPE_BUFFER);
- shbuffer = gst_buffer_copy (inbuffer);
- gst_value_set_buffer (&value, shbuffer);
- gst_buffer_unref (shbuffer);
- gst_value_array_append_value (&array, &value);
- g_value_unset (&value);
- gst_structure_set_value (structure, "streamheader", &array);
- g_value_unset (&array);
- caps_string = gst_caps_to_string (caps);
-
- gst_buffer_set_caps (inbuffer, caps);
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing gives away my reference */
- fail_unless (gst_pad_push (myshsrcpad, inbuffer) == GST_FLOW_OK);
-
- /* we should have three buffers now */
- fail_unless_equals_int (g_list_length (buffers), 3);
-
- /* our sink pad should now have GDP caps with a streamheader that includes
- * GDP wrappings of our streamheader */
- sinkcaps = gst_pad_get_negotiated_caps (mysinkpad);
- structure = gst_caps_get_structure (sinkcaps, 0);
- fail_unless_equals_string ((gchar *) gst_structure_get_name (structure),
- "application/x-gdp");
- fail_unless (gst_structure_has_field (structure, "streamheader"));
- sh = gst_structure_get_value (structure, "streamheader");
- fail_unless (G_VALUE_TYPE (sh) == GST_TYPE_ARRAY);
- shbuffers = g_value_peek_pointer (sh);
- /* a serialized new_segment, a serialized caps, and serialization of our
- * incoming streamheader */
- fail_unless_equals_int (shbuffers->len, 3);
-
- gst_caps_unref (sinkcaps);
-
- /* first buffer is the serialized new_segment event;
- * the element also holds a ref to it */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
- gst_buffer_unref (outbuffer);
-
- /* second buffer is the serialized caps;
- * the element also holds a ref to it */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
- length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
- /* the third buffer is the GDP buffer for our pushed buffer */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
- length = GST_DP_HEADER_LENGTH + 4;
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
- /* second buffer */
- GST_DEBUG ("second buffer");
- inbuffer = gst_buffer_new_and_alloc (4);
- gst_buffer_set_caps (inbuffer, caps);
-
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing gives away my reference */
- fail_unless (gst_pad_push (myshsrcpad, inbuffer) == GST_FLOW_OK);
-
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
-
- /* the third output buffer is data */
- length = GST_DP_HEADER_LENGTH + 4;
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
- /* a third buffer without caps set explicitly; should work */
- GST_DEBUG ("Creating third buffer, no caps set");
- inbuffer = gst_buffer_new_and_alloc (4);
-
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing gives away my reference */
- fail_unless (gst_pad_push (myshsrcpad, inbuffer) == GST_FLOW_OK);
-
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
-
- /* the fourth output buffer is data */
- length = GST_DP_HEADER_LENGTH + 4;
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
-
- gst_caps_unref (caps);
- g_free (caps_string);
- g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
- g_list_free (buffers);
- buffers = NULL;
- ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1);
- gst_object_unref (gdppay);
-}
-
-GST_END_TEST;
-
-
-GST_START_TEST (test_first_no_caps)
-{
- GstElement *gdppay;
- GstBuffer *inbuffer;
-
- gdppay = setup_gdppay ();
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
-
- GST_DEBUG ("first buffer");
- inbuffer = gst_buffer_new_and_alloc (4);
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing should trigger an error */
- fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_NOT_NEGOTIATED);
-
- fail_unless_equals_int (g_list_length (buffers), 0);
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
-
- g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
- g_list_free (buffers);
- buffers = NULL;
- ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1);
- gst_object_unref (gdppay);
-}
-
-GST_END_TEST;
-
-/* element should still work if no new_segment is sent before the first
- * buffer */
-GST_START_TEST (test_first_no_new_segment)
-{
- GstElement *gdppay;
- GstBuffer *inbuffer;
- GstCaps *caps;
-
- gdppay = setup_gdppay ();
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
-
- GST_DEBUG ("first buffer");
- inbuffer = gst_buffer_new_and_alloc (4);
- caps = gst_caps_from_string (AUDIO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
-
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing gives away my reference */
- fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
-
- /* we should have three buffers now;
- * one for an "invented" new segment, one for GDP caps, and one with our
- * buffer */
- fail_unless_equals_int (g_list_length (buffers), 3);
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
-
- g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
- g_list_free (buffers);
- buffers = NULL;
- ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1);
- gst_object_unref (gdppay);
-}
-
-GST_END_TEST;
-
-GST_START_TEST (test_crc)
-{
- GstCaps *caps;
- GstElement *gdppay;
- GstBuffer *inbuffer, *outbuffer;
- GstEvent *event;
- gchar *caps_string;
- gint length;
- guint16 crc_calculated, crc_read;
-
- gdppay = setup_gdppay ();
- g_object_set (gdppay, "crc-header", TRUE, NULL);
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
-
- GST_DEBUG ("new segment");
- event =
- gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0);
- fail_unless (gst_pad_push_event (mysrcpad, event));
-
- /* no buffer should be pushed yet, waiting for caps */
- fail_unless_equals_int (g_list_length (buffers), 0);
-
- GST_DEBUG ("first buffer");
- inbuffer = gst_buffer_new_and_alloc (4);
- caps = gst_caps_from_string (AUDIO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
- caps_string = gst_caps_to_string (caps);
-
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- /* pushing gives away my reference */
- fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
-
- /* we should have three buffers now */
- fail_unless_equals_int (g_list_length (buffers), 3);
-
- /* first buffer is the serialized new_segment event;
- * the element also holds a ref to it */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
-
- /* verify the header checksum */
- /* CRC's start at 58 in the header */
- crc_calculated = gst_dp_crc (GST_BUFFER_DATA (outbuffer), 58);
- crc_read = GST_READ_UINT16_BE (GST_BUFFER_DATA (outbuffer) + 58);
- fail_unless_equals_int (crc_calculated, crc_read);
-
- /* change a byte in the header and verify that the checksum now fails */
- GST_BUFFER_DATA (outbuffer)[0] = 0xff;
- crc_calculated = gst_dp_crc (GST_BUFFER_DATA (outbuffer), 58);
- fail_if (crc_calculated == crc_read,
- "Introducing a byte error in the header should make the checksum fail");
-
- gst_buffer_unref (outbuffer);
-
- /* second buffer is the serialized caps;
- * the element also holds a ref to it */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
- length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
- /* the third buffer is the GDP buffer for our pushed buffer */
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- buffers = g_list_remove (buffers, outbuffer);
- ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
- length = GST_DP_HEADER_LENGTH + 4;
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
- gst_buffer_unref (outbuffer);
-
- fail_unless (gst_element_set_state (gdppay,
- GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
-
- gst_caps_unref (caps);
- g_free (caps_string);
- g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
- g_list_free (buffers);
- buffers = NULL;
- ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1);
- gst_object_unref (gdppay);
-}
-
-GST_END_TEST;
-
-
-Suite *
-gdppay_suite (void)
-{
- Suite *s = suite_create ("gdppay");
- TCase *tc_chain = tcase_create ("general");
-
- suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_audio);
- tcase_add_test (tc_chain, test_first_no_caps);
- tcase_add_test (tc_chain, test_first_no_new_segment);
- tcase_add_test (tc_chain, test_streamheader);
- tcase_add_test (tc_chain, test_crc);
-
- return s;
-}
-
-int
-main (int argc, char **argv)
-{
- int nf;
-
- Suite *s = gdppay_suite ();
- SRunner *sr = srunner_create (s);
-
- gst_check_init (&argc, &argv);
-
- srunner_run_all (sr, CK_NORMAL);
- nf = srunner_ntests_failed (sr);
- srunner_free (sr);
-
- return nf;
-}