From: Ronald S. Bultje Date: Sun, 19 Dec 2004 00:32:13 +0000 (+0000) Subject: ext/ffmpeg/gstffmpegprotocol.c: Some "seeking" hacks, and separate peek from read... X-Git-Tag: 1.19.3~499^2~1914 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3be46cada1d468ee0b510556ad512f1cbe16ff20;p=platform%2Fupstream%2Fgstreamer.git ext/ffmpeg/gstffmpegprotocol.c: Some "seeking" hacks, and separate peek from read (read = peek + flush) so seek can u... Original commit message from CVS: * ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek), (gst_ffmpegdata_read), (gst_ffmpegdata_seek): Some "seeking" hacks, and separate peek from read (read = peek + flush) so seek can use peek as well to workaround typefind. With this, I'm able to play several of the gaming format movies in Totem. --- diff --git a/ChangeLog b/ChangeLog index 69e6903..d77b1b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-12-19 Ronald S. Bultje + + * ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek), + (gst_ffmpegdata_read), (gst_ffmpegdata_seek): + Some "seeking" hacks, and separate peek from read (read = peek + + flush) so seek can use peek as well to workaround typefind. With + this, I'm able to play several of the gaming format movies in + Totem. + 2004-12-18 Ronald S. Bultje * ext/ffmpeg/Makefile.am: diff --git a/ext/ffmpeg/gstffmpegprotocol.c b/ext/ffmpeg/gstffmpegprotocol.c index 51af68b..b757aa8 100644 --- a/ext/ffmpeg/gstffmpegprotocol.c +++ b/ext/ffmpeg/gstffmpegprotocol.c @@ -90,7 +90,7 @@ gst_ffmpegdata_open (URLContext * h, const char *filename, int flags) } static int -gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size) +gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size) { GstByteStream *bs; guint32 total, request; @@ -159,12 +159,28 @@ gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size) } while ((!info->eos && total != request) || have_event); memcpy (buf, data, total); - gst_bytestream_flush_fast (bs, total); return total; } static int +gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size) +{ + gint res; + GstByteStream *bs; + GstProtocolInfo *info; + + info = (GstProtocolInfo *) h->priv_data; + bs = info->bs; + res = gst_ffmpegdata_peek (h, buf, size); + if (res > 0) { + gst_bytestream_flush_fast (bs, res); + } + + return res; +} + +static int gst_ffmpegdata_write (URLContext * h, unsigned char *buf, int size) { GstProtocolInfo *info; @@ -195,19 +211,18 @@ gst_ffmpegdata_seek (URLContext * h, offset_t pos, int whence) /* get data (typefind hack) */ if (gst_bytestream_tell (info->bs) != gst_bytestream_length (info->bs)) { - //gchar buf; - //gst_ffmpegdata_read (h, &buf, 1); - //peek!!!!! not read = data loss if not seekable + gchar buf; + gst_ffmpegdata_peek (h, &buf, 1); } /* hack in ffmpeg to get filesize... */ if (whence == SEEK_END && pos == -1) return gst_bytestream_length (info->bs) - 1; + else if (whence == SEEK_END && pos == 0) + return gst_bytestream_length (info->bs); /* another hack to get the current position... */ else if (whence == SEEK_CUR && pos == 0) return gst_bytestream_tell (info->bs); - //else - //g_assert (pos >= 0); switch (whence) { case SEEK_SET: