Skip to content
Snippets Groups Projects
Commit ea8ae27a authored by Sven Dueking's avatar Sven Dueking Committed by Luca Barbato
Browse files

avformat/libsrt: add payload size option

parent 35ed7f93
No related branches found
No related tags found
No related merge requests found
...@@ -755,6 +755,17 @@ only if @option{pbkeylen} is non-zero. It is used on ...@@ -755,6 +755,17 @@ only if @option{pbkeylen} is non-zero. It is used on
the receiver only if the received data is encrypted. the receiver only if the received data is encrypted.
The configured passphrase cannot be recovered (write-only). The configured passphrase cannot be recovered (write-only).
@item payloadsize=@var{bytes}
Sets the maximum declared size of a packet transferred
during the single call to the sending function in Live
mode. Use 0 if this value isn't used (which is default in
file mode).
Default value is for MPEG-TS; if you are going to use SRT
to send any different kind of payload, such as, for example,
wrapping a live stream in very small frames, then you can
use a bigger maximum frame size, though not greater than
1456 bytes.
@item pbkeylen=@var{bytes} @item pbkeylen=@var{bytes}
Sender encryption key length, in bytes. Sender encryption key length, in bytes.
Only can be set to 0, 16, 24 and 32. Only can be set to 0, 16, 24 and 32.
......
...@@ -34,6 +34,16 @@ ...@@ -34,6 +34,16 @@
#include "os_support.h" #include "os_support.h"
#include "url.h" #include "url.h"
/* This is for MPEG-TS and it's a default SRTO_PAYLOADSIZE for SRTT_LIVE (8 TS packets) */
#ifndef SRT_LIVE_DEFAULT_PAYLOAD_SIZE
#define SRT_LIVE_DEFAULT_PAYLOAD_SIZE 1316
#endif
/* This is the maximum payload size for Live mode, should you have a different payload type than MPEG-TS */
#ifndef SRT_LIVE_MAX_PAYLOAD_SIZE
#define SRT_LIVE_MAX_PAYLOAD_SIZE 1456
#endif
enum SRTMode { enum SRTMode {
SRT_MODE_CALLER = 0, SRT_MODE_CALLER = 0,
SRT_MODE_LISTENER = 1, SRT_MODE_LISTENER = 1,
...@@ -62,6 +72,7 @@ typedef struct SRTContext { ...@@ -62,6 +72,7 @@ typedef struct SRTContext {
int tlpktdrop; int tlpktdrop;
int nakreport; int nakreport;
int64_t connect_timeout; int64_t connect_timeout;
int payload_size;
enum SRTMode mode; enum SRTMode mode;
} SRTContext; } SRTContext;
...@@ -86,6 +97,9 @@ static const AVOption libsrt_options[] = { ...@@ -86,6 +97,9 @@ static const AVOption libsrt_options[] = {
{ "tlpktdrop", "Enable receiver pkt drop", OFFSET(tlpktdrop), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E }, { "tlpktdrop", "Enable receiver pkt drop", OFFSET(tlpktdrop), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E },
{ "nakreport", "Enable receiver to send periodic NAK reports", OFFSET(nakreport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E }, { "nakreport", "Enable receiver to send periodic NAK reports", OFFSET(nakreport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E },
{ "connect_timeout", "Connect timeout. Caller default: 3000, rendezvous (x 10)", OFFSET(connect_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E }, { "connect_timeout", "Connect timeout. Caller default: 3000, rendezvous (x 10)", OFFSET(connect_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
{ "payload size", "maximum declared size of a packet transferred", OFFSET(payload_size), AV_OPT_TYPE_INT, { .i64 = SRT_LIVE_DEFAULT_PAYLOAD_SIZE }, -1, SRT_LIVE_MAX_PAYLOAD_SIZE, .flags = D|E },
{ "ts_size", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_LIVE_DEFAULT_PAYLOAD_SIZE }, INT_MIN, INT_MAX, .flags = D|E, "payload_size" },
{ "max_size", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_LIVE_MAX_PAYLOAD_SIZE }, INT_MIN, INT_MAX, .flags = D|E, "payload_size" },
{ "mode", "Connection mode (caller, listener, rendezvous)", OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = SRT_MODE_CALLER }, SRT_MODE_CALLER, SRT_MODE_RENDEZVOUS, .flags = D|E, "mode" }, { "mode", "Connection mode (caller, listener, rendezvous)", OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = SRT_MODE_CALLER }, SRT_MODE_CALLER, SRT_MODE_RENDEZVOUS, .flags = D|E, "mode" },
{ "caller", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_MODE_CALLER }, INT_MIN, INT_MAX, .flags = D|E, "mode" }, { "caller", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_MODE_CALLER }, INT_MIN, INT_MAX, .flags = D|E, "mode" },
{ "listener", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_MODE_LISTENER }, INT_MIN, INT_MAX, .flags = D|E, "mode" }, { "listener", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_MODE_LISTENER }, INT_MIN, INT_MAX, .flags = D|E, "mode" },
...@@ -276,7 +290,8 @@ static int libsrt_set_options_pre(URLContext *h, int fd) ...@@ -276,7 +290,8 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
(tsbpddelay >= 0 && libsrt_setsockopt(h, fd, SRTO_TSBPDDELAY, "SRTO_TSBPDELAY", &tsbpddelay, sizeof(tsbpddelay)) < 0) || (tsbpddelay >= 0 && libsrt_setsockopt(h, fd, SRTO_TSBPDDELAY, "SRTO_TSBPDELAY", &tsbpddelay, sizeof(tsbpddelay)) < 0) ||
(s->tlpktdrop >= 0 && libsrt_setsockopt(h, fd, SRTO_TLPKTDROP, "SRTO_TLPKDROP", &s->tlpktdrop, sizeof(s->tlpktdrop)) < 0) || (s->tlpktdrop >= 0 && libsrt_setsockopt(h, fd, SRTO_TLPKTDROP, "SRTO_TLPKDROP", &s->tlpktdrop, sizeof(s->tlpktdrop)) < 0) ||
(s->nakreport >= 0 && libsrt_setsockopt(h, fd, SRTO_NAKREPORT, "SRTO_NAKREPORT", &s->nakreport, sizeof(s->nakreport)) < 0) || (s->nakreport >= 0 && libsrt_setsockopt(h, fd, SRTO_NAKREPORT, "SRTO_NAKREPORT", &s->nakreport, sizeof(s->nakreport)) < 0) ||
(connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) <0 )) { (connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) < 0) ||
(s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0)) {
return AVERROR(EIO); return AVERROR(EIO);
} }
return 0; return 0;
...@@ -454,6 +469,9 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) ...@@ -454,6 +469,9 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
if (av_find_info_tag(buf, sizeof(buf), "connect_timeout", p)) { if (av_find_info_tag(buf, sizeof(buf), "connect_timeout", p)) {
s->connect_timeout = strtol(buf, NULL, 10); s->connect_timeout = strtol(buf, NULL, 10);
} }
if (av_find_info_tag(buf, sizeof(buf), "payload_size", p)) {
s->payload_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "mode", p)) { if (av_find_info_tag(buf, sizeof(buf), "mode", p)) {
if (!strcmp(buf, "caller")) { if (!strcmp(buf, "caller")) {
s->mode = SRT_MODE_CALLER; s->mode = SRT_MODE_CALLER;
...@@ -466,6 +484,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) ...@@ -466,6 +484,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
} }
} }
} }
h->max_packet_size = s->payload_size > 0 ? s->payload_size : SRT_LIVE_DEFAULT_PAYLOAD_SIZE;
return libsrt_setup(h, uri, flags); return libsrt_setup(h, uri, flags);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment