[svn r427] bug fixed trunk
authorrenatofilho
Wed Mar 21 14:51:07 2007 +0000 (2007-03-21)
branchtrunk
changeset 422fc0a5721cd04
parent 421 d04e08f9893a
child 423 099cfb245b15
[svn r427] bug fixed
gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c
     1.1 --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Tue Mar 20 21:50:24 2007 +0000
     1.2 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Wed Mar 21 14:51:07 2007 +0000
     1.3 @@ -356,6 +356,16 @@
     1.4  {
     1.5    nuv->priv = GST_NUV_DEMUX_GET_PRIVATE (nuv);
     1.6    nuv->priv->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
     1.7 +
     1.8 +  /* creating adapter */
     1.9 +  nuv->priv->mode = NUV_PUSH_MODE;
    1.10 +  nuv->priv->adapter = gst_adapter_new ();
    1.11 +
    1.12 +  g_debug ("Adapter %p", nuv->priv->adapter);
    1.13 +
    1.14 +  nuv->priv->new_audio_segment = TRUE;
    1.15 +  nuv->priv->new_video_segment = TRUE;
    1.16 +
    1.17    gst_pad_set_activate_function (nuv->priv->sinkpad, gst_nuv_demux_sink_activate);
    1.18    gst_pad_set_activatepull_function (nuv->priv->sinkpad,
    1.19        gst_nuv_demux_sink_activate_pull);
    1.20 @@ -365,16 +375,9 @@
    1.21        GST_DEBUG_FUNCPTR (gst_nuv_demux_chain));
    1.22    gst_pad_set_event_function (nuv->priv->sinkpad,
    1.23        gst_nuv_demux_sink_event);
    1.24 +
    1.25    gst_element_add_pad (GST_ELEMENT (nuv), nuv->priv->sinkpad);
    1.26  
    1.27 -  nuv->priv->new_audio_segment = TRUE;
    1.28 -  nuv->priv->new_video_segment = TRUE;
    1.29 -
    1.30 -  /* creating adapter */
    1.31 -  nuv->priv->mode = NUV_PUSH_MODE;
    1.32 -  nuv->priv->adapter = gst_adapter_new ();
    1.33 -
    1.34 -  gst_nuv_demux_reset (nuv);
    1.35  }
    1.36  
    1.37  static void
    1.38 @@ -382,6 +385,8 @@
    1.39  {
    1.40    GstNuvDemux *nuv = GST_NUV_DEMUX (object);
    1.41  
    1.42 +  g_debug ("NUV DISPOSE");
    1.43 +
    1.44    if (nuv->priv->mpeg_buffer != NULL) {
    1.45      gst_buffer_unref (nuv->priv->mpeg_buffer);
    1.46    }
    1.47 @@ -1080,20 +1085,16 @@
    1.48  {
    1.49    gboolean res = TRUE;
    1.50    GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (sinkpad));
    1.51 + 
    1.52 +  g_debug ("SINK ACTIVATE");
    1.53  
    1.54    if (gst_pad_check_pull_range (sinkpad)) {
    1.55 -    if (nuv->priv->adapter) {
    1.56 -      gst_adapter_clear (nuv->priv->adapter);
    1.57 -      g_object_unref (nuv->priv->adapter);
    1.58 -      nuv->priv->adapter = NULL;
    1.59 -    }
    1.60 +    g_debug ("PULL");
    1.61 +    gst_adapter_clear (nuv->priv->adapter);
    1.62      res = gst_pad_activate_pull (sinkpad, TRUE);
    1.63    } else {
    1.64 -    if (nuv->priv->adapter) {
    1.65 -      gst_adapter_clear (nuv->priv->adapter);
    1.66 -    } else {
    1.67 -      nuv->priv->adapter = gst_adapter_new ();
    1.68 -    }
    1.69 +    g_debug ("PUSH");
    1.70 +    gst_adapter_clear (nuv->priv->adapter);
    1.71      res = gst_pad_activate_push (sinkpad, TRUE);
    1.72    }
    1.73    
    1.74 @@ -1109,14 +1110,12 @@
    1.75    if (active) {
    1.76      GST_DEBUG_OBJECT (nuv, "activating pull function");
    1.77      nuv->priv->mode = NUV_PULL_MODE;
    1.78 -    if (nuv->priv->adapter) {
    1.79 -      gst_adapter_clear (nuv->priv->adapter);
    1.80 -      g_object_unref (nuv->priv->adapter);
    1.81 -      nuv->priv->adapter = NULL;
    1.82 -    }
    1.83 +    gst_adapter_clear (nuv->priv->adapter);
    1.84 +
    1.85      gst_pad_start_task (sinkpad, (GstTaskFunction) gst_nuv_demux_loop, sinkpad);
    1.86    } else {
    1.87      GST_DEBUG_OBJECT (nuv, "deactivating pull function");
    1.88 +    g_debug ("STOP TASK");
    1.89      gst_pad_stop_task (sinkpad);
    1.90    }
    1.91    gst_object_unref (nuv);
    1.92 @@ -1129,8 +1128,10 @@
    1.93  {
    1.94    GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
    1.95  
    1.96 +  if (active) {
    1.97 +    nuv->priv->mode = NUV_PUSH_MODE;
    1.98 +    gst_adapter_clear (nuv->priv->adapter);
    1.99  
   1.100 -  if (active) {
   1.101      GST_DEBUG_OBJECT (nuv, "activating push/chain function");
   1.102    } else {
   1.103      GST_DEBUG_OBJECT (nuv, "deactivating push/chain function");
   1.104 @@ -1163,6 +1164,7 @@
   1.105  
   1.106        gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur, &stop_type, &stop);
   1.107        GST_DEBUG_OBJECT (nuv, "got seek, start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, cur, stop);
   1.108 +      g_debug ("got seek, start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, cur, stop);
   1.109        break;
   1.110      }
   1.111      case GST_EVENT_NEWSEGMENT:
   1.112 @@ -1176,6 +1178,7 @@
   1.113        gst_event_parse_new_segment (event, &update, &rate, &format, &start, &stop, &time);
   1.114  
   1.115        GST_DEBUG_OBJECT (nuv, "got newsegment, start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, start, stop);
   1.116 +      g_debug ("got newsegment, start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, start, stop);
   1.117        nuv->priv->duration_bytes = stop - start;
   1.118        gst_event_unref (event);
   1.119        res = TRUE;
   1.120 @@ -1211,8 +1214,12 @@
   1.121  gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf)
   1.122  {
   1.123    GstFlowReturn ret = GST_FLOW_OK;
   1.124 +  GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
   1.125 +  
   1.126 +  if (nuv->priv->mode != NUV_PUSH_MODE)
   1.127 +    return ret;
   1.128  
   1.129 -  GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
   1.130 +  g_debug ("CHAIN ADP %p", nuv->priv->adapter);
   1.131  
   1.132    gst_adapter_push (nuv->priv->adapter, buf);  
   1.133    
   1.134 @@ -1222,6 +1229,8 @@
   1.135  
   1.136    nuv->priv->more_data = FALSE;
   1.137    gst_object_unref (nuv);
   1.138 +
   1.139 +  g_debug ("CHAIN END");
   1.140    
   1.141    return ret;
   1.142  }
   1.143 @@ -1237,7 +1246,7 @@
   1.144  {
   1.145    nuv->priv->more_data = FALSE;
   1.146    nuv->priv->state = GST_NUV_DEMUX_START;
   1.147 -  nuv->priv->mode = 0;
   1.148 +  nuv->priv->mode = NUV_PUSH_MODE;
   1.149    nuv->priv->offset = 0;
   1.150    nuv->priv->streamer_offset = 0;
   1.151    nuv->priv->time_start = 0;
   1.152 @@ -1247,9 +1256,7 @@
   1.153    nuv->priv->duration_average = GST_CLOCK_TIME_NONE;
   1.154    gst_segment_init (&nuv->priv->segment, GST_FORMAT_TIME);
   1.155  
   1.156 -  if (nuv->priv->adapter != NULL) {
   1.157 -    gst_adapter_clear (nuv->priv->adapter);
   1.158 -  }
   1.159 +  gst_adapter_clear (nuv->priv->adapter);
   1.160  
   1.161    if (nuv->priv->mpeg_buffer != NULL) {
   1.162      gst_buffer_unref (nuv->priv->mpeg_buffer);
   1.163 @@ -1278,6 +1285,7 @@
   1.164  
   1.165    switch (transition) {
   1.166      case GST_STATE_CHANGE_NULL_TO_READY:
   1.167 +	g_debug ("NULL_TO_READY");
   1.168        gst_nuv_demux_reset (GST_NUV_DEMUX (element));
   1.169        gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element));
   1.170        break;
   1.171 @@ -1292,6 +1300,7 @@
   1.172  
   1.173    switch (transition) {
   1.174      case GST_STATE_CHANGE_READY_TO_NULL:
   1.175 +	g_debug ("READY_TO_NULL");
   1.176        gst_nuv_demux_reset (GST_NUV_DEMUX (element));
   1.177        gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element));
   1.178        break;