From patchwork Sat Mar 6 23:26:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 26232 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id F099244B0B2 for ; Sun, 7 Mar 2021 01:27:29 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DA1C868A700; Sun, 7 Mar 2021 01:27:29 +0200 (EET) 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 56E6068A6F0 for ; Sun, 7 Mar 2021 01:27:23 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3E6FDE512F; Sun, 7 Mar 2021 00:27:23 +0100 (CET) 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 pQnMd3MUEl6d; Sun, 7 Mar 2021 00:26:53 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8BAF9E5129; Sun, 7 Mar 2021 00:26:27 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Mar 2021 00:26:15 +0100 Message-Id: <20210306232619.5963-3-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210306232619.5963-1-cus@passwd.hu> References: <20210306232619.5963-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7] avformat/librist: make packet size adjustable for writing, fix it for reading 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Maximum packet size is 10000 (RIST_MAX_PACKET_SIZE, which is unfortunately private) minus the RIST protocol overhead which is 28 bytes for the unencrypted case, 36 for the encrypted case. Signed-off-by: Marton Balint --- doc/protocols.texi | 3 +++ libavformat/librist.c | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 11fb351bf6..2664406f25 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -708,6 +708,9 @@ This one is default. @item buffer_size Set internal RIST buffer size for retransmission of data. +@item pkt_size +Set maximum packet size for sending data. 1316 by default. + @item log_level Set loglevel for RIST logging messages. diff --git a/libavformat/librist.c b/libavformat/librist.c index c4ba1192e9..3f74521cb4 100644 --- a/libavformat/librist.c +++ b/libavformat/librist.c @@ -34,11 +34,15 @@ #include +// RIST_MAX_PACKET_SIZE - 28 minimum protocol overhead +#define MAX_PAYLOAD_SIZE (10000-28) + typedef struct RISTContext { const AVClass *class; int profile; int buffer_size; + int packet_size; int log_level; int encryption; char *secret; @@ -59,6 +63,7 @@ static const AVOption librist_options[] = { { "main", NULL, 0, AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_MAIN}, 0, 0, .flags = D|E, "profile" }, { "advanced", NULL, 0, AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_ADVANCED}, 0, 0, .flags = D|E, "profile" }, { "buffer_size", "set buffer_size", OFFSET(buffer_size), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, .flags = D|E }, + { "pkt_size", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64=1316}, 1, MAX_PAYLOAD_SIZE, .flags = D|E }, { "log_level", "set loglevel", OFFSET(log_level), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, .flags = D|E }, { "secret", "set encryption secret",OFFSET(secret), AV_OPT_TYPE_STRING,{.str=NULL}, 0, 0, .flags = D|E }, { "encryption","set encryption type",OFFSET(encryption), AV_OPT_TYPE_INT ,{.i64=0}, 0, INT_MAX, .flags = D|E }, @@ -123,13 +128,17 @@ static int librist_open(URLContext *h, const char *uri, int flags) if (ret < 0) return risterr2ret(ret); - if (flags & AVIO_FLAG_WRITE) + if (flags & AVIO_FLAG_WRITE) { + h->max_packet_size = s->packet_size; ret = rist_sender_create(&s->ctx, s->profile, 0, logging_settings); + } if (ret < 0) goto err; - if (flags & AVIO_FLAG_READ) + if (flags & AVIO_FLAG_READ) { + h->max_packet_size = MAX_PAYLOAD_SIZE; ret = rist_receiver_create(&s->ctx, s->profile, logging_settings); + } if (ret < 0) goto err; @@ -167,8 +176,6 @@ static int librist_open(URLContext *h, const char *uri, int flags) if (ret < 0) goto err; - h->max_packet_size = 9968; - return 0; err: @@ -190,7 +197,7 @@ static int librist_read(URLContext *h, uint8_t *buf, int size) if (ret == 0) return AVERROR(EAGAIN); - if (data_block->payload_len > 9968) { + if (data_block->payload_len > MAX_PAYLOAD_SIZE) { rist_receiver_data_block_free((struct rist_data_block**)&data_block); return AVERROR_EXTERNAL; }