# HG changeset patch # User renatofilho # Date 1163614305 0 # Node ID 2a70ed80ed1a4e9bf8bbf7ca24b34824283e9654 # Parent 9ea342c364ded203063dff02ed8b46ba21f97125 [svn r89] diff -r 9ea342c364de -r 2a70ed80ed1a gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Wed Nov 15 18:07:23 2006 +0000 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Wed Nov 15 18:11:45 2006 +0000 @@ -405,7 +405,6 @@ { static const GstQueryType src_types[] = { GST_QUERY_POSITION, - GST_QUERY_DURATION, 0 }; @@ -427,18 +426,6 @@ GST_DEBUG_OBJECT (nuv, "POS %d", nuv->last_frame_time); } break; - case GST_QUERY_DURATION: - if (nuv->duration != 0) { - gint64 total; - gint64 fps; - - fps = nuv->h->i_fpsn / nuv->h->i_fpsd; - total = gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps); - gst_query_set_duration (query, GST_FORMAT_TIME, total); - GST_DEBUG_OBJECT (nuv, "DURATION %d", total); - res = TRUE; - } - break; default: res = FALSE; break; @@ -520,6 +507,25 @@ return ret; } +static gboolean +gst_nuv_combine_flow (GstNuvDemux *nuv) +{ + GstFlowReturn ret_video = nuv->last_video_return; + GstFlowReturn ret_audio = nuv->last_audio_return; + + if ((ret_video != GST_FLOW_OK) && + (ret_audio != GST_FLOW_OK)) + return FALSE; + + if (GST_FLOW_IS_FATAL (nuv->last_video_return)) + return FALSE; + + if (GST_FLOW_IS_FATAL (nuv->last_audio_return)) + return FALSE; + + return TRUE; +} + static GstFlowReturn gst_nuv_demux_stream_data (GstNuvDemux * nuv) { @@ -552,11 +558,6 @@ if (h->i_length == 0) break; - if (!gst_pad_is_linked (nuv->src_video_pad)) { - gst_buffer_unref (buf); - break; - } - if (nuv->new_video_segment) { /* send new segment event*/ gst_pad_push_event (nuv->src_video_pad, @@ -567,10 +568,11 @@ GST_BUFFER_SIZE (buf) = h->i_length; gst_buffer_set_caps (buf, GST_PAD_CAPS (nuv->src_video_pad)); - ret = gst_pad_push (nuv->src_video_pad, buf); - if (ret != GST_FLOW_OK) { - GST_WARNING_OBJECT (nuv, "error pushing on srcpad %s, is linked? = %d", - gst_pad_get_name (nuv->src_video_pad), gst_pad_is_linked (nuv->src_video_pad)); + nuv->last_video_return = gst_pad_push (nuv->src_video_pad, buf); + if (!gst_nuv_combine_flow (nuv)) { + ret = nuv->last_video_return; + GST_WARNING_OBJECT (nuv, "error: %d pushing on srcpad %s, is linked? = %d", + nuv->last_video_return, gst_pad_get_name (nuv->src_video_pad), gst_pad_is_linked (nuv->src_video_pad)); } break; } @@ -578,11 +580,6 @@ { if (h->i_length == 0) break; - - if (!gst_pad_is_linked (nuv->src_audio_pad)) { - gst_buffer_unref (buf); - break; - } if (nuv->new_audio_segment) { /* send new segment event*/ @@ -594,10 +591,11 @@ GST_BUFFER_SIZE (buf) = h->i_length; gst_buffer_set_caps (buf, GST_PAD_CAPS (nuv->src_audio_pad)); - ret = gst_pad_push (nuv->src_audio_pad, buf); - if (ret != GST_FLOW_OK) { - GST_WARNING_OBJECT (nuv, "Error pushing on srcpad %s, is linked? = %d", - gst_pad_get_name (nuv->src_audio_pad), gst_pad_is_linked (nuv->src_audio_pad)); + nuv->last_audio_return = gst_pad_push (nuv->src_audio_pad, buf); + if (!gst_nuv_combine_flow (nuv)) { + ret = nuv->last_audio_return; + GST_WARNING_OBJECT (nuv, "Error %d pushing on srcpad %s, is linked? = %d", + nuv->last_audio_return, gst_pad_get_name (nuv->src_audio_pad), gst_pad_is_linked (nuv->src_audio_pad)); } break; } diff -r 9ea342c364de -r 2a70ed80ed1a gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h Wed Nov 15 18:07:23 2006 +0000 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h Wed Nov 15 18:11:45 2006 +0000 @@ -165,6 +165,9 @@ GstPad *src_video_pad; GstPad *src_audio_pad; + GstFlowReturn last_video_return; + GstFlowReturn last_audio_return; + /* NUV decoding state */ GstNuvDemuxState state; guint64 duration;