Message ID | tencent_CF81A835233EDB56BF9CF0E1CA5B74345909@qq.com |
---|---|
State | Accepted |
Commit | 49b8f043ca3e39141929d8614876131be0a801a9 |
Headers | show |
Series | [FFmpeg-devel,v3,1/8] avformat/file: add fd option for pipe | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
On Thu, 2022-12-15 at 01:10 +0800, Zhao Zhili wrote: > From: Zhao Zhili <zhilizhao@tencent.com> > > --- > doc/protocols.texi | 4 +++- > libavformat/file.c | 9 +++++++-- > libavformat/version.h | 2 +- > 3 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/doc/protocols.texi b/doc/protocols.texi > index d1c6fced7b..a686a7f0ac 100644 > --- a/doc/protocols.texi > +++ b/doc/protocols.texi > @@ -687,7 +687,7 @@ The accepted syntax is: > pipe:[@var{number}] > @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} > is not specified, by default the stdout file descriptor will be used > 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. > Setting this value reasonably low improves user termination request > reaction > time, which is valuable if data transmission is slow. > +@item fd > +Set file descriptor. > @end table > > Note that some formats (typically MOV), require the output protocol > to > diff --git a/libavformat/file.c b/libavformat/file.c > index 6103c37b34..db619fcaac 100644 > --- a/libavformat/file.c > +++ b/libavformat/file.c > @@ -92,6 +92,7 @@ static const AVOption file_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 }, > + { "fd", "set file descriptor", offsetof(FileContext, fd), > AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, > AV_OPT_FLAG_ENCODING_PARAM }, > { NULL } > }; > > @@ -381,6 +382,8 @@ static int pipe_open(URLContext *h, const char > *filename, int flags) > FileContext *c = h->priv_data; > int fd; > char *final; > + > + if (c->fd < 0) { > av_strstart(filename, "pipe:", &filename); > > fd = strtol(filename, &final, 10); > @@ -391,10 +394,12 @@ static int pipe_open(URLContext *h, const char > *filename, int flags) > fd = 0; > } > } > + c->fd = fd; > + } > + > #if HAVE_SETMODE > - setmode(fd, O_BINARY); > + setmode(c->fd, O_BINARY); > #endif > - c->fd = fd; > h->is_streamed = 1; > return 0; > } > diff --git a/libavformat/version.h b/libavformat/version.h > index a7e5a9ac66..63e753a3aa 100644 > --- a/libavformat/version.h > +++ b/libavformat/version.h > @@ -32,7 +32,7 @@ > #include "version_major.h" > > #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, \ > LIBAVFORMAT_VERSION_M > INOR, \ Ping for the patchset.
diff --git a/doc/protocols.texi b/doc/protocols.texi index d1c6fced7b..a686a7f0ac 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -687,7 +687,7 @@ The accepted syntax is: pipe:[@var{number}] @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} is not specified, by default the stdout file descriptor will be used 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. Setting this value reasonably low improves user termination request reaction time, which is valuable if data transmission is slow. +@item fd +Set file descriptor. @end table Note that some formats (typically MOV), require the output protocol to diff --git a/libavformat/file.c b/libavformat/file.c index 6103c37b34..db619fcaac 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -92,6 +92,7 @@ static const AVOption file_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 }, + { "fd", "set file descriptor", offsetof(FileContext, fd), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; @@ -381,6 +382,8 @@ static int pipe_open(URLContext *h, const char *filename, int flags) FileContext *c = h->priv_data; int fd; char *final; + + if (c->fd < 0) { av_strstart(filename, "pipe:", &filename); fd = strtol(filename, &final, 10); @@ -391,10 +394,12 @@ static int pipe_open(URLContext *h, const char *filename, int flags) fd = 0; } } + c->fd = fd; + } + #if HAVE_SETMODE - setmode(fd, O_BINARY); + setmode(c->fd, O_BINARY); #endif - c->fd = fd; h->is_streamed = 1; return 0; } diff --git a/libavformat/version.h b/libavformat/version.h index a7e5a9ac66..63e753a3aa 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ #include "version_major.h" #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, \ LIBAVFORMAT_VERSION_MINOR, \
From: Zhao Zhili <zhilizhao@tencent.com> --- doc/protocols.texi | 4 +++- libavformat/file.c | 9 +++++++-- libavformat/version.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)