[FFmpeg-devel] [PATCH] libavformat/prompeg.c: Add parameters to control FEC ports.

Romain Beauxis romain.beauxis at gmail.com
Fri Dec 13 18:38:35 EET 2024


Le ven. 13 déc. 2024 à 16:42, Romain Beauxis
<romain.beauxis at gmail.com> a écrit :
>
> This patch adds parameters to pick specific ports for the two FEC error-
> correction streams associated with a Pro-MPEG CoP #3-R2 FEC streams.
>
> Radio France is currently interested in using this technology to do
> error-correction on some of their stream. In this context, they may not
> have full control over their available UDP ports and would like to be able to
> pick any two ports for these streams.
>
> The specifications for this protocol is available online: https://www.yumpu.com/en/document/read/8808550/pro-mpeg-code-of-practice-3-release-2-pro-mpeg-forum
>
> In section 5.2, page 14, port assignments for the FEC streams are under
> "shall" thus the changes in this patch should still be valid w.r.t. the
> specs.

A bit surprised, as I re-read the specs now, to learn that "shall" is
to be interpreted as a mandatory requirement while, usually, "must" is
used. My understanding of the English language has failed me once
more!

Still, I believe that this patch should be useful (shall, if
considering the use-case I came from!).

> ---
>  doc/protocols.texi    | 8 +++++++-
>  libavformat/prompeg.c | 8 ++++++--
>  2 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index ed70af4b33..3e14b732c6 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -796,7 +796,7 @@ The required syntax is:
>  -f rtp_mpegts -fec prompeg=@var{option}=@var{val}... rtp://@var{hostname}:@var{port}
>  @end example
>
> -The destination UDP ports are @code{port + 2} for the column FEC stream
> +The default destination UDP ports are @code{port + 2} for the column FEC stream
>  and @code{port + 4} for the row FEC stream.
>
>  This protocol accepts the following options:
> @@ -808,6 +808,12 @@ The number of columns (4-20, LxD <= 100)
>  @item d=@var{n}
>  The number of rows (4-20, LxD <= 100)
>
> + at item column_port_offset=@var{n}
> +Port offset, relative to the main stream port, for the column stream
> +
> + at item row_port_offset=@var{n}
> +Port offset, relative to the main stream port, for the row stream
> +
>  @end table
>
>  Example usage:
> diff --git a/libavformat/prompeg.c b/libavformat/prompeg.c
> index 322eb6560a..398638c66d 100644
> --- a/libavformat/prompeg.c
> +++ b/libavformat/prompeg.c
> @@ -103,6 +103,8 @@ typedef struct PrompegContext {
>      URLContext *fec_col_hd, *fec_row_hd;
>      PrompegFec **fec_arr, **fec_col_tmp, **fec_col, *fec_row;
>      int ttl;
> +    int column_port_offset;
> +    int row_port_offset;
>      uint8_t l, d;
>      uint8_t *rtp_buf;
>      uint16_t rtp_col_sn, rtp_row_sn;
> @@ -123,6 +125,8 @@ static const AVOption options[] = {
>      { "ttl",   "Time to live (in milliseconds, multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = E },
>      { "l", "FEC L", OFFSET(l), AV_OPT_TYPE_INT, { .i64 =  5 }, 4, 20, .flags = E },
>      { "d", "FEC D", OFFSET(d), AV_OPT_TYPE_INT, { .i64 =  5 }, 4, 20, .flags = E },
> +    { "column_port_offset", "Port offset, relative to the main stream port, for the column stream", OFFSET(column_port_offset), AV_OPT_TYPE_INT, { .i64 =  2 }, -INT_MAX, INT_MAX, .flags = E },
> +    { "row_port_offset", "Port offset, relative to the main stream port, for the row stream", OFFSET(row_port_offset), AV_OPT_TYPE_INT, { .i64 =  4 }, -INT_MAX, INT_MAX, .flags = E },
>      { NULL }
>  };
>
> @@ -293,11 +297,11 @@ static int prompeg_open(URLContext *h, const char *uri, int flags) {
>          av_dict_set_int(&udp_opts, "ttl", s->ttl, 0);
>      }
>
> -    ff_url_join(buf, sizeof (buf), "udp", NULL, hostname, rtp_port + 2, NULL);
> +    ff_url_join(buf, sizeof (buf), "udp", NULL, hostname, rtp_port + s->column_port_offset, NULL);
>      if (ffurl_open_whitelist(&s->fec_col_hd, buf, flags, &h->interrupt_callback,
>              &udp_opts, h->protocol_whitelist, h->protocol_blacklist, h) < 0)
>          goto fail;
> -    ff_url_join(buf, sizeof (buf), "udp", NULL, hostname, rtp_port + 4, NULL);
> +    ff_url_join(buf, sizeof (buf), "udp", NULL, hostname, rtp_port + s->row_port_offset, NULL);
>      if (ffurl_open_whitelist(&s->fec_row_hd, buf, flags, &h->interrupt_callback,
>              &udp_opts, h->protocol_whitelist, h->protocol_blacklist, h) < 0)
>          goto fail;
> --
> 2.39.3 (Apple Git-146)
>


More information about the ffmpeg-devel mailing list