summaryrefslogtreecommitdiffstats
path: root/gst/cdxaparse
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
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')
-rw-r--r--gst/cdxaparse/gstcdxaparse.c198
-rw-r--r--gst/cdxaparse/gstcdxaparse.h55
2 files changed, 112 insertions, 141 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,
diff --git a/gst/cdxaparse/gstcdxaparse.h b/gst/cdxaparse/gstcdxaparse.h
index 4dc1236e..1ad618a1 100644
--- a/gst/cdxaparse/gstcdxaparse.h
+++ b/gst/cdxaparse/gstcdxaparse.h
@@ -19,8 +19,8 @@
*/
-#ifndef __GST_CDXA_PARSE_H__
-#define __GST_CDXA_PARSE_H__
+#ifndef __GST_CDXAPARSE_H__
+#define __GST_CDXAPARSE_H__
#include <gst/gst.h>
#include "gst/riff/riff-ids.h"
@@ -30,25 +30,26 @@
extern "C" {
#endif /* __cplusplus */
-#define GST_TYPE_CDXA_PARSE \
- (gst_cdxa_parse_get_type())
-#define GST_CDXA_PARSE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CDXA_PARSE,GstCDXAParse))
-#define GST_CDXA_PARSE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CDXA_PARSE,GstCDXAParse))
-#define GST_IS_CDXA_PARSE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CDXA_PARSE))
-#define GST_IS_CDXA_PARSE_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CDXA_PARSE))
+#define GST_TYPE_CDXAPARSE \
+ (gst_cdxaparse_get_type())
+#define GST_CDXAPARSE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CDXAPARSE,GstCDXAParse))
+#define GST_CDXAPARSE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CDXAPARSE,GstCDXAParse))
+#define GST_IS_CDXAPARSE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CDXAPARSE))
+#define GST_IS_CDXAPARSE_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CDXAPARSE))
#define GST_CDXA_SECTOR_SIZE 2352
#define GST_CDXA_DATA_SIZE 2324
+#define GST_CDXA_HEADER_SIZE 24
typedef enum {
- GST_CDXA_PARSE_START,
- GST_CDXA_PARSE_FMT,
- GST_CDXA_PARSE_OTHER,
- GST_CDXA_PARSE_DATA,
+ GST_CDXAPARSE_START,
+ GST_CDXAPARSE_FMT,
+ GST_CDXAPARSE_OTHER,
+ GST_CDXAPARSE_DATA,
} GstCDXAParseState;
typedef struct _GstCDXAParse GstCDXAParse;
@@ -63,23 +64,7 @@ struct _GstCDXAParse {
/* CDXA decoding state */
GstCDXAParseState state;
- /* useful CDXA data
- guint32 riff_size;
- guint32 data_size;
- guint32 sectors;
-
-#define CDXA_SUB_MODE_EOF(c) ((c&0x80)>>7)
-#define CDXA_SUB_MODE_RT(c) ((c&0x40)>>6)
-#define CDXA_SUB_MODE_FORM(c) ((c&0x20)>>5)
-#define CDXA_SUB_MODE_TRIGGER(c)((c&0x10)>>4)
-#define CDXA_SUB_MODE_DATA(c) ((c&0x08)>>3)
-#define CDXA_SUB_MODE_VIDEO(c) ((c&0x04)>>2)
-#define CDXA_SUB_MODE_AUDIO(c) ((c&0x02)>>1)
-#define CDXA_SUB_MODE_EOR(c) ((c&0x01) )
-
-*/
-
- guint64 dataleft;
+ guint64 dataleft, datasize, datastart;
int byteoffset;
gboolean seek_pending;
@@ -90,12 +75,12 @@ struct _GstCDXAParseClass {
GstElementClass parent_class;
};
-GType gst_cdxa_parse_get_type (void);
+GType gst_cdxaparse_get_type (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
-#endif /* __GST_CDXA_PARSE_H__ */
+#endif /* __GST_CDXAPARSE_H__ */