gst/realmedia/: Added RDT depayloader.

Original commit message from CVS:
* gst/realmedia/Makefile.am:
* gst/realmedia/rdtdepay.c: (gst_rdt_depay_base_init),
(gst_rdt_depay_class_init), (gst_rdt_depay_init),
(gst_rdt_depay_setcaps), (gst_rdt_depay_chain),
(gst_rdt_depay_set_property), (gst_rdt_depay_get_property),
(gst_rdt_depay_change_state), (gst_rdt_depay_plugin_init):
* gst/realmedia/rdtdepay.h:
Added RDT depayloader.
* gst/realmedia/rmdemux.c: (gst_rmdemux_parse_mdpr),
(gst_rmdemux_plugin_init), (plugin_init):
Remove unused function.
Added some more mime-types.
This commit is contained in:
Wim Taymans 2006-10-03 10:55:42 +00:00
parent 65d7dd9c60
commit 8dd0cc1db3
6 changed files with 459 additions and 37 deletions

View file

@ -1,3 +1,19 @@
2006-10-03 Wim Taymans <wim@fluendo.com>
* gst/realmedia/Makefile.am:
* gst/realmedia/rdtdepay.c: (gst_rdt_depay_base_init),
(gst_rdt_depay_class_init), (gst_rdt_depay_init),
(gst_rdt_depay_setcaps), (gst_rdt_depay_chain),
(gst_rdt_depay_set_property), (gst_rdt_depay_get_property),
(gst_rdt_depay_change_state), (gst_rdt_depay_plugin_init):
* gst/realmedia/rdtdepay.h:
Added RDT depayloader.
* gst/realmedia/rmdemux.c: (gst_rmdemux_parse_mdpr),
(gst_rmdemux_plugin_init), (plugin_init):
Remove unused function.
Added some more mime-types.
2006-09-28 Jan Schmidt <thaytan@mad.scientist.com> 2006-09-28 Jan Schmidt <thaytan@mad.scientist.com>
* gst/dvdlpcmdec/gstdvdlpcmdec.c: (update_timestamps): * gst/dvdlpcmdec/gstdvdlpcmdec.c: (update_timestamps):

2
common

@ -1 +1 @@
Subproject commit bdd0108b3540ffadeb82cee28b8867a8a6e7ae78 Subproject commit 9991f6fa61ee11475c390dd6675ef7952f079e43

View file

@ -1,9 +1,9 @@
plugin_LTLIBRARIES = libgstrmdemux.la plugin_LTLIBRARIES = libgstrmdemux.la
libgstrmdemux_la_SOURCES = rmdemux.c rmutils.c libgstrmdemux_la_SOURCES = rmdemux.c rmutils.c rdtdepay.c
libgstrmdemux_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) libgstrmdemux_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS)
libgstrmdemux_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) libgstrmdemux_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS)
libgstrmdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstrmdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = rmdemux.h rmutils.h noinst_HEADERS = rmdemux.h rmutils.h rdtdepay.h

352
gst/realmedia/rdtdepay.c Normal file
View file

