From patchwork Thu Aug 4 12:54:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sebechlebskyjan@gmail.com X-Patchwork-Id: 89 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp1184801vsd; Thu, 4 Aug 2016 05:55:49 -0700 (PDT) X-Received: by 10.28.234.16 with SMTP id i16mr30310475wmh.76.1470315349836; Thu, 04 Aug 2016 05:55:49 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p71si3886847wmb.47.2016.08.04.05.55.48; Thu, 04 Aug 2016 05:55:49 -0700 (PDT) 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=@gmail.com; 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 dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5AC568A494; Thu, 4 Aug 2016 15:55:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E82AA68A481 for ; Thu, 4 Aug 2016 15:55:19 +0300 (EEST) Received: by mail-wm0-f66.google.com with SMTP id o80so44045211wme.0 for ; Thu, 04 Aug 2016 05:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aoc1AY6TAWnnj6DpjzX2vd1k9F8O0cBK4Fk3amv4zoQ=; b=GlpsUsldsU4c0XbTxa08EUIZO3CVZvwaHWUMwbfisJjzhtLMDYpy1dRo8N5qY+nl2C vaxakorJAHPp4nkZaUxfZ7PQkkJi9tgTJEAobMtf3Lxg2VCENqxVl9ul7W/SOlNBvQ3o cPWFdtjLCpx97Clb3vDp114O4Y6oYVsHVpCLT/gTFkP2Ffu/COCIZbZ1oNzTQQnnPUqP Hk/84uoiOudVNJkeI2EDz3Ht1YGu4qf+n4Ri9Mjz/zjvVwix0EzqGrmo0i1qW7NcLiin 0rRdVttr/Zv+oiqk2u/h2kPQRXz7Yo62jwiDr2CIDEH7lxqKIc+/H/iHnYlo4kj946jt vwQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aoc1AY6TAWnnj6DpjzX2vd1k9F8O0cBK4Fk3amv4zoQ=; b=chPG6xr+GnI/EyqbWRejbbHbBbV4FMScrUm5I+1zMSQWxVmTbH1Wgx6QbxCINLQDTn n1mvAmeEsaWMRhwtOESOPhQQb5TKVO+JqmXSCs5yvDspZpqCVNZzHxNZPx6g9TpVX7ga R6r5sFjRWWvddA2MUBdi/liemgKav5OZWPa/rkre0QhDuPqdTxivoWvx8YsPvDRrm5i8 a55qKqoVHNHqG3tg2wyablW8AbTDQzBHEkZagobqzTF6H4Yq8CKHkr+Oi7oPkvsJLPyI IMbJ6Om0Q2n6KQTqzNCu5aHiC+K9PEgt+A+4cGiw/Cn4rAXU/cdVcMhQeb5HxLE1Ne79 Hr5g== X-Gm-Message-State: AEkoousccQBe7ReGRqfnod1SHtMLdt1ILPfUGYJlSb9h2a0bpkf1be0oFw0VXDlimYBKsA== X-Received: by 10.194.48.39 with SMTP id i7mr73488008wjn.173.1470315326020; Thu, 04 Aug 2016 05:55:26 -0700 (PDT) Received: from localhost.localdomain (157.174.broadband3.iol.cz. [85.70.174.157]) by smtp.gmail.com with ESMTPSA id f4sm3551005wmf.8.2016.08.04.05.55.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 05:55:25 -0700 (PDT) From: sebechlebskyjan@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Aug 2016 14:54:53 +0200 Message-Id: <1470315293-18795-1-git-send-email-sebechlebskyjan@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20160803131552.GA1808810@phare.normalesup.org> References: <20160803131552.GA1808810@phare.normalesup.org> Subject: [FFmpeg-devel] [PATCH v2 06/11] avformat: add avformat_write_abort() function X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Jan Sebechlebsky MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Jan Sebechlebsky Signed-off-by: Jan Sebechlebsky --- Changes from last version of patch: - removed AVFMT_FLAG_NONBLOCK check and modified comment so it states how function behaves with both blocking / non-blocking muxer libavformat/avformat.h | 15 +++++++++++++++ libavformat/mux.c | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 578f99f..3f6a6eb 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2512,6 +2512,8 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index); * * If AVFMT_FLAG_NONBLOCK is set, this call may return AVERROR(EAGAIN) * meaning the operation is pending and the call should be repeated. + * If caller decides to abort operation (after too many calls have returned + * AVERROR(EAGAIN)), it can be done by calling @ref avformat_write_abort(). * * @param s media file handle * @return 0 if OK, AVERROR(EAGAIN) in case call should be repeated, @@ -2520,6 +2522,19 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index); int av_write_trailer(AVFormatContext *s); /** + * Abort muxer operation and free private data. + * For muxer operating in blocking mode, this is equivalent to calling + * av_write_trailer. For muxer operating in non-blocking mode, this will + * call deinitialize routine even if there is operation pending + * and @ref av_write_trailer() keeps returning AVERROR(EAGAIN). + * May only be called after a successful call to avformat_write_header. + * + * @param s Media file handle + * return >= 0 on success, negative AVERROR on error + */ +int avformat_write_abort(AVFormatContext *s); + +/** * Return the output format in the list of registered output formats * which best matches the provided parameters, or return NULL if * there is no match. diff --git a/libavformat/mux.c b/libavformat/mux.c index bc9c98f..a3c1d8a 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1267,6 +1267,19 @@ fail: return ret; } +int avformat_write_abort(AVFormatContext *s) +{ + int ret; + + ret = av_write_trailer(s); + if (ret == AVERROR(EAGAIN)) { + deinit_muxer(s); + ret = 0; + } + + return ret; +} + int av_get_output_timestamp(struct AVFormatContext *s, int stream, int64_t *dts, int64_t *wall) {