summaryrefslogtreecommitdiffstats
path: root/gst/cdxaparse/gstcdxaparse.c
diff options
context:
space:
mode:
authorStéphane Loeuillet <gstreamer@leroutier.net>2004-05-21 14:09:51 +0000
committerStéphane Loeuillet <gstreamer@leroutier.net>2004-05-21 14:09:51 +0000
commit04590b89202a1d22abfd298fcc0a83f9ea2b3d44 (patch)
tree3aa0a632d57cc67087cba6eb0df6f514d7d4a091 /gst/cdxaparse/gstcdxaparse.c
parentf4c6cf17f800779b367de18819e644bb244f095d (diff)
downloadgst-plugins-bad-04590b89202a1d22abfd298fcc0a83f9ea2b3d44.tar.gz
gst-plugins-bad-04590b89202a1d22abfd298fcc0a83f9ea2b3d44.tar.bz2
gst-plugins-bad-04590b89202a1d22abfd298fcc0a83f9ea2b3d44.zip
gst/cdxaparse/gstcdxaparse.*: some renaming add some checks/sanity prepare for seek addition
Original commit message from CVS: * gst/cdxaparse/gstcdxaparse.c: * gst/cdxaparse/gstcdxaparse.h: some renaming add some checks/sanity prepare for seek addition * sys/sunaudio/gstsunaudio.c: remove exported dupe init function
Diffstat (limited to 'gst/cdxaparse/gstcdxaparse.c')
-rw-r--r--gst/cdxaparse/gstcdxaparse.c198
1 files changed, 92 insertions, 106 deletions
diff --git a/gst/cdxaparse/gstcdxaparse.c b/gst/cdxaparse/gstcdxaparse.c
index b7b4dc68..472f6482 100644
--- a/gst/cdxaparse/gstcdxaparse.c
+++ b/gst/cdxaparse/gstcdxaparse.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* <2002> Wim Taymans <wim.taymans@chello.be>
@@ -29,20 +28,13 @@
#include "gst/riff/riff-ids.h"
#include "gst/riff/riff-media.h"
-static void gst_cdxa_parse_base_init (gpointer g_class);
-static void gst_cdxa_parse_class_init (GstCDXAParseClass * klass);
-static void gst_cdxa_parse_init (GstCDXAParse * cdxa_parse);
+static void gst_cdxaparse_base_init (gpointer g_class);
+static void gst_cdxaparse_class_init (GstCDXAParseClass * klass);
+static void gst_cdxaparse_init (GstCDXAParse * cdxaparse);
-static GstElementStateReturn gst_cdxa_parse_change_state (GstElement * element);
+static GstElementStateReturn gst_cdxaparse_change_state (GstElement * element);
-static void gst_cdxa_parse_loop (GstElement * element);
-
-/* elementfactory information */
-static GstElementDetails gst_cdxa_parse_details =
-GST_ELEMENT_DETAILS (".dat parser",
- "Codec/Parser",
- "Parse a .dat file (VCD) into raw mpeg1",
- "Wim Taymans <wim.taymans@tvd.be>");
+static void gst_cdxaparse_loop (GstElement * element);
static GstStaticPadTemplate sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
@@ -73,40 +65,43 @@ enum
static GstElementClass *parent_class = NULL;
-/*static guint gst_cdxa_parse_signals[LAST_SIGNAL] = { 0 }; */
-
GType
-gst_cdxa_parse_get_type (void)
+gst_cdxaparse_get_type (void)
{
- static GType cdxa_parse_type = 0;
+ static GType cdxaparse_type = 0;
- if (!cdxa_parse_type) {
- static const GTypeInfo cdxa_parse_info = {
+ if (!cdxaparse_type) {
+ static const GTypeInfo cdxaparse_info = {
sizeof (GstCDXAParseClass),
- gst_cdxa_parse_base_init,
+ gst_cdxaparse_base_init,
NULL,
- (GClassInitFunc) gst_cdxa_parse_class_init,
+ (GClassInitFunc) gst_cdxaparse_class_init,
NULL,
NULL,
sizeof (GstCDXAParse),
0,
- (GInstanceInitFunc) gst_cdxa_parse_init,
+ (GInstanceInitFunc) gst_cdxaparse_init,
};
- cdxa_parse_type =
+ cdxaparse_type =
g_type_register_static (GST_TYPE_RIFF_READ, "GstCDXAParse",
- &cdxa_parse_info, 0);
+ &cdxaparse_info, 0);
}
- return cdxa_parse_type;
+ return cdxaparse_type;
}
static void
-gst_cdxa_parse_base_init (gpointer g_class)
+gst_cdxaparse_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+ static GstElementDetails gst_cdxaparse_details =
+ GST_ELEMENT_DETAILS (".dat parser",
+ "Codec/Parser",
+ "Parse a .dat file (VCD) into raw mpeg1",
+ "Wim Taymans <wim.taymans@tvd.be>");
- gst_element_class_set_details (element_class, &gst_cdxa_parse_details);
+ gst_element_class_set_details (element_class, &gst_cdxaparse_details);
/* register src pads */
gst_element_class_add_pad_template (element_class,
@@ -116,7 +111,7 @@ gst_cdxa_parse_base_init (gpointer g_class)
}
static void
-gst_cdxa_parse_class_init (GstCDXAParseClass * klass)
+gst_cdxaparse_class_init (GstCDXAParseClass * klass)
{
GstElementClass *gstelement_class;
GObjectClass *object_class;
@@ -126,45 +121,44 @@ gst_cdxa_parse_class_init (GstCDXAParseClass * klass)
parent_class = g_type_class_ref (GST_TYPE_RIFF_READ);
- gstelement_class->change_state = gst_cdxa_parse_change_state;
+ gstelement_class->change_state = gst_cdxaparse_change_state;
}
static void
-gst_cdxa_parse_init (GstCDXAParse * cdxa_parse)
+gst_cdxaparse_init (GstCDXAParse * cdxaparse)
{
/* sink */
- cdxa_parse->sinkpad =
+ cdxaparse->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&sink_template_factory), "sink");
- gst_element_add_pad (GST_ELEMENT (cdxa_parse), cdxa_parse->sinkpad);
- GST_RIFF_READ (cdxa_parse)->sinkpad = cdxa_parse->sinkpad;
+ gst_element_add_pad (GST_ELEMENT (cdxaparse), cdxaparse->sinkpad);
+ GST_RIFF_READ (cdxaparse)->sinkpad = cdxaparse->sinkpad;
- gst_element_set_loop_function (GST_ELEMENT (cdxa_parse), gst_cdxa_parse_loop);
+ gst_element_set_loop_function (GST_ELEMENT (cdxaparse), gst_cdxaparse_loop);
+ cdxaparse->state = GST_CDXAPARSE_START;
- cdxa_parse->srcpad =
+ cdxaparse->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&src_template_factory), "src");
- gst_element_add_pad (GST_ELEMENT (cdxa_parse), cdxa_parse->srcpad);
-
- cdxa_parse->state = GST_CDXA_PARSE_START;
+ gst_element_add_pad (GST_ELEMENT (cdxaparse), cdxaparse->srcpad);
- cdxa_parse->seek_pending = FALSE;
- cdxa_parse->seek_offset = 0;
+ cdxaparse->seek_pending = FALSE;
+ cdxaparse->seek_offset = 0;
}
static gboolean
-gst_cdxa_parse_stream_init (GstCDXAParse * cdxa_parse)
+gst_cdxaparse_stream_init (GstCDXAParse * cdxa)
{
- GstRiffRead *riff = GST_RIFF_READ (cdxa_parse);
+ GstRiffRead *riff = GST_RIFF_READ (cdxa);
guint32 doctype;
if (!gst_riff_read_header (riff, &doctype))
return FALSE;
if (doctype != GST_RIFF_RIFF_CDXA) {
- GST_ELEMENT_ERROR (cdxa_parse, STREAM, WRONG_TYPE, (NULL), (NULL));
+ GST_ELEMENT_ERROR (cdxa, STREAM, WRONG_TYPE, (NULL), (NULL));
return FALSE;
}
@@ -173,9 +167,9 @@ gst_cdxa_parse_stream_init (GstCDXAParse * cdxa_parse)
/* Read 'fmt ' header */
static gboolean
-gst_cdxa_parse_fmt (GstCDXAParse * cdxa_parse)
+gst_cdxaparse_fmt (GstCDXAParse * cdxa)
{
- GstRiffRead *riff = GST_RIFF_READ (cdxa_parse);
+ GstRiffRead *riff = GST_RIFF_READ (cdxa);
gst_riff_strf_auds *header;
if (!gst_riff_read_strf_auds (riff, &header)) {
@@ -189,50 +183,34 @@ gst_cdxa_parse_fmt (GstCDXAParse * cdxa_parse)
}
static gboolean
-gst_cdxa_parse_other (GstCDXAParse * cdxa_parse)
+gst_cdxaparse_other (GstCDXAParse * cdxa)
{
- GstRiffRead *riff = GST_RIFF_READ (cdxa_parse);
+ GstRiffRead *riff = GST_RIFF_READ (cdxa);
guint32 tag, length;
- /* Fixme, need to handle a seek...can you seek in cdxa? */
-
if (!gst_riff_peek_head (riff, &tag, &length, NULL)) {
return FALSE;
}
switch (tag) {
case GST_RIFF_TAG_data:
- gst_bytestream_flush (riff->bs, 8);
+ if (!gst_bytestream_flush (riff->bs, 8))
+ return FALSE;
- cdxa_parse->state = GST_CDXA_PARSE_DATA;
- cdxa_parse->dataleft = (guint64) length;
+ cdxa->state = GST_CDXAPARSE_DATA;
+ cdxa->dataleft = cdxa->datasize = (guint64) length;
+ cdxa->datastart = gst_bytestream_tell (riff->bs);
break;
default:
- gst_riff_read_skip (riff);
+ if (!gst_riff_read_skip (riff))
+ return FALSE;
break;
}
return TRUE;
}
-#define MAX_BUFFER_SIZE 4096
-
-static void
-gst_cdxa_parse_loop (GstElement * element)
-{
- GstCDXAParse *cdxa_parse = GST_CDXA_PARSE (element);
- GstRiffRead *riff = GST_RIFF_READ (cdxa_parse);
-
- if (cdxa_parse->state == GST_CDXA_PARSE_DATA) {
- if (cdxa_parse->dataleft > 0) {
- guint32 got_bytes, desired;
- GstBuffer *buf, *outbuf;
-
- desired = GST_CDXA_SECTOR_SIZE;
-
- buf = gst_riff_read_element_data (riff, desired, &got_bytes);
-
/*
A sector is 2352 bytes long and is composed of:
@@ -250,60 +228,69 @@ edc : checksum
*/
-/*
- if (got_bytes < GST_CDXA_SECTOR_SIZE) {
- gst_cdxa_parse_handle_event (cdxa_parse);
+static void
+gst_cdxaparse_loop (GstElement * element)
+{
+ GstCDXAParse *cdxa = GST_CDXAPARSE (element);
+ GstRiffRead *riff = GST_RIFF_READ (cdxa);
+
+ if (cdxa->state == GST_CDXAPARSE_DATA) {
+
+ if (cdxa->dataleft > 0) {
+ guint32 got_bytes, desired;
+ GstBuffer *buf = NULL;
+ GstBuffer *outbuf = NULL;
+
+ desired = GST_CDXA_SECTOR_SIZE;
+
+ if (!(buf = gst_riff_read_element_data (riff, desired, &got_bytes)))
return;
- }
-*/
- /* Extract time from CDXA header */
-/* printf( "%02u:%02u:%02u\n", (unsigned char) *(GST_BUFFER_DATA(buf)+12), (unsigned char) *(GST_BUFFER_DATA(buf)+13), (unsigned char) *(GST_BUFFER_DATA(buf)+14) );*/
+ /* Skip CDXA headers, only keep data */
+ outbuf =
+ gst_buffer_create_sub (buf, GST_CDXA_HEADER_SIZE, GST_CDXA_DATA_SIZE);
- /* Jump CDXA headers, only keep data */
- outbuf = gst_buffer_create_sub (buf, 24, GST_CDXA_DATA_SIZE);
gst_buffer_unref (buf);
+ gst_pad_push (cdxa->srcpad, GST_DATA (outbuf));
- gst_pad_push (cdxa_parse->srcpad, GST_DATA (outbuf));
-
- cdxa_parse->byteoffset += got_bytes;
- if (got_bytes < cdxa_parse->dataleft) {
- cdxa_parse->dataleft -= got_bytes;
+ cdxa->byteoffset += got_bytes;
+ if (got_bytes < cdxa->dataleft) {
+ cdxa->dataleft -= got_bytes;
return;
} else {
- cdxa_parse->dataleft = 0;
- cdxa_parse->state = GST_CDXA_PARSE_OTHER;
+ cdxa->dataleft = 0;
+ cdxa->state = GST_CDXAPARSE_OTHER;
}
} else {
- cdxa_parse->state = GST_CDXA_PARSE_OTHER;
+ cdxa->state = GST_CDXAPARSE_OTHER;
}
}
- switch (cdxa_parse->state) {
- case GST_CDXA_PARSE_START:
- if (!gst_cdxa_parse_stream_init (cdxa_parse)) {
+ switch (cdxa->state) {
+ case GST_CDXAPARSE_START:
+ if (!gst_cdxaparse_stream_init (cdxa)) {
return;
}
- cdxa_parse->state = GST_CDXA_PARSE_FMT;
+ cdxa->state = GST_CDXAPARSE_FMT;
/* fall-through */
- case GST_CDXA_PARSE_FMT:
- if (!gst_cdxa_parse_fmt (cdxa_parse)) {
+ case GST_CDXAPARSE_FMT:
+ if (!gst_cdxaparse_fmt (cdxa)) {
return;
}
- cdxa_parse->state = GST_CDXA_PARSE_OTHER;
+ cdxa->state = GST_CDXAPARSE_OTHER;
/* fall-through */
- case GST_CDXA_PARSE_OTHER:
- if (!gst_cdxa_parse_other (cdxa_parse)) {
+ case GST_CDXAPARSE_OTHER:
+ if (!gst_cdxaparse_other (cdxa)) {
return;
}
break;
- case GST_CDXA_PARSE_DATA:
+ case GST_CDXAPARSE_DATA:
default:
g_assert_not_reached ();
@@ -311,16 +298,16 @@ edc : checksum
}
static GstElementStateReturn
-gst_cdxa_parse_change_state (GstElement * element)
+gst_cdxaparse_change_state (GstElement * element)
{
- GstCDXAParse *cdxa_parse = GST_CDXA_PARSE (element);
+ GstCDXAParse *cdxa = GST_CDXAPARSE (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
- cdxa_parse->state = GST_CDXA_PARSE_START;
+ cdxa->state = GST_CDXAPARSE_START;
break;
case GST_STATE_PAUSED_TO_PLAYING:
@@ -330,11 +317,10 @@ gst_cdxa_parse_change_state (GstElement * element)
break;
case GST_STATE_PAUSED_TO_READY:
- cdxa_parse->state = GST_CDXA_PARSE_START;
-
+ cdxa->state = GST_CDXAPARSE_START;
- cdxa_parse->seek_pending = FALSE;
- cdxa_parse->seek_offset = 0;
+ cdxa->seek_pending = FALSE;
+ cdxa->seek_offset = 0;
break;
case GST_STATE_READY_TO_NULL:
@@ -354,8 +340,8 @@ plugin_init (GstPlugin * plugin)
return FALSE;
}
- return gst_element_register (plugin, "cdxaparse", GST_RANK_SECONDARY,
- GST_TYPE_CDXA_PARSE);
+ return gst_element_register (plugin, "cdxaparse", GST_RANK_PRIMARY,
+ GST_TYPE_CDXAPARSE);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,