---
libavformat/libsrt.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index fe3b312151..fced18fb92 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -84,6 +84,8 @@ typedef struct SRTContext {
char *smoother;
int messageapi;
SRT_TRANSTYPE transtype;
+ char *localip;
+ char *localport;
} SRTContext;
#define D AV_OPT_FLAG_DECODING_PARAM
@@ -128,6 +130,8 @@ static const AVOption libsrt_options[] = {
{ "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" },
+ { "localip", "IP address of network card to use in rendezvous mode
(Req. in rendezvous mode)", OFFSET(localip),
AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
+ { "localport", "Source port to use in rendezvous mode (Req. in
rendezvous mode)", OFFSET(localport), AV_OPT_TYPE_STRING, {
.str = NULL }, .flags = D|E },
{ NULL }
};
@@ -355,6 +359,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int
flags)
char portstr[10];
int open_timeout = 5000000;
int eid;
+ struct sockaddr_in la;
eid = srt_epoll_create();
if (eid < 0)
@@ -395,7 +400,25 @@ static int libsrt_setup(URLContext *h, const char *uri,
int flags)
}
cur_ai = ai;
-
+
+ //Fix for rendezvous mode. Not good only for IPv4 but working.
+ if (s->mode == SRT_MODE_RENDEZVOUS) {
+ if(s->localip == NULL || s->localport == NULL) {
+ av_log(h, AV_LOG_ERROR, "Invalid adapter
configuration\n");
+ return AVERROR(EIO);
+ }
+ av_log(h, AV_LOG_DEBUG , "Adapter options %s:%s\n", s->localip,
s->localport);
+
+ int lp = strtol(s->localport, NULL, 10); //TODO: What if
localport do not contain numers
+ if (lp <= 0 || lp >= 65536) {
+ av_log(h, AV_LOG_ERROR, "Local port missing in uri\n");
+ return AVERROR(EINVAL);
+ }
+
+ la.sin_family = AF_INET; //TODO: Add support for IPv6
+ la.sin_port = htons(port);
+ la.sin_addr.s_addr = inet_addr(s->localip); //TODO: Check if
localip is IP of local interface
+ }
restart:
fd = srt_socket(cur_ai->ai_family, cur_ai->ai_socktype, 0);
@@ -423,7 +446,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int
flags)
fd = ret;
} else {
if (s->mode == SRT_MODE_RENDEZVOUS) {
- ret = srt_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
+ ret = srt_bind(fd, (struct sockaddr *)&la, sizeof(struct
sockaddr_in));
if (ret)
goto fail1;
}
@@ -579,6 +602,12 @@ static int libsrt_open(URLContext *h, const char *uri, int
flags)
} else {
return AVERROR(EINVAL);
}
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "localip", p)) {
+ s->localip = av_strndup(buf, strlen(buf));
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
+ s->localport = av_strndup(buf, strlen(buf));
}
}
return libsrt_setup(h, uri, flags);
--
2.19.2.windows.1
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel