* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+#include "libavutil/avstring.h"
#include "avformat.h"
-#include "avstring.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
+#include <stdlib.h>
+#include "os_support.h"
/* standard file protocol */
static int pipe_open(URLContext *h, const char *filename, int flags)
{
int fd;
+ char *final;
+ av_strstart(filename, "pipe:", &filename);
- if (flags & URL_WRONLY) {
- fd = 1;
- } else {
- fd = 0;
+ fd = strtol(filename, &final, 10);
+ if((filename == final) || *final ) {/* No digits found, or something like 10ab */
+ if (flags & URL_WRONLY) {
+ fd = 1;
+ } else {
+ fd = 0;
+ }
}
#ifdef O_BINARY
setmode(fd, O_BINARY);
return 0;
}
-static int pipe_read(URLContext *h, unsigned char *buf, int size)
-{
- int fd = (size_t)h->priv_data;
- return read(fd, buf, size);
-}
-
URLProtocol pipe_protocol = {
"pipe",
pipe_open,
file_read,
file_write,
- NULL,
- pipe_close,
};