From patchwork Mon Oct 11 01:26:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31024 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp3222655ioa; Sun, 10 Oct 2021 18:26:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK+BvusZTb45Bl+0OOlK8Tp5sGuFkffv/eYzJZXur2j8cah8n345WfYPskj4WGS8fEBDOo X-Received: by 2002:a50:e0c3:: with SMTP id j3mr37532438edl.97.1633915593986; Sun, 10 Oct 2021 18:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633915593; cv=none; d=google.com; s=arc-20160816; b=Ha09RxFs9Cu6/aMgGod6+k8PXYKanymQDETnAnubzA/oPoOxXxcIukWBzz17ftYGNY r/TGj+TJQ0bUUIl1o/TeTpCdgBaSkpABAvbQa2YNRmqrjL2ahxXJzjql3gwKw6uhBuXj UgzpavlnIFWfZ75sQy5pzeqGOKcY/WwZlUv/Hib28ejayvWlATEQ9I/G8FDJhKg3Z4zI avbVkFqF4tMibv8HuB4w6yIIfh04+kP6TD6wKIBTmKwluI89RdNuoe3vN8jASeBLJQC4 0YWQVb4IzI+sMsSIRCQtJlx3UBEDxqdd/SQMk0SJBl5wnMiBPiMrQ0RRvnY4/gYFOSWc Mtvg== 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:dkim-signature:delivered-to; bh=869/ycGBU1gENShkjALIsxgjI/9MrfYPc9PMzaByh+Q=; b=v1oz/tb4g9gssIGEQOoMAljHRGlt/MMKr2O3ujgW/uRgxelQQ6ffvaMfcTov9/3zNe VnGmiDHxYFlWKiI/KDyMFVrpNqDgPinUOfHZUiTXtea/hkk7GOYq06Gk5jmBUS3nnqEc dmVJs4oubgibTEzHsCWG3UIlqW+Tge4ZikNTvPL4TjG13iPuvphYJCKyfQt0VXm3BmGB +G8PyNDKHzGNoz6GOSV2hfjtsmZoX53LOwkzwFN3zpTu1n2wcG0KNqL85mJK7X/6YQT8 S+UFmuhBqqkMA5p87FuE2DVTGHMhTVviJ4bx2D9B7/rvyy64P/Mm3kcuG+ffNV4GGQDF M5Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="T2O/qGJm"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p16si9573146ejy.242.2021.10.10.18.26.33; Sun, 10 Oct 2021 18:26:33 -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 header.s=20210112 header.b="T2O/qGJm"; 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=QUARANTINE 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 721A668A789; Mon, 11 Oct 2021 04:26:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BCEAB68008C for ; Mon, 11 Oct 2021 04:26:22 +0300 (EEST) Received: by mail-pg1-f182.google.com with SMTP id 75so9288110pga.3 for ; Sun, 10 Oct 2021 18:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YVC5/nZGigbkQyp42WXVtJLzdATNoSt+hEjAtMTOzYk=; b=T2O/qGJm4zutcCKwxPGkW+u/5dHiSYsgqrfkQOcyq7XSULHEf4K1HNlvTgZU2b0e0/ aPi52Kf9bGO70O/AfnaUypdtcQUp8cwwnsCi8qpaSQ+g8K21KiCucB9GABH7fecfRtxz cyovW2L7VwBCeI5hRzo9XwtFcBBKv4vpEhySZCDUW6x5rKI5C8OrKLiUgllrbt9uA8lB B+kqxB0ubPAFZymGl0A17aPzR7XKTuDeoYKyQOIDTQn1OrwFIgEpzheFQd5bOmtZfb5a /vyfpjsvmdN7OCVZiZkaeB4IZFR3Eb3CKxEQA/XGEDCFI9+ziOQ8g0drcwWK764ErYkt AdEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YVC5/nZGigbkQyp42WXVtJLzdATNoSt+hEjAtMTOzYk=; b=aghkldak8pYVjG0ZHQ9dvMLBrD5Bs4mMFe6A1LFfRLIXA3B7WNoPPoN/z5/IxYzaji JsLbHMd7nK4r/+zSGXBBrBsjtWqxksMx142q6OUSplozerRVMYZT8JNid80Lf2UNkMcb 6E95VuWhroOE+fhlfAV1NSTpq1bONW8uwI7JNM2Fbx5naW4ZylPdmyr+LpruYKIT/UxO VueVCI304lNJw7GEgDfgucWc7wNpUqeK2soNoq6cJZm2SqI0yh6d/WndUNZRutqkLUqO 4iPUgydr+Arr2RO9UQS54Hc3bQpXje0zerrE5hvuK3ZckbVqJzVsjWC12SKHDKbDsPee JAPg== X-Gm-Message-State: AOAM530Qs8RfVMWEH6bfH0ZKnvevqf204iSSFrufgPfpBuhrgSyTKe3A 2bKhxlfx5IM8LIhp/bSD/Fk6WZjv3us= X-Received: by 2002:a62:d043:0:b0:44d:e0f:b084 with SMTP id p64-20020a62d043000000b0044d0e0fb084mr5191180pfg.66.1633915580621; Sun, 10 Oct 2021 18:26:20 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id y2sm5432804pjl.6.2021.10.10.18.26.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Oct 2021 18:26:20 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Oct 2021 09:26:15 +0800 Message-Id: <1633915575-30349-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1632964440-24060-5-git-send-email-lance.lmwang@gmail.com> References: <1632964440-24060-5-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3] avformat/libsrt: add snddropdelay parameter for srt 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qWKcZGH7Viag From: Limin Wang Signed-off-by: Limin Wang --- doc/protocols.texi | 6 ++++++ libavformat/libsrt.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/doc/protocols.texi b/doc/protocols.texi index 726e5f1..c100f23 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1496,6 +1496,12 @@ when the old encryption key is decommissioned. Default is -1. -1 means auto (0x1000 in srt library). The range for this option is integers in the 0 - @code{INT_MAX}. +@item snddropdelay=@var{microseconds} +The sender's extra delay before dropping packets. This delay is +added to the default drop delay time interval value. + +Special value -1: Do not drop packets on the sender at all. + @item payload_size=@var{bytes} Sets the maximum declared size of a packet transferred during the single call to the sending function in Live diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index c6308d1..145eea2 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -65,6 +65,7 @@ typedef struct SRTContext { int enforced_encryption; int kmrefreshrate; int kmpreannounce; + int64_t snddropdelay; #endif int mss; int ffs; @@ -111,6 +112,7 @@ static const AVOption libsrt_options[] = { { "enforced_encryption", "Enforces that both connection parties have the same passphrase set", OFFSET(enforced_encryption), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, .flags = D|E }, { "kmrefreshrate", "The number of packets to be transmitted after which the encryption key is switched to a new key", OFFSET(kmrefreshrate), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "kmpreannounce", "The interval between when a new encryption key is sent and when switchover occurs", OFFSET(kmpreannounce), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, + { "snddropdelay", "The sender's extra delay(in microseconds) before dropping packets", OFFSET(snddropdelay), AV_OPT_TYPE_INT64, { .i64 = -2 }, -2, INT64_MAX, .flags = D|E }, #endif { "mss", "The Maximum Segment Size", OFFSET(mss), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1500, .flags = D|E }, { "ffs", "Flight flag size (window size) (in bytes)", OFFSET(ffs), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, @@ -318,6 +320,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd) int latency = s->latency / 1000; int rcvlatency = s->rcvlatency / 1000; int peerlatency = s->peerlatency / 1000; + int snddropdelay = s->snddropdelay > 0 ? s->snddropdelay / 1000 : s->snddropdelay; int connect_timeout = s->connect_timeout; if ((s->mode == SRT_MODE_RENDEZVOUS && libsrt_setsockopt(h, fd, SRTO_RENDEZVOUS, "SRTO_RENDEZVOUS", &yes, sizeof(yes)) < 0) || @@ -334,6 +337,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd) #endif (s->kmrefreshrate >= 0 && libsrt_setsockopt(h, fd, SRTO_KMREFRESHRATE, "SRTO_KMREFRESHRATE", &s->kmrefreshrate, sizeof(s->kmrefreshrate)) < 0) || (s->kmpreannounce >= 0 && libsrt_setsockopt(h, fd, SRTO_KMPREANNOUNCE, "SRTO_KMPREANNOUNCE", &s->kmpreannounce, sizeof(s->kmpreannounce)) < 0) || + (s->snddropdelay >=-1 && libsrt_setsockopt(h, fd, SRTO_SNDDROPDELAY, "SRTO_SNDDROPDELAY", &snddropdelay, sizeof(snddropdelay)) < 0) || #endif (s->mss >= 0 && libsrt_setsockopt(h, fd, SRTO_MSS, "SRTO_MSS", &s->mss, sizeof(s->mss)) < 0) || (s->ffs >= 0 && libsrt_setsockopt(h, fd, SRTO_FC, "SRTO_FC", &s->ffs, sizeof(s->ffs)) < 0) || @@ -549,6 +553,9 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) if (av_find_info_tag(buf, sizeof(buf), "kmpreannounce", p)) { s->kmpreannounce = strtol(buf, NULL, 10); } + if (av_find_info_tag(buf, sizeof(buf), "snddropdelay", p)) { + s->snddropdelay = strtoll(buf, NULL, 10); + } #endif if (av_find_info_tag(buf, sizeof(buf), "mss", p)) { s->mss = strtol(buf, NULL, 10);