diff mbox series

[FFmpeg-devel,v2,2/2] avformat/libsrt: add tsbpd option

Message ID tencent_1267E42A9FD3085C5D8BB4263D90B866C306@qq.com
State Accepted
Commit 55c54ff74455c70aee243c944c124a04ecdb2d9d
Headers show
Series [FFmpeg-devel,v2,1/2] avformat/libsrt: send message in order | 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 June 4, 2021, 7:22 a.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

---
v2: update doc

 doc/protocols.texi   | 5 +++++
 libavformat/libsrt.c | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

Comments

Marton Balint June 5, 2021, 9:23 a.m. UTC | #1
On Fri, 4 Jun 2021, Zhao Zhili wrote:

> From: Zhao Zhili <zhilizhao@tencent.com>
>
> ---
> v2: update doc

LGTM for the set.

Thanks,
Marton

>
> doc/protocols.texi   | 5 +++++
> libavformat/libsrt.c | 5 ++++-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index 8b21ce046e..d3095c88c6 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -1610,6 +1610,11 @@ Default is -1. -1 means auto (off with 0 seconds in live mode, on with 180
> seconds in file mode). The range for this option is integers in the
> 0 - @code{INT_MAX}.
>
> +@item tsbpd=@var{1|0}
> +When true, use Timestamp-based Packet Delivery mode. The default behavior
> +depends on the transmission type: enabled in live mode, disabled in file
> +mode.
> +
> @end table
>
> For more information see: @url{https://github.com/Haivision/srt}.
> diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
> index 5298725ad5..d02b7a95ec 100644
> --- a/libavformat/libsrt.c
> +++ b/libavformat/libsrt.c
> @@ -90,6 +90,7 @@ typedef struct SRTContext {
>     int messageapi;
>     SRT_TRANSTYPE transtype;
>     int linger;
> +    int tsbpd;
> } SRTContext;
>
> #define D AV_OPT_FLAG_DECODING_PARAM
> @@ -141,6 +142,7 @@ static const AVOption libsrt_options[] = {
>     { "live",           NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRTT_LIVE }, INT_MIN, INT_MAX, .flags = D|E, "transtype" },
>     { "file",           NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRTT_FILE }, INT_MIN, INT_MAX, .flags = D|E, "transtype" },
>     { "linger",         "Number of seconds that the socket waits for unsent data when closing", OFFSET(linger),           AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, INT_MAX,   .flags = D|E },
> +    { "tsbpd",          "Timestamp-based packet delivery",                                      OFFSET(tsbpd),            AV_OPT_TYPE_BOOL,     { .i64 = -1 }, -1, 1,         .flags = D|E },
>     { NULL }
> };
>
> @@ -356,7 +358,8 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
> #endif
>         (s->messageapi >= 0 && libsrt_setsockopt(h, fd, SRTO_MESSAGEAPI, "SRTO_MESSAGEAPI", &s->messageapi, sizeof(s->messageapi)) < 0) ||
>         (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0) ||
> -        ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, SRTO_SENDER, "SRTO_SENDER", &yes, sizeof(yes)) < 0)) {
> +        ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, SRTO_SENDER, "SRTO_SENDER", &yes, sizeof(yes)) < 0) ||
> +        (s->tsbpd >= 0 && libsrt_setsockopt(h, fd, SRTO_TSBPDMODE, "SRTO_TSBPDMODE", &s->tsbpd, sizeof(s->tsbpd)) < 0)) {
>         return AVERROR(EIO);
>     }
>
> -- 
> 2.31.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Marton Balint June 8, 2021, 10:19 p.m. UTC | #2
On Sat, 5 Jun 2021, Marton Balint wrote:

>
>
> On Fri, 4 Jun 2021, Zhao Zhili wrote:
>
>> From: Zhao Zhili <zhilizhao@tencent.com>
>> 
>> ---
>> v2: update doc
>
> LGTM for the set.

Applied, thanks.

Marton

>> 
>> doc/protocols.texi   | 5 +++++
>> libavformat/libsrt.c | 5 ++++-
>> 2 files changed, 9 insertions(+), 1 deletion(-)
>> 
>> diff --git a/doc/protocols.texi b/doc/protocols.texi
>> index 8b21ce046e..d3095c88c6 100644
>> --- a/doc/protocols.texi
>> +++ b/doc/protocols.texi
>> @@ -1610,6 +1610,11 @@ Default is -1. -1 means auto (off with 0 seconds in 
>> live mode, on with 180
>> seconds in file mode). The range for this option is integers in the
>> 0 - @code{INT_MAX}.
>> 
>> +@item tsbpd=@var{1|0}
>> +When true, use Timestamp-based Packet Delivery mode. The default behavior
>> +depends on the transmission type: enabled in live mode, disabled in file
>> +mode.
>> +
>> @end table
>> 
>> For more information see: @url{https://github.com/Haivision/srt}.
>> diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
>> index 5298725ad5..d02b7a95ec 100644
>> --- a/libavformat/libsrt.c
>> +++ b/libavformat/libsrt.c
>> @@ -90,6 +90,7 @@ typedef struct SRTContext {
>>     int messageapi;
>>     SRT_TRANSTYPE transtype;
>>     int linger;
>> +    int tsbpd;
>> } SRTContext;
>> 
>> #define D AV_OPT_FLAG_DECODING_PARAM
>> @@ -141,6 +142,7 @@ static const AVOption libsrt_options[] = {
>>     { "live",           NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRTT_LIVE }, 
>> INT_MIN, INT_MAX, .flags = D|E, "transtype" },
>>     { "file",           NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRTT_FILE }, 
>> INT_MIN, INT_MAX, .flags = D|E, "transtype" },
>>     { "linger",         "Number of seconds that the socket waits for unsent 
>> data when closing", OFFSET(linger),           AV_OPT_TYPE_INT,      { .i64 
>> = -1 }, -1, INT_MAX,   .flags = D|E },
>> +    { "tsbpd",          "Timestamp-based packet delivery", 
>> OFFSET(tsbpd),            AV_OPT_TYPE_BOOL,     { .i64 = -1 }, -1, 1, 
>> .flags = D|E },
>>     { NULL }
>> };
>> 
>> @@ -356,7 +358,8 @@ static int libsrt_set_options_pre(URLContext *h, int 
>> fd)
>> #endif
>>         (s->messageapi >= 0 && libsrt_setsockopt(h, fd, SRTO_MESSAGEAPI, 
>> "SRTO_MESSAGEAPI", &s->messageapi, sizeof(s->messageapi)) < 0) ||
>>         (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, 
>> "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0) ||
>> -        ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, 
>> SRTO_SENDER, "SRTO_SENDER", &yes, sizeof(yes)) < 0)) {
>> +        ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, 
>> SRTO_SENDER, "SRTO_SENDER", &yes, sizeof(yes)) < 0) ||
>> +        (s->tsbpd >= 0 && libsrt_setsockopt(h, fd, SRTO_TSBPDMODE, 
>> "SRTO_TSBPDMODE", &s->tsbpd, sizeof(s->tsbpd)) < 0)) {
>>         return AVERROR(EIO);
>>     }
>> 
>> -- 
>> 2.31.1
>> 
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 8b21ce046e..d3095c88c6 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1610,6 +1610,11 @@  Default is -1. -1 means auto (off with 0 seconds in live mode, on with 180
 seconds in file mode). The range for this option is integers in the
 0 - @code{INT_MAX}.
 
+@item tsbpd=@var{1|0}
+When true, use Timestamp-based Packet Delivery mode. The default behavior
+depends on the transmission type: enabled in live mode, disabled in file
+mode.
+
 @end table
 
 For more information see: @url{https://github.com/Haivision/srt}.
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 5298725ad5..d02b7a95ec 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -90,6 +90,7 @@  typedef struct SRTContext {
     int messageapi;
     SRT_TRANSTYPE transtype;
     int linger;
+    int tsbpd;
 } SRTContext;
 
 #define D AV_OPT_FLAG_DECODING_PARAM
@@ -141,6 +142,7 @@  static const AVOption libsrt_options[] = {
     { "live",           NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRTT_LIVE }, INT_MIN, INT_MAX, .flags = D|E, "transtype" },
     { "file",           NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRTT_FILE }, INT_MIN, INT_MAX, .flags = D|E, "transtype" },
     { "linger",         "Number of seconds that the socket waits for unsent data when closing", OFFSET(linger),           AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, INT_MAX,   .flags = D|E },
+    { "tsbpd",          "Timestamp-based packet delivery",                                      OFFSET(tsbpd),            AV_OPT_TYPE_BOOL,     { .i64 = -1 }, -1, 1,         .flags = D|E },
     { NULL }
 };
 
@@ -356,7 +358,8 @@  static int libsrt_set_options_pre(URLContext *h, int fd)
 #endif
         (s->messageapi >= 0 && libsrt_setsockopt(h, fd, SRTO_MESSAGEAPI, "SRTO_MESSAGEAPI", &s->messageapi, sizeof(s->messageapi)) < 0) ||
         (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0) ||
-        ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, SRTO_SENDER, "SRTO_SENDER", &yes, sizeof(yes)) < 0)) {
+        ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, SRTO_SENDER, "SRTO_SENDER", &yes, sizeof(yes)) < 0) ||
+        (s->tsbpd >= 0 && libsrt_setsockopt(h, fd, SRTO_TSBPDMODE, "SRTO_TSBPDMODE", &s->tsbpd, sizeof(s->tsbpd)) < 0)) {
         return AVERROR(EIO);
     }