From d23d9dc39421226622dbeb3c6c62c54ad1c3a667 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 9 Jul 2015 15:51:31 +0200 Subject: stream_file: add fd:// protocol --- stream/stream_file.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'stream/stream_file.c') 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, }; -- cgit v1.2.3