ext/ffmpeg/gstffmpegprotocol.c: Add debug. Don't EOS unless all data was read.

Original commit message from CVS:
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Add debug. Don't EOS unless all data was read.
This commit is contained in:
Ronald S. Bultje 2004-12-19 01:07:21 +00:00
parent 3be46cada1
commit cbeebe3b43
2 changed files with 30 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2004-12-19 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Add debug. Don't EOS unless all data was read.
2004-12-19 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek),

View file

@ -50,6 +50,8 @@ gst_ffmpegdata_open (URLContext * h, const char *filename, int flags)
GstProtocolInfo *info;
GstPad *pad;
GST_LOG ("Opening %s", filename);
info = g_new0 (GstProtocolInfo, 1);
info->flags = flags;
@ -96,7 +98,7 @@ gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
guint32 total, request;
guint8 *data;
GstProtocolInfo *info;
gboolean have_event;
gboolean have_event, will_get_eos;
info = (GstProtocolInfo *) h->priv_data;
@ -108,12 +110,12 @@ gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
return 0;
do {
have_event = FALSE;
have_event = FALSE, will_get_eos = FALSE;
/* prevent EOS */
if (gst_bytestream_tell (bs) + size > gst_bytestream_length (bs)) {
if (gst_bytestream_tell (bs) + size >= gst_bytestream_length (bs)) {
request = (int) (gst_bytestream_length (bs) - gst_bytestream_tell (bs));
info->eos = TRUE;
will_get_eos = TRUE;
} else {
request = size;
}
@ -134,6 +136,8 @@ gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
g_warning ("gstffmpegprotocol: no bytestream event");
return total;
}
GST_LOG ("Reading (req %d, got %d) gave event of type %d",
request, total, GST_EVENT_TYPE (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
gst_event_unref (event);
@ -155,6 +159,10 @@ gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
gst_pad_event_default (info->pad, event);
break;
}
} else {
GST_DEBUG ("got data (%d bytes)", request);
if (will_get_eos)
info->eos = TRUE;
}
} while ((!info->eos && total != request) || have_event);
@ -170,6 +178,8 @@ gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
GstByteStream *bs;
GstProtocolInfo *info;
GST_DEBUG ("Reading %d bytes of data", size);
info = (GstProtocolInfo *) h->priv_data;
bs = info->bs;
res = gst_ffmpegdata_peek (h, buf, size);
@ -177,6 +187,8 @@ gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
gst_bytestream_flush_fast (bs, res);
}
GST_DEBUG ("Returning %d bytes", res);
return res;
}
@ -186,6 +198,8 @@ gst_ffmpegdata_write (URLContext * h, unsigned char *buf, int size)
GstProtocolInfo *info;
GstBuffer *outbuf;
GST_DEBUG ("Writing %d bytes", size);
info = (GstProtocolInfo *) h->priv_data;
g_return_val_if_fail (info->flags == URL_WRONLY, -EIO);
@ -207,6 +221,8 @@ gst_ffmpegdata_seek (URLContext * h, offset_t pos, int whence)
GstProtocolInfo *info;
guint64 newpos;
GST_DEBUG ("Seeking to %" G_GINT64_FORMAT ", whence=%d", pos, whence);
info = (GstProtocolInfo *) h->priv_data;
/* get data (typefind hack) */
@ -313,6 +329,8 @@ gst_ffmpegdata_close (URLContext * h)
info = (GstProtocolInfo *) h->priv_data;
GST_LOG ("Closing file");
switch (info->flags) {
case URL_WRONLY:{
/* send EOS - that closes down the stream */