* [FFmpeg-devel] [PATCH] Various small things in regarding URL options (PR #20390)
@ 2025-09-01 23:35 Marton Balint via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Marton Balint via ffmpeg-devel @ 2025-09-01 23:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
PR #20390 opened by Marton Balint (cus)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20390
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20390.patch
This is a preparation series for a future patchset aiming to set protocol URL options via AVOptions.
This series adds AVOptions for previously URL-only options, adds some AVOption aliases where the URL option name and the AVOption name was different, has some factorization work and also fixes a small issue in the URL decoding function.
>From 4c20eeb14a26c01c4cd4dd4972c49a9562309c9b Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Sun, 24 Aug 2025 23:28:36 +0200
Subject: [PATCH 1/9] avformat/udp: add DSCP as a normal AVOption
Previously this was an URL-only option.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/protocols.texi | 3 +++
libavformat/udp.c | 10 ++++++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 6b582fde30..4b871dddb7 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -2162,6 +2162,9 @@ Explicitly allow or disallow reusing UDP sockets.
@item ttl=@var{ttl}
Set the time to live value (for multicast only).
+@item dscp=@var{dscp}
+Set the 6-bit DSCP field for outgoing packets.
+
@item connect=@var{1|0}
Initialize the UDP socket with @code{connect()}. In this case, the
destination address can't be changed with ff_udp_set_remote_url later.
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 84f9d3e62e..ded7a1a85e 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -118,6 +118,7 @@ typedef struct UDPContext {
int remaining_in_dg;
char *localaddr;
int timeout;
+ int dscp;
struct sockaddr_storage local_addr_storage;
char *sources;
char *block;
@@ -142,6 +143,7 @@ static const AVOption options[] = {
{ "reuse_socket", "explicitly allow reusing UDP sockets", OFFSET(reuse_socket), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, .flags = D|E },
{ "broadcast", "explicitly allow or disallow broadcast destination", OFFSET(is_broadcast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
{ "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 255, E },
+ { "dscp", "DSCP class for outgoing packets", OFFSET(dscp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 63, E },
{ "connect", "set if connect() should be called on socket", OFFSET(is_connected), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
{ "fifo_size", "set the UDP receiving circular buffer size, expressed as a number of packets with size of 188 bytes", OFFSET(circular_buffer_size), AV_OPT_TYPE_INT, {.i64 = 7*4096}, 0, INT_MAX, D },
{ "overrun_nonfatal", "survive in case of UDP receiving circular buffer overrun", OFFSET(overrun_nonfatal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D },
@@ -691,7 +693,7 @@ end:
static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024];
- int port, udp_fd = -1, tmp, bind_ret = -1, dscp = -1;
+ int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = h->priv_data;
int is_output;
const char *p;
@@ -760,7 +762,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
s->is_connected = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "dscp", p)) {
- dscp = strtol(buf, NULL, 10);
+ s->dscp = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10);
@@ -870,8 +872,8 @@ static int udp_open(URLContext *h, const char *uri, int flags)
av_log(h, AV_LOG_WARNING, "socket option UDPLITE_RECV_CSCOV not available");
}
- if (dscp >= 0) {
- dscp <<= 2;
+ if (s->dscp >= 0) {
+ int dscp = s->dscp << 2;
if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0) {
ret = ff_neterrno();
goto fail;
--
2.49.1
>From b1c70e0e7d7c2e8128f084ade72e0049de713206 Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Mon, 25 Aug 2025 21:02:54 +0200
Subject: [PATCH 2/9] avformat/udp: factorize warning unsupported options for
builds without PTHREAD_CANCEL
Also fix 'circular_buffer_size' parameter name in the message and the
'fifo_size' option description.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavformat/udp.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/libavformat/udp.c b/libavformat/udp.c
index ded7a1a85e..e1dec49010 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -145,7 +145,7 @@ static const AVOption options[] = {
{ "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 255, E },
{ "dscp", "DSCP class for outgoing packets", OFFSET(dscp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 63, E },
{ "connect", "set if connect() should be called on socket", OFFSET(is_connected), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
- { "fifo_size", "set the UDP receiving circular buffer size, expressed as a number of packets with size of 188 bytes", OFFSET(circular_buffer_size), AV_OPT_TYPE_INT, {.i64 = 7*4096}, 0, INT_MAX, D },
+ { "fifo_size", "set the UDP circular buffer size (in 188-byte packets)", OFFSET(circular_buffer_size), AV_OPT_TYPE_INT, {.i64 = HAVE_PTHREAD_CANCEL ? 7*4096 : 0}, 0, INT_MAX, D },
{ "overrun_nonfatal", "survive in case of UDP receiving circular buffer overrun", OFFSET(overrun_nonfatal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D },
{ "timeout", "set raise error timeout, in microseconds (only in read mode)",OFFSET(timeout), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, D },
{ "sources", "Source list", OFFSET(sources), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
@@ -733,10 +733,6 @@ static int udp_open(URLContext *h, const char *uri, int flags)
/* assume if no digits were found it is a request to enable it */
if (buf == endptr)
s->overrun_nonfatal = 1;
- if (!HAVE_PTHREAD_CANCEL)
- av_log(h, AV_LOG_WARNING,
- "'overrun_nonfatal' option was set but it is not supported "
- "on this build (pthread support is required)\n");
}
if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
s->ttl = strtol(buf, NULL, 10);
@@ -766,17 +762,9 @@ static int udp_open(URLContext *h, const char *uri, int flags)
}
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10);
- if (!HAVE_PTHREAD_CANCEL)
- av_log(h, AV_LOG_WARNING,
- "'circular_buffer_size' option was set but it is not supported "
- "on this build (pthread support is required)\n");
}
if (av_find_info_tag(buf, sizeof(buf), "bitrate", p)) {
s->bitrate = strtoll(buf, NULL, 10);
- if (!HAVE_PTHREAD_CANCEL)
- av_log(h, AV_LOG_WARNING,
- "'bitrate' option was set but it is not supported "
- "on this build (pthread support is required)\n");
}
if (av_find_info_tag(buf, sizeof(buf), "burst_bits", p)) {
s->burst_bits = strtoll(buf, NULL, 10);
@@ -802,6 +790,16 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (is_output && av_find_info_tag(buf, sizeof(buf), "broadcast", p))
s->is_broadcast = strtol(buf, NULL, 10);
}
+ if (!HAVE_PTHREAD_CANCEL) {
+ int64_t optvals[] = {s->overrun_nonfatal, s->bitrate, s->circular_buffer_size};
+ const char* optnames[] = { "overrun_nonfatal", "bitrate", "fifo_size"};
+ for (unsigned i = 0; i < FF_ARRAY_ELEMS(optvals); i++) {
+ if (optvals[i])
+ av_log(h, AV_LOG_WARNING,
+ "'%s' option was set but it is not supported "
+ "on this build (pthread support is required)\n", optnames[i]);
+ }
+ }
/* handling needed to support options picking from both AVOption and URL */
s->circular_buffer_size *= 188;
if (flags & AVIO_FLAG_WRITE) {
--
2.49.1
>From d0f6416873cc6b5b8cc8cbd85b9ff0ddc63f1bbb Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Mon, 25 Aug 2025 23:13:36 +0200
Subject: [PATCH 3/9] avformat/tls: add some URL options as AVOption aliases
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/protocols.texi | 4 ++--
libavformat/tls.h | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 4b871dddb7..130ce35f36 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1989,7 +1989,7 @@ need to be specified for verification to work, but not all libraries and
setups have defaults built in.
The file must be in OpenSSL PEM format.
-@item tls_verify=@var{1|0}
+@item tls_verify, verify=@var{1|0}
If enabled, try to verify the peer that we are communicating with.
Note, if using OpenSSL, this currently only makes sure that the
peer certificate is signed by one of the root certificates in the CA
@@ -2055,7 +2055,7 @@ need to be specified for verification to work, but not all libraries and
setups have defaults built in.
The file must be in OpenSSL PEM format.
-@item tls_verify=@var{1|0}
+@item tls_verify, verify=@var{1|0}
If enabled, try to verify the peer that we are communicating with.
Note, if using OpenSSL, this currently only makes sure that the
peer certificate is signed by one of the root certificates in the CA
diff --git a/libavformat/tls.h b/libavformat/tls.h
index 2afa248f4c..55361aab30 100644
--- a/libavformat/tls.h
+++ b/libavformat/tls.h
@@ -77,8 +77,11 @@ typedef struct TLSShared {
{"ca_file", "Certificate Authority database file", offsetof(pstruct, options_field . ca_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"cafile", "Certificate Authority database file", offsetof(pstruct, options_field . ca_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"tls_verify", "Verify the peer certificate", offsetof(pstruct, options_field . verify), AV_OPT_TYPE_INT, { .i64 = TLS_VERIFY_DEFAULT }, 0, 1, .flags = TLS_OPTFL }, \
+ {"verify", "Verify the peer certificate", offsetof(pstruct, options_field . verify), AV_OPT_TYPE_INT, { .i64 = TLS_VERIFY_DEFAULT }, 0, 1, .flags = TLS_OPTFL }, \
{"cert_file", "Certificate file", offsetof(pstruct, options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
+ {"cert", "Certificate file", offsetof(pstruct, options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"key_file", "Private key file", offsetof(pstruct, options_field . key_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
+ {"key", "Private key file", offsetof(pstruct, options_field . key_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"verifyhost", "Verify against a specific hostname", offsetof(pstruct, options_field . host), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }
#define TLS_COMMON_OPTIONS(pstruct, options_field) \
--
2.49.1
>From d3b6835402475389c56e904857eeec6f3080912f Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Sun, 31 Aug 2025 22:03:05 +0200
Subject: [PATCH 4/9] avformat/tls: use AV_OPT_TYPE_BOOL for some AVOptions
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavformat/tls.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavformat/tls.h b/libavformat/tls.h
index 55361aab30..b72537c063 100644
--- a/libavformat/tls.h
+++ b/libavformat/tls.h
@@ -76,8 +76,8 @@ typedef struct TLSShared {
#define FF_TLS_CLIENT_OPTIONS(pstruct, options_field) \
{"ca_file", "Certificate Authority database file", offsetof(pstruct, options_field . ca_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"cafile", "Certificate Authority database file", offsetof(pstruct, options_field . ca_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
- {"tls_verify", "Verify the peer certificate", offsetof(pstruct, options_field . verify), AV_OPT_TYPE_INT, { .i64 = TLS_VERIFY_DEFAULT }, 0, 1, .flags = TLS_OPTFL }, \
- {"verify", "Verify the peer certificate", offsetof(pstruct, options_field . verify), AV_OPT_TYPE_INT, { .i64 = TLS_VERIFY_DEFAULT }, 0, 1, .flags = TLS_OPTFL }, \
+ {"tls_verify", "Verify the peer certificate", offsetof(pstruct, options_field . verify), AV_OPT_TYPE_BOOL, { .i64 = TLS_VERIFY_DEFAULT }, 0, 1, .flags = TLS_OPTFL }, \
+ {"verify", "Verify the peer certificate", offsetof(pstruct, options_field . verify), AV_OPT_TYPE_BOOL, { .i64 = TLS_VERIFY_DEFAULT }, 0, 1, .flags = TLS_OPTFL }, \
{"cert_file", "Certificate file", offsetof(pstruct, options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"cert", "Certificate file", offsetof(pstruct, options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"key_file", "Private key file", offsetof(pstruct, options_field . key_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
@@ -87,8 +87,8 @@ typedef struct TLSShared {
#define TLS_COMMON_OPTIONS(pstruct, options_field) \
{"listen", "Listen for incoming connections", offsetof(pstruct, options_field . listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
{"http_proxy", "Set proxy to tunnel through", offsetof(pstruct, options_field . http_proxy), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
- {"external_sock", "Use external socket", offsetof(pstruct, options_field . external_sock), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
- {"use_srtp", "Enable use_srtp DTLS extension", offsetof(pstruct, options_field . use_srtp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
+ {"external_sock", "Use external socket", offsetof(pstruct, options_field . external_sock), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
+ {"use_srtp", "Enable use_srtp DTLS extension", offsetof(pstruct, options_field . use_srtp), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
{"mtu", "Maximum Transmission Unit", offsetof(pstruct, options_field . mtu), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = TLS_OPTFL}, \
{"cert_pem", "Certificate PEM string", offsetof(pstruct, options_field . cert_buf), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"key_pem", "Private key PEM string", offsetof(pstruct, options_field . key_buf), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
--
2.49.1
>From f4814982068183ae900ec1af26861d4235bb33b5 Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Tue, 26 Aug 2025 00:07:32 +0200
Subject: [PATCH 5/9] avformat/tls: move AVClass to TLSShared
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavformat/tls.h | 1 +
libavformat/tls_gnutls.c | 1 -
libavformat/tls_libtls.c | 1 -
libavformat/tls_mbedtls.c | 1 -
libavformat/tls_openssl.c | 1 -
libavformat/tls_schannel.c | 1 -
libavformat/tls_securetransport.c | 1 -
7 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/libavformat/tls.h b/libavformat/tls.h
index b72537c063..6c5f7bc15f 100644
--- a/libavformat/tls.h
+++ b/libavformat/tls.h
@@ -35,6 +35,7 @@
#define MAX_CERTIFICATE_SIZE 8192
typedef struct TLSShared {
+ const AVClass *class;
char *ca_file;
int verify;
char *cert_file;
diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index df251ad79c..fbd9780d8a 100644
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@ -42,7 +42,6 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
#endif
typedef struct TLSContext {
- const AVClass *class;
TLSShared tls_shared;
gnutls_session_t session;
gnutls_certificate_credentials_t cred;
diff --git a/libavformat/tls_libtls.c b/libavformat/tls_libtls.c
index 22858d4867..4f011ad67a 100644
--- a/libavformat/tls_libtls.c
+++ b/libavformat/tls_libtls.c
@@ -32,7 +32,6 @@
#include <tls.h>
typedef struct TLSContext {
- const AVClass *class;
TLSShared tls_shared;
struct tls *ctx;
} TLSContext;
diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index e802c6b872..2bcd3cca63 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -40,7 +40,6 @@
#include "libavutil/avstring.h"
typedef struct TLSContext {
- const AVClass *class;
TLSShared tls_shared;
mbedtls_ssl_context ssl_context;
mbedtls_ssl_config ssl_config;
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index db7147e491..edfd657a3f 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -418,7 +418,6 @@ static X509 *cert_from_pem_string(const char *pem_str)
typedef struct TLSContext {
- const AVClass *class;
TLSShared tls_shared;
SSL_CTX *ctx;
SSL *ssl;
diff --git a/libavformat/tls_schannel.c b/libavformat/tls_schannel.c
index b854f484fa..6708302b65 100644
--- a/libavformat/tls_schannel.c
+++ b/libavformat/tls_schannel.c
@@ -587,7 +587,6 @@ end:
}
typedef struct TLSContext {
- const AVClass *class;
TLSShared tls_shared;
char *cert_store_subject;
diff --git a/libavformat/tls_securetransport.c b/libavformat/tls_securetransport.c
index a5a3bd87a1..f52fc97db2 100644
--- a/libavformat/tls_securetransport.c
+++ b/libavformat/tls_securetransport.c
@@ -43,7 +43,6 @@ SecIdentityRef SecIdentityCreate(CFAllocatorRef allocator, SecCertificateRef cer
#define ioErr -36
typedef struct TLSContext {
- const AVClass *class;
TLSShared tls_shared;
SSLContextRef ssl_context;
CFArrayRef ca_array;
--
2.49.1
>From f5e5639705eece47ed369c59f049b2489111f2e2 Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Mon, 25 Aug 2025 23:00:33 +0200
Subject: [PATCH 6/9] avformat/rtpproto: add some URL options as AVOption
aliases
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/protocols.texi | 14 +++++---------
libavformat/rtpproto.c | 5 +++++
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 130ce35f36..cd0726cc7a 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1164,7 +1164,7 @@ rtp://@var{hostname}[:@var{port}][?@var{options}]
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}.
-The following URL options are supported:
+The following options are supported:
@table @option
@@ -1174,10 +1174,12 @@ Set the TTL (Time-To-Live) value (for multicast only).
@item rtcpport=@var{n}
Set the remote RTCP port to @var{n}.
-@item localrtpport=@var{n}
+@item localport, local_rtpport, localrtpport=@var{n}
Set the local RTP port to @var{n}.
-@item localrtcpport=@var{n}'
+Using the localport option name is deprecated and should not be used.
+
+@item local_rtcpport, localrtcpport=@var{n}'
Set the local RTCP port to @var{n}.
@item pkt_size=@var{n}
@@ -1200,12 +1202,6 @@ List disallowed (blocked) source IP addresses.
Send packets to the source address of the latest received packet (if
set to 1) or to a default remote address (if set to 0).
-@item localport=@var{n}
-Set the local RTP port to @var{n}.
-
-This is a deprecated option. Instead, @option{localrtpport} should be
-used.
-
@item localaddr=@var{addr}
Local IP address of a network interface used for sending packets or joining
multicast groups.
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 15d0050936..a8f718114d 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -66,12 +66,17 @@ typedef struct RTPContext {
#define OFFSET(x) offsetof(RTPContext, x)
#define D AV_OPT_FLAG_DECODING_PARAM
#define E AV_OPT_FLAG_ENCODING_PARAM
+#define DEPR AV_OPT_FLAG_DEPRECATED
static const AVOption options[] = {
{ "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, .flags = D|E },
{ "buffer_size", "Send/Receive buffer size (in bytes)", OFFSET(buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "rtcp_port", "Custom rtcp port", OFFSET(rtcp_port), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
+ { "rtcpport", "Custom rtcp port", OFFSET(rtcp_port), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "local_rtpport", "Local rtp port", OFFSET(local_rtpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
+ { "localrtpport", "Local rtp port", OFFSET(local_rtpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
+ { "localport", "Local rtp port", OFFSET(local_rtpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E|DEPR },
{ "local_rtcpport", "Local rtcp port", OFFSET(local_rtcpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
+ { "localrtcpport", "Local rtcp port", OFFSET(local_rtcpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "connect", "Connect socket", OFFSET(connect), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
{ "write_to_source", "Send packets to the source address of the latest received packet", OFFSET(write_to_source), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
{ "pkt_size", "Maximum packet size", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
--
2.49.1
>From 050ae39499ca2cdec80244a87b698ff8d2ca2ebf Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Mon, 25 Aug 2025 21:40:40 +0200
Subject: [PATCH 7/9] avformat/rtpproto: use proper return error codes in
rtp_open
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavformat/rtpproto.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index a8f718114d..69879b7fa8 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -240,6 +240,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
const char *p;
int i, max_retry_count = 3;
int rtcpflags;
+ int ret;
av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port,
path, sizeof(path), uri);
@@ -296,8 +297,10 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
av_freep(&s->localaddr);
s->localaddr = av_strdup(buf);
- if (!s->localaddr)
+ if (!s->localaddr) {
+ ret = AVERROR(ENOMEM);
goto fail;
+ }
}
}
if (s->rw_timeout >= 0)
@@ -308,10 +311,12 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
if (!(fec_protocol = av_get_token(&p, "="))) {
av_log(h, AV_LOG_ERROR, "Failed to parse the FEC protocol value\n");
+ ret = AVERROR(EINVAL);
goto fail;
}
if (strcmp(fec_protocol, "prompeg")) {
av_log(h, AV_LOG_ERROR, "Unsupported FEC protocol %s\n", fec_protocol);
+ ret = AVERROR(EINVAL);
goto fail;
}
@@ -320,6 +325,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
if (av_dict_parse_string(&fec_opts, p, "=", ":", 0) < 0) {
av_log(h, AV_LOG_ERROR, "Failed to parse the FEC options\n");
+ ret = AVERROR(EINVAL);
goto fail;
}
if (s->ttl > 0) {
@@ -331,8 +337,9 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
build_udp_url(s, buf, sizeof(buf),
hostname, s->localaddr, rtp_port, s->local_rtpport,
sources, block);
- if (ffurl_open_whitelist(&s->rtp_hd, buf, flags, &h->interrupt_callback,
- NULL, h->protocol_whitelist, h->protocol_blacklist, h) < 0)
+ ret = ffurl_open_whitelist(&s->rtp_hd, buf, flags, &h->interrupt_callback,
+ NULL, h->protocol_whitelist, h->protocol_blacklist, h);
+ if (ret < 0)
goto fail;
s->local_rtpport = ff_udp_get_local_port(s->rtp_hd);
if(s->local_rtpport == 65535) {
@@ -356,8 +363,9 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
build_udp_url(s, buf, sizeof(buf),
hostname, s->localaddr, s->rtcp_port, s->local_rtcpport,
sources, block);
- if (ffurl_open_whitelist(&s->rtcp_hd, buf, rtcpflags, &h->interrupt_callback,
- NULL, h->protocol_whitelist, h->protocol_blacklist, h) < 0)
+ ret = ffurl_open_whitelist(&s->rtcp_hd, buf, rtcpflags, &h->interrupt_callback,
+ NULL, h->protocol_whitelist, h->protocol_blacklist, h);
+ if (ret < 0)
goto fail;
break;
}
@@ -365,8 +373,9 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
s->fec_hd = NULL;
if (fec_protocol) {
ff_url_join(buf, sizeof(buf), fec_protocol, NULL, hostname, rtp_port, NULL);
- if (ffurl_open_whitelist(&s->fec_hd, buf, flags, &h->interrupt_callback,
- &fec_opts, h->protocol_whitelist, h->protocol_blacklist, h) < 0)
+ ret = ffurl_open_whitelist(&s->fec_hd, buf, flags, &h->interrupt_callback,
+ &fec_opts, h->protocol_whitelist, h->protocol_blacklist, h);
+ if (ret < 0)
goto fail;
}
@@ -390,7 +399,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
ffurl_closep(&s->fec_hd);
av_free(fec_protocol);
av_dict_free(&fec_opts);
- return AVERROR(EIO);
+ return ret;
}
static int rtp_read(URLContext *h, uint8_t *buf, int size)
--
2.49.1
>From dc1e0bc8f0072ccd7db1bc106a964d50a1e33120 Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Mon, 1 Sep 2025 00:21:57 +0200
Subject: [PATCH 8/9] avformat/urldecode: fix decoding last char if it was
percent encoded
The length check was too strict and if the end of the string was a percent
encoded sequence it did not decode correctly.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavformat/urldecode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/urldecode.c b/libavformat/urldecode.c
index 5261bcd0cd..150c64c15c 100644
--- a/libavformat/urldecode.c
+++ b/libavformat/urldecode.c
@@ -50,7 +50,7 @@ char *ff_urldecode(const char *url, int decode_plus_sign)
while (s < url_len) {
c = url[s++];
- if (c == '%' && s + 2 < url_len) {
+ if (c == '%' && s + 1 < url_len) {
char c2 = url[s++];
char c3 = url[s++];
if (av_isxdigit(c2) && av_isxdigit(c3)) {
--
2.49.1
>From 85bc1ea39e2cf9fd126d5d06a079df95483283c1 Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Tue, 26 Aug 2025 09:22:57 +0200
Subject: [PATCH 9/9] avformat/urldecode: factorize core url decoding from
ff_urldecode
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavformat/urldecode.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/libavformat/urldecode.c b/libavformat/urldecode.c
index 150c64c15c..e7fa27b3fa 100644
--- a/libavformat/urldecode.c
+++ b/libavformat/urldecode.c
@@ -32,20 +32,10 @@
#include "libavutil/avstring.h"
#include "urldecode.h"
-char *ff_urldecode(const char *url, int decode_plus_sign)
+static size_t urldecode(char *dest, const char *url, size_t url_len, int decode_plus_sign)
{
- int s = 0, d = 0, url_len = 0;
+ size_t s = 0, d = 0;
char c;
- char *dest = NULL;
-
- if (!url)
- return NULL;
-
- url_len = strlen(url) + 1;
- dest = av_malloc(url_len);
-
- if (!dest)
- return NULL;
while (s < url_len) {
c = url[s++];
@@ -82,5 +72,24 @@ char *ff_urldecode(const char *url, int decode_plus_sign)
}
+ return d;
+}
+
+char *ff_urldecode(const char *url, int decode_plus_sign)
+{
+ char *dest = NULL;
+ size_t url_len;
+
+ if (!url)
+ return NULL;
+
+ url_len = strlen(url) + 1;
+ dest = av_malloc(url_len);
+
+ if (!dest)
+ return NULL;
+
+ urldecode(dest, url, url_len, decode_plus_sign);
+
return dest;
}
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-01 23:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-01 23:35 [FFmpeg-devel] [PATCH] Various small things in regarding URL options (PR #20390) Marton Balint via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git