From patchwork Tue Aug 2 13:24:17 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: 60 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp217388vsd; Tue, 2 Aug 2016 06:37:28 -0700 (PDT) X-Received: by 10.28.17.138 with SMTP id 132mr60243240wmr.81.1470145048262; Tue, 02 Aug 2016 06:37:28 -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 v11si3223976wmb.146.2016.08.02.06.37.27; Tue, 02 Aug 2016 06:37:28 -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 80623689F6A; Tue, 2 Aug 2016 16:37:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 32265689F59 for ; Tue, 2 Aug 2016 16:37:13 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id q128so30892701wma.1 for ; Tue, 02 Aug 2016 06:37:19 -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=P5eKp1W97TceJccuviHGlV7njM4U1jdaMhjnj6oRL8I=; b=Swwa/snNVjWaKVaKn0xRSTFv3tPlql5whQk9ruLtcpw0k4nJbc1PKQPCgckxGhGN0D ppntV4zJuM3NKoI70mlgZqg20SGZpubedp0X1qAwOIppIGZKbQZa5kSsImIPi0WYR9Fo wqcDCHxcv1fGIKGsds8TTzOWTZa92uy06gE/r0GS/N0OwKQyKa9T/StfdjJgAhLSKwxf D+V+FCHAe+Zylnzdr25V73lZJWdXaVJzLtcRDzlswl8L0kwCn3YC58Uz+ocDnSZ0IAku r+lU12wRqa4M6yMbBzEjdIJfn/VA5zLFiOt1PGS70MBObj/q4l1ycMobOdyKG/9smNMk xlzA== 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=P5eKp1W97TceJccuviHGlV7njM4U1jdaMhjnj6oRL8I=; b=EJId1AzzWFRQvXGD1vUiPMVaj5UqX5bw15didmW0HdPRT0XoUYy9pZeHJmPykr9eMT Ka2AJsXNw276qK8/xSfZqGhnvccfYKy8WhOyIx4ANSORuLIFtXShsIpxrejwy/vlVpZD Agqms3ylFpB6PgkvYqaGEbZVBob4Xt9AmQjga0z5R+ewFipWE7dwUanbG9wogD373RUs 2esKMRqHiEAqQToBEQaLNY3xVaTdydw//rba9wR1v97dSpEICdPfrWOC4WeyZbOWWrip 8zef+CD7edh3ZD7vtEYdDXZ//02tQVErKL9PmD4kOUQCIelqaEDKfdlXu+SsY9MLUKtB sbvA== X-Gm-Message-State: AEkoouuhuhWwqzyEXqJ9C/n92kSnGZ7ZoCv1dY83vBQdKRNwyUdf+/fmtAIFFHtjnk1QXg== X-Received: by 10.194.221.232 with SMTP id qh8mr56137821wjc.117.1470144278314; Tue, 02 Aug 2016 06:24:38 -0700 (PDT) Received: from localhost.localdomain (157.174.broadband3.iol.cz. [85.70.174.157]) by smtp.gmail.com with ESMTPSA id n131sm22060902wmd.3.2016.08.02.06.24.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Aug 2016 06:24:37 -0700 (PDT) From: sebechlebskyjan@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Aug 2016 15:24:17 +0200 Message-Id: <1470144262-13167-7-git-send-email-sebechlebskyjan@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470144262-13167-1-git-send-email-sebechlebskyjan@gmail.com> References: <1470144262-13167-1-git-send-email-sebechlebskyjan@gmail.com> Subject: [FFmpeg-devel] [PATCH 06/11] avformat: add av_abort_output() 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 --- libavformat/avformat.h | 14 ++++++++++++++ libavformat/mux.c | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9191c69..9173908 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2510,6 +2510,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 av_abort_output(). * * @param s media file handle * @return 0 if OK, AVERROR(EAGAIN) in case call should be repeated, @@ -2518,6 +2520,18 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index); int av_write_trailer(AVFormatContext *s); /** + * Abort non-blocking muxer operation and free private data. + * + * May only be called after a successful call to avformat_write_header, + * and used only with muxer operating in non-blocking mode (AVFMT_FLAG_NONBLOCK) + * must be set. + * + * @param s media file handle + * return >= 0 on success, negative AVERROR on error + */ +int av_abort_output(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..888a9f1 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1267,6 +1267,22 @@ fail: return ret; } +int av_abort_output(AVFormatContext *s) +{ + int ret; + + if (!(s->flags & AVFMT_FLAG_NONBLOCK)) + return AVERROR(EINVAL); + + 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) {