[MPlayer-dev-eng] [PATCH] stream: add fallback to ffmpeg for unknown streams

Vincenzo Nicosia katolaz at freaknet.org
Wed Jan 15 02:25:56 EET 2020


On Tue, Jan 14, 2020 at 02:20:56PM +0100, Vincenzo Nicosia wrote:
> Dear devs,
> 
> please find attached a preliminary attempt to let open_stream_full
> fallback to ffmpeg if the url does not belong to any known scheme.
> This allows to open stuff like:
> 
>   mplayer gopher://bitreich.org/9/memecache/firewall.webm
> 

Dear mplayer devs,

please find below a shorter and more elegant patch, which avoids a
goto and allocates the fname string only if needed. Thanks to Quentin
Rameau for comments on the previous one.

HND

Index: stream/stream.c
===================================================================
--- stream/stream.c	(revision 38159)
+++ stream/stream.c	(working copy)
@@ -38,6 +38,7 @@
 #endif
 
 #include "mp_msg.h"
+#include "mp_strings.h"
 #include "help_mp.h"
 #include "osdep/shmem.h"
 #include "osdep/timer.h"
@@ -218,7 +219,7 @@
 }
 
 
-stream_t* open_stream_full(const char* filename,int mode, char** options, int* file_format) {
+stream_t* open_stream_full_attempt(const char* filename,int mode, char** options, int* file_format) {
   int i,j;
 
   for(i = 0 ; auto_open_streams[i] ; i++) {
@@ -256,6 +257,22 @@
   return NULL;
 }
 
+stream_t* open_stream_full(const char* filename,int mode, char** options, int* file_format) {
+
+  char *fname;
+  stream_t *res=open_stream_full_attempt(filename, mode, options, file_format);
+#ifdef CONFIG_FFMPEG
+  if (res == NULL){
+  /* If everything else failed, and ffmpeg is enabled, then make a last try via ffmpeg */
+    fname=mp_asprintf("ffmpeg://%s",filename);
+    mp_msg(MSGT_OPEN,MSGL_WARN, "No stream plugin matched. Trying via ffmpeg now\n");
+    res=open_stream_full_attempt(fname, mode, options, file_format);
+    free(fname);
+#endif
+  }  
+  return res;
+}
+
 stream_t* open_output_stream(const char* filename, char** options) {
   int file_format; //unused
   if(!filename) {


More information about the MPlayer-dev-eng mailing list