[MPlayer-dev-eng] [PATCH] support for playing from named pipes (fifo)

Martin Josefsson gandalf at wlug.westbo.se
Fri Nov 9 22:17:06 CET 2001


Hi,

I found myself having the need for playing from a named pipe and found out
that it didn't work so I added support for it.

I don't know if it's OS independant, it works fine on Linux.

/Martin

Never argue with an idiot. They drag you down to their level, then beat you with experience.
-------------- next part --------------
--- test/main/libmpdemux/open.c	Sat Oct 20 22:35:12 2001
+++ main/libmpdemux/open.c	Fri Nov  9 21:58:37 2001
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <sys/stat.h>
 
 #include "config.h"
 #include "mp_msg.h"
@@ -83,6 +84,8 @@
 int bsize = VCD_SECTOR_SIZE;
 #endif
 
+struct stat statbuf;
+
 //============ Open VideoCD track ==============
 if(vcd_track){
   int ret,ret2;
@@ -273,17 +276,22 @@
 //============ Open plain FILE ============
        f=open(filename,O_RDONLY);
        if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; }
-       len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
-       if (len == -1)
-	 perror("Error: lseek failed to obtain video file size");
-       else
+       fstat(f, &statbuf);
+       if ( statbuf.st_mode & S_IFIFO )
+	       stream=new_stream(f,STREAMTYPE_STREAM);
+       else {
+	       len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
+	       if (len == -1)
+			 perror("Error: lseek failed to obtain video file size");
+	       else
 #ifdef _LARGEFILE_SOURCE
-	 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len);
+			 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len);
 #else
-	 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len);
+			 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len);
 #endif
-       stream=new_stream(f,STREAMTYPE_FILE);
-       stream->end_pos=len;
+	       stream=new_stream(f,STREAMTYPE_FILE);
+	       stream->end_pos=len;
+       }
        return stream;
 
 }


More information about the MPlayer-dev-eng mailing list