# HG changeset patch # User renatofilho # Date 1165326268 0 # Node ID 244e5bd5119404416e351b3a97176b0b71bdbf1f # Parent 418267061bed69145bd195a1da33d3979270e02f [svn r195] diff -r 418267061bed -r 244e5bd51194 gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Mon Dec 04 23:13:44 2006 +0000 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Tue Dec 05 13:44:28 2006 +0000 @@ -192,6 +192,7 @@ /* Flow control */ GstFlowReturn last_video_return; GstFlowReturn last_audio_return; + gboolean more_data; /* NUV decoding state */ GstNuvDemuxState state; @@ -494,6 +495,7 @@ if ((res != GST_FLOW_OK) || (buf == NULL)) { goto done; } + data = buf->data; h->i_type = GPOINTER_TO_INT (data[0]); @@ -830,8 +832,10 @@ gst_buffer_unref (buf); buf = NULL; } - nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER; - memset (&nuv->priv->fh, 0, sizeof (nuv->priv->fh)); + if (ret == GST_FLOW_OK) { + nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER; + memset (&nuv->priv->fh, 0, sizeof (nuv->priv->fh)); + } return ret; } @@ -1004,6 +1008,7 @@ g_assert_not_reached (); } + GST_DEBUG_OBJECT (nuv, "state: %d res:%s", nuv->priv->state, gst_flow_get_name (res)); return GST_FLOW_OK; @@ -1058,8 +1063,10 @@ return GST_FLOW_WRONG_STATE; } } else { - if (gst_adapter_available (nuv->priv->adapter) < size) + if (gst_adapter_available (nuv->priv->adapter) < size) { + nuv->priv->more_data = TRUE; return GST_FLOW_ERROR_NO_DATA; + } if (move) { *buffer = gst_adapter_take_buffer (nuv->priv->adapter, size); } else { @@ -1078,9 +1085,8 @@ gboolean res = TRUE; GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (sinkpad)); + return gst_pad_activate_push (sinkpad, TRUE); - res = gst_pad_activate_push (sinkpad, TRUE); - return res; if (gst_pad_check_pull_range (sinkpad)) { if (nuv->priv->adapter) { gst_adapter_clear (nuv->priv->adapter); @@ -1210,20 +1216,21 @@ static GstFlowReturn gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf) { + GstFlowReturn ret = GST_FLOW_OK; + GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); - GST_DEBUG_OBJECT (nuv, " gst_nuv_demux_chain function"); + GST_DEBUG_OBJECT (nuv, " gst_nuv_demux_chain function buffersize %d", buf->size); + gst_adapter_push (nuv->priv->adapter, buf); - if (NULL == nuv->priv->adapter) { - GST_ERROR ("pull expected! Chain func should not be called"); - return GST_FLOW_UNEXPECTED; + while ((ret == GST_FLOW_OK) && (nuv->priv->more_data == FALSE)) { + ret = gst_nuv_demux_play (pad); } + + nuv->priv->more_data = FALSE; + gst_object_unref (nuv); - gst_adapter_push (nuv->priv->adapter, buf); - - /* gst_object_unref (nuv); */ - - return gst_nuv_demux_play (pad); + return ret; } static void @@ -1235,6 +1242,7 @@ static void gst_nuv_demux_reset (GstNuvDemux * nuv) { + nuv->priv->more_data = FALSE; nuv->priv->state = GST_NUV_DEMUX_START; nuv->priv->mode = 0; nuv->priv->offset = 0; @@ -1317,8 +1325,9 @@ gint64 average = 0; gint64 duration_bytes = gst_nuv_demux_get_bytes_duration (nuv); - if (duration_bytes == GST_CLOCK_TIME_NONE) + if (duration_bytes == GST_CLOCK_TIME_NONE) { return; + } interval = gst_util_uint64_scale (1, current_timestamp - nuv->priv->time_start, GST_SECOND); if (interval > 0) {