changeset 30456:0eee9d2e7a1d

Add support for FFmpeg's rtsp dummy URL-with-pseudo-demuxer scheme. ffmpeg://rtsp://... will play a rtsp stream via FFmpeg.
author reimar
date Wed, 03 Feb 2010 22:32:48 +0000
parents cfebff6a5ef9
children 04bdf393175b
files libmpdemux/demux_lavf.c stream/stream_ffmpeg.c
diffstat 2 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_lavf.c	Wed Feb 03 21:12:23 2010 +0000
+++ b/libmpdemux/demux_lavf.c	Wed Feb 03 22:32:48 2010 +0000
@@ -155,13 +155,15 @@
     }
 
     probe_data_size = stream_read(demuxer->stream, priv->buffer, PROBE_BUF_SIZE);
-    if(probe_data_size <= 0)
+    if(probe_data_size < 0)
         return 0;
     avpd.filename= demuxer->stream->url;
+    if (!strncmp(avpd.filename, "ffmpeg://", 9))
+        avpd.filename += 9;
     avpd.buf= priv->buffer;
     avpd.buf_size= probe_data_size;
 
-    priv->avif= av_probe_input_format(&avpd, 1);
+    priv->avif= av_probe_input_format(&avpd, probe_data_size > 0);
     if(!priv->avif){
         mp_msg(MSGT_HEADER,MSGL_V,"LAVF_check: no clue about this gibberish!\n");
         return 0;
@@ -458,9 +460,12 @@
         }
     }
 
-    if(demuxer->stream->url)
+    if(demuxer->stream->url) {
+        if (!strncmp(demuxer->stream->url, "ffmpeg://rtsp:", 14))
+            strncpy(mp_filename, demuxer->stream->url + 9, sizeof(mp_filename)-3);
+        else
         strncpy(mp_filename + 3, demuxer->stream->url, sizeof(mp_filename)-3);
-    else
+    } else
         strncpy(mp_filename + 3, "foobar.dummy", sizeof(mp_filename)-3);
 
     priv->pb = av_alloc_put_byte(priv->buffer, BIO_BUFFER_SIZE, 0,
--- a/stream/stream_ffmpeg.c	Wed Feb 03 21:12:23 2010 +0000
+++ b/stream/stream_ffmpeg.c	Wed Feb 03 22:32:48 2010 +0000
@@ -75,6 +75,7 @@
     URLContext *ctx = NULL;
     int res = STREAM_ERROR;
     int64_t size;
+    int dummy;
 
     av_register_all();
     if (mode == STREAM_READ)
@@ -95,25 +96,28 @@
     }
     if (!strncmp(filename, prefix, strlen(prefix)))
         filename += strlen(prefix);
+    dummy = !strncmp(filename, "rtsp:", 5);
     mp_msg(MSGT_OPEN, MSGL_V, "[ffmpeg] Opening %s\n", filename);
 
-    if (url_open(&ctx, filename, flags) < 0)
+    if (!dummy && url_open(&ctx, filename, flags) < 0)
         goto out;
 
     stream->priv = ctx;
-    size = url_filesize(ctx);
+    size = dummy ? 0 : url_filesize(ctx);
     if (size >= 0)
         stream->end_pos = size;
     stream->type = STREAMTYPE_FILE;
     stream->seek = seek;
-    if (ctx->is_streamed) {
+    if (dummy || ctx->is_streamed) {
         stream->type = STREAMTYPE_STREAM;
         stream->seek = NULL;
     }
+    if (!dummy) {
     stream->fill_buffer = fill_buffer;
     stream->write_buffer = write_buffer;
     stream->control = control;
     stream->close = close_f;
+    }
     res = STREAM_OK;
 
 out: