[FFmpeg-devel] [PATCH] avformat/libsrt: add mininputbw option

Zhao Zhili quinkblack at foxmail.com
Wed Jul 14 10:53:15 EEST 2021


---
 libavformat/libsrt.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 8dee6aa3f3..5113858d97 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -72,6 +72,9 @@ typedef struct SRTContext {
     int ipttl;
     int iptos;
     int64_t inputbw;
+#if SRT_VERSION_VALUE >= 0x010403
+    int64_t mininputbw;
+#endif
     int oheadbw;
     int64_t latency;
     int tlpktdrop;
@@ -118,6 +121,9 @@ static const AVOption libsrt_options[] = {
     { "ipttl",          "IP Time To Live",                                                      OFFSET(ipttl),            AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, 255,       .flags = D|E },
     { "iptos",          "IP Type of Service",                                                   OFFSET(iptos),            AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, 255,       .flags = D|E },
     { "inputbw",        "Estimated input stream rate",                                          OFFSET(inputbw),          AV_OPT_TYPE_INT64,    { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
+#if SRT_VERSION_VALUE >= 0x010403
+    { "mininputbw",     "Minimum value of the estimated input stream rate",                     OFFSET(mininputbw),       AV_OPT_TYPE_INT64,    { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
+#endif
     { "oheadbw",        "MaxBW ceiling based on % over input stream rate",                      OFFSET(oheadbw),          AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, 100,       .flags = D|E },
     { "latency",        "receiver delay (in microseconds) to absorb bursts of missed packet retransmissions",                     OFFSET(latency),          AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
     { "tsbpddelay",     "deprecated, same effect as latency option",                            OFFSET(latency),          AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
@@ -297,6 +303,9 @@ static int libsrt_set_options_post(URLContext *h, int fd)
     SRTContext *s = h->priv_data;
 
     if ((s->inputbw >= 0 && libsrt_setsockopt(h, fd, SRTO_INPUTBW, "SRTO_INPUTBW", &s->inputbw, sizeof(s->inputbw)) < 0) ||
+#if SRT_VERSION_VALUE >= 0x010403
+        (s->mininputbw >= 0 && libsrt_setsockopt(h, fd, SRTO_MININPUTBW, "SRTO_MININPUTBW", &s->mininputbw, sizeof(s->mininputbw)) < 0) ||
+#endif
         (s->oheadbw >= 0 && libsrt_setsockopt(h, fd, SRTO_OHEADBW, "SRTO_OHEADBW", &s->oheadbw, sizeof(s->oheadbw)) < 0)) {
         return AVERROR(EIO);
     }
@@ -560,6 +569,13 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         if (av_find_info_tag(buf, sizeof(buf), "inputbw", p)) {
             s->inputbw = strtoll(buf, NULL, 10);
         }
+        if (av_find_info_tag(buf, sizeof(buf), "mininputbw", p)) {
+#if SRT_VERSION_VALUE >= 0x010403
+            s->mininputbw = strtoll(buf, NULL, 10);
+#else
+            av_log(h, AV_LOG_WARNING, "mininputbw unsupported for libsrt version %s\n", SRT_VERSION_STRING);
+#endif
+        }
         if (av_find_info_tag(buf, sizeof(buf), "oheadbw", p)) {
             s->oheadbw = strtoll(buf, NULL, 10);
         }
-- 
2.31.1



More information about the ffmpeg-devel mailing list