From patchwork Wed Jun 9 10:33:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 28184 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp700591iol; Wed, 9 Jun 2021 03:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxInXuZDcIk5y+BJHmfLoxLKXqQb5F8RHTJud+Q4sTBHa4wOt1Z/8Lc2BkX/NJo/7KpFrkd X-Received: by 2002:a17:906:c311:: with SMTP id s17mr27301579ejz.202.1623234826299; Wed, 09 Jun 2021 03:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623234826; cv=none; d=google.com; s=arc-20160816; b=HVIqO+77H2JoWi7ixBk9irKmSZXUVpK660NALyWfaDZNFA9EtoLSWbshyMP3KZVjNe qSEXYwL5gGalSCRmKPVoi19lrrv4J6245x8AOdiNEBuDs63gPnDC0R1xq29Rf8q7DqjP dUeFRoHLF1FYMAct5wYkz1SAJI6P+9ORLjfKiQ0XWC/dQr2YLc5ASWfUfhcjc+Q3GQXg gL0/8rxotaCOyNItdl0coSQADxZql4uxOJ0xc9DDjQ46kPakEJJK36smdbar4Fw7XQ/W d2yeiCGUq6oya5uX7fijo/bmT7Q/6Vlkxh9WTrUcdKChdJv8BVkIq2fdhwkul6yVGLUa nqQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:mime-version:date:message-id:from:to :dkim-signature:delivered-to; bh=JuWZheaz/wNzJzrHO/lwshIVZGwf39DlgG93yw1RWuY=; b=ViKq0glYUot71iSx+xyvjwa4eg3V6dQwmM5c+Yxm4E5/srFN16af9zP5YSlSKHmyLA 0+6SNaeMF1Jcxj2X7Zxvet7nMqnGh9aferuvzLntroUK78p6HUFQkgV9XV+YxzI3PPKn 9mzkUZHLCXaRhNyfWpO6nqV/wKAEQwPL58jb0/ccjUEYFkTz9+q/ZYfwDn6TBPgOp/NC c2XM+PFZ6b6pma/OvF4KiiMawJ+LsnvFHonNa/ZZ3ZvukQ9eztYUb2hWJQOhV8F4aeXz Y0tl5esLFsMKa9V7xeSGHNRsgvvjN+3ShYEIyZw22cYwKFzzKcNFdAf5ZSvDfkHZd5Ha ASUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=IW0kNBs7; 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 sp=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id kd26si2124191ejc.672.2021.06.09.03.33.45; Wed, 09 Jun 2021 03:33:46 -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=@mail.de header.s=mailde202009 header.b=IW0kNBs7; 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 sp=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE6436880B0; Wed, 9 Jun 2021 13:33:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout01.mail.de (shout01.mail.de [62.201.172.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5FE2A687FCC for ; Wed, 9 Jun 2021 13:33:34 +0300 (EEST) Received: from postfix01.mail.de (postfix03.bt.mail.de [10.0.121.127]) by shout01.mail.de (Postfix) with ESMTP id E306610077F for ; Wed, 9 Jun 2021 12:33:33 +0200 (CEST) Received: from smtp02.mail.de (smtp02.bt.mail.de [10.0.121.212]) by postfix01.mail.de (Postfix) with ESMTP id CB287801E9 for ; Wed, 9 Jun 2021 12:33:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1623234813; bh=aej89H8vyhdsX6jbPnlISwArI/ihIDBoh4WwJDjUsV8=; h=To:From:Subject:Date:From; b=IW0kNBs767ROAp0Pmq0pgga/+43UOBS8u0VFAR5izS6r9go8+Uuxq8gh/wtMkRy2t +TZEKYQxJbGfaY3MbxorQKv/OCrtd9LWG2uh3rkUzKkyDOYFYMMGGGmZk7sjHVqbbA TW688xUHDbJlbdX/tafbEsj3GGMZTEb5mQ65Y6OunOapLN0p8eJemCR6cMHvotpsC5 txOarDzjGEJDHX6D5KtRpaKMHjrxaCQcjAjVsXavgkEzdvhRyZHOJRwl5SWllLVxoF yN7uuSxsm7COiJiaRlGrsq0jqQ7ubr72XuFCnCCkeLgrgpXfu3Dqa9wROxCDQG2mdp ZuxizJfmIUM3w== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtp02.mail.de (Postfix) with ESMTPSA id 95C1AA11DC for ; Wed, 9 Jun 2021 12:33:33 +0200 (CEST) To: FFmpeg development discussions and patches From: Thilo Borgmann Message-ID: <4813bcaf-cf3a-ef22-7f52-13feaea41280@mail.de> Date: Wed, 9 Jun 2021 12:33:32 +0200 MIME-Version: 1.0 Content-Language: de-DE X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 5831 X-purgate-ID: 154282::1623234813-000001E5-AB02FAB5/0/0 Subject: [FFmpeg-devel] [PATCH] lavf/rtmp: Add option to set TCP_NODELAY for rtmp X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: b2z8puaYHt23 Hi, $subject seems to be useful depending on the network. -Thilo From 936826eec00ac2ceaa4579e8a6030a85191320a5 Mon Sep 17 00:00:00 2001 From: Nick Ruff Date: Wed, 9 Jun 2021 12:26:03 +0200 Subject: [PATCH] lavf/rtmp: Add option to set TCP_NODELAY for rtmp Suggested-By: ffmpeg@fb.com --- doc/protocols.texi | 3 +++ libavformat/rtmpproto.c | 8 +++++--- libavformat/tcp.c | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 8371f83..3b1cf12 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -843,6 +843,9 @@ URL to player swf file, compute hash/size automatically. @item rtmp_tcurl URL of the target stream. Defaults to proto://host[:port]/app. +@item tcp_nodelay=@var{1|0} +Set TCP_NODELAY to disable Nagle's algorithm. Default value is 0. + @end table For example to read with @command{ffplay} a multimedia resource named diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 5a540e3..b14d23b 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -123,6 +123,7 @@ typedef struct RTMPContext { int listen_timeout; ///< listen timeout to wait for new connections int nb_streamid; ///< The next stream id to return on createStream calls double duration; ///< Duration of the stream in seconds as returned by the server (only valid if non-zero) + int tcp_nodelay; ///< Use TCP_NODELAY to disable Nagle's algorithm if set to 1 char username[50]; char password[50]; char auth_params[500]; @@ -2653,10 +2654,10 @@ static int rtmp_open(URLContext *s, const char *uri, int flags, AVDictionary **o port = RTMP_DEFAULT_PORT; if (rt->listen) ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, - "?listen&listen_timeout=%d", - rt->listen_timeout * 1000); + "?listen&listen_timeout=%d&tcp_nodelay=%d", + rt->listen_timeout * 1000, rt->tcp_nodelay); else - ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); + ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, "?tcp_nodelay=%d", rt->tcp_nodelay); } reconnect: @@ -3115,6 +3116,7 @@ static const AVOption rtmp_options[] = { {"rtmp_tcurl", "URL of the target stream. Defaults to proto://host[:port]/app.", OFFSET(tcurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, {"rtmp_listen", "Listen for incoming rtmp connections", OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtmp_listen" }, {"listen", "Listen for incoming rtmp connections", OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtmp_listen" }, + {"tcp_nodelay", "Use TCP_NODELAY to disable Nagle's algorithm", OFFSET(tcp_nodelay), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC|ENC}, {"timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies -rtmp_listen 1", OFFSET(listen_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC, "rtmp_listen" }, { NULL }, }; diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 2198e0f..1c19aed 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -135,6 +135,9 @@ static int tcp_open(URLContext *h, const char *uri, int flags) if (av_find_info_tag(buf, sizeof(buf), "listen_timeout", p)) { s->listen_timeout = strtol(buf, NULL, 10); } + if (av_find_info_tag(buf, sizeof(buf), "tcp_nodelay", p)) { + s->tcp_nodelay = strtol(buf, NULL, 10); + } } if (s->rw_timeout >= 0) { s->open_timeout =