[svn r157] trunk
authorrenatofilho
Thu Nov 30 21:05:13 2006 +0000 (2006-11-30)
branchtrunk
changeset 1564b24a328c655
parent 155 1842993f4473
child 157 585b3db817a1
[svn r157]
gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c
     1.1 --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Thu Nov 30 20:28:25 2006 +0000
     1.2 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Thu Nov 30 21:05:13 2006 +0000
     1.3 @@ -1078,12 +1078,14 @@
     1.4        return GST_FLOW_ERROR_NO_DATA;
     1.5  
     1.6      if (move) {
     1.7 -      guint8 *data = (guint8 *) gst_adapter_take (nuv->priv->adapter, size);
     1.8 -      *buffer = gst_buffer_new_and_alloc ( size );
     1.9 +      guint8 *data = NULL;
    1.10 +      data = (guint8 *) gst_adapter_take (nuv->priv->adapter, size);
    1.11 +      *buffer = gst_buffer_new ();
    1.12        gst_buffer_set_data (*buffer, data, size);
    1.13      } else {
    1.14 -      guint8 *data = (guint8 *) gst_adapter_peek (nuv->priv->adapter, size);
    1.15 -      *buffer = gst_buffer_new_and_alloc ( size );
    1.16 +      guint8 *data = NULL;
    1.17 +      data = (guint8 *) gst_adapter_peek (nuv->priv->adapter, size);
    1.18 +      *buffer = gst_buffer_new ();
    1.19        gst_buffer_set_data (*buffer, data, size);
    1.20      }
    1.21    }
    1.22 @@ -1323,6 +1325,7 @@
    1.23      interval  = current_timestamp - nuv->priv->last_update;
    1.24  
    1.25      if (interval > (10 * GST_SECOND)) {
    1.26 +        GstMessage* msg = NULL;
    1.27          gint64 average = 0;
    1.28          gint64 duration_bytes = gst_nuv_demux_get_bytes_duration (nuv);
    1.29  
    1.30 @@ -1338,9 +1341,8 @@
    1.31                  nuv->priv->duration_average = gst_util_uint64_scale (GST_SECOND, duration_bytes, average);
    1.32              }
    1.33              nuv->priv->last_update = current_timestamp;
    1.34 -            gst_element_post_message (GST_ELEMENT (nuv), 
    1.35 -            		gst_message_new_duration (GST_OBJECT (nuv), GST_FORMAT_TIME, 
    1.36 -            						nuv->priv->duration_average) );
    1.37 +            msg = gst_message_new_duration (GST_OBJECT (nuv), GST_FORMAT_TIME, nuv->priv->duration_average);
    1.38 +            gst_element_post_message (GST_ELEMENT (nuv), msg);
    1.39              GST_DEBUG_OBJECT (nuv, "New Duration Average %"G_GUINT64_FORMAT, nuv->priv->duration_average);
    1.40          }
    1.41      }
    1.42 @@ -1350,11 +1352,16 @@
    1.43  gst_nuv_demux_get_bytes_duration (GstNuvDemux *nuv)
    1.44  {
    1.45      if (nuv->priv->duration_bytes == GST_CLOCK_TIME_NONE) {
    1.46 -        GstFormat format = GST_FORMAT_BYTES;
    1.47 -        gint64 duration = 0;
    1.48 -        if (gst_pad_query_peer_duration (nuv->priv->sinkpad, &format, &duration)) {            
    1.49 +        GstPad *peer = gst_pad_get_peer (nuv->priv->sinkpad);
    1.50 +        GstQuery *query = gst_query_new_duration (GST_FORMAT_BYTES);
    1.51 +        if (gst_pad_query (peer, query)) {
    1.52 +            gint64 duration;
    1.53 +
    1.54 +            gst_query_parse_duration (query, NULL, &duration);
    1.55              nuv->priv->duration_bytes = duration;
    1.56          }
    1.57 +        gst_object_unref (peer);
    1.58 +        gst_query_unref (query);
    1.59      }
    1.60      return nuv->priv->duration_bytes;
    1.61  }
    1.62 @@ -1363,11 +1370,15 @@
    1.63  gst_nuv_demux_get_time_duration (GstNuvDemux *nuv)
    1.64  {
    1.65      if (nuv->priv->duration_time == GST_CLOCK_TIME_NONE) {
    1.66 -        GstFormat format = GST_FORMAT_TIME;
    1.67 -        gint64 duration = 0;
    1.68 -        if (gst_pad_query_peer_duration (nuv->priv->sinkpad, &format, &duration)) {            
    1.69 +        GstPad *peer = gst_pad_get_peer (nuv->priv->sinkpad);
    1.70 +        GstQuery *query = gst_query_new_duration (GST_FORMAT_TIME);
    1.71 +        if (gst_pad_query (peer, query)) {
    1.72 +            gint64 duration;
    1.73 +            gst_query_parse_duration (query, NULL, &duration);
    1.74              nuv->priv->duration_time = duration;
    1.75          }
    1.76 +        gst_object_unref (peer);
    1.77 +        gst_query_unref (query);
    1.78      }
    1.79      return nuv->priv->duration_time;
    1.80  }