summaryrefslogtreecommitdiffstats
path: root/gst/mpegaudioparse/gstmpegaudioparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/mpegaudioparse/gstmpegaudioparse.c')
-rw-r--r--gst/mpegaudioparse/gstmpegaudioparse.c151
1 files changed, 76 insertions, 75 deletions
diff --git a/gst/mpegaudioparse/gstmpegaudioparse.c b/gst/mpegaudioparse/gstmpegaudioparse.c
index 1e77bf42..4e5b9b00 100644
--- a/gst/mpegaudioparse/gstmpegaudioparse.c
+++ b/gst/mpegaudioparse/gstmpegaudioparse.c
@@ -36,9 +36,9 @@ static GstStaticPadTemplate mp3_src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/mpeg, "
- "mpegversion = (int) 1, "
- "layer = (int) [ 1, 3 ], "
- "rate = (int) [ 8000, 48000], " "channels = (int) [ 1, 2 ]")
+ "mpegversion = (int) 1, "
+ "layer = (int) [ 1, 3 ], "
+ "rate = (int) [ 8000, 48000], " "channels = (int) [ 1, 2 ]")
);
static GstStaticPadTemplate mp3_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -98,8 +98,9 @@ gst_mp3parse_get_type (void)
0,
(GInstanceInitFunc) gst_mp3parse_init,
};
+
mp3parse_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstMPEGAudioParse", &mp3parse_info, 0);
+ "GstMPEGAudioParse", &mp3parse_info, 0);
}
return mp3parse_type;
}
@@ -238,8 +239,8 @@ gst_mp3parse_class_init (GstMPEGAudioParseClass * klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) 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_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE, g_param_spec_int ("bitrate", "Bitrate", "Bit Rate", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
+ 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_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE, g_param_spec_int ("bitrate", "Bitrate", "Bit Rate", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
@@ -354,89 +355,89 @@ gst_mp3parse_chain (GstPad * pad, GstData * _data)
* the frames are not independently coded.
********************************************************************************/
if (mp3parse->in_flush) {
- guint32 header2;
+ guint32 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 */
- header2 = GUINT32_FROM_BE (*((guint32 *) (data + offset + bpf)));
- GST_DEBUG ("mp3parse: header=%08X, header2=%08X, bpf=%d",
- (unsigned int) header, (unsigned int) header2, bpf);
+ 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 = GUINT32_FROM_BE (*((guint32 *) (data + offset + bpf)));
+ GST_DEBUG ("mp3parse: header=%08X, header2=%08X, bpf=%d",
+ (unsigned int) header, (unsigned int) header2, bpf);
/* mask the bits which are allowed to differ between frames */
#define HDRMASK ~((0xF << 12) /* bitrate */ | \
(0x1 << 9) /* padding */ | \
- (0x3 << 4)) /*mode extension */
+ (0x3 << 4)) /*mode extension */
- if ((header2 & HDRMASK) != (header & HDRMASK)) { /* require 2 matching headers in a row */
- GST_DEBUG
- ("mp3parse: next header doesn't match (header=%08X, header2=%08X, bpf=%d)",
- (unsigned int) header, (unsigned int) header2, bpf);
- offset++; /* This frame is invalid. Start looking for a valid frame at the next position in the stream */
- continue;
- }
+ if ((header2 & HDRMASK) != (header & HDRMASK)) { /* require 2 matching headers in a row */
+ GST_DEBUG
+ ("mp3parse: next header doesn't match (header=%08X, header2=%08X, bpf=%d)",
+ (unsigned int) header, (unsigned int) header2, bpf);
+ 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 ((size - offset) < bpf) {
- GST_DEBUG ("mp3parse: partial buffer needed %ld < %d ", (size - offset),
- bpf);
- break;
+ GST_DEBUG ("mp3parse: partial buffer needed %ld < %d ", (size - offset),
+ bpf);
+ break;
} else {
- guint bitrate, layer, rate, channels;
-
- if (!mp3_type_frame_length_from_header (header, &layer,
- &channels, &bitrate, &rate)) {
- g_error ("Header failed internal error");
- }
- if (channels != mp3parse->channels ||
- rate != mp3parse->rate ||
- layer != mp3parse->layer || bitrate != mp3parse->bit_rate) {
- GstCaps *caps = mp3_caps_create (layer, channels, bitrate, rate);
-
- gst_pad_set_explicit_caps (mp3parse->srcpad, caps);
-
- mp3parse->channels = channels;
- mp3parse->layer = layer;
- mp3parse->rate = rate;
- mp3parse->bit_rate = bitrate;
- }
-
- outbuf = gst_buffer_create_sub (mp3parse->partialbuf, offset, bpf);
-
- offset += bpf;
- if (mp3parse->skip == 0) {
- GST_DEBUG ("mp3parse: pushing buffer of %d bytes",
- GST_BUFFER_SIZE (outbuf));
- if (mp3parse->in_flush) {
- /* FIXME do some sort of flush event */
- mp3parse->in_flush = FALSE;
- }
- GST_BUFFER_TIMESTAMP (outbuf) = last_ts;
- GST_BUFFER_DURATION (outbuf) =
- 8 * (GST_SECOND / 1000) * GST_BUFFER_SIZE (outbuf) /
- mp3parse->bit_rate;
-
- if (GST_PAD_CAPS (mp3parse->srcpad) != NULL) {
- gst_pad_push (mp3parse->srcpad, GST_DATA (outbuf));
- } else {
- GST_DEBUG ("No capsnego yet, delaying buffer push");
- gst_buffer_unref (outbuf);
- }
- } else {
- GST_DEBUG ("mp3parse: skipping buffer of %d bytes",
- GST_BUFFER_SIZE (outbuf));
- gst_buffer_unref (outbuf);
- mp3parse->skip--;
- }
+ guint bitrate, layer, rate, channels;
+
+ if (!mp3_type_frame_length_from_header (header, &layer,
+ &channels, &bitrate, &rate)) {
+ g_error ("Header failed internal error");
+ }
+ if (channels != mp3parse->channels ||
+ rate != mp3parse->rate ||
+ layer != mp3parse->layer || bitrate != mp3parse->bit_rate) {
+ GstCaps *caps = mp3_caps_create (layer, channels, bitrate, rate);
+
+ gst_pad_set_explicit_caps (mp3parse->srcpad, caps);
+
+ mp3parse->channels = channels;
+ mp3parse->layer = layer;
+ mp3parse->rate = rate;
+ mp3parse->bit_rate = bitrate;
+ }
+
+ outbuf = gst_buffer_create_sub (mp3parse->partialbuf, offset, bpf);
+
+ offset += bpf;
+ if (mp3parse->skip == 0) {
+ GST_DEBUG ("mp3parse: pushing buffer of %d bytes",
+ GST_BUFFER_SIZE (outbuf));
+ if (mp3parse->in_flush) {
+ /* FIXME do some sort of flush event */
+ mp3parse->in_flush = FALSE;
+ }
+ GST_BUFFER_TIMESTAMP (outbuf) = last_ts;
+ GST_BUFFER_DURATION (outbuf) =
+ 8 * (GST_SECOND / 1000) * GST_BUFFER_SIZE (outbuf) /
+ mp3parse->bit_rate;
+
+ if (GST_PAD_CAPS (mp3parse->srcpad) != NULL) {
+ gst_pad_push (mp3parse->srcpad, GST_DATA (outbuf));
+ } else {
+ GST_DEBUG ("No capsnego yet, delaying buffer push");
+ gst_buffer_unref (outbuf);
+ }
+ } else {
+ GST_DEBUG ("mp3parse: skipping buffer of %d bytes",
+ GST_BUFFER_SIZE (outbuf));
+ gst_buffer_unref (outbuf);
+ mp3parse->skip--;
+ }
}
} else {
offset++;
if (!mp3parse->in_flush)
- GST_DEBUG ("mp3parse: *** wrong header, skipping byte (FIXME?)");
+ GST_DEBUG ("mp3parse: *** wrong header, skipping byte (FIXME?)");
}
}
/* if we have processed this block and there are still */
@@ -445,7 +446,7 @@ gst_mp3parse_chain (GstPad * pad, GstData * _data)
glong remainder = (size - offset);
GST_DEBUG ("mp3parse: partial buffer needed %ld for trailing bytes",
- remainder);
+ remainder);
outbuf = gst_buffer_create_sub (mp3parse->partialbuf, offset, remainder);
gst_buffer_unref (mp3parse->partialbuf);
@@ -462,7 +463,7 @@ bpf_from_header (GstMPEGAudioParse * parse, unsigned long header)
guint bitrate, layer, rate, channels, length;
if (!(length = mp3_type_frame_length_from_header (header, &layer,
- &channels, &bitrate, &rate))) {
+ &channels, &bitrate, &rate))) {
return 0;
}