1.1 --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Mon Nov 13 20:53:58 2006 +0000
1.2 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Tue Nov 14 13:34:22 2006 +0000
1.3 @@ -219,7 +219,7 @@
1.4 GstBuffer *buffer = NULL;
1.5 GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 72, TRUE, &buffer);
1.6
1.7 - if (res != GST_FLOW_OK)
1.8 + if ((res != GST_FLOW_OK) || (buffer == NULL))
1.9 return res;
1.10
1.11 nuv_header *h = g_new0 (nuv_header, 1);
1.12 @@ -269,7 +269,7 @@
1.13 GstBuffer *file_header = NULL;
1.14
1.15 res = gst_nuv_demux_read_bytes (nuv, 12, FALSE, &file_header);
1.16 - if (res != GST_FLOW_OK) {
1.17 + if ((res != GST_FLOW_OK) || (file_header == NULL)) {
1.18 return res;
1.19 } else {
1.20 if (strncmp ((gchar *) file_header->data, "MythTVVideo", 11) ||
1.21 @@ -298,7 +298,7 @@
1.22
1.23 GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 12, TRUE, &buf);
1.24
1.25 - if (res != GST_FLOW_OK) {
1.26 + if ((res != GST_FLOW_OK) || (buf == NULL)) {
1.27 if (buf != NULL) {
1.28 gst_buffer_unref (buf);
1.29 }
1.30 @@ -337,7 +337,7 @@
1.31
1.32 GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 512, TRUE, &buff);
1.33
1.34 - if (res != GST_FLOW_OK) {
1.35 + if ((res != GST_FLOW_OK) || (buff == NULL)) {
1.36 if (buff != NULL) {
1.37 gst_buffer_unref (buff);
1.38 }
1.39 @@ -459,13 +459,15 @@
1.40
1.41 if (h->i_length > 0) {
1.42 ret = gst_nuv_demux_read_bytes (nuv, h->i_length, TRUE, &buf);
1.43 - if (ret != GST_FLOW_OK)
1.44 + if ((ret != GST_FLOW_OK) || (buf == NULL))
1.45 return ret;
1.46
1.47 - if(h->i_timecode < 0) {
1.48 - GST_WARNING_OBJECT (nuv, "timecode negative");
1.49 - h->i_timecode = 0;
1.50 + if (h->i_timecode < 0) {
1.51 + h->i_timecode = h->i_timecode * -1;
1.52 + nuv->time_offset = h->i_timecode;
1.53 }
1.54 + else
1.55 + h->i_timecode += nuv->time_offset;
1.56
1.57 GST_BUFFER_TIMESTAMP (buf) = h->i_timecode * GST_MSECOND;
1.58 }
1.59 @@ -476,8 +478,10 @@
1.60 if (h->i_length == 0)
1.61 break;
1.62
1.63 - if ( !gst_pad_is_linked( nuv->src_video_pad ) )
1.64 + if (!gst_pad_is_linked (nuv->src_video_pad)) {
1.65 + gst_buffer_unref (buf);
1.66 break;
1.67 + }
1.68
1.69 if (nuv->new_video_segment) {
1.70 /* send new segment event*/
1.71 @@ -486,9 +490,6 @@
1.72 GST_CLOCK_TIME_NONE, 0));
1.73 nuv->new_video_segment = FALSE;
1.74 }
1.75 - //GST_WARNING_OBJECT (nuv, "setting timestamp to zero");
1.76 -
1.77 - //GST_BUFFER_TIMESTAMP (buf) = 0;
1.78 GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;
1.79 GST_BUFFER_SIZE (buf) = h->i_length;
1.80 gst_buffer_set_caps (buf, GST_PAD_CAPS (nuv->src_video_pad));
1.81 @@ -504,8 +505,10 @@
1.82 if (h->i_length == 0)
1.83 break;
1.84
1.85 - if ( !gst_pad_is_linked( nuv->src_audio_pad ) )
1.86 + if (!gst_pad_is_linked (nuv->src_audio_pad)) {
1.87 + gst_buffer_unref (buf);
1.88 break;
1.89 + }
1.90
1.91 if (nuv->new_audio_segment) {
1.92 /* send new segment event*/
1.93 @@ -515,7 +518,6 @@
1.94 nuv->new_audio_segment = FALSE;
1.95 }
1.96
1.97 - //GST_BUFFER_TIMESTAMP (buf) = h->i_timecode * GST_MSECOND;
1.98 GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;
1.99 GST_BUFFER_SIZE (buf) = h->i_length;
1.100 gst_buffer_set_caps (buf, GST_PAD_CAPS (nuv->src_audio_pad));
1.101 @@ -576,7 +578,7 @@
1.102 ret =
1.103 gst_nuv_demux_read_bytes (nuv, nuv->mpeg_data_size, TRUE,
1.104 &nuv->mpeg_buffer);
1.105 - if (ret != GST_FLOW_OK) {
1.106 + if ((ret != GST_FLOW_OK) || (nuv->mpeg_buffer == NULL)) {
1.107 return ret;
1.108 }
1.109 GST_BUFFER_SIZE (nuv->mpeg_buffer) = nuv->mpeg_data_size;
1.110 @@ -638,7 +640,7 @@
1.111 GstFlowReturn res = GST_FLOW_OK;
1.112
1.113 res = gst_nuv_demux_read_bytes (nuv, 1, FALSE, &buf);
1.114 - if (res != GST_FLOW_OK) {
1.115 + if ((res != GST_FLOW_OK) || (buf == NULL)) {
1.116 if (buf != NULL) {
1.117 gst_buffer_unref (buf);
1.118 }
1.119 @@ -786,7 +788,6 @@
1.120 GstFlowReturn ret = GST_FLOW_OK;
1.121
1.122 if (size == 0) {
1.123 - *buffer = gst_buffer_new ();
1.124 return ret;
1.125 }
1.126
1.127 @@ -905,7 +906,7 @@
1.128 nuv->state = GST_NUV_DEMUX_START;
1.129 nuv->mode = 0;
1.130 nuv->offset = 0;
1.131 - nuv->last_time = 0;
1.132 + nuv->time_offset = 0;
1.133
1.134 if (nuv->adapter != NULL)
1.135 gst_adapter_clear (nuv->adapter);
2.1 --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h Mon Nov 13 20:53:58 2006 +0000
2.2 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h Tue Nov 14 13:34:22 2006 +0000
2.3 @@ -163,9 +163,11 @@
2.4 GstPad *src_audio_pad;
2.5
2.6 /* NUV decoding state */
2.7 - GstNuvDemuxState state;
2.8 - guint64 offset;
2.9 - guint last_time;
2.10 + GstNuvDemuxState state;
2.11 + guint64 offset;
2.12 + guint time_offset;
2.13 + gboolean new_audio_segment;
2.14 + gboolean new_video_segment;
2.15
2.16
2.17 /* Mpeg ExtraData */
2.18 @@ -176,16 +178,8 @@
2.19 nuv_extended_header *eh;
2.20 nuv_frame_header *fh;
2.21
2.22 - /* index */
2.23 - nuv_demux_index *index_entries;
2.24 - guint index_size;
2.25 - guint64 index_offset;
2.26 - guint current_entry;
2.27 -
2.28 /* FIXME: change these fields to private struct */
2.29 /* first data buffer received, should sent new_segment */
2.30 - gboolean new_audio_segment;
2.31 - gboolean new_video_segment;
2.32 } GstNuvDemux;
2.33
2.34 typedef struct _GstNuvDemuxClass {