changeset 34544:36ef1a75aa48

Some hacks to allow stream_ffmpeg to compile against newer FFmpeg. Keep the old code so that it is still possible to compile against older FFmpeg without using internal API.
author reimar
date Sat, 28 Jan 2012 13:47:01 +0000
parents 21caebba991b
children d1f195e84b9e
files stream/stream_ffmpeg.c
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_ffmpeg.c	Sat Jan 28 13:22:57 2012 +0000
+++ b/stream/stream_ffmpeg.c	Sat Jan 28 13:47:01 2012 +0000
@@ -26,6 +26,16 @@
 #include "m_struct.h"
 #include "av_helpers.h"
 
+#ifndef URL_RDONLY
+#include "libavformat/url.h"
+#define url_read_complete ffurl_read_complete
+#define url_write ffurl_write
+#define url_seek ffurl_seek
+#define url_filesize ffurl_size
+#define url_close ffurl_close
+#define url_open(c, n, f) ffurl_open(c, n, f, NULL, NULL)
+#endif
+
 static int fill_buffer(stream_t *s, char *buffer, int max_len)
 {
     int r = url_read_complete(s->priv, buffer, max_len);
@@ -51,6 +61,7 @@
 
 static int control(stream_t *s, int cmd, void *arg)
 {
+    URLContext *ctx = s->priv;
     int64_t size, ts;
     double pts;
     switch(cmd) {
@@ -64,7 +75,13 @@
     case STREAM_CTRL_SEEK_TO_TIME:
         pts = *(double *)arg;
         ts = pts * AV_TIME_BASE;
+#ifdef URL_RDONLY
         ts = av_url_read_seek(s->priv, -1, ts, 0);
+#else
+        if (!ctx->prot->url_read_seek)
+            break;
+        ts = ctx->prot->url_read_seek(s->priv, -1, ts, 0);
+#endif
         if (ts >= 0)
             return 1;
         break;
@@ -90,9 +107,9 @@
 
     init_avformat();
     if (mode == STREAM_READ)
-        flags = URL_RDONLY;
+        flags = AVIO_FLAG_READ;
     else if (mode == STREAM_WRITE)
-        flags = URL_WRONLY;
+        flags = AVIO_FLAG_WRITE;
     else {
         mp_msg(MSGT_OPEN, MSGL_ERR, "[ffmpeg] Unknown open mode %d\n", mode);
         res = STREAM_UNSUPPORTED;