avformat/file: add fd option for pipe
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
@@ -687,7 +687,7 @@ The accepted syntax is:
|
|||||||
pipe:[@var{number}]
|
pipe:[@var{number}]
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@var{number} is the number corresponding to the file descriptor of the
|
If @option{fd} isn't specified, @var{number} is the number corresponding to the file descriptor of the
|
||||||
pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If @var{number}
|
pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If @var{number}
|
||||||
is not specified, by default the stdout file descriptor will be used
|
is not specified, by default the stdout file descriptor will be used
|
||||||
for writing, stdin for reading.
|
for writing, stdin for reading.
|
||||||
@@ -714,6 +714,8 @@ Set I/O operation maximum block size, in bytes. Default value is
|
|||||||
@code{INT_MAX}, which results in not limiting the requested block size.
|
@code{INT_MAX}, which results in not limiting the requested block size.
|
||||||
Setting this value reasonably low improves user termination request reaction
|
Setting this value reasonably low improves user termination request reaction
|
||||||
time, which is valuable if data transmission is slow.
|
time, which is valuable if data transmission is slow.
|
||||||
|
@item fd
|
||||||
|
Set file descriptor.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
Note that some formats (typically MOV), require the output protocol to
|
Note that some formats (typically MOV), require the output protocol to
|
||||||
|
@@ -92,6 +92,7 @@ static const AVOption file_options[] = {
|
|||||||
|
|
||||||
static const AVOption pipe_options[] = {
|
static const AVOption pipe_options[] = {
|
||||||
{ "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
|
{ "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
|
||||||
|
{ "fd", "set file descriptor", offsetof(FileContext, fd), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -381,6 +382,8 @@ static int pipe_open(URLContext *h, const char *filename, int flags)
|
|||||||
FileContext *c = h->priv_data;
|
FileContext *c = h->priv_data;
|
||||||
int fd;
|
int fd;
|
||||||
char *final;
|
char *final;
|
||||||
|
|
||||||
|
if (c->fd < 0) {
|
||||||
av_strstart(filename, "pipe:", &filename);
|
av_strstart(filename, "pipe:", &filename);
|
||||||
|
|
||||||
fd = strtol(filename, &final, 10);
|
fd = strtol(filename, &final, 10);
|
||||||
@@ -391,10 +394,12 @@ static int pipe_open(URLContext *h, const char *filename, int flags)
|
|||||||
fd = 0;
|
fd = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if HAVE_SETMODE
|
|
||||||
setmode(fd, O_BINARY);
|
|
||||||
#endif
|
|
||||||
c->fd = fd;
|
c->fd = fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if HAVE_SETMODE
|
||||||
|
setmode(c->fd, O_BINARY);
|
||||||
|
#endif
|
||||||
h->is_streamed = 1;
|
h->is_streamed = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
#include "version_major.h"
|
#include "version_major.h"
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_MINOR 34
|
#define LIBAVFORMAT_VERSION_MINOR 34
|
||||||
#define LIBAVFORMAT_VERSION_MICRO 102
|
#define LIBAVFORMAT_VERSION_MICRO 103
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||||
LIBAVFORMAT_VERSION_MINOR, \
|
LIBAVFORMAT_VERSION_MINOR, \
|
||||||
|
Reference in New Issue
Block a user