move out some code to a function
Original commit message from CVS: move out some code to a function
This commit is contained in:
parent
99da9aa987
commit
7df5e894a6
2
common
2
common
@ -1 +1 @@
|
|||||||
Subproject commit 92ff5101d55c0f853620bf13f8dd528992824137
|
Subproject commit 773e3a64961084c37477faa464f12add3dfcd6dc
|
@ -932,26 +932,22 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
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:
|
case GST_EVENT_DISCONTINUOUS:
|
||||||
{
|
{
|
||||||
gint n = GST_EVENT_DISCONT_OFFSET_LEN (event);
|
gint n = GST_EVENT_DISCONT_OFFSET_LEN (event);
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i=0; i<n; i++) {
|
for (i = 0; i < n; i++)
|
||||||
if (gst_pad_handles_format (pad, GST_EVENT_DISCONT_OFFSET(event,i).format))
|
{
|
||||||
|
if (gst_pad_handles_format (pad,
|
||||||
|
GST_EVENT_DISCONT_OFFSET(event, i).format))
|
||||||
{
|
{
|
||||||
gint64 value = GST_EVENT_DISCONT_OFFSET (event, i).value;
|
gint64 value = GST_EVENT_DISCONT_OFFSET (event, i).value;
|
||||||
gint64 time;
|
gint64 time;
|
||||||
@ -961,8 +957,8 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
|
|||||||
/* see how long the input bytes take */
|
/* see how long the input bytes take */
|
||||||
format = GST_FORMAT_TIME;
|
format = GST_FORMAT_TIME;
|
||||||
if (!gst_pad_convert (pad,
|
if (!gst_pad_convert (pad,
|
||||||
GST_EVENT_DISCONT_OFFSET (event, i).format, value,
|
GST_EVENT_DISCONT_OFFSET (event, i).format,
|
||||||
&format, &time))
|
value, &format, &time))
|
||||||
{
|
{
|
||||||
time = 0;
|
time = 0;
|
||||||
}
|
}
|
||||||
@ -973,8 +969,10 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
|
|||||||
|
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
|
|
||||||
if (GST_PAD_IS_USABLE (mad->srcpad)) {
|
if (GST_PAD_IS_USABLE (mad->srcpad))
|
||||||
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time, NULL);
|
{
|
||||||
|
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
|
||||||
|
time, NULL);
|
||||||
gst_pad_push (mad->srcpad, GST_BUFFER (discont));
|
gst_pad_push (mad->srcpad, GST_BUFFER (discont));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -991,8 +989,24 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
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 (GST_BUFFER_TIMESTAMP (buffer) != -1) {
|
||||||
/* if there is nothing queued (partial buffer), we prepare to set the
|
/* if there is nothing queued (partial buffer), we prepare to set the
|
||||||
* timestamp on the next buffer */
|
* timestamp on the next buffer */
|
||||||
@ -1011,11 +1025,12 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
|
|||||||
data = GST_BUFFER_DATA (buffer);
|
data = GST_BUFFER_DATA (buffer);
|
||||||
size = GST_BUFFER_SIZE (buffer);
|
size = GST_BUFFER_SIZE (buffer);
|
||||||
|
|
||||||
while (size > 0) {
|
/* process the incoming buffer in chunks of maximum MDLEN bytes */
|
||||||
|
while (size > 0)
|
||||||
|
{
|
||||||
gint tocopy;
|
gint tocopy;
|
||||||
guchar *mad_input_buffer;
|
guchar *mad_input_buffer;
|
||||||
|
|
||||||
/* cut the buffer in MDLEN pieces */
|
|
||||||
tocopy = MIN (MAD_BUFFER_MDLEN, size);
|
tocopy = MIN (MAD_BUFFER_MDLEN, size);
|
||||||
|
|
||||||
memcpy (mad->tempbuffer + mad->tempsize, data, tocopy);
|
memcpy (mad->tempbuffer + mad->tempsize, data, tocopy);
|
||||||
@ -1045,25 +1060,28 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
|
else if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
|
||||||
|
/* lost sync, force a resync */
|
||||||
signed long tagsize;
|
signed long tagsize;
|
||||||
|
|
||||||
tagsize = id3_tag_query (mad->stream.this_frame,
|
tagsize = id3_tag_query (mad->stream.this_frame,
|
||||||
mad->stream.bufend - mad->stream.this_frame);
|
mad->stream.bufend - mad->stream.this_frame);
|
||||||
|
|
||||||
if (tagsize > mad->tempsize) {
|
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) {
|
else if (tagsize > 0) {
|
||||||
struct id3_tag *tag;
|
struct id3_tag *tag;
|
||||||
id3_byte_t const *data;
|
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;
|
data = mad->stream.this_frame;
|
||||||
|
|
||||||
/* mad has moved the pointer to the next frame over the start of the
|
/* 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);
|
mad_stream_skip (&mad->stream, tagsize - 1);
|
||||||
|
|
||||||
tag = id3_tag_parse (data, tagsize);
|
tag = id3_tag_parse (data, tagsize);
|
||||||
if (tag) {
|
if (tag) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user