mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-08 13:18:52 +00:00
Try to fix Annodex plugin.
Original commit message from CVS: 2006-02-25 Julien MOUTTE <julien@moutte.net> * ext/annodex/Makefile.am: * ext/annodex/gstannodex.c: (plugin_init): * ext/annodex/gstcmmldec.c: * ext/annodex/gstskeldec.c: * ext/annodex/gstskeldec.h: * tests/check/Makefile.am: * tests/check/elements/skeldec.c: Try to fix Annodex plugin.
This commit is contained in:
parent
7734c8c654
commit
7f87731d5b
8 changed files with 21 additions and 712 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2006-02-25 Julien MOUTTE <julien@moutte.net>
|
||||||
|
|
||||||
|
* ext/annodex/Makefile.am:
|
||||||
|
* ext/annodex/gstannodex.c: (plugin_init):
|
||||||
|
* ext/annodex/gstcmmldec.c:
|
||||||
|
* ext/annodex/gstskeldec.c:
|
||||||
|
* ext/annodex/gstskeldec.h:
|
||||||
|
* tests/check/Makefile.am:
|
||||||
|
* tests/check/elements/skeldec.c: Try to fix Annodex plugin.
|
||||||
|
|
||||||
2006-02-25 Julien MOUTTE <julien@moutte.net>
|
2006-02-25 Julien MOUTTE <julien@moutte.net>
|
||||||
|
|
||||||
* tests/check/Makefile.am: Disable those checks as well.
|
* tests/check/Makefile.am: Disable those checks as well.
|
||||||
|
|
|
@ -13,15 +13,16 @@ libgstannodex_la_SOURCES = \
|
||||||
gstcmmlenc.c \
|
gstcmmlenc.c \
|
||||||
gstcmmltag.c \
|
gstcmmltag.c \
|
||||||
gstcmmlparser.c \
|
gstcmmlparser.c \
|
||||||
gstskeldec.c \
|
|
||||||
gstskeltag.c
|
gstskeltag.c
|
||||||
|
|
||||||
# flags used to compile this plugin
|
# flags used to compile this plugin
|
||||||
# we use the GST_LIBS flags because we might be using plug-in libs
|
# we use the GST_LIBS flags because we might be using plug-in libs
|
||||||
libgstannodex_la_CFLAGS = $(GST_CFLAGS) $(XML_CFLAGS)
|
libgstannodex_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
|
||||||
libgstannodex_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(XML_LIBS)
|
$(GST_CFLAGS) $(XML_CFLAGS)
|
||||||
|
libgstannodex_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
|
||||||
|
$(GST_LIBS) $(XML_LIBS)
|
||||||
libgstannodex_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
libgstannodex_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
|
|
||||||
# headers we need but don't want installed
|
# headers we need but don't want installed
|
||||||
noinst_HEADERS = gstannodex.h gstcmmlutils.h gstcmmltag.h gstcmmlparser.h \
|
noinst_HEADERS = gstannodex.h gstcmmlutils.h gstcmmltag.h gstcmmlparser.h \
|
||||||
gstcmmldec.h gstskeldec.h gstcmmlenc.h
|
gstcmmldec.h gstcmmlenc.h
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <gst/tag/tag.h>
|
||||||
#include "gstcmmlenc.h"
|
#include "gstcmmlenc.h"
|
||||||
#include "gstcmmldec.h"
|
#include "gstcmmldec.h"
|
||||||
#include "gstskeldec.h"
|
|
||||||
|
|
||||||
GstClockTime
|
GstClockTime
|
||||||
gst_annodex_granule_to_time (gint64 granulepos, gint64 granulerate_n,
|
gst_annodex_granule_to_time (gint64 granulepos, gint64 granulerate_n,
|
||||||
|
@ -151,9 +151,6 @@ plugin_init (GstPlugin * plugin)
|
||||||
if (!gst_cmml_dec_plugin_init (plugin))
|
if (!gst_cmml_dec_plugin_init (plugin))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!gst_skel_dec_plugin_init (plugin))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include <gst/tag/tag.h>
|
||||||
#include "gstannodex.h"
|
#include "gstannodex.h"
|
||||||
#include "gstcmmltag.h"
|
#include "gstcmmltag.h"
|
||||||
#include "gstcmmldec.h"
|
#include "gstcmmldec.h"
|
||||||
|
|
|
@ -1,380 +0,0 @@
|
||||||
/*
|
|
||||||
* gstskeldec.c - GStreamer annodex skeleton decoder
|
|
||||||
* Copyright (C) 2005 Alessandro Decina
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Alessandro Decina <alessandro@nnva.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 "gstskeldec.h"
|
|
||||||
#include "gstskeltag.h"
|
|
||||||
#include "gstannodex.h"
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY (skeldec);
|
|
||||||
#define GST_CAT_DEFAULT skeldec
|
|
||||||
|
|
||||||
#define FISHEAD_SIZE 64
|
|
||||||
#define FISBONE_MIN_SIZE 52
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
GST_SKEL_TAG_FISHEAD_UTC_LEN = 19
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
static GstElementDetails gst_skel_dec_details = {
|
|
||||||
"skeldec: Annodex skeleton stream decoder",
|
|
||||||
"Codec/Decoder",
|
|
||||||
"Decodes ogg skeleton streams",
|
|
||||||
"Alessandro Decina <alessandro@nnva.org>",
|
|
||||||
};
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_skel_dec_src_factory =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS ("application/x-ogg-skeleton, parsed=(boolean)TRUE")
|
|
||||||
);
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_skel_dec_sink_factory =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
||||||
GST_PAD_SINK,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS ("application/x-ogg-skeleton, parsed=(boolean)FALSE")
|
|
||||||
);
|
|
||||||
|
|
||||||
/* GstSkelDec prototypes */
|
|
||||||
GST_BOILERPLATE (GstSkelDec, gst_skel_dec, GstElement, GST_TYPE_ELEMENT);
|
|
||||||
static gboolean gst_skel_dec_sink_query (GstPad * pad, GstQuery * query);
|
|
||||||
static GstStateChangeReturn gst_skel_dec_change_state (GstElement * element,
|
|
||||||
GstStateChange transition);
|
|
||||||
static GstFlowReturn gst_skel_dec_chain (GstPad * pad, GstBuffer * buffer);
|
|
||||||
static GstFlowReturn gst_skel_dec_parse_fishead (GstSkelDec * dec,
|
|
||||||
GstBuffer * buffer);
|
|
||||||
static GstFlowReturn gst_skel_dec_parse_fisbone (GstSkelDec * dec,
|
|
||||||
GstBuffer * buffer);
|
|
||||||
|
|
||||||
/* GstSkelDec code */
|
|
||||||
static void
|
|
||||||
gst_skel_dec_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_skel_dec_sink_factory));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_skel_dec_src_factory));
|
|
||||||
gst_element_class_set_details (element_class, &gst_skel_dec_details);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_skel_dec_class_init (GstSkelDecClass * klass)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
||||||
|
|
||||||
element_class->change_state = gst_skel_dec_change_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_skel_dec_init (GstSkelDec * dec, GstSkelDecClass * klass)
|
|
||||||
{
|
|
||||||
dec->sinkpad =
|
|
||||||
gst_pad_new_from_static_template (&gst_skel_dec_sink_factory, "sink");
|
|
||||||
gst_pad_set_query_function (dec->sinkpad, gst_skel_dec_sink_query);
|
|
||||||
gst_pad_set_chain_function (dec->sinkpad, gst_skel_dec_chain);
|
|
||||||
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
|
|
||||||
|
|
||||||
dec->srcpad =
|
|
||||||
gst_pad_new_from_static_template (&gst_skel_dec_src_factory, "src");
|
|
||||||
gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_skel_dec_sink_query (GstPad * pad, GstQuery * query)
|
|
||||||
{
|
|
||||||
gboolean res = FALSE;
|
|
||||||
|
|
||||||
switch (GST_QUERY_TYPE (query)) {
|
|
||||||
case GST_QUERY_CONVERT:
|
|
||||||
{
|
|
||||||
GstFormat src_format, dest_format;
|
|
||||||
gint64 src_val, dest_val;
|
|
||||||
|
|
||||||
gst_query_parse_convert (query, &src_format, &src_val,
|
|
||||||
&dest_format, &dest_val);
|
|
||||||
|
|
||||||
if (dest_format == GST_FORMAT_TIME) {
|
|
||||||
dest_val = GST_CLOCK_TIME_NONE;
|
|
||||||
res = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
gst_query_set_convert (query, src_format, src_val,
|
|
||||||
dest_format, dest_val);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstStateChangeReturn
|
|
||||||
gst_skel_dec_change_state (GstElement * element, GstStateChange transition)
|
|
||||||
{
|
|
||||||
GstSkelDec *dec = GST_SKEL_DEC (element);
|
|
||||||
GstStateChangeReturn res;
|
|
||||||
|
|
||||||
/* handle the upward state changes */
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
|
||||||
dec->major = 0;
|
|
||||||
dec->minor = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = parent_class->change_state (element, transition);
|
|
||||||
|
|
||||||
/* no need to handle downward state changes */
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_skel_dec_chain (GstPad * pad, GstBuffer * buffer)
|
|
||||||
{
|
|
||||||
GstSkelDec *dec = GST_SKEL_DEC (GST_PAD_PARENT (pad));
|
|
||||||
GstFlowReturn ret;
|
|
||||||
|
|
||||||
gint size = GST_BUFFER_SIZE (buffer);
|
|
||||||
guint8 *data = GST_BUFFER_DATA (buffer);
|
|
||||||
|
|
||||||
if (GST_BUFFER_SIZE (buffer) == 0) {
|
|
||||||
/* the skeleton EOS has no packet data */
|
|
||||||
return GST_FLOW_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size >= GST_SKEL_OGG_FISHEAD_SIZE && !memcmp (data, "fishead\0", 8)) {
|
|
||||||
ret = gst_skel_dec_parse_fishead (dec, buffer);
|
|
||||||
} else if (size >= 8 && !memcmp (data, "fisbone\0", 8)) {
|
|
||||||
ret = gst_skel_dec_parse_fisbone (dec, buffer);
|
|
||||||
} else {
|
|
||||||
/* maybe it would be better to ignore the packet */
|
|
||||||
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("unknown packet type"));
|
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_skel_dec_parse_fishead (GstSkelDec * dec, GstBuffer * buffer)
|
|
||||||
{
|
|
||||||
GstTagList *tags;
|
|
||||||
guint8 *data = GST_BUFFER_DATA (buffer);
|
|
||||||
GstSkelTagFishead *fishead;
|
|
||||||
|
|
||||||
if (GST_BUFFER_SIZE (buffer) != FISHEAD_SIZE)
|
|
||||||
goto wrong_size;
|
|
||||||
|
|
||||||
fishead = g_object_new (GST_TYPE_SKEL_TAG_FISHEAD, NULL);
|
|
||||||
|
|
||||||
data += 8;
|
|
||||||
fishead->major = GST_READ_UINT16_LE (data);
|
|
||||||
data += 2;
|
|
||||||
fishead->minor = GST_READ_UINT16_LE (data);
|
|
||||||
data += 2;
|
|
||||||
fishead->prestime_n = (gint64) GST_READ_UINT64_LE (data);
|
|
||||||
data += 8;
|
|
||||||
fishead->prestime_d = (gint64) GST_READ_UINT64_LE (data);
|
|
||||||
data += 8;
|
|
||||||
fishead->basetime_n = (gint64) GST_READ_UINT64_LE (data);
|
|
||||||
data += 8;
|
|
||||||
fishead->basetime_d = (gint64) GST_READ_UINT64_LE (data);
|
|
||||||
data += 8;
|
|
||||||
fishead->utc = g_strndup ((gchar *) data, GST_SKEL_TAG_FISHEAD_UTC_LEN);
|
|
||||||
|
|
||||||
GST_INFO_OBJECT (dec, "fishead parsed ("
|
|
||||||
"major: %" G_GUINT16_FORMAT " minor: %" G_GUINT16_FORMAT
|
|
||||||
" prestime_n: %" G_GINT64_FORMAT " prestime_d: %" G_GINT64_FORMAT
|
|
||||||
" basetime_n: %" G_GINT64_FORMAT " basetime_d: %" G_GINT64_FORMAT
|
|
||||||
" utc: %s)", fishead->major, fishead->minor, fishead->prestime_n,
|
|
||||||
fishead->prestime_d, fishead->basetime_n, fishead->basetime_d,
|
|
||||||
fishead->utc);
|
|
||||||
|
|
||||||
/* send the TAG_MESSAGE */
|
|
||||||
tags = gst_tag_list_new ();
|
|
||||||
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND,
|
|
||||||
GST_TAG_SKELETON_FISHEAD, fishead, NULL);
|
|
||||||
gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, tags);
|
|
||||||
|
|
||||||
g_object_unref (fishead);
|
|
||||||
|
|
||||||
/* forward the fishead */
|
|
||||||
gst_buffer_set_caps (buffer,
|
|
||||||
gst_static_pad_template_get_caps (&gst_skel_dec_src_factory));
|
|
||||||
return gst_pad_push (dec->srcpad, buffer);
|
|
||||||
|
|
||||||
wrong_size:
|
|
||||||
GST_ELEMENT_ERROR (dec, STREAM, DECODE,
|
|
||||||
(NULL), ("wrong fishead packet size: %d", GST_BUFFER_SIZE (buffer)));
|
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
return GST_FLOW_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_skel_dec_parse_fisbone (GstSkelDec * dec, GstBuffer * buffer)
|
|
||||||
{
|
|
||||||
GstSkelTagFisbone *fisbone;
|
|
||||||
guint8 *data;
|
|
||||||
gchar *headers;
|
|
||||||
gchar **tokens;
|
|
||||||
const gchar *content_type;
|
|
||||||
GstTagList *tags;
|
|
||||||
GValue *val;
|
|
||||||
|
|
||||||
if (GST_BUFFER_SIZE (buffer) < FISBONE_MIN_SIZE)
|
|
||||||
goto wrong_size;
|
|
||||||
|
|
||||||
data = GST_BUFFER_DATA (buffer);
|
|
||||||
fisbone = g_object_new (GST_TYPE_SKEL_TAG_FISBONE, NULL);
|
|
||||||
|
|
||||||
data += 8;
|
|
||||||
fisbone->hdr_offset = GST_READ_UINT32_LE (data);
|
|
||||||
data += 4;
|
|
||||||
fisbone->serialno = GST_READ_UINT32_LE (data);
|
|
||||||
data += 4;
|
|
||||||
fisbone->hdr_num = GST_READ_UINT32_LE (data);
|
|
||||||
data += 4;
|
|
||||||
fisbone->granulerate_n = GST_READ_UINT64_LE (data);
|
|
||||||
data += 8;
|
|
||||||
fisbone->granulerate_d = GST_READ_UINT64_LE (data);
|
|
||||||
data += 8;
|
|
||||||
fisbone->start_granule = GST_READ_UINT64_LE (data);
|
|
||||||
data += 8;
|
|
||||||
fisbone->preroll = GST_READ_UINT32_LE (data);
|
|
||||||
data += 4;
|
|
||||||
fisbone->granuleshift = GST_READ_UINT8 (data);
|
|
||||||
data += 1;
|
|
||||||
data += 3; /* padding */
|
|
||||||
|
|
||||||
/* 8 = strlen ("fishead\0") */
|
|
||||||
headers = g_strndup ((gchar *) data,
|
|
||||||
GST_BUFFER_SIZE (buffer) - 8 - fisbone->hdr_offset);
|
|
||||||
fisbone->headers = gst_annodex_parse_headers (headers);
|
|
||||||
g_free (headers);
|
|
||||||
|
|
||||||
if (!fisbone->headers)
|
|
||||||
goto bad_headers;
|
|
||||||
|
|
||||||
/* check for the mandatory Content-Type header: it MUST be the first
|
|
||||||
* header */
|
|
||||||
if (fisbone->headers->n_values < 2 ||
|
|
||||||
(val = g_value_array_get_nth (fisbone->headers, 0)) == NULL ||
|
|
||||||
strcmp (g_value_get_string (val), "Content-Type"))
|
|
||||||
goto no_content_type;
|
|
||||||
|
|
||||||
/* get the Content-Type value */
|
|
||||||
val = g_value_array_get_nth (fisbone->headers, 1);
|
|
||||||
content_type = g_value_get_string (val);
|
|
||||||
|
|
||||||
/* Content-Type must not be empty */
|
|
||||||
if (*content_type == '\0')
|
|
||||||
goto bad_content_type;
|
|
||||||
|
|
||||||
/* split the content-type field into "content_type; encoding" */
|
|
||||||
tokens = g_strsplit (content_type, ";", 2);
|
|
||||||
fisbone->content_type = g_strdup (g_strstrip (tokens[0]));
|
|
||||||
fisbone->encoding = tokens[1] == NULL ? NULL :
|
|
||||||
g_strdup (g_strstrip (tokens[1]));
|
|
||||||
g_strfreev (tokens);
|
|
||||||
|
|
||||||
GST_INFO_OBJECT (dec, "fisbone parsed ("
|
|
||||||
"serialno %" G_GUINT32_FORMAT " granulerate_n: %" G_GINT64_FORMAT
|
|
||||||
" granulerate_d: %" G_GINT64_FORMAT " start_granule: %" G_GINT64_FORMAT
|
|
||||||
" preroll: %" G_GUINT32_FORMAT " granuleshift: %d"
|
|
||||||
" content-type: %s)",
|
|
||||||
fisbone->serialno, fisbone->granulerate_n, fisbone->granulerate_d,
|
|
||||||
fisbone->start_granule, fisbone->preroll, fisbone->granuleshift,
|
|
||||||
fisbone->content_type);
|
|
||||||
|
|
||||||
/* send the tag message */
|
|
||||||
tags = gst_tag_list_new ();
|
|
||||||
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND,
|
|
||||||
GST_TAG_SKELETON_FISBONE, fisbone, NULL);
|
|
||||||
gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, tags);
|
|
||||||
|
|
||||||
g_object_unref (fisbone);
|
|
||||||
|
|
||||||
gst_buffer_set_caps (buffer,
|
|
||||||
gst_static_pad_template_get_caps (&gst_skel_dec_src_factory));
|
|
||||||
return gst_pad_push (dec->srcpad, buffer);
|
|
||||||
|
|
||||||
wrong_size:
|
|
||||||
GST_ELEMENT_ERROR (dec, STREAM, DECODE,
|
|
||||||
(NULL), ("wrong fisbone size (%d)", GST_BUFFER_SIZE (buffer)));
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
return GST_FLOW_ERROR;
|
|
||||||
|
|
||||||
bad_headers:
|
|
||||||
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("bad fisbone headers"));
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
g_object_unref (fisbone);
|
|
||||||
return GST_FLOW_ERROR;
|
|
||||||
|
|
||||||
no_content_type:
|
|
||||||
bad_content_type:
|
|
||||||
GST_ELEMENT_ERROR (dec, STREAM, DECODE,
|
|
||||||
(NULL), ("missing or bad fisbone content-type"));
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
g_object_unref (fisbone);
|
|
||||||
return GST_FLOW_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_skel_dec_plugin_init (GstPlugin * plugin)
|
|
||||||
{
|
|
||||||
if (!gst_element_register (plugin, "skeldec", GST_RANK_PRIMARY,
|
|
||||||
gst_skel_dec_get_type ()))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gst_tag_register (GST_TAG_SKELETON_FISHEAD, GST_TAG_FLAG_META,
|
|
||||||
GST_TYPE_SKEL_TAG_FISHEAD, "skeleton-fishead",
|
|
||||||
"annodex skeleton fishead tag", NULL);
|
|
||||||
|
|
||||||
gst_tag_register (GST_TAG_SKELETON_FISBONE, GST_TAG_FLAG_META,
|
|
||||||
GST_TYPE_SKEL_TAG_FISBONE, "skeleton-fisbone",
|
|
||||||
"annodex skeleton fisbone tag", NULL);
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (skeldec, "skeldec", 0,
|
|
||||||
"annodex skeleton decoding element");
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* gstskeldec.h - GStreamer annodex skeleton decoder
|
|
||||||
* Copyright (C) 2005 Alessandro Decina
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Alessandro Decina <alessandro@nnva.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_SKEL_DEC_H__
|
|
||||||
#define __GST_SKEL_DEC_H__
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
/* GstSkelDec */
|
|
||||||
#define GST_TYPE_SKEL_DEC (gst_skel_dec_get_type ())
|
|
||||||
#define GST_SKEL_DEC(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_SKEL_DEC, GstSkelDec))
|
|
||||||
#define GST_SKEL_DEC_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_SKEL_DEC, GstSkelDec))
|
|
||||||
#define GST_SKEL_DEC_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_SKEL_DEC, GstSkelDecClass))
|
|
||||||
|
|
||||||
typedef struct _GstSkelDec GstSkelDec;
|
|
||||||
typedef struct _GstSkelDecClass GstSkelDecClass;
|
|
||||||
|
|
||||||
#define GST_SKEL_OGG_FISHEAD_SIZE 64
|
|
||||||
#define UTC_LEN 20
|
|
||||||
|
|
||||||
struct _GstSkelDec
|
|
||||||
{
|
|
||||||
GstElement element;
|
|
||||||
|
|
||||||
GstPad *sinkpad;
|
|
||||||
GstPad *srcpad;
|
|
||||||
|
|
||||||
gint16 major; /* skeleton version major */
|
|
||||||
gint16 minor; /* skeleton version minor */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GstSkelDecClass
|
|
||||||
{
|
|
||||||
GstElementClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_skel_dec_get_type (void);
|
|
||||||
gboolean gst_skel_dec_plugin_init (GstPlugin * plugin);
|
|
||||||
|
|
||||||
#endif /* __GST_SKEL_DEC_H__ */
|
|
|
@ -19,10 +19,10 @@ TESTS = $(check_PROGRAMS)
|
||||||
|
|
||||||
check_PROGRAMS = \
|
check_PROGRAMS = \
|
||||||
elements/level \
|
elements/level \
|
||||||
elements/matroskamux
|
elements/matroskamux \
|
||||||
# elements/cmmldec \
|
elements/cmmldec \
|
||||||
# elements/cmmlenc \
|
elements/cmmlenc \
|
||||||
# elements/skeldec
|
elements/skeldec
|
||||||
|
|
||||||
|
|
||||||
# these tests don't even pass
|
# these tests don't even pass
|
||||||
|
|
|
@ -1,258 +0,0 @@
|
||||||
/*
|
|
||||||
* skeldec.c - GStreamer annodex skeleton decoder test suite
|
|
||||||
* Copyright (C) 2005 Alessandro Decina
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Alessandro Decina <alessandro@nnva.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 <gst/check/gstcheck.h>
|
|
||||||
|
|
||||||
GList *buffers;
|
|
||||||
|
|
||||||
GstPad *srcpad, *sinkpad;
|
|
||||||
|
|
||||||
#define SKELETON_CAPS "application/x-ogg-skeleton"
|
|
||||||
|
|
||||||
#define SKELETON_FISHEAD \
|
|
||||||
"fishead\0"\
|
|
||||||
"\x03\0\0\0"\
|
|
||||||
"\x39\x30\0\0\0\0\0\0"\
|
|
||||||
"\x39\x30\0\0\0\0\0\0"\
|
|
||||||
"\x39\x30\0\0\0\0\0\0"\
|
|
||||||
"\x39\x30\0\0\0\0\0\0"\
|
|
||||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
|
||||||
|
|
||||||
#define SKELETON_FISHEAD_SIZE 64
|
|
||||||
|
|
||||||
#define SKELETON_FISBONE \
|
|
||||||
"fisbone\0"\
|
|
||||||
"\x2c\0\0\0"\
|
|
||||||
"\x39\x30\0\0"\
|
|
||||||
"\x39\x30\0\0"\
|
|
||||||
"\x39\x30\0\0\0\0\0\0"\
|
|
||||||
"\x39\x30\0\0\0\0\0\0"\
|
|
||||||
"\x39\x30\0\0\0\0\0\0"\
|
|
||||||
"\x39\x30\0\0"\
|
|
||||||
"\x20"\
|
|
||||||
"\0\0\0"\
|
|
||||||
"Content-Type: application/ogg; UTF-8\r\n"
|
|
||||||
|
|
||||||
#define SKELETON_FISBONE_SIZE 90
|
|
||||||
|
|
||||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
||||||
GST_PAD_SINK,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS_ANY);
|
|
||||||
|
|
||||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS (SKELETON_CAPS)
|
|
||||||
);
|
|
||||||
|
|
||||||
static GstElement *
|
|
||||||
setup_skeldec ()
|
|
||||||
{
|
|
||||||
GstElement *skeldec;
|
|
||||||
|
|
||||||
GST_DEBUG ("setup_skeldec");
|
|
||||||
skeldec = gst_check_setup_element ("skeldec");
|
|
||||||
srcpad = gst_check_setup_src_pad (skeldec, &srctemplate, NULL);
|
|
||||||
sinkpad = gst_check_setup_sink_pad (skeldec, &sinktemplate, NULL);
|
|
||||||
|
|
||||||
return skeldec;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cleanup_skeldec (GstElement * skeldec)
|
|
||||||
{
|
|
||||||
GST_DEBUG ("cleanup_skeldec");
|
|
||||||
|
|
||||||
gst_check_teardown_src_pad (skeldec);
|
|
||||||
gst_check_teardown_sink_pad (skeldec);
|
|
||||||
gst_check_teardown_element (skeldec);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
skel_buffer_unref (void *buf, void *user_data)
|
|
||||||
{
|
|
||||||
GstBuffer *buffer = GST_BUFFER (buf);
|
|
||||||
|
|
||||||
ASSERT_OBJECT_REFCOUNT (buffer, "skel-buffer", 1);
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstBuffer *
|
|
||||||
skel_buffer_new (gchar * buffer_data, guint size)
|
|
||||||
{
|
|
||||||
GstBuffer *buffer;
|
|
||||||
GstCaps *caps;
|
|
||||||
|
|
||||||
buffer = gst_buffer_new_and_alloc (size);
|
|
||||||
memcpy (GST_BUFFER_DATA (buffer), buffer_data, size);
|
|
||||||
caps = gst_caps_from_string (SKELETON_CAPS);
|
|
||||||
gst_buffer_set_caps (buffer, caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_START_TEST (test_dec)
|
|
||||||
{
|
|
||||||
GstElement *skeldec;
|
|
||||||
GstBus *bus;
|
|
||||||
GstBuffer *inbuffer;
|
|
||||||
GstMessage *message;
|
|
||||||
GstTagList *tags;
|
|
||||||
const GValue *tag_val, *val;
|
|
||||||
GObject *tag;
|
|
||||||
gint major, minor;
|
|
||||||
gint64 prestime_n, prestime_d;
|
|
||||||
gint64 basetime_n, basetime_d;
|
|
||||||
guint serial_number;
|
|
||||||
gint64 granule_rate_n, granule_rate_d;
|
|
||||||
gint64 granule_start;
|
|
||||||
guint64 preroll;
|
|
||||||
guint granule_shift;
|
|
||||||
GValueArray *headers;
|
|
||||||
gchar *content_type;
|
|
||||||
gchar *encoding;
|
|
||||||
|
|
||||||
skeldec = setup_skeldec ();
|
|
||||||
|
|
||||||
bus = gst_bus_new ();
|
|
||||||
gst_element_set_bus (skeldec, bus);
|
|
||||||
|
|
||||||
fail_unless (gst_element_set_state (skeldec,
|
|
||||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
||||||
"could not set to playing");
|
|
||||||
|
|
||||||
/* test the fishead */
|
|
||||||
inbuffer = skel_buffer_new (SKELETON_FISHEAD, SKELETON_FISHEAD_SIZE);
|
|
||||||
fail_unless_equals_int (gst_pad_push (srcpad, inbuffer), GST_FLOW_OK);
|
|
||||||
|
|
||||||
message = gst_bus_poll (bus, GST_MESSAGE_TAG, -1);
|
|
||||||
fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (skeldec));
|
|
||||||
|
|
||||||
gst_message_parse_tag (message, &tags);
|
|
||||||
fail_unless (tags != NULL);
|
|
||||||
fail_unless_equals_int (gst_tag_list_get_tag_size (tags,
|
|
||||||
GST_TAG_SKELETON_FISHEAD), 1);
|
|
||||||
|
|
||||||
tag_val = gst_tag_list_get_value_index (tags, GST_TAG_SKELETON_FISHEAD, 0);
|
|
||||||
fail_unless (tag_val != NULL);
|
|
||||||
|
|
||||||
tag = g_value_get_object (tag_val);
|
|
||||||
fail_unless (tag != NULL);
|
|
||||||
|
|
||||||
g_object_get (tag,
|
|
||||||
"version-major", &major, "version-minor", &minor,
|
|
||||||
"presentation-time-numerator", &prestime_n,
|
|
||||||
"presentation-time-denominator", &prestime_d,
|
|
||||||
"base-time-numerator", &basetime_n,
|
|
||||||
"base-time-denominator", &basetime_d, NULL);
|
|
||||||
|
|
||||||
fail_unless_equals_int (major, 3);
|
|
||||||
fail_unless_equals_int (minor, 0);
|
|
||||||
fail_unless_equals_int (prestime_n, 12345);
|
|
||||||
fail_unless_equals_int (prestime_d, 12345);
|
|
||||||
fail_unless_equals_int (basetime_n, 12345);
|
|
||||||
fail_unless_equals_int (basetime_d, 12345);
|
|
||||||
|
|
||||||
gst_tag_list_free (tags);
|
|
||||||
gst_message_unref (message);
|
|
||||||
|
|
||||||
/* test the fisbone */
|
|
||||||
inbuffer = skel_buffer_new (SKELETON_FISBONE, SKELETON_FISBONE_SIZE);
|
|
||||||
fail_unless_equals_int (gst_pad_push (srcpad, inbuffer), GST_FLOW_OK);
|
|
||||||
|
|
||||||
message = gst_bus_poll (bus, GST_MESSAGE_TAG, -1);
|
|
||||||
fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (skeldec));
|
|
||||||
|
|
||||||
gst_message_parse_tag (message, &tags);
|
|
||||||
fail_unless (tags != NULL);
|
|
||||||
fail_unless_equals_int (gst_tag_list_get_tag_size (tags,
|
|
||||||
GST_TAG_SKELETON_FISBONE), 1);
|
|
||||||
|
|
||||||
tag_val = gst_tag_list_get_value_index (tags, GST_TAG_SKELETON_FISBONE, 0);
|
|
||||||
fail_unless (tag_val != NULL);
|
|
||||||
|
|
||||||
tag = g_value_get_object (tag_val);
|
|
||||||
fail_unless (tag != NULL);
|
|
||||||
|
|
||||||
g_object_get (tag, "serial-number", &serial_number,
|
|
||||||
"granule-rate-numerator", &granule_rate_n,
|
|
||||||
"granule-rate-denominator", &granule_rate_d,
|
|
||||||
"granule-start", &granule_start,
|
|
||||||
"granule-shift", &granule_shift,
|
|
||||||
"preroll", &preroll,
|
|
||||||
"headers", &headers,
|
|
||||||
"content-type", &content_type, "encoding", &encoding, NULL);
|
|
||||||
|
|
||||||
fail_unless_equals_int (serial_number, 12345);
|
|
||||||
fail_unless_equals_int (granule_rate_n, 12345);
|
|
||||||
fail_unless_equals_int (granule_rate_d, 12345);
|
|
||||||
fail_unless_equals_int (granule_start, 12345);
|
|
||||||
fail_unless_equals_int (preroll, 12345);
|
|
||||||
fail_unless_equals_int (granule_shift, 32);
|
|
||||||
fail_unless_equals_int (headers->n_values, 2);
|
|
||||||
fail_unless_equals_string (content_type, "application/ogg");
|
|
||||||
fail_unless_equals_string (encoding, "UTF-8");
|
|
||||||
|
|
||||||
g_value_array_free (headers);
|
|
||||||
g_free (content_type);
|
|
||||||
g_free (encoding);
|
|
||||||
gst_tag_list_free (tags);
|
|
||||||
gst_message_unref (message);
|
|
||||||
gst_bus_set_flushing (bus, TRUE);
|
|
||||||
gst_object_unref (bus);
|
|
||||||
g_list_foreach (buffers, skel_buffer_unref, NULL);
|
|
||||||
cleanup_skeldec (skeldec);
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_END_TEST;
|
|
||||||
|
|
||||||
static Suite *
|
|
||||||
skeldec_suite ()
|
|
||||||
{
|
|
||||||
Suite *s = suite_create ("skeldec");
|
|
||||||
TCase *tc_chain = tcase_create ("general");
|
|
||||||
|
|
||||||
suite_add_tcase (s, tc_chain);
|
|
||||||
tcase_add_test (tc_chain, test_dec);
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
int nf;
|
|
||||||
|
|
||||||
Suite *s = skeldec_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;
|
|
||||||
}
|
|
Loading…
Reference in a new issue