From: Tristan Matthews via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Tristan Matthews <httamt@protonmail.com>,
Marvin Scholz <epirat07@gmail.com>
Subject: Re: [FFmpeg-devel] [PATCH 1/2] rtpdec: add fmtp parsing of sprop-maxcapturerate for opus
Date: Thu, 22 May 2025 19:55:42 +0000
Message-ID: <O100lykjhXTLtu6tQju5aKstb2aX2dYScG8MhaSesbOSPMJNRJMuoyC0wEEQbIyUr7kWmH5wh4GFJ36MwXPc62L71fHWhz1ITU-KTVlOMaQ=@protonmail.com> (raw)
In-Reply-To: <20250505200743.5231-1-epirat07@gmail.com>
Hi,
On Monday, May 5th, 2025 at 4:07 PM, Marvin Scholz <epirat07@gmail.com> wrote:
> From: Erik Linge erikli@axis.com
>
>
> Co-authored-by: Marvin Scholz epirat07@gmail.com
>
> Signed-off-by: Marvin Scholz epirat07@gmail.com
>
> ---
> libavformat/Makefile | 1 +
> libavformat/rtpdec.c | 8 +----
> libavformat/rtpdec_formats.h | 1 +
> libavformat/rtpdec_opus.c | 62 ++++++++++++++++++++++++++++++++++++
> 4 files changed, 65 insertions(+), 7 deletions(-)
> create mode 100644 libavformat/rtpdec_opus.c
>
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 6c9992adab..ee68345858 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -62,6 +62,7 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \
> rtpdec_mpeg12.o \
> rtpdec_mpeg4.o \
> rtpdec_mpegts.o \
> + rtpdec_opus.o \
> rtpdec_qcelp.o \
> rtpdec_qdm2.o \
> rtpdec_qt.o \
> diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
> index a7d5a79a83..10e9502ae2 100644
> --- a/libavformat/rtpdec.c
> +++ b/libavformat/rtpdec.c
> @@ -61,12 +61,6 @@ static const RTPDynamicProtocolHandler speex_dynamic_handler = {
> .codec_id = AV_CODEC_ID_SPEEX,
> };
>
> -static const RTPDynamicProtocolHandler opus_dynamic_handler = {
> - .enc_name = "opus",
> - .codec_type = AVMEDIA_TYPE_AUDIO,
> - .codec_id = AV_CODEC_ID_OPUS,
> -};
> -
> static const RTPDynamicProtocolHandler t140_dynamic_handler = { /* RFC 4103 */
> .enc_name = "t140",
> .codec_type = AVMEDIA_TYPE_SUBTITLE,
> @@ -110,6 +104,7 @@ static const RTPDynamicProtocolHandler *const rtp_dynamic_protocol_handler_list[
> &ff_mpegts_dynamic_handler,
> &ff_ms_rtp_asf_pfa_handler,
> &ff_ms_rtp_asf_pfv_handler,
> + &ff_opus_dynamic_handler,
> &ff_qcelp_dynamic_handler,
> &ff_qdm2_dynamic_handler,
> &ff_qt_rtp_aud_handler,
> @@ -125,7 +120,6 @@ static const RTPDynamicProtocolHandler const rtp_dynamic_protocol_handler_list[
> &ff_vp9_dynamic_handler,
> &gsm_dynamic_handler,
> &l24_dynamic_handler,
> - &opus_dynamic_handler,
> &realmedia_mp3_dynamic_handler,
> &speex_dynamic_handler,
> &t140_dynamic_handler,
> diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h
> index 72a8f16a90..1ff2a72d2a 100644
> --- a/libavformat/rtpdec_formats.h
> +++ b/libavformat/rtpdec_formats.h
> @@ -77,6 +77,7 @@ extern const RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler;
> extern const RTPDynamicProtocolHandler ff_mpegts_dynamic_handler;
> extern const RTPDynamicProtocolHandler ff_ms_rtp_asf_pfa_handler;
> extern const RTPDynamicProtocolHandler ff_ms_rtp_asf_pfv_handler;
> +extern const RTPDynamicProtocolHandler ff_opus_dynamic_handler;
> extern const RTPDynamicProtocolHandler ff_qcelp_dynamic_handler;
> extern const RTPDynamicProtocolHandler ff_qdm2_dynamic_handler;
> extern const RTPDynamicProtocolHandler ff_qt_rtp_aud_handler;
> diff --git a/libavformat/rtpdec_opus.c b/libavformat/rtpdec_opus.c
> new file mode 100644
> index 0000000000..60ff2244b6
> --- /dev/null
> +++ b/libavformat/rtpdec_opus.c
> @@ -0,0 +1,62 @@
> +/
> + * RTP OPUS Depacketizer, RFC 7587
> + * Copyright (c) 2022 Erik Linge
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "avformat.h"
> +#include "rtpdec_formats.h"
> +#include "libavutil/avstring.h"
> +
> +static int parse_fmtp(AVFormatContext *s,
> + AVStream *stream, PayloadContext *data,
> + const char *attr, const char *value)
> +{
> + if (!strcmp(attr, "sprop-maxcapturerate")) {
> + int rate = atoi(value);
> + if (rate < 8000 || rate > 48000) {
>
> + av_log(s, AV_LOG_ERROR,
> + "fmtp field 'sprop-maxcapturerate' must be between 8000 to 48000 (provided value: %s)",
> + value);
> + return AVERROR_INVALIDDATA;
> + }
> + stream->codecpar->sample_rate = rate;
>
> + }
> + return 0;
> +}
> +
> +static int opus_parse_sdp_line(AVFormatContext *s, int st_index,
> + PayloadContext *data, const char *line)
> +{
> + const char *p;
> +
> + if (st_index < 0)
> + return 0;
> +
> + if (av_strstart(line, "fmtp:", &p)) {
> + return ff_parse_fmtp(s, s->streams[st_index], data, p, parse_fmtp);
>
> + }
> + return 0;
> +}
> +
> +const RTPDynamicProtocolHandler ff_opus_dynamic_handler = {
> + .enc_name = "opus",
> + .codec_type = AVMEDIA_TYPE_AUDIO,
> + .codec_id = AV_CODEC_ID_OPUS,
> + .parse_sdp_a_line = opus_parse_sdp_line,
> +};
> --
> 2.39.5 (Apple Git-154)
LGTM.
Best,
Tristan
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2025-05-22 19:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 20:07 Marvin Scholz
2025-05-05 20:07 ` [FFmpeg-devel] [PATCH 2/2] rtpdec: Set bitrate for pcm-mulaw audio Marvin Scholz
2025-05-22 19:55 ` Tristan Matthews via ffmpeg-devel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='O100lykjhXTLtu6tQju5aKstb2aX2dYScG8MhaSesbOSPMJNRJMuoyC0wEEQbIyUr7kWmH5wh4GFJ36MwXPc62L71fHWhz1ITU-KTVlOMaQ=@protonmail.com' \
--to=ffmpeg-devel@ffmpeg.org \
--cc=epirat07@gmail.com \
--cc=httamt@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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