[PATCH] stream: add fallback to ffmpeg for unknown streams
Vincenzo Nicosia <[email protected]>
| Newsgroups | gmane.comp.video.mplayer.devel |
|---|---|
| Message-ID | <[email protected]> |
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
but instead of working just for gopher, it works for any scheme
supported by ffmpeg (and not supported by any of the stream plugins
enabled in mplayer).
Comments are welcome. If the patch looks good to you, I will also add
a patch to the manpage, so that the behaviour is appropriately
documented.
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"
@@ -220,31 +221,41 @@
stream_t* open_stream_full(const char* filename,int mode, char** options, int* file_format) {
int i,j;
+ char first=1;
+ char *fname;
+ fname=mp_asprintf("%s", filename);
+
+retry:
for(i = 0 ; auto_open_streams[i] ; i++) {
const stream_info_t *sinfo = auto_open_streams[i];
for(j = 0 ; sinfo->protocols[j] ; j++) {
int l = strlen(sinfo->protocols[j]);
// l == 0 => Don't do protocol matching (ie network and filenames)
- if((l == 0 && !strstr(filename, "://")) ||
- ((strncasecmp(sinfo->protocols[j],filename,l) == 0) &&
- (strncmp("://",filename+l,3) == 0))) {
+ if((l == 0 && !strstr(fname, "://")) ||
+ ((strncasecmp(sinfo->protocols[j],fname,l) == 0) &&
+ (strncmp("://",fname+l,3) == 0))) {
int r;
char *redirected_url = NULL;
stream_t* s;
*file_format = DEMUXER_TYPE_UNKNOWN;
- s = open_stream_plugin(sinfo,filename,mode,options,file_format,&r,
+ s = open_stream_plugin(sinfo,fname,mode,options,file_format,&r,
&redirected_url);
- if(s) return s;
+ if(s) {
+ free(fname);
+ return s;
+ }
if(r == STREAM_REDIRECTED && redirected_url) {
mp_msg(MSGT_OPEN,MSGL_V, "[%s] open %s redirected to %s\n",
- sinfo->info, filename, redirected_url);
+ sinfo->info, fname, redirected_url);
s = open_stream_full(redirected_url, mode, options, file_format);
free(redirected_url);
+ free(fname);
return s;
}
else if(r != STREAM_UNSUPPORTED) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_FailedToOpen,filename);
+ mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_FailedToOpen,fname);
+ free(fname);
return NULL;
}
break;
@@ -251,7 +262,17 @@
}
}
}
-
+#ifdef CONFIG_FFMPEG
+ /* If everything else failed, make a last try via ffmpeg */
+ if (first){
+ first=0;
+ free(fname);
+ fname=mp_asprintf("ffmpeg://%s",filename);
+ mp_msg(MSGT_OPEN,MSGL_WARN, "No stream plugin matched. Trying via ffmpeg now\n");
+ goto retry;
+ }
+#endif
+ free(fname);
mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_StreamCantHandleURL,filename);
return NULL;
}
_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
signature.asc
(application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSOWdaqRF79tKFTPVpfILOuC18GLwUCXh3AMgAKCRBfILOuC18G L44BAJ0Z/Wpn6d0jZApZ8vOhcRql2KXFHQCfY3DOJJXgkthLVjJs59sHP9FuKXs= =UDfD -----END PGP SIGNATURE-----