[svn r719] Fixed bug when changing program info, and the new file starts not on a frame header, but in a file header. trunk
authorrosfran
Fri May 25 15:56:10 2007 +0100 (2007-05-25)
branchtrunk
changeset 713e8fe96f87916
parent 712 8d28bf09d12f
child 714 03f2acbda6b1
[svn r719] Fixed bug when changing program info, and the new file starts not on a frame header, but in a file header.
gst-gmyth/nuvdemux/gstnuvdemux.c
     1.1 --- a/gst-gmyth/nuvdemux/gstnuvdemux.c	Fri May 25 14:14:18 2007 +0100
     1.2 +++ b/gst-gmyth/nuvdemux/gstnuvdemux.c	Fri May 25 15:56:10 2007 +0100
     1.3 @@ -273,7 +273,7 @@
     1.4    gint64 segment_stop, GstFormat format);
     1.5  
     1.6  
     1.7 -
     1.8 +static GstFlowReturn gst_nuv_demux_move_bytes (GstNuvDemux * nuv, guint64 size);
     1.9  static GstFlowReturn gst_nuv_demux_read_bytes (GstNuvDemux * nuv, guint64 size,
    1.10      gboolean move, GstBuffer ** buffer);
    1.11  static void gst_nuv_demux_reset (GstNuvDemux * nuv);
    1.12 @@ -510,13 +510,20 @@
    1.13    unsigned char *data;
    1.14    GstBuffer *buf = NULL;
    1.15  
    1.16 -  GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 12, TRUE, &buf);
    1.17 +  GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 12, FALSE, &buf);
    1.18  
    1.19    if ((res != GST_FLOW_OK) || (buf == NULL)) {
    1.20        goto done;
    1.21    }
    1.22  
    1.23    data = buf->data;
    1.24 +  /* verifies if it is a MythTV file header */
    1.25 +  if ( ( data[0] == 'M' || data[0] == 'N') && data[6] == 'V' )  {
    1.26 +	  nuv->priv->state = GST_NUV_DEMUX_HEADER_DATA;
    1.27 +	  goto done;
    1.28 +  }
    1.29 +  /* it is not a NUV file header, so now can move the 12 bytes */
    1.30 +  res = gst_nuv_demux_move_bytes (nuv, 12);
    1.31  
    1.32    h->i_type = GPOINTER_TO_INT (data[0]);
    1.33    h->i_compression = GPOINTER_TO_INT (data[1]);
    1.34 @@ -1195,7 +1202,6 @@
    1.35      return ret;
    1.36    }
    1.37  
    1.38 -
    1.39    if (nuv->priv->mode == NUV_PULL_MODE) {
    1.40      ret = gst_pad_pull_range (nuv->priv->sinkpad, nuv->priv->offset, size, buffer);
    1.41      if (ret == GST_FLOW_OK) {
    1.42 @@ -1223,6 +1229,27 @@
    1.43    return ret;
    1.44  }
    1.45  
    1.46 +static GstFlowReturn
    1.47 +gst_nuv_demux_move_bytes (GstNuvDemux * nuv, guint64 size)
    1.48 +{
    1.49 +  GstFlowReturn ret = GST_FLOW_OK;
    1.50 +
    1.51 +  if (size == 0) {
    1.52 +    return ret;
    1.53 +  }
    1.54 +
    1.55 +  if (nuv->priv->mode == NUV_PULL_MODE) {
    1.56 +      nuv->priv->offset += size;
    1.57 +  } else {
    1.58 +    if (gst_adapter_available (nuv->priv->adapter) < size) {
    1.59 +      nuv->priv->more_data = TRUE;
    1.60 +      return GST_FLOW_ERROR_NO_DATA;
    1.61 +    }
    1.62 +    gst_adapter_flush (nuv->priv->adapter, size);
    1.63 +  }
    1.64 +  return ret;
    1.65 +}
    1.66 +
    1.67  static gboolean
    1.68  gst_nuv_demux_sink_activate (GstPad * sinkpad)
    1.69  {