Mercurial > libavformat.hg
comparison file.c @ 2395:1e827f59ddae libavformat
Allow pipe: URL to take fd number as input
Patch by Vincent Fourmond [vincent dot fourmond at 9online dot fr]
author | ramiro |
---|---|
date | Fri, 17 Aug 2007 15:14:29 +0000 |
parents | be66ba5bc96d |
children | ea55b48f3fbd |
comparison
equal
deleted
inserted
replaced
2394:be66ba5bc96d | 2395:1e827f59ddae |
---|---|
21 #include "avformat.h" | 21 #include "avformat.h" |
22 #include "avstring.h" | 22 #include "avstring.h" |
23 #include <fcntl.h> | 23 #include <fcntl.h> |
24 #include <unistd.h> | 24 #include <unistd.h> |
25 #include <sys/time.h> | 25 #include <sys/time.h> |
26 #include <stdlib.h> | |
26 | 27 |
27 | 28 |
28 /* standard file protocol */ | 29 /* standard file protocol */ |
29 | 30 |
30 static int file_open(URLContext *h, const char *filename, int flags) | 31 static int file_open(URLContext *h, const char *filename, int flags) |
88 /* pipe protocol */ | 89 /* pipe protocol */ |
89 | 90 |
90 static int pipe_open(URLContext *h, const char *filename, int flags) | 91 static int pipe_open(URLContext *h, const char *filename, int flags) |
91 { | 92 { |
92 int fd; | 93 int fd; |
94 const char * final; | |
95 av_strstart(filename, "pipe:", &filename); | |
93 | 96 |
97 fd = strtol(filename, &final, 10); | |
98 if((filename == final) || *final ) {/* No digits found, or something like 10ab */ | |
94 if (flags & URL_WRONLY) { | 99 if (flags & URL_WRONLY) { |
95 fd = 1; | 100 fd = 1; |
96 } else { | 101 } else { |
97 fd = 0; | 102 fd = 0; |
98 } | 103 } |
104 } | |
99 #ifdef O_BINARY | 105 #ifdef O_BINARY |
100 setmode(fd, O_BINARY); | 106 setmode(fd, O_BINARY); |
101 #endif | 107 #endif |
102 h->priv_data = (void *)(size_t)fd; | 108 h->priv_data = (void *)(size_t)fd; |
103 h->is_streamed = 1; | 109 h->is_streamed = 1; |