# HG changeset patch # User renatofilho # Date 1174488667 0 # Node ID fc0a5721cd04d8dc674034ea098163c898737024 # Parent d04e08f9893a2bfe875346746ac02334fbf97442 [svn r427] bug fixed diff -r d04e08f9893a -r fc0a5721cd04 gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Tue Mar 20 21:50:24 2007 +0000 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Wed Mar 21 14:51:07 2007 +0000 @@ -356,6 +356,16 @@ { nuv->priv = GST_NUV_DEMUX_GET_PRIVATE (nuv); nuv->priv->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); + + /* creating adapter */ + nuv->priv->mode = NUV_PUSH_MODE; + nuv->priv->adapter = gst_adapter_new (); + + g_debug ("Adapter %p", nuv->priv->adapter); + + nuv->priv->new_audio_segment = TRUE; + nuv->priv->new_video_segment = TRUE; + gst_pad_set_activate_function (nuv->priv->sinkpad, gst_nuv_demux_sink_activate); gst_pad_set_activatepull_function (nuv->priv->sinkpad, gst_nuv_demux_sink_activate_pull); @@ -365,16 +375,9 @@ GST_DEBUG_FUNCPTR (gst_nuv_demux_chain)); gst_pad_set_event_function (nuv->priv->sinkpad, gst_nuv_demux_sink_event); + gst_element_add_pad (GST_ELEMENT (nuv), nuv->priv->sinkpad); - nuv->priv->new_audio_segment = TRUE; - nuv->priv->new_video_segment = TRUE; - - /* creating adapter */ - nuv->priv->mode = NUV_PUSH_MODE; - nuv->priv->adapter = gst_adapter_new (); - - gst_nuv_demux_reset (nuv); } static void @@ -382,6 +385,8 @@ { GstNuvDemux *nuv = GST_NUV_DEMUX (object); + g_debug ("NUV DISPOSE"); + if (nuv->priv->mpeg_buffer != NULL) { gst_buffer_unref (nuv->priv->mpeg_buffer); } @@ -1080,20 +1085,16 @@ { gboolean res = TRUE; GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (sinkpad)); + + g_debug ("SINK ACTIVATE"); if (gst_pad_check_pull_range (sinkpad)) { - if (nuv->priv->adapter) { - gst_adapter_clear (nuv->priv->adapter); - g_object_unref (nuv->priv->adapter); - nuv->priv->adapter = NULL; - } + g_debug ("PULL"); + gst_adapter_clear (nuv->priv->adapter); res = gst_pad_activate_pull (sinkpad, TRUE); } else { - if (nuv->priv->adapter) { - gst_adapter_clear (nuv->priv->adapter); - } else { - nuv->priv->adapter = gst_adapter_new (); - } + g_debug ("PUSH"); + gst_adapter_clear (nuv->priv->adapter); res = gst_pad_activate_push (sinkpad, TRUE); } @@ -1109,14 +1110,12 @@ if (active) { GST_DEBUG_OBJECT (nuv, "activating pull function"); nuv->priv->mode = NUV_PULL_MODE; - if (nuv->priv->adapter) { - gst_adapter_clear (nuv->priv->adapter); - g_object_unref (nuv->priv->adapter); - nuv->priv->adapter = NULL; - } + gst_adapter_clear (nuv->priv->adapter); + gst_pad_start_task (sinkpad, (GstTaskFunction) gst_nuv_demux_loop, sinkpad); } else { GST_DEBUG_OBJECT (nuv, "deactivating pull function"); + g_debug ("STOP TASK"); gst_pad_stop_task (sinkpad); } gst_object_unref (nuv); @@ -1129,8 +1128,10 @@ { GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); + if (active) { + nuv->priv->mode = NUV_PUSH_MODE; + gst_adapter_clear (nuv->priv->adapter); - if (active) { GST_DEBUG_OBJECT (nuv, "activating push/chain function"); } else { GST_DEBUG_OBJECT (nuv, "deactivating push/chain function"); @@ -1163,6 +1164,7 @@ gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur, &stop_type, &stop); GST_DEBUG_OBJECT (nuv, "got seek, start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, cur, stop); + g_debug ("got seek, start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, cur, stop); break; } case GST_EVENT_NEWSEGMENT: @@ -1176,6 +1178,7 @@ gst_event_parse_new_segment (event, &update, &rate, &format, &start, &stop, &time); GST_DEBUG_OBJECT (nuv, "got newsegment, start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, start, stop); + g_debug ("got newsegment, start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, start, stop); nuv->priv->duration_bytes = stop - start; gst_event_unref (event); res = TRUE; @@ -1211,8 +1214,12 @@ gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf) { GstFlowReturn ret = GST_FLOW_OK; + GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); + + if (nuv->priv->mode != NUV_PUSH_MODE) + return ret; - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); + g_debug ("CHAIN ADP %p", nuv->priv->adapter); gst_adapter_push (nuv->priv->adapter, buf); @@ -1222,6 +1229,8 @@ nuv->priv->more_data = FALSE; gst_object_unref (nuv); + + g_debug ("CHAIN END"); return ret; } @@ -1237,7 +1246,7 @@ { nuv->priv->more_data = FALSE; nuv->priv->state = GST_NUV_DEMUX_START; - nuv->priv->mode = 0; + nuv->priv->mode = NUV_PUSH_MODE; nuv->priv->offset = 0; nuv->priv->streamer_offset = 0; nuv->priv->time_start = 0; @@ -1247,9 +1256,7 @@ nuv->priv->duration_average = GST_CLOCK_TIME_NONE; gst_segment_init (&nuv->priv->segment, GST_FORMAT_TIME); - if (nuv->priv->adapter != NULL) { - gst_adapter_clear (nuv->priv->adapter); - } + gst_adapter_clear (nuv->priv->adapter); if (nuv->priv->mpeg_buffer != NULL) { gst_buffer_unref (nuv->priv->mpeg_buffer); @@ -1278,6 +1285,7 @@ switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: + g_debug ("NULL_TO_READY"); gst_nuv_demux_reset (GST_NUV_DEMUX (element)); gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element)); break; @@ -1292,6 +1300,7 @@ switch (transition) { case GST_STATE_CHANGE_READY_TO_NULL: + g_debug ("READY_TO_NULL"); gst_nuv_demux_reset (GST_NUV_DEMUX (element)); gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element)); break;