@ -0,0 +1,352 @@
/* GStreamer
* Copyright (C) <2006> Lutz Mueller <lutz at topfrose dot de>
* <2006> Wim Taymans <wim@fluendo.com>
*
* 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 <string.h>
#include "rdtdepay.h"
GST_DEBUG_CATEGORY_STATIC (rdtdepay_debug);
#define GST_CAT_DEFAULT rdtdepay_debug
/* elementfactory information */
static const GstElementDetails gst_rdtdepay_details =
GST_ELEMENT_DETAILS ("RDT packet parser",
"Codec/Depayloader/Network",
"Extracts RealMedia from RDT packets",
"Lutz Mueller <lutz at topfrose dot de>, " "Wim Taymans <wim@fluendo.com>");
/* RDTDepay signals and args */
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum
{
ARG_0,
};
static GstStaticPadTemplate gst_rdt_depay_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/vnd.rn-realmedia")
);
static GstStaticPadTemplate gst_rdt_depay_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"application\", "
"clock-rate = (int) [1, MAX ], "
"encoding-name = (string) \"x-real-rdt\""
/* All optional parameters
*
* "config="
*/
)
);
GST_BOILERPLATE (GstRDTDepay, gst_rdt_depay, GstElement, GST_TYPE_ELEMENT);
static gboolean gst_rdt_depay_setcaps (GstPad * pad, GstCaps * caps);
static GstFlowReturn gst_rdt_depay_chain (GstPad * pad, GstBuffer * buf);
static void gst_rdt_depay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_rdt_depay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstStateChangeReturn gst_rdt_depay_change_state (GstElement *
element, GstStateChange transition);
static void
gst_rdt_depay_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rdt_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rdt_depay_sink_template));
gst_element_class_set_details (element_class, &gst_rdtdepay_details);
GST_DEBUG_CATEGORY_INIT (rdtdepay_debug, "rdtdepay",
0, "Depayloader for RDT RealMedia packets");
}
static void
gst_rdt_depay_class_init (GstRDTDepayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->set_property = gst_rdt_depay_set_property;
gobject_class->get_property = gst_rdt_depay_get_property;
gstelement_class->change_state = gst_rdt_depay_change_state;
}
static void
gst_rdt_depay_init (GstRDTDepay * rdtdepay, GstRDTDepayClass * klass)
{
rdtdepay->sinkpad =
gst_pad_new_from_static_template (&gst_rdt_depay_sink_template, "sink");
gst_pad_set_chain_function (rdtdepay->sinkpad, gst_rdt_depay_chain);
gst_pad_set_setcaps_function (rdtdepay->sinkpad, gst_rdt_depay_setcaps);
gst_element_add_pad (GST_ELEMENT_CAST (rdtdepay), rdtdepay->sinkpad);
rdtdepay->srcpad =
gst_pad_new_from_static_template (&gst_rdt_depay_src_template, "src");
gst_element_add_pad (GST_ELEMENT_CAST (rdtdepay), rdtdepay->srcpad);
}
static gboolean
gst_rdt_depay_setcaps (GstPad * pad, GstCaps * caps)
{
GstStructure *structure;
GstRDTDepay *rdtdepay;
GstCaps *srccaps;
gint clock_rate = 1000; /* default */
const GValue *config;
GstBuffer *header;
rdtdepay = GST_RDT_DEPAY (GST_PAD_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
if (gst_structure_has_field (structure, "clock-rate"))
gst_structure_get_int (structure, "clock-rate", &clock_rate);
/* config contains the RealMedia header as a buffer. */
config = gst_structure_get_value (structure, "config");
if (!config)
goto no_header;
header = gst_value_get_buffer (config);
if (!header)
goto no_header;
/* need to ref because we are going to give away a ref in push */
gst_buffer_ref (header);
/* caps seem good, configure element */
rdtdepay->clock_rate = clock_rate;
/* set caps on pad and on header */
srccaps = gst_caps_new_simple ("application/vnd.rn-realmedia", NULL);
gst_pad_set_caps (rdtdepay->srcpad, srccaps);
gst_buffer_set_caps (header, srccaps);
gst_caps_unref (srccaps);
/* push header data first */
gst_pad_push (rdtdepay->srcpad, header);
return TRUE;
/* ERRORS */
no_header:
{
GST_ERROR_OBJECT (rdtdepay, "no header found in caps, no 'config' field");
return FALSE;
}
}
#define ASSERT_SIZE(n) if (size < (n)) goto not_enough_data;
static GstFlowReturn
gst_rdt_depay_chain (GstPad * pad, GstBuffer * buf)
{
GstRDTDepay *rdtdepay;
GstFlowReturn ret;
GstBuffer *outbuf;
guint8 *data, *outdata;
guint size, channel = 0;
gboolean length_included_flag;
gboolean need_reliable_flag = 0;
gboolean is_reliable;
guint16 seq_no;
gboolean back_to_back;
gboolean slow_data;
guint asm_rule;
guint32 ts;
guint16 total_reliable;
guint16 packet_type, packet_length;
rdtdepay = GST_RDT_DEPAY (GST_PAD_PARENT (pad));
/* data is in RDT format. */
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
while (size > 0) {
ASSERT_SIZE (1);
length_included_flag = (data[0] & 0x80) >> 7;
need_reliable_flag = (data[0] & 0x40) >> 6;
is_reliable = (data[0] & 0x01) >> 0;
channel = (data[0] & 0x3e) >> 1;
GST_DEBUG_OBJECT (rdtdepay, "length_included_flag=%i "
"need_reliable_flag=%i is_reliable=%i", length_included_flag,
need_reliable_flag, is_reliable);
/* we can stop skipping */
if (!length_included_flag)
break;
ASSERT_SIZE (5);
packet_type = GST_READ_UINT16_BE (data + 1);
packet_length = GST_READ_UINT16_BE (data + 3);
GST_DEBUG_OBJECT (rdtdepay, "Skipping packet of type %02x and length=%d...",
packet_type, packet_length);
ASSERT_SIZE (packet_length);
data += packet_length;
size -= packet_length;
}
ASSERT_SIZE (3);
seq_no = GST_READ_UINT16_BE (data + 1);
ASSERT_SIZE (4);
back_to_back = (data[3] >> 7) & 0x01;
slow_data = (data[3] >> 6) & 0x01;
asm_rule = ((data[3] << 2) & 0xf) >> 2;
ASSERT_SIZE (8);
ts = GST_READ_UINT32_BE (data + 4);
if (need_reliable_flag) {
ASSERT_SIZE (10);
total_reliable = GST_READ_UINT16_BE (data + 8);
data += 10;
size -= 10;
} else {
data += 9;
size -= 9;
}
GST_DEBUG_OBJECT (rdtdepay, "Passing on packet %d: "
"back_to_back=%i slow_data=%i asm_rule=%i timestamp=%u",
seq_no, back_to_back, slow_data, asm_rule, ts);
outbuf = gst_buffer_new_and_alloc (12 + size);
outdata = GST_BUFFER_DATA (outbuf);
GST_BUFFER_TIMESTAMP (outbuf) =
gst_util_uint64_scale_int (ts, GST_SECOND, rdtdepay->clock_rate);
GST_WRITE_UINT16_BE (outdata + 0, 0); /* version */
GST_WRITE_UINT16_BE (outdata + 2, size + 12); /* length */
GST_WRITE_UINT16_BE (outdata + 4, channel); /* stream */
GST_WRITE_UINT32_BE (outdata + 6, ts); /* timestamp */
GST_WRITE_UINT16_BE (outdata + 10, 0); /* flags */
memcpy (outdata + 12, data, size);
gst_buffer_unref (buf);
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (rdtdepay->srcpad));
ret = gst_pad_push (rdtdepay->srcpad, outbuf);
return ret;
/* ERRORS */
not_enough_data:
{
GST_ELEMENT_WARNING (rdtdepay, STREAM, DECODE, (NULL),
("Not enough data."));
return GST_FLOW_OK;
}
}
static void
gst_rdt_depay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstRDTDepay *rdtdepay;
rdtdepay = GST_RDT_DEPAY (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_rdt_depay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstRDTDepay *rdtdepay;
rdtdepay = GST_RDT_DEPAY (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GstStateChangeReturn
gst_rdt_depay_change_state (GstElement * element, GstStateChange transition)
{
GstRDTDepay *rdtdepay;
GstStateChangeReturn ret;
rdtdepay = GST_RDT_DEPAY (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
break;
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_READY_TO_NULL:
break;
default:
break;
}
return ret;
}
gboolean
gst_rdt_depay_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "rdtdepay",
GST_RANK_MARGINAL, GST_TYPE_RDT_DEPAY);
}

