From patchwork Thu Aug 11 12:42:04 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: 152 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp45184vsd; Thu, 11 Aug 2016 05:42:30 -0700 (PDT) X-Received: by 10.28.148.21 with SMTP id w21mr9580376wmd.50.1470919350437; Thu, 11 Aug 2016 05:42:30 -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 hq7si2284072wjb.234.2016.08.11.05.42.24; Thu, 11 Aug 2016 05:42:30 -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 DEF1268A659; Thu, 11 Aug 2016 15:42:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 372BE68A652 for ; Thu, 11 Aug 2016 15:42:14 +0300 (EEST) Received: by mail-wm0-f67.google.com with SMTP id q128so1168812wma.1 for ; Thu, 11 Aug 2016 05:42:14 -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=axFj7KnxlA8XMeEniHHeHyQIDmfvnTgJWDPjhszcwJQ=; b=wM5cyn2SuigskKYZ66inDQ27WKPmvfBGI/cttthIU7Ra9UXicxcOb9u1M8EO1026+g uMroEV64SDpqLQEjumuHycY74l+ZGTnk4HpyW1VOgHvhxX1FAHchUjWD5DH14GVoMfxz RLbMx5k9rCLZCuk47s6p0nmBRaTujKqURWVVLFMcnos5NQwYugEMv1Cu8LvR50W+a/ZK jUw7HHhC6mql/fMdXar//tXgtOK01b9hVLpBvnXftZKkf0ezPEf6zlbDO7Uk6hrGJm5B fOozTrO4axIBlUORxY+kYCTbj6YJBMsiZexsod5pIwWoZvf3TRAixy4qeijMtiZFpwgI i6/w== 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=axFj7KnxlA8XMeEniHHeHyQIDmfvnTgJWDPjhszcwJQ=; b=lCJ4cvFuOxtBc4FGLjS08rFLnLpadGSIBfd3B4LlMD676+aBxzDqMs+HMYIE8KSWO0 NrKZODESDKHhYtiqEPQH6l0fv2YJjiaGGzQUJcwLbt8bdPoJTjJIU8n8Nt1P02sVAJbo gcd7sAw5tsxrVgJeApaTXM2sTuwBuJ+Pu9mELW0SUZQc5QsGA4VGFFM6vKnXnh0y6OM9 RAs/lVH9hxhDPO4ij6t1et1dYdI+fl6GOG2NQi3qk7/gvoY+5BcW9S87mAmwFUMWwL24 b0xx8VEq21zNKCJZ3iIogZFPhjcYEKb03nUHHs+uMfqiIrXkO+igCvcIESuvi+tNYFys 5cyA== X-Gm-Message-State: AEkoous/rLyhxk1+miPDmEg8WgmpaffXKk72BAL9kKUaoX50ZjYCl0YgIZOLCte/nRUX1w== X-Received: by 10.28.113.135 with SMTP id d7mr8574825wmi.43.1470919334152; Thu, 11 Aug 2016 05:42:14 -0700 (PDT) Received: from localhost.localdomain (157.174.broadband3.iol.cz. [85.70.174.157]) by smtp.gmail.com with ESMTPSA id d80sm13299206wmd.14.2016.08.11.05.42.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 05:42:13 -0700 (PDT) From: sebechlebskyjan@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Aug 2016 14:42:04 +0200 Message-Id: <1470919324-3702-1-git-send-email-sebechlebskyjan@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20160810170430.GC5460@nb4> References: <20160810170430.GC5460@nb4> Subject: [FFmpeg-devel] [PATCH v3 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 --- No changes since the last version of the patch, just rebased because of the changes in previous patches. libavformat/avformat.h | 15 +++++++++++++++ libavformat/mux.c | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 2cc3156..83903b5 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 45f1401..0f002a3 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1270,6 +1270,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) {