# HG changeset patch # User rosfran # Date 1180104970 -3600 # Node ID e8fe96f879168efe42ec11319e201b9722e1e7d9 # Parent 8d28bf09d12f77e62b4282101c70fb8dd7da1a58 [svn r719] Fixed bug when changing program info, and the new file starts not on a frame header, but in a file header. diff -r 8d28bf09d12f -r e8fe96f87916 gst-gmyth/nuvdemux/gstnuvdemux.c --- a/gst-gmyth/nuvdemux/gstnuvdemux.c Fri May 25 14:14:18 2007 +0100 +++ b/gst-gmyth/nuvdemux/gstnuvdemux.c Fri May 25 15:56:10 2007 +0100 @@ -273,7 +273,7 @@ gint64 segment_stop, GstFormat format); - +static GstFlowReturn gst_nuv_demux_move_bytes (GstNuvDemux * nuv, guint64 size); static GstFlowReturn gst_nuv_demux_read_bytes (GstNuvDemux * nuv, guint64 size, gboolean move, GstBuffer ** buffer); static void gst_nuv_demux_reset (GstNuvDemux * nuv); @@ -510,13 +510,20 @@ unsigned char *data; GstBuffer *buf = NULL; - GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 12, TRUE, &buf); + GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 12, FALSE, &buf); if ((res != GST_FLOW_OK) || (buf == NULL)) { goto done; } data = buf->data; + /* verifies if it is a MythTV file header */ + if ( ( data[0] == 'M' || data[0] == 'N') && data[6] == 'V' ) { + nuv->priv->state = GST_NUV_DEMUX_HEADER_DATA; + goto done; + } + /* it is not a NUV file header, so now can move the 12 bytes */ + res = gst_nuv_demux_move_bytes (nuv, 12); h->i_type = GPOINTER_TO_INT (data[0]); h->i_compression = GPOINTER_TO_INT (data[1]); @@ -1195,7 +1202,6 @@ return ret; } - if (nuv->priv->mode == NUV_PULL_MODE) { ret = gst_pad_pull_range (nuv->priv->sinkpad, nuv->priv->offset, size, buffer); if (ret == GST_FLOW_OK) { @@ -1223,6 +1229,27 @@ return ret; } +static GstFlowReturn +gst_nuv_demux_move_bytes (GstNuvDemux * nuv, guint64 size) +{ + GstFlowReturn ret = GST_FLOW_OK; + + if (size == 0) { + return ret; + } + + if (nuv->priv->mode == NUV_PULL_MODE) { + nuv->priv->offset += size; + } else { + if (gst_adapter_available (nuv->priv->adapter) < size) { + nuv->priv->more_data = TRUE; + return GST_FLOW_ERROR_NO_DATA; + } + gst_adapter_flush (nuv->priv->adapter, size); + } + return ret; +} + static gboolean gst_nuv_demux_sink_activate (GstPad * sinkpad) {