61
gst/realmedia/rdtdepay.h Normal file
View file

@ -0,0 +1,61 @@
/* GStreamer
* Copyright (C) <2006> Lutz Mueller <lutz at topfrose dot de>
* <2006> Wim Taymans <wim@fluendo.com>
*
* 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_RDT_DEPAY_H__
#define __GST_RDT_DEPAY_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_RDT_DEPAY \
(gst_rdt_depay_get_type())
#define GST_RDT_DEPAY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RDT_DEPAY,GstRDTDepay))
#define GST_RDT_DEPAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RDT_DEPAY,GstRDTDepayClass))
#define GST_IS_RDT_DEPAY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RDT_DEPAY))
#define GST_IS_RDT_DEPAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RDT_DEPAY))
typedef struct _GstRDTDepay GstRDTDepay;
typedef struct _GstRDTDepayClass GstRDTDepayClass;
struct _GstRDTDepay
{
GstElement parent;
GstPad *sinkpad;
GstPad *srcpad;
guint clock_rate;
};
struct _GstRDTDepayClass
{
GstElementClass parent_class;
};
gboolean gst_rdt_depay_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_RDT_DEPAY_H__ */

View file

@ -27,6 +27,7 @@
# include "config.h" # include "config.h"
#endif #endif
#include "rmdemux.h" #include "rmdemux.h"
#include "rdtdepay.h"
#include "rmutils.h" #include "rmutils.h"
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
@ -1431,36 +1432,6 @@ beach:
gst_caps_unref (stream_caps); gst_caps_unref (stream_caps);
} }
G_GNUC_UNUSED static void
re_hexdump_bytes (guint8 * ptr, int len, int offset)
{
guint8 *end = ptr + len;
int i;
while (1) {
if (ptr >= end)
return;
g_print ("%08x: ", offset);
for (i = 0; i < 16; i++) {
if (ptr + i >= end) {
g_print (" ");
} else {
g_print ("%02x ", ptr[i]);
}
}
for (i = 0; i < 16; i++) {
if (ptr + i >= end) {
g_print (" ");
} else {
g_print ("%c", g_ascii_isprint (ptr[i]) ? ptr[i] : '.');
}
}
g_print ("\n");
ptr += 16;
offset += 16;
}
}
static int static int
re_skip_pascal_string (const guint8 * ptr) re_skip_pascal_string (const guint8 * ptr)
{ {
@ -1546,8 +1517,17 @@ gst_rmdemux_parse_mdpr (GstRMDemux * rmdemux, const void *data, int length)
if (strcmp (stream2_type_string, "video/x-pn-realvideo") == 0) { if (strcmp (stream2_type_string, "video/x-pn-realvideo") == 0) {
stream_type = GST_RMDEMUX_STREAM_VIDEO; stream_type = GST_RMDEMUX_STREAM_VIDEO;
} else if (strcmp (stream2_type_string,
"video/x-pn-multirate-realvideo") == 0) {
stream_type = GST_RMDEMUX_STREAM_VIDEO;
} else if (strcmp (stream2_type_string, "audio/x-pn-realaudio") == 0) { } else if (strcmp (stream2_type_string, "audio/x-pn-realaudio") == 0) {
stream_type = GST_RMDEMUX_STREAM_AUDIO; stream_type = GST_RMDEMUX_STREAM_AUDIO;
} else if (strcmp (stream2_type_string,
"audio/x-pn-multirate-realaudio") == 0) {
stream_type = GST_RMDEMUX_STREAM_AUDIO;
} else if (strcmp (stream2_type_string,
"audio/x-pn-multirate-realaudio-live") == 0) {
stream_type = GST_RMDEMUX_STREAM_AUDIO;
} else if (strcmp (stream2_type_string, "audio/x-ralf-mpeg4-generic") == 0) { } else if (strcmp (stream2_type_string, "audio/x-ralf-mpeg4-generic") == 0) {
/* Another audio type found in the real testsuite */ /* Another audio type found in the real testsuite */
stream_type = GST_RMDEMUX_STREAM_AUDIO; stream_type = GST_RMDEMUX_STREAM_AUDIO;
@ -2003,15 +1983,28 @@ unknown_stream:
} }
} }
static gboolean gboolean
plugin_init (GstPlugin * plugin) gst_rmdemux_plugin_init (GstPlugin * plugin)
{ {
return gst_element_register (plugin, "rmdemux", return gst_element_register (plugin, "rmdemux",
GST_RANK_PRIMARY, GST_TYPE_RMDEMUX); GST_RANK_PRIMARY, GST_TYPE_RMDEMUX);
} }
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_rmdemux_plugin_init (plugin))
return FALSE;
if (!gst_rdt_depay_plugin_init (plugin))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR, GST_VERSION_MINOR,
"rmdemux", "realmedia",
"Realmedia stream demuxer", "RealMedia demuxer and depayloader",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);