From patchwork Wed Dec 14 17:10:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 39704 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp496431pzb; Wed, 14 Dec 2022 09:11:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf6AHkESwfIg3nVqhl95/P6N1SCIcn8p5ZwxwlW184KXiLAV9COp9Oo3bWAaPoD+Ihb6KnAF X-Received: by 2002:a17:907:cbc8:b0:7c1:6e08:4c20 with SMTP id vk8-20020a170907cbc800b007c16e084c20mr13535194ejc.7.1671037872256; Wed, 14 Dec 2022 09:11:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671037872; cv=none; d=google.com; s=arc-20160816; b=YdyHR1HuwpWRv3Z157xKnZpv0Fbqz1FtoHlk/fi7hQA9yDJHvmlCkhxbkPp5eumS5L 6S8tM01KefUIl73afnH6SOWHtmswf5y38TTPeFSQQfcF8lDXa63kYoiVNxatkPmYyG5L 3O4Gm2AHqFfa62RdwxPSz/nGrRXo98YqLpe15YGWFTnw91jd4KOGauTKo1Vpwq4HZItb l4GxF2tEmdsHbCe/RcmZP3qHyWo2cqpRpiVziN41KfIm7iMxhJP2CsksymJDwA6hZ/cs 8t7OdWqsTCMIDvbNJptOJYuAmtsxnZFq0RCEBLBHRTJn3GH/WOzU0+uIWeuS5Z4nDBMV 53uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=Q18+n5ME1zZNB2m+Tgp5wieBbtf+un94eJl1erwrdEI=; b=EiHZgWgyMcnTxEwaQYh4/VA3rhLhqn4wY6xrC8BNb4osjg1Btr529N7jkdi7ZXfRSS eVdtaniqJ0TKX7rnZwepxzz8ZHoZ7OD0hljVs+qKKYObWtSLNWL6bonh7r13vlSjZgk4 3xNAk0NOp+bnIYAQxk1VjaBqgb0yulck5eqnxdC0snhSekcTI+tf3MzLdKtb1bKL0Mnv 0u4LSadIL2If+H3wHuzq+JWQG8sm2CowRjnrPsyN8mVgJwPNng4t+7j1Pnhn3qzKWIOV ouu1EkVPNUn+I0o+kByEvTjL2aINXoHbRQpIaiJDcm5e8PQUg+MMmjcbcbNTQlzQCgMW rp1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=u4oihdLa; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m9-20020a170906848900b007bf9de4fe93si8750673ejx.154.2022.12.14.09.11.11; Wed, 14 Dec 2022 09:11:12 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=u4oihdLa; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D795B68BC88; Wed, 14 Dec 2022 19:10:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-58-211.mail.qq.com (out162-62-58-211.mail.qq.com [162.62.58.211]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 508CB68B635 for ; Wed, 14 Dec 2022 19:10:43 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1671037839; bh=rex6kISFF9T83kTNO5+lnUrc0elkOB4KUMr2VJpYk3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=u4oihdLaklcKT1RlpfVeUK9zPnQRvPqgCzw9CEcsjs9IvF8KT5pB9FOVGMWU/vVCG PY9rVrfOP3PbC9DuZpUBpdoVJH4JVCqwdfQPIabvhFLqROemGdSgjakAp6kJTvu3D7 r7sC/6+W8p+vDa/4c7TJzguIPUa+BAxD05H9aLwA= Received: from localhost.localdomain ([113.116.29.217]) by newxmesmtplogicsvrsza12-0.qq.com (NewEsmtp) with SMTP id 2A515E8A; Thu, 15 Dec 2022 01:10:37 +0800 X-QQ-mid: xmsmtpt1671037838tvaxg0dkx Message-ID: X-QQ-XMAILINFO: Mg/0DM1Zd+nH8P/0guWe+XSm5hwmwpMrBiuPheFIhhoLp+33b2/+Zr0FC7yVw1 wE9wY/0F2imu4WMMGBcWNLNmJaNpG4YQ346U52FloQ885oLqBSqD8Bgv/QU+ovrUIRDnQu8aTS2Y Oa+urxxMuHYpJrzxHFnOtCMYz7UZjswOduoHQt6g/S1ia2zQeeXdQGjtV1dBXfksx8SWH135cypD U99M3Zmz88VuEvUHDVA5WqBcDLenG5VAT3xcU3klZWbLmDzdSOASIon16Rl8fwkUxYabbPoZl+ox HRqzbsD9utrcUu4ck2lWIKrimr221C3rZppMWe2aPWH5ZHZodTE6b3+VCGKcBzm5oZio/ksdwUTG K6v3mfOjrlKk8egVvDAQ2ZjW4k5eE610pgYuwcz5X8hl/WtkPJdqIL/u/vQpUZo5kxajHgHimCME +XHzqslC0lulx1R5mbRYma2pEkjlvFwO3pToWWOb4uTcpyippnzaVIdMzIbuKuGomgzGqoajXwa7 KjnLJajCeksG/02vFWn60EhF9CimT4HKJ5tJ5M2N0sTu0QmU022FH25LUVkkHKkQg8IYQ1xuxlxj VUs2nN1w2V6H5fax1Z0bu/NXzsZt6vQUknAKr5dr3dLzk96IQz77gzijs3sfn3jU1RKM48z9NiIe 0SNLVSjW0LN4ZKP6BwA426cWQXxRCCuOvaZJG/3gJ/SAvMj1zZqaKgVbyBR60pA2gEVFIvRljs0j mr3gId3vZtI8/7iRaEjMH60Ct1bgAdkQX9NxJv4tKIRVLxI7hC/Yi8AypGuJVHGtwC0yu7E3xZO8 +hrTPJkOKGNPm5kURPNAuHQ50vRFuSLVxGipKa9nh3RyPy3OiAAkX9hmw9cU5IGQ4sbGszoMpTrO rYkmgJx/p/Sv4NJSpFqZmeLt2UlX6gcvl4YnfFeSXSHXzWCWbx6/alJ5Pg8kVXobJlV9YKc9LA8V WUrzj6i8M1TRtUdhtmStev01+sIRW9 From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Thu, 15 Dec 2022 01:10:07 +0800 X-OQ-MSGID: <20221214171014.1058709-2-quinkblack@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221214171014.1058709-1-quinkblack@foxmail.com> References: <20221214171014.1058709-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/8] avformat/file: add fd option for pipe X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CnElaH5537mN From: Zhao Zhili --- 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_MINOR, \