move out some code to a function

Original commit message from CVS:
move out some code to a function
This commit is contained in:
Thomas Vander Stichele 2002-12-11 21:57:39 +00:00
parent 99da9aa987
commit 7df5e894a6
2 changed files with 78 additions and 60 deletions

2
common

@ -1 +1 @@
Subproject commit 92ff5101d55c0f853620bf13f8dd528992824137
Subproject commit 773e3a64961084c37477faa464f12add3dfcd6dc

View file

@ -932,26 +932,22 @@ fail:
}
static void
gst_mad_chain (GstPad *pad, GstBuffer *buffer)
gst_mad_handle_event (GstPad *pad, GstBuffer *buffer)
{
GstMad *mad;
gchar *data;
glong size;
gboolean new_pts = FALSE;
mad = GST_MAD (gst_pad_get_parent (pad));
if (GST_IS_EVENT (buffer)) {
GstEvent *event = GST_EVENT (buffer);
GstMad *mad = GST_MAD (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
switch (GST_EVENT_TYPE (event))
{
case GST_EVENT_DISCONTINUOUS:
{
gint n = GST_EVENT_DISCONT_OFFSET_LEN (event);
gint i;
for (i=0; i<n; i++) {
if (gst_pad_handles_format (pad, GST_EVENT_DISCONT_OFFSET(event,i).format))
for (i = 0; i < n; i++)
{
if (gst_pad_handles_format (pad,
GST_EVENT_DISCONT_OFFSET(event, i).format))
{
gint64 value = GST_EVENT_DISCONT_OFFSET (event, i).value;
gint64 time;
@ -961,8 +957,8 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
/* see how long the input bytes take */
format = GST_FORMAT_TIME;
if (!gst_pad_convert (pad,
GST_EVENT_DISCONT_OFFSET (event, i).format, value,
&format, &time))
GST_EVENT_DISCONT_OFFSET (event, i).format,
value, &format, &time))
{
time = 0;
}
@ -973,8 +969,10 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
gst_event_unref (event);
if (GST_PAD_IS_USABLE (mad->srcpad)) {
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time, NULL);
if (GST_PAD_IS_USABLE (mad->srcpad))
{
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
time, NULL);
gst_pad_push (mad->srcpad, GST_BUFFER (discont));
}
break;
@ -993,6 +991,22 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
return;
}
static void
gst_mad_chain (GstPad *pad, GstBuffer *buffer)
{
GstMad *mad;
gchar *data;
glong size;
gboolean new_pts = FALSE;
mad = GST_MAD (gst_pad_get_parent (pad));
/* handle events */
if (GST_IS_EVENT (buffer))
{
gst_mad_handle_event (pad, buffer);
return;
}
if (GST_BUFFER_TIMESTAMP (buffer) != -1) {
/* if there is nothing queued (partial buffer), we prepare to set the
* timestamp on the next buffer */
@ -1011,11 +1025,12 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
data = GST_BUFFER_DATA (buffer);
size = GST_BUFFER_SIZE (buffer);
while (size > 0) {
/* process the incoming buffer in chunks of maximum MDLEN bytes */
while (size > 0)
{
gint tocopy;
guchar *mad_input_buffer;
/* cut the buffer in MDLEN pieces */
tocopy = MIN (MAD_BUFFER_MDLEN, size);
memcpy (mad->tempbuffer + mad->tempsize, data, tocopy);
@ -1045,24 +1060,27 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
return;
}
else if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
/* lost sync, force a resync */
signed long tagsize;
tagsize = id3_tag_query (mad->stream.this_frame,
mad->stream.bufend - mad->stream.this_frame);
if (tagsize > mad->tempsize) {
GST_INFO (GST_CAT_PLUGIN_INFO, "mad: got partial id3 tag in buffer, skipping");
GST_INFO (GST_CAT_PLUGIN_INFO,
"mad: got partial id3 tag in buffer, skipping");
}
else if (tagsize > 0) {
struct id3_tag *tag;
id3_byte_t const *data;
GST_INFO (GST_CAT_PLUGIN_INFO, "mad: got ID3 tag size %ld", tagsize);
GST_INFO (GST_CAT_PLUGIN_INFO,
"mad: got ID3 tag size %ld", tagsize);
data = mad->stream.this_frame;
/* mad has moved the pointer to the next frame over the start of the
* id3 tags, so we need to flush one byte less n the tagsize */
* id3 tags, so we need to flush one byte less than the tagsize */
mad_stream_skip (&mad->stream, tagsize - 1);
tag = id3_tag_parse (data, tagsize);