[svn r195] trunk
authorrenatofilho
Tue Dec 05 13:44:28 2006 +0000 (2006-12-05)
branchtrunk
changeset 194244e5bd51194
parent 193 418267061bed
child 195 5fc1d2edcca4
[svn r195]
gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c
     1.1 --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Mon Dec 04 23:13:44 2006 +0000
     1.2 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Tue Dec 05 13:44:28 2006 +0000
     1.3 @@ -192,6 +192,7 @@
     1.4    /* Flow control */
     1.5    GstFlowReturn last_video_return;
     1.6    GstFlowReturn last_audio_return;
     1.7 +  gboolean      more_data;
     1.8  
     1.9    /* NUV decoding state */
    1.10    GstNuvDemuxState  state;
    1.11 @@ -494,6 +495,7 @@
    1.12    if ((res != GST_FLOW_OK) || (buf == NULL)) {
    1.13        goto done;
    1.14    }
    1.15 +
    1.16    data = buf->data;
    1.17  
    1.18    h->i_type = GPOINTER_TO_INT (data[0]);
    1.19 @@ -830,8 +832,10 @@
    1.20        gst_buffer_unref (buf);
    1.21        buf = NULL;
    1.22    }
    1.23 -  nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER;
    1.24 -  memset (&nuv->priv->fh, 0, sizeof (nuv->priv->fh));
    1.25 +  if (ret == GST_FLOW_OK) {
    1.26 +     nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER;
    1.27 +     memset (&nuv->priv->fh, 0, sizeof (nuv->priv->fh));
    1.28 +  }
    1.29    return ret;
    1.30  }
    1.31  
    1.32 @@ -1004,6 +1008,7 @@
    1.33        g_assert_not_reached ();
    1.34    }
    1.35  
    1.36 +
    1.37    GST_DEBUG_OBJECT (nuv, "state: %d res:%s", nuv->priv->state, gst_flow_get_name (res));
    1.38  
    1.39    return GST_FLOW_OK;
    1.40 @@ -1058,8 +1063,10 @@
    1.41        return GST_FLOW_WRONG_STATE;
    1.42      }
    1.43    } else {
    1.44 -    if (gst_adapter_available (nuv->priv->adapter) < size)
    1.45 +    if (gst_adapter_available (nuv->priv->adapter) < size) {
    1.46 +      nuv->priv->more_data = TRUE;
    1.47        return GST_FLOW_ERROR_NO_DATA;
    1.48 +    }
    1.49      if (move) {
    1.50        *buffer = gst_adapter_take_buffer (nuv->priv->adapter, size);
    1.51      } else {
    1.52 @@ -1078,9 +1085,8 @@
    1.53    gboolean res = TRUE;
    1.54    GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (sinkpad));
    1.55  
    1.56 +  return gst_pad_activate_push (sinkpad, TRUE);
    1.57  
    1.58 -    res = gst_pad_activate_push (sinkpad, TRUE);
    1.59 -    return res;
    1.60    if (gst_pad_check_pull_range (sinkpad)) {
    1.61      if (nuv->priv->adapter) {
    1.62        gst_adapter_clear (nuv->priv->adapter);
    1.63 @@ -1210,20 +1216,21 @@
    1.64  static GstFlowReturn
    1.65  gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf)
    1.66  {
    1.67 +  GstFlowReturn ret = GST_FLOW_OK;
    1.68 +
    1.69    GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
    1.70  
    1.71 -  GST_DEBUG_OBJECT (nuv, " gst_nuv_demux_chain function");
    1.72 +  GST_DEBUG_OBJECT (nuv, " gst_nuv_demux_chain function buffersize %d", buf->size);
    1.73 +  gst_adapter_push (nuv->priv->adapter, buf);  
    1.74    
    1.75 -  if (NULL == nuv->priv->adapter) {
    1.76 -    GST_ERROR ("pull expected! Chain func should not be called");
    1.77 -    return GST_FLOW_UNEXPECTED;
    1.78 +  while ((ret == GST_FLOW_OK) && (nuv->priv->more_data == FALSE)) {
    1.79 +      ret = gst_nuv_demux_play (pad);
    1.80    }
    1.81 +
    1.82 +  nuv->priv->more_data = FALSE;
    1.83 +  gst_object_unref (nuv);
    1.84    
    1.85 -  gst_adapter_push (nuv->priv->adapter, buf);
    1.86 -
    1.87 -  /* gst_object_unref (nuv); */
    1.88 -
    1.89 -  return gst_nuv_demux_play (pad);
    1.90 +  return ret;
    1.91  }
    1.92  
    1.93  static void
    1.94 @@ -1235,6 +1242,7 @@
    1.95  static void
    1.96  gst_nuv_demux_reset (GstNuvDemux * nuv)
    1.97  {
    1.98 +  nuv->priv->more_data = FALSE;
    1.99    nuv->priv->state = GST_NUV_DEMUX_START;
   1.100    nuv->priv->mode = 0;
   1.101    nuv->priv->offset = 0;
   1.102 @@ -1317,8 +1325,9 @@
   1.103          gint64 average = 0;
   1.104          gint64 duration_bytes = gst_nuv_demux_get_bytes_duration (nuv);
   1.105  
   1.106 -        if (duration_bytes == GST_CLOCK_TIME_NONE)
   1.107 +        if (duration_bytes == GST_CLOCK_TIME_NONE) {
   1.108              return;
   1.109 +        }
   1.110  
   1.111          interval = gst_util_uint64_scale (1, current_timestamp - nuv->priv->time_start, GST_SECOND);
   1.112          if (interval > 0) {