mirror of https://github.com/mpv-player/mpv
stream_file: add fd:// protocol
This commit is contained in:
parent
23220db924
commit
d23d9dc394
|
@ -614,6 +614,11 @@ PROTOCOLS
|
|||
``PATH`` itself should start with a third ``/`` to make the path an
|
||||
absolute path.
|
||||
|
||||
``fd://123``
|
||||
Read data from the given UNIX FD (for example 123). This is similar to
|
||||
piping data to stdin via ``-``, but can use an arbitrary file descriptor.
|
||||
Will not work correctly on MS Windows.
|
||||
|
||||
``edl://[edl specification as in edl-mpv.rst]``
|
||||
Stitch together parts of multiple files and play them.
|
||||
|
||||
|
|
|
@ -247,7 +247,15 @@ static int open_f(stream_t *stream)
|
|||
filename = stream->path;
|
||||
}
|
||||
|
||||
if (!strcmp(filename, "-")) {
|
||||
if (strncmp(stream->url, "fd://", 5) == 0) {
|
||||
char *end = NULL;
|
||||
priv->fd = strtol(stream->url + 5, &end, 0);
|
||||
if (!end || end == stream->url + 5 || end[0]) {
|
||||
MP_ERR(stream, "Invalid FD: %s\n", stream->url);
|
||||
return STREAM_ERROR;
|
||||
}
|
||||
priv->close = false;
|
||||
} else if (!strcmp(filename, "-")) {
|
||||
if (!write) {
|
||||
MP_INFO(stream, "Reading from stdin...\n");
|
||||
fd = 0;
|
||||
|
@ -316,7 +324,7 @@ static int open_f(stream_t *stream)
|
|||
const stream_info_t stream_info_file = {
|
||||
.name = "file",
|
||||
.open = open_f,
|
||||
.protocols = (const char*const[]){ "file", "", NULL },
|
||||
.protocols = (const char*const[]){ "file", "", "fd", NULL },
|
||||
.can_write = true,
|
||||
.is_safe = true,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue