From patchwork Thu Aug 11 12:44: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: 153 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp45906vsd; Thu, 11 Aug 2016 05:44:25 -0700 (PDT) X-Received: by 10.28.167.80 with SMTP id q77mr9575163wme.62.1470919465628; Thu, 11 Aug 2016 05:44:25 -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 i71si12548184wme.14.2016.08.11.05.44.25; Thu, 11 Aug 2016 05:44:25 -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 313CB68A04F; Thu, 11 Aug 2016 15:44:23 +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 BB0EB68A63E for ; Thu, 11 Aug 2016 15:44:15 +0300 (EEST) Received: by mail-wm0-f67.google.com with SMTP id q128so1178836wma.1 for ; Thu, 11 Aug 2016 05:44:16 -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=upxGvGad5FYKV+y3sS+X2ELWwx1RsSvCcIPMNE0iPf0=; b=RKxtV3s2opL+gQD7NA7Yz6+6oUKMetx9rpadubHEr+N4eCZdGtWCUfvNl5sgh9JJoT x+kPBxhsDsmTLLl+gv86RC4N/DpE9GuyGetJ62f29iFLRxPh1kz0SwgFSwOoj6wtY8sn x4cTSpqbbO5E7+ED165E+mbDR/aQqQ8soilhBvt+lB8QhC4dpBVhAD8Ogu640PHHgI2u JjgS04nWkhY6Jmagw14tqRDvjM8wdivs/olAK1MeopJIwv6ucrufUeY1x2ixBLZL0bVA lQrt/AUBybu10Cp0nA7+bkjUlUdrzvUM+S/lq5+QE+zrEnpqh5UtP1xBSrOeZBB7dC99 bibA== 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=upxGvGad5FYKV+y3sS+X2ELWwx1RsSvCcIPMNE0iPf0=; b=BSHqoYjEsay0PjFgC3LSVtcQ0GdNCfADEIGJZjVHeIjlPrHoHL1iWM9dMY8qVsBg+/ dxmkhVaLKv5p5cZ9zNTo31b3cX5MYqbdI3YP5+KxAAClIHWzYC8wGEnEHhpTFHJykhpA aPAibEqYh5p20RUU1c7Hu03EgcozCedVEhPWLFXXxKvBMPBiMKE6usBGKz0RS+Qq7mdc wfL1fptgI9yCh0e6BGs8LnLaXYb1VWq2OtmRw05Xaey6FUZawFgujEyMiGkMwUOd7dXX idmFVd/cou3N2lIj6WjWX7IM96ghclSn01/DzOIyBqLx3rHGxQE9vZZ9C1qH8onwm4ZJ TuuQ== X-Gm-Message-State: AEkoouspSy5E0NWNWIRj1r27pM5/na5g5UTaymWG61On4DdV10p+uxsZxtiWOtz+DaouJQ== X-Received: by 10.28.163.199 with SMTP id m190mr9459370wme.5.1470919454484; Thu, 11 Aug 2016 05:44:14 -0700 (PDT) Received: from localhost.localdomain (157.174.broadband3.iol.cz. [85.70.174.157]) by smtp.gmail.com with ESMTPSA id d64sm3034525wmc.22.2016.08.11.05.44.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 05:44:13 -0700 (PDT) From: sebechlebskyjan@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Aug 2016 14:44:04 +0200 Message-Id: <1470919444-3843-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 07/11] avformat/mux: Comment and assert AVFMT_FLAG_NONBLOCK 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 Add comments regarding AVFMG_FLAG_NONBLOCK usage with muxers. Add assert forbiding use of nonblocking muxer with av_interleaved_write_frame. Signed-off-by: Jan Sebechlebsky --- Changes since the last version of the patch: - added assert to the beginning of av_interleaved_write_frame ensuring it is not called with muxer in nonblocking mode. - Changed commit description. libavformat/avformat.h | 9 ++++++++- libavformat/mux.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 83903b5..79c2511 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1428,7 +1428,7 @@ typedef struct AVFormatContext { int flags; #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index. -#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. +#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input / writing packets to output. #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container #define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled @@ -2391,6 +2391,10 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options); * the interleaving should call av_interleaved_write_frame() instead of this * function. * + * In case the muxer is operating in non-blocking mode (AVFMT_FLAG_NONBLOCK + * is set), this function can return AVERROR(EAGAIN) meaning the call should + * be repeated. + * * @param s media file handle * @param pkt The packet containing the data to be written. Note that unlike * av_interleaved_write_frame(), this function does not take @@ -2433,6 +2437,9 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); * knowledge of future packets, improving e.g. the behaviour of the mp4 * muxer for VFR content in fragmenting mode. * + * This call is not supported and must not be called if muxer is operating + * in non-blocking mode (AVFMT_FLAG_NONBLOCK is set). + * * @param s media file handle * @param pkt The packet containing the data to be written. *
diff --git a/libavformat/mux.c b/libavformat/mux.c index 0f002a3..b4698b7 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1139,6 +1139,8 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) { int ret, flush = 0; + av_assert0(!(s->flags & AVFMT_FLAG_NONBLOCK)); + ret = prepare_input_packet(s, pkt); if (ret < 0) goto fail;