diff mbox series

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

Message ID tencent_39B705483307684C53EDD36275C42917EE05@qq.com
State Superseded
Headers show
Series [FFmpeg-devel] avformat/libsrt: add mininputbw option | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Zhao Zhili July 14, 2021, 7:53 a.m. UTC
---
 libavformat/libsrt.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Gyan Doshi July 14, 2021, 8:32 a.m. UTC | #1
On 2021-07-14 13:23, Zhao Zhili wrote:
> ---
>   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);
>           }

Update doc/protocols.texi as well.

Regards,
Gyan
diff mbox series

Patch

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);
         }