summaryrefslogtreecommitdiff
path: root/libavformat/libsrt.c
diff options
context:
space:
mode:
authorMatsuzawa Tomohiro <thmatuza75@hotmail.com>2018-10-23 04:34:29 +0000
committerMarton Balint <cus@passwd.hu>2018-10-23 19:42:48 +0200
commitc2ac3b8e6a040e33d53fa13548848c8ba981a8e4 (patch)
treef26dfa26220095c59fa42dcd9fd41615bc20e5ea /libavformat/libsrt.c
parent110b4a491859e6e635f6513670785a9378c9551b (diff)
avformat/libsrt: add several options supported in srt 1.3.0
Several SRT options are missing. Since pkg_config requires libsrt v1.3.0 and above, it should be able to support options added in libsrt v1.3.0 and below. This commit adds 8 SRT options. sndbuf, rcvbuf, lossmaxttl, minversion, streamid, smoother, messageapi and transtype The keys of option are equivalent to stransmit. https://github.com/Haivision/srt/blob/v1.3.0/apps/socketoptions.hpp#L196-L223 Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/libsrt.c')
-rw-r--r--libavformat/libsrt.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index fbfd6ace83..fe3b312151 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -76,6 +76,14 @@ typedef struct SRTContext {
int64_t rcvlatency;
int64_t peerlatency;
enum SRTMode mode;
+ int sndbuf;
+ int rcvbuf;
+ int lossmaxttl;
+ int minversion;
+ char *streamid;
+ char *smoother;
+ int messageapi;
+ SRT_TRANSTYPE transtype;
} SRTContext;
#define D AV_OPT_FLAG_DECODING_PARAM
@@ -110,6 +118,16 @@ static const AVOption libsrt_options[] = {
{ "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" },
{ "rendezvous", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_MODE_RENDEZVOUS }, INT_MIN, INT_MAX, .flags = D|E, "mode" },
+ { "sndbuf", "Send buffer size (in bytes)", OFFSET(sndbuf), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
+ { "rcvbuf", "Receive buffer size (in bytes)", OFFSET(rcvbuf), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
+ { "lossmaxttl", "Maximum possible packet reorder tolerance", OFFSET(lossmaxttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
+ { "minversion", "The minimum SRT version that is required from the peer", OFFSET(minversion), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
+ { "streamid", "A string of up to 512 characters that an Initiator can pass to a Responder", OFFSET(streamid), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
+ { "smoother", "The type of Smoother used for the transmission for that socket", OFFSET(smoother), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
+ { "messageapi", "Enable message API", OFFSET(messageapi), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E },
+ { "transtype", "The transmission type for the socket", OFFSET(transtype), AV_OPT_TYPE_INT, { .i64 = SRTT_INVALID }, SRTT_LIVE, SRTT_INVALID, .flags = D|E, "transtype" },
+ { "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" },
{ NULL }
};
@@ -297,6 +315,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
int connect_timeout = s->connect_timeout;
if ((s->mode == SRT_MODE_RENDEZVOUS && libsrt_setsockopt(h, fd, SRTO_RENDEZVOUS, "SRTO_RENDEZVOUS", &yes, sizeof(yes)) < 0) ||
+ (s->transtype != SRTT_INVALID && libsrt_setsockopt(h, fd, SRTO_TRANSTYPE, "SRTO_TRANSTYPE", &s->transtype, sizeof(s->transtype)) < 0) ||
(s->maxbw >= 0 && libsrt_setsockopt(h, fd, SRTO_MAXBW, "SRTO_MAXBW", &s->maxbw, sizeof(s->maxbw)) < 0) ||
(s->pbkeylen >= 0 && libsrt_setsockopt(h, fd, SRTO_PBKEYLEN, "SRTO_PBKEYLEN", &s->pbkeylen, sizeof(s->pbkeylen)) < 0) ||
(s->passphrase && libsrt_setsockopt(h, fd, SRTO_PASSPHRASE, "SRTO_PASSPHRASE", s->passphrase, strlen(s->passphrase)) < 0) ||
@@ -310,6 +329,13 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
(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) ||
(connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) <0 ) ||
+ (s->sndbuf >= 0 && libsrt_setsockopt(h, fd, SRTO_SNDBUF, "SRTO_SNDBUF", &s->sndbuf, sizeof(s->sndbuf)) < 0) ||
+ (s->rcvbuf >= 0 && libsrt_setsockopt(h, fd, SRTO_RCVBUF, "SRTO_RCVBUF", &s->rcvbuf, sizeof(s->rcvbuf)) < 0) ||
+ (s->lossmaxttl >= 0 && libsrt_setsockopt(h, fd, SRTO_LOSSMAXTTL, "SRTO_LOSSMAXTTL", &s->lossmaxttl, sizeof(s->lossmaxttl)) < 0) ||
+ (s->minversion >= 0 && libsrt_setsockopt(h, fd, SRTO_MINVERSION, "SRTO_MINVERSION", &s->minversion, sizeof(s->minversion)) < 0) ||
+ (s->streamid && libsrt_setsockopt(h, fd, SRTO_STREAMID, "SRTO_STREAMID", s->streamid, strlen(s->streamid)) < 0) ||
+ (s->smoother && libsrt_setsockopt(h, fd, SRTO_SMOOTHER, "SRTO_SMOOTHER", s->smoother, strlen(s->smoother)) < 0) ||
+ (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)) {
return AVERROR(EIO);
}
@@ -522,6 +548,38 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
return AVERROR(EIO);
}
}
+ if (av_find_info_tag(buf, sizeof(buf), "sndbuf", p)) {
+ s->sndbuf = strtol(buf, NULL, 10);
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "rcvbuf", p)) {
+ s->rcvbuf = strtol(buf, NULL, 10);
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "lossmaxttl", p)) {
+ s->lossmaxttl = strtol(buf, NULL, 10);
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "minversion", p)) {
+ s->minversion = strtol(buf, NULL, 0);
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "streamid", p)) {
+ av_freep(&s->streamid);
+ s->streamid = av_strdup(buf);
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "smoother", p)) {
+ av_freep(&s->smoother);
+ s->smoother = av_strdup(buf);
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "messageapi", p)) {
+ s->messageapi = strtol(buf, NULL, 10);
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "transtype", p)) {
+ if (!strcmp(buf, "live")) {
+ s->transtype = SRTT_LIVE;
+ } else if (!strcmp(buf, "file")) {
+ s->transtype = SRTT_FILE;
+ } else {
+ return AVERROR(EINVAL);
+ }
+ }
}
return libsrt_setup(h, uri, flags);
}