summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2002-03-17 18:17:56 +0000
committerBenjamin Otte <otte@gnome.org>2002-03-17 18:17:56 +0000
commit1fa4ff50772c1977b9825d4fae86bad2c0c17f2e (patch)
treebac7e84f67bbbb339625339ae09bb5b350fe76c4
parent5e0b3439b08b622b94ef4af91ca207414d7a8de7 (diff)
adapt mad / oss / mpegaudioparse to the changes inside the coreBRANCH-EVENTS2
Original commit message from CVS: adapt mad / oss / mpegaudioparse to the changes inside the core
-rw-r--r--ext/mad/gstmad.c48
-rw-r--r--gst/mpegaudioparse/gstmpegaudioparse.c66
2 files changed, 66 insertions, 48 deletions
diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c
index 617802b4..fb26db71 100644
--- a/ext/mad/gstmad.c
+++ b/ext/mad/gstmad.c
@@ -135,21 +135,28 @@ GST_PADTEMPLATE_FACTORY (mad_sink_template_factory,
)
-static void gst_mad_class_init (GstMadClass *klass);
-static void gst_mad_init (GstMad *mad);
-static void gst_mad_dispose (GObject *object);
-
-static void gst_mad_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_mad_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static void gst_mad_chain (GstPad *pad, GstData *data);
+static void gst_mad_class_init (GstMadClass *klass);
+static void gst_mad_init (GstMad *mad);
+static void gst_mad_dispose (GObject *object);
+
+static void gst_mad_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gst_mad_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gst_mad_chain (GstPad *pad,
+ GstData *data);
+static void gst_mad_bufferpool_notify (GstPad *pad);
static GstElementStateReturn
- gst_mad_change_state (GstElement *element);
-static gpointer gst_mad_srcpad_event (GstPad *pad, GstData *event);
-static GstEventLength * gst_mad_new_length_event (GstEventLength *length);
+ gst_mad_change_state (GstElement *element);
+static gpointer gst_mad_srcpad_event (GstPad *pad,
+ GstData *event);
+static GstEventLength * gst_mad_new_length_event (GstEventLength *length);
static GstElementClass *parent_class = NULL;
/* static guint gst_mad_signals[LAST_SIGNAL] = { 0 }; */
@@ -236,7 +243,8 @@ gst_mad_init (GstMad *mad)
GST_PADTEMPLATE_GET (mad_src_template_factory), "src");
gst_element_add_pad(GST_ELEMENT(mad),mad->srcpad);
gst_pad_set_event_function (mad->srcpad, gst_mad_srcpad_event);
-
+ gst_pad_set_bufferpool_notify_function (mad->srcpad, gst_mad_bufferpool_notify);
+
mad->tempbuffer = g_malloc (MAD_BUFFER_MDLEN * 3);
mad->tempsize = 0;
mad->need_flush = FALSE;
@@ -626,6 +634,14 @@ next:
gst_data_unref (dat);
}
+static void
+gst_mad_bufferpool_notify (GstPad *pad)
+{
+ GstMad *mad = GST_MAD (gst_pad_get_parent (pad));
+
+ gst_pad_set_bufferpool (mad->sinkpad, gst_pad_get_bufferpool (pad));
+}
+
static GstElementStateReturn
gst_mad_change_state (GstElement *element)
{
@@ -666,8 +682,8 @@ gst_mad_srcpad_event (GstPad *pad, GstData *event)
{
GstEventSeek *seek;
gpointer ret = NULL;
- GstMad *mad = GST_MAD (GST_PAD_PARENT (pad));
- GstPad *nextpad = GST_PAD_CAST (GST_RPAD_PEER (mad->sinkpad));
+ GstMad *mad = GST_MAD (gst_pad_get_parent (pad));
+ GstPad *nextpad = gst_pad_get_peer (mad->sinkpad);
switch (GST_DATA_TYPE (event))
{
diff --git a/gst/mpegaudioparse/gstmpegaudioparse.c b/gst/mpegaudioparse/gstmpegaudioparse.c
index d4d26a9e..268cac4c 100644
--- a/gst/mpegaudioparse/gstmpegaudioparse.c
+++ b/gst/mpegaudioparse/gstmpegaudioparse.c
@@ -17,7 +17,7 @@
* Boston, MA 02111-1307, USA.
*/
-//#define GST_DEBUG_ENABLED
+/* #define GST_DEBUG_ENABLED */
#include <gstmpegaudioparse.h>
@@ -94,7 +94,8 @@ static void gst_mp3parse_set_property (GObject *object, guint prop_id, const GV
static void gst_mp3parse_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static GstElementClass *parent_class = NULL;
-//static guint gst_mp3parse_signals[LAST_SIGNAL] = { 0 };
+/* static guint gst_mp3parse_signals[LAST_SIGNAL] = { 0 };
+*/
GType
gst_mp3parse_get_type(void) {
@@ -127,10 +128,10 @@ gst_mp3parse_class_init (GstMPEGAudioParseClass *klass)
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SKIP,
g_param_spec_int("skip","skip","skip",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME
+ G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BIT_RATE,
g_param_spec_int("bit_rate","bit_rate","bit_rate",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE)); // CHECKME
+ G_MININT,G_MAXINT,0,G_PARAM_READABLE)); /* CHECKME */
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
@@ -144,15 +145,15 @@ gst_mp3parse_init (GstMPEGAudioParse *mp3parse)
mp3parse->sinkpad = gst_pad_new_from_template(sink_temp, "sink");
gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->sinkpad);
-#if 1 // set this to one to use the old chaining code
+#if 1 /* set this to one to use the old chaining code */
gst_pad_set_chain_function(mp3parse->sinkpad,gst_mp3parse_chain);
-#else // else you get the new loop-based code, which isn't complete yet
+#else /* else you get the new loop-based code, which isn't complete yet */
gst_element_set_loop_function (GST_ELEMENT(mp3parse),gst_mp3parse_loop);
#endif
mp3parse->srcpad = gst_pad_new_from_template(src_temp, "src");
gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->srcpad);
- //gst_pad_set_type_id(mp3parse->srcpad, mp3frametype);
+ /* gst_pad_set_type_id(mp3parse->srcpad, mp3frametype); */
mp3parse->partialbuf = NULL;
mp3parse->skip = 0;
@@ -191,31 +192,31 @@ gst_mp3parse_loop (GstElement *element)
gint bpf;
while (1) {
- // get a new buffer
+ /* get a new buffer */
inbuf = gst_pad_pull (parse->sinkpad);
size = GST_BUFFER_SIZE (inbuf);
data = GST_BUFFER_DATA (inbuf);
offset = 0;
fprintf(stderr, "have buffer of %d bytes\n",size);
- // loop through it and find all the frames
+ /* loop through it and find all the frames */
while (offset < (size - 4)) {
start = gst_mp3parse_next_header (data,size,offset);
fprintf(stderr, "skipped %d bytes searching for the next header\n",start-offset);
header = GULONG_FROM_BE(*((guint32 *)(data+start)));
fprintf(stderr, "header is 0x%08x\n",header);
- // figure out how big the frame is supposed to be
+ /* figure out how big the frame is supposed to be */
bpf = bpf_from_header (parse, header);
- // see if there are enough bytes in this buffer for the whole frame
+ /* see if there are enough bytes in this buffer for the whole frame */
if ((start + bpf) <= size) {
outbuf = gst_buffer_create_sub (GST_BUFFER (inbuf), start, bpf);
fprintf(stderr, "sending buffer of %d bytes\n",bpf);
gst_pad_push (parse->srcpad, GST_DATA (outbuf));
offset = start + bpf;
- // if not, we have to deal with it somehow
+ /* if not, we have to deal with it somehow */
} else {
fprintf(stderr,"don't have enough data for this frame\n");
@@ -239,8 +240,8 @@ gst_mp3parse_chain (GstPad *pad, GstData *buf)
g_return_if_fail(pad != NULL);
g_return_if_fail(GST_IS_PAD(pad));
g_return_if_fail(buf != NULL);
-// g_return_if_fail(GST_IS_BUFFER(buf));
-
+/* g_return_if_fail(GST_IS_BUFFER(buf));
+*/
mp3parse = GST_MP3PARSE (gst_pad_get_parent (pad));
GST_DEBUG (0,"mp3parse: received buffer of %d bytes\n",GST_BUFFER_SIZE(buf));
@@ -256,11 +257,11 @@ gst_mp3parse_chain (GstPad *pad, GstData *buf)
mp3parse->in_flush = TRUE;
*/
- // if we have something left from the previous frame
+ /* if we have something left from the previous frame */
if (mp3parse->partialbuf) {
mp3parse->partialbuf = gst_buffer_append(mp3parse->partialbuf, GST_BUFFER (buf));
- // and the one we received..
+ /* and the one we received.. */
gst_data_unref (buf);
}
else {
@@ -270,22 +271,22 @@ gst_mp3parse_chain (GstPad *pad, GstData *buf)
size = GST_BUFFER_SIZE(mp3parse->partialbuf);
data = GST_BUFFER_DATA(mp3parse->partialbuf);
- // while we still have bytes left -4 for the header
+ /* while we still have bytes left -4 for the header */
while (offset < size-4) {
int skipped = 0;
GST_DEBUG (0,"mp3parse: offset %ld, size %ld \n",offset, size);
- // search for a possible start byte
+ /* search for a possible start byte */
for (;((data[offset] != 0xff) && (offset < size));offset++) skipped++;
if (skipped && !mp3parse->in_flush) {
GST_DEBUG (0,"mp3parse: **** now at %ld skipped %d bytes\n",offset,skipped);
}
- // construct the header word
+ /* construct the header word */
header = GULONG_FROM_BE(*((gulong *)(data+offset)));
- // if it's a valid header, go ahead and send off the frame
+ /* if it's a valid header, go ahead and send off the frame */
if (head_check(header)) {
- // calculate the bpf of the frame
+ /* calculate the bpf of the frame */
bpf = bpf_from_header(mp3parse, header);
/********************************************************************************
@@ -303,22 +304,22 @@ gst_mp3parse_chain (GstPad *pad, GstData *buf)
if ( mp3parse->in_flush ) {
unsigned long header2;
- if ((size-offset)<(bpf+4)) { if (mp3parse->in_flush) break; } // wait until we have the the entire current frame as well as the next frame header
+ if ((size-offset)<(bpf+4)) { if (mp3parse->in_flush) break; } /* wait until we have the the entire current frame as well as the next frame header */
header2 = GULONG_FROM_BE(*((gulong *)(data+offset+bpf)));
GST_DEBUG(0,"mp3parse: header=%08lX, header2=%08lX, bpf=%d\n", header, header2, bpf );
- #define HDRMASK ~( (0xF<<12)/*bitrate*/ | (1<<9)/*padding*/ | (3<<4)/*mode extension*/ ) // mask the bits which are allowed to differ between frames
+ #define HDRMASK ~( (0xF<<12)/*bitrate*/ | (1<<9)/*padding*/ | (3<<4)/*mode extension*/ ) /* mask the bits which are allowed to differ between frames */
- if ( (header2&HDRMASK) != (header&HDRMASK) ) { // require 2 matching headers in a row
+ if ( (header2&HDRMASK) != (header&HDRMASK) ) { /* require 2 matching headers in a row */
GST_DEBUG(0,"mp3parse: next header doesn't match (header=%08lX, header2=%08lX, bpf=%d)\n", header, header2, bpf );
- offset++; // This frame is invalid. Start looking for a valid frame at the next position in the stream
+ offset++; /* This frame is invalid. Start looking for a valid frame at the next position in the stream */
continue;
}
}
- // if we don't have the whole frame...
+ /* if we don't have the whole frame... */
if ((size - offset) < bpf) {
GST_DEBUG (0,"mp3parse: partial buffer needed %ld < %d \n",(size-offset), bpf);
break;
@@ -347,8 +348,8 @@ gst_mp3parse_chain (GstPad *pad, GstData *buf)
if (!mp3parse->in_flush) GST_DEBUG (0,"mp3parse: *** wrong header, skipping byte (FIXME?)\n");
}
}
- // if we have processed this block and there are still
- // bytes left not in a partial block, copy them over.
+ /* if we have processed this block and there are still
+ bytes left not in a partial block, copy them over. */
if (size-offset > 0) {
glong remainder = (size - offset);
GST_DEBUG (0,"mp3parse: partial buffer needed %ld for trailing bytes\n",remainder);
@@ -358,7 +359,7 @@ gst_mp3parse_chain (GstPad *pad, GstData *buf)
mp3parse->partialbuf = outbuf;
}
else {
- gst_buffer_unref(mp3parse->partialbuf);
+ gst_data_unref (GST_DATA (mp3parse->partialbuf));
mp3parse->partialbuf = NULL;
}
}
@@ -382,7 +383,7 @@ bpf_from_header (GstMPEGAudioParse *parse, unsigned long header)
int layer_index,layer,lsf,samplerate_index,padding;
long bpf;
- //mpegver = (header >> 19) & 0x3; // don't need this for bpf
+ /* mpegver = (header >> 19) & 0x3; don't need this for bpf */
layer_index = (header >> 17) & 0x3;
layer = 4 - layer_index;
lsf = (header & (1 << 20)) ? ((header & (1 << 19)) ? 0 : 1) : 1;
@@ -400,8 +401,9 @@ bpf_from_header (GstMPEGAudioParse *parse, unsigned long header)
bpf += padding;
}
- //g_print("%08x: layer %d lsf %d bitrate %d samplerate_index %d padding %d - bpf %d\n",
-//header,layer,lsf,bitrate,samplerate_index,padding,bpf);
+ /*g_print("%08x: layer %d lsf %d bitrate %d samplerate_index %d padding %d - bpf %d\n",
+ header,layer,lsf,bitrate,samplerate_index,padding,bpf);
+ */
return bpf;
}