From patchwork Sun Jun 18 22:02:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 4026 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp643775vsw; Sun, 18 Jun 2017 15:03:18 -0700 (PDT) X-Received: by 10.223.181.132 with SMTP id c4mr16192469wre.167.1497823398403; Sun, 18 Jun 2017 15:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497823398; cv=none; d=google.com; s=arc-20160816; b=J9kx0UGk+rqfx90oZZzOSBAwMitPCzk5eIcAFG5XnEs+gHab4jNKuc3O19GEp0xjJj ki75Tuge59rjMtNIs0aAaj+zvtYWq6aFHW/TF1udAlYf+sZiU6itDS1qOiA24jj9vBZ+ r0R0ziTbsqKAJaFExKtcqxua6Igk+BsyS64Cozx6+4Q/m9u++ZrhLvLr4bGylbnbVkdR Pw0XGKlxMnaAtlnX310wgkxBYEJhmqq1w8eRUk5GfYx7Y8f0lp6bOmJsh0J9zwk0ttKK 3EBqnlS8/jbVLUFm/vrKyGnfAwnRQ1VCS9xWs3fVWZxFO6VeQDPghb6uaH70Ji/QK2ym Ei0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=ooB+IHxHmpdU7n4agLhEuYh1A4/K3YuF7ZPXHdpBSCI=; b=oY+N1xIEtuBW2e/XL5QaqV0Y51FQUD/ghhHcnJ+sDmbWRnyKoiu7WCDi00nk8aGO5J xagyu1YKll1pyUT9eUout+rknRibCeSmaPqizOEuPTP9e+9lxHbcWjPMSDswgHye7z4O gc3giW3fRHXJ3MpekjMW0c1FZBa/VeAb/UrHNoGTx1y21354VqpQV79O4uqRXE0Ccfjj JX/afgx/sseF5jtyxIV7BgdOJczXLtK2YfYB+9LWSNmCBhZ36TNvXPtMnX6KrPMqGEzZ OHFbThK9YER7jhWErcBfCwha/s9ybNyGasAO6asBon5Z1+ahbBL9W4b5WiQjE/+hggFo j9Sg== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c2si8135638wre.235.2017.06.18.15.03.18; Sun, 18 Jun 2017 15:03:18 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3390768A2C9; Mon, 19 Jun 2017 01:03:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9F57A68A2A8 for ; Mon, 19 Jun 2017 01:02:58 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 13007103425; Mon, 19 Jun 2017 00:03:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YJaEHVGJelDA; Mon, 19 Jun 2017 00:03:01 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A9338103429; Mon, 19 Jun 2017 00:03:01 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Jun 2017 00:02:52 +0200 Message-Id: <20170618220254.21682-2-cus@passwd.hu> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170618220254.21682-1-cus@passwd.hu> References: <20170618220254.21682-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 2/4] avformat/aviobuf: add support for specifying minimum packet size and marking flush points 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/avio.h | 13 ++++++++++++- libavformat/aviobuf.c | 7 +++++++ libavformat/url.h | 1 + libavformat/version.h | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 844a5723d3..f14b003ba5 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -137,7 +137,13 @@ enum AVIODataMarkerType { * Trailer data, which doesn't contain actual content, but only for * finalizing the output file. */ - AVIO_DATA_MARKER_TRAILER + AVIO_DATA_MARKER_TRAILER, + /** + * A point in the output bytestream where the underlying AVIOContext might + * flush the buffer depending on latency or buffering requirements. Typically + * means the end of a packet. + */ + AVIO_DATA_MARKER_FLUSH_POINT, }; /** @@ -339,6 +345,11 @@ typedef struct AVIOContext { * used keeping track of already written data for a later flush. */ unsigned char *buf_ptr_max; + + /** + * Try to buffer at least this amount of data before flushing it + */ + int min_packet_size; } AVIOContext; /** diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index dcb91570d8..7f4e740a33 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -104,6 +104,7 @@ int ffio_init_context(AVIOContext *s, s->eof_reached = 0; s->error = 0; s->seekable = seek ? AVIO_SEEKABLE_NORMAL : 0; + s->min_packet_size = 0; s->max_packet_size = 0; s->update_checksum = NULL; s->short_seek_threshold = SHORT_SEEK_THRESHOLD; @@ -489,6 +490,11 @@ void avio_wb24(AVIOContext *s, unsigned int val) void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type) { + if (type == AVIO_DATA_MARKER_FLUSH_POINT) { + if (s->buf_ptr - s->buffer >= s->min_packet_size) + avio_flush(s); + return; + } if (!s->write_data_type) return; // If ignoring boundary points, just treat it as unknown @@ -941,6 +947,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL; (*s)->max_packet_size = max_packet_size; + (*s)->min_packet_size = h->min_packet_size; if(h->prot) { (*s)->read_pause = io_read_pause; (*s)->read_seek = io_read_seek; diff --git a/libavformat/url.h b/libavformat/url.h index 910f1e00b3..df90333059 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -42,6 +42,7 @@ typedef struct URLContext { char *filename; /**< specified URL */ int flags; int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ + int min_packet_size; /**< if non zero, the stream is packetized with this min packet size */ int is_streamed; /**< true if streamed (no seek possible), default = false */ int is_connected; AVIOInterruptCB interrupt_callback; diff --git a/libavformat/version.h b/libavformat/version.h index 1fb8ffb2b9..44c16ac75a 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 57 -#define LIBAVFORMAT_VERSION_MINOR 74 +#define LIBAVFORMAT_VERSION_MINOR 75 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \