1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-10-06 05:47:18 +02:00

avformat/rtpproto: use ff_parse_opts_from_query_string() to set URL parameters

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint
2025-08-25 21:35:40 +02:00
parent f231439ee7
commit 3166e3b539
2 changed files with 21 additions and 56 deletions

View File

@@ -1162,9 +1162,13 @@ rtp://@var{hostname}[:@var{port}][?@var{options}]
@var{port} specifies the RTP port to use.
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}.
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
The following options are supported:
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@table @option

View File

@@ -29,6 +29,7 @@
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "avformat.h"
#include "internal.h"
#include "rtp.h"
#include "rtpproto.h"
#include "url.h"
@@ -232,8 +233,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
RTPContext *s = h->priv_data;
AVDictionary *fec_opts = NULL;
int rtp_port;
char hostname[256], include_sources[1024] = "", exclude_sources[1024] = "";
char *sources = include_sources, *block = exclude_sources;
char hostname[256];
char *fec_protocol = NULL;
char buf[1024];
char path[1024];
@@ -250,58 +250,17 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
p = strchr(uri, '?');
if (p) {
if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
s->ttl = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
s->rtcp_port = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
s->local_rtpport = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "localrtpport", p)) {
s->local_rtpport = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "localrtcpport", p)) {
s->local_rtcpport = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
s->pkt_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
s->connect = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "write_to_source", p)) {
s->write_to_source = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "dscp", p)) {
s->dscp = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "timeout", p)) {
s->rw_timeout = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
av_strlcpy(include_sources, buf, sizeof(include_sources));
ff_ip_parse_sources(h, buf, &s->filters);
} else {
ff_ip_parse_sources(h, s->sources, &s->filters);
sources = s->sources;
}
if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
av_strlcpy(exclude_sources, buf, sizeof(exclude_sources));
ff_ip_parse_blocks(h, buf, &s->filters);
} else {
ff_ip_parse_blocks(h, s->block, &s->filters);
block = s->block;
}
if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
av_freep(&s->localaddr);
s->localaddr = av_strdup(buf);
if (!s->localaddr) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
ret = ff_parse_opts_from_query_string(s, p, 1);
if (ret < 0)
goto fail;
}
if (s->sources) {
if ((ret = ff_ip_parse_sources(h, s->sources, &s->filters)) < 0)
goto fail;
}
if (s->block) {
if ((ret = ff_ip_parse_blocks(h, s->block, &s->filters)) < 0)
goto fail;
}
if (s->rw_timeout >= 0)
h->rw_timeout = s->rw_timeout;
@@ -334,6 +293,8 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
}
for (i = 0; i < max_retry_count; i++) {
const char *sources = s->sources ? s->sources : "";
const char *block = s->block ? s->block : "";
build_udp_url(s, buf, sizeof(buf),
hostname, s->localaddr, rtp_port, s->local_rtpport,
sources, block);