lavf: restore old behavior for custom AVIOContex with an AVFMT_NOFILE format.
authorAnton Khirnov <anton@khirnov.net>
Fri, 24 Jun 2011 05:58:16 +0000 (07:58 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sat, 2 Jul 2011 06:41:57 +0000 (08:41 +0200)
av_open_input_stream used to allow this, even though it makes no sense.
Make it just print a warning instead of failing, thus restoring
compatibility.

Note that avformat_open_input() will still reject this combination.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavformat/utils.c

index 92debd54047a07bd6d40401fa34816b24dfd557d..de26a1886eb79d41ea81b629813ae050349d371d 100644 (file)
@@ -459,9 +459,14 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
         err = AVERROR(ENOMEM);
         goto fail;
     }
-    ic->pb = pb;
+    if (pb && fmt && fmt->flags & AVFMT_NOFILE)
+        av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "
+                                   "will be ignored with AVFMT_NOFILE format.\n");
+    else
+        ic->pb = pb;
 
     err = avformat_open_input(&ic, filename, fmt, &opts);
+    ic->pb = ic->pb ? ic->pb : pb; // don't leak custom pb if it wasn't set above
 
     *ic_ptr = ic;
 fail: