# HG changeset patch # User renatofilho # Date 1163511262 0 # Node ID 8b867c828e8965e2ac4d59b1c0f749ad9bdaf43d # Parent 7550ece159431a61637a92ff9b95dc818771cf12 [svn r85] timestamp bug fix diff -r 7550ece15943 -r 8b867c828e89 gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Mon Nov 13 20:53:58 2006 +0000 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Tue Nov 14 13:34:22 2006 +0000 @@ -219,7 +219,7 @@ GstBuffer *buffer = NULL; GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 72, TRUE, &buffer); - if (res != GST_FLOW_OK) + if ((res != GST_FLOW_OK) || (buffer == NULL)) return res; nuv_header *h = g_new0 (nuv_header, 1); @@ -269,7 +269,7 @@ GstBuffer *file_header = NULL; res = gst_nuv_demux_read_bytes (nuv, 12, FALSE, &file_header); - if (res != GST_FLOW_OK) { + if ((res != GST_FLOW_OK) || (file_header == NULL)) { return res; } else { if (strncmp ((gchar *) file_header->data, "MythTVVideo", 11) || @@ -298,7 +298,7 @@ GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 12, TRUE, &buf); - if (res != GST_FLOW_OK) { + if ((res != GST_FLOW_OK) || (buf == NULL)) { if (buf != NULL) { gst_buffer_unref (buf); } @@ -337,7 +337,7 @@ GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 512, TRUE, &buff); - if (res != GST_FLOW_OK) { + if ((res != GST_FLOW_OK) || (buff == NULL)) { if (buff != NULL) { gst_buffer_unref (buff); } @@ -459,13 +459,15 @@ if (h->i_length > 0) { ret = gst_nuv_demux_read_bytes (nuv, h->i_length, TRUE, &buf); - if (ret != GST_FLOW_OK) + if ((ret != GST_FLOW_OK) || (buf == NULL)) return ret; - if(h->i_timecode < 0) { - GST_WARNING_OBJECT (nuv, "timecode negative"); - h->i_timecode = 0; + if (h->i_timecode < 0) { + h->i_timecode = h->i_timecode * -1; + nuv->time_offset = h->i_timecode; } + else + h->i_timecode += nuv->time_offset; GST_BUFFER_TIMESTAMP (buf) = h->i_timecode * GST_MSECOND; } @@ -476,8 +478,10 @@ if (h->i_length == 0) break; - if ( !gst_pad_is_linked( nuv->src_video_pad ) ) + if (!gst_pad_is_linked (nuv->src_video_pad)) { + gst_buffer_unref (buf); break; + } if (nuv->new_video_segment) { /* send new segment event*/ @@ -486,9 +490,6 @@ GST_CLOCK_TIME_NONE, 0)); nuv->new_video_segment = FALSE; } - //GST_WARNING_OBJECT (nuv, "setting timestamp to zero"); - - //GST_BUFFER_TIMESTAMP (buf) = 0; GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE; GST_BUFFER_SIZE (buf) = h->i_length; gst_buffer_set_caps (buf, GST_PAD_CAPS (nuv->src_video_pad)); @@ -504,8 +505,10 @@ if (h->i_length == 0) break; - if ( !gst_pad_is_linked( nuv->src_audio_pad ) ) + if (!gst_pad_is_linked (nuv->src_audio_pad)) { + gst_buffer_unref (buf); break; + } if (nuv->new_audio_segment) { /* send new segment event*/ @@ -515,7 +518,6 @@ nuv->new_audio_segment = FALSE; } - //GST_BUFFER_TIMESTAMP (buf) = h->i_timecode * GST_MSECOND; GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE; GST_BUFFER_SIZE (buf) = h->i_length; gst_buffer_set_caps (buf, GST_PAD_CAPS (nuv->src_audio_pad)); @@ -576,7 +578,7 @@ ret = gst_nuv_demux_read_bytes (nuv, nuv->mpeg_data_size, TRUE, &nuv->mpeg_buffer); - if (ret != GST_FLOW_OK) { + if ((ret != GST_FLOW_OK) || (nuv->mpeg_buffer == NULL)) { return ret; } GST_BUFFER_SIZE (nuv->mpeg_buffer) = nuv->mpeg_data_size; @@ -638,7 +640,7 @@ GstFlowReturn res = GST_FLOW_OK; res = gst_nuv_demux_read_bytes (nuv, 1, FALSE, &buf); - if (res != GST_FLOW_OK) { + if ((res != GST_FLOW_OK) || (buf == NULL)) { if (buf != NULL) { gst_buffer_unref (buf); } @@ -786,7 +788,6 @@ GstFlowReturn ret = GST_FLOW_OK; if (size == 0) { - *buffer = gst_buffer_new (); return ret; } @@ -905,7 +906,7 @@ nuv->state = GST_NUV_DEMUX_START; nuv->mode = 0; nuv->offset = 0; - nuv->last_time = 0; + nuv->time_offset = 0; if (nuv->adapter != NULL) gst_adapter_clear (nuv->adapter); diff -r 7550ece15943 -r 8b867c828e89 gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h Mon Nov 13 20:53:58 2006 +0000 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h Tue Nov 14 13:34:22 2006 +0000 @@ -163,9 +163,11 @@ GstPad *src_audio_pad; /* NUV decoding state */ - GstNuvDemuxState state; - guint64 offset; - guint last_time; + GstNuvDemuxState state; + guint64 offset; + guint time_offset; + gboolean new_audio_segment; + gboolean new_video_segment; /* Mpeg ExtraData */ @@ -176,16 +178,8 @@ nuv_extended_header *eh; nuv_frame_header *fh; - /* index */ - nuv_demux_index *index_entries; - guint index_size; - guint64 index_offset; - guint current_entry; - /* FIXME: change these fields to private struct */ /* first data buffer received, should sent new_segment */ - gboolean new_audio_segment; - gboolean new_video_segment; } GstNuvDemux; typedef struct _GstNuvDemuxClass {