summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-07-09 15:51:31 +0200
committerwm4 <wm4@nowhere>2015-07-09 15:51:31 +0200
commitd23d9dc39421226622dbeb3c6c62c54ad1c3a667 (patch)
tree0f1716cd239d5668cab4c3cd046ea012d9b6d0a7
parent23220db92443a5748cb034edf29b4c3b428bee5a (diff)
downloadmpv-d23d9dc39421226622dbeb3c6c62c54ad1c3a667.tar.bz2
mpv-d23d9dc39421226622dbeb3c6c62c54ad1c3a667.tar.xz
stream_file: add fd:// protocol
-rw-r--r--DOCS/man/mpv.rst5
-rw-r--r--stream/stream_file.c12
2 files changed, 15 insertions, 2 deletions
diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst
index 1f48827cee..7fd5d07485 100644
--- a/DOCS/man/mpv.rst
+++ b/DOCS/man/mpv.rst
@@ -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.
diff --git a/stream/stream_file.c b/stream/stream_file.c
index d0da8629bc..bfc50df5de 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -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,
};