From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 5427E4BEBB for ; Thu, 22 May 2025 19:56:00 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 877FF68DD9B; Thu, 22 May 2025 22:55:56 +0300 (EEST) Received: from mail-4319.protonmail.ch (mail-4319.protonmail.ch [185.70.43.19]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 99DC268DD46 for ; Thu, 22 May 2025 22:55:50 +0300 (EEST) Date: Thu, 22 May 2025 19:55:42 +0000 To: FFmpeg development discussions and patches Message-ID: In-Reply-To: <20250505200743.5231-1-epirat07@gmail.com> References: <20250505200743.5231-1-epirat07@gmail.com> Feedback-ID: 32895411:user:proton X-Pm-Message-ID: 872382600c0e0e29207b1744e4583ea30362674e MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 1/2] rtpdec: add fmtp parsing of sprop-maxcapturerate for opus X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tristan Matthews via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Tristan Matthews , Marvin Scholz Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Hi, On Monday, May 5th, 2025 at 4:07 PM, Marvin Scholz 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".