From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 552004E657 for ; Mon, 5 May 2025 20:07:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 22143687DEF; Mon, 5 May 2025 23:07:52 +0300 (EEST) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1849C687DDC for ; Mon, 5 May 2025 23:07:46 +0300 (EEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-39ee682e0ddso3273350f8f.1 for ; Mon, 05 May 2025 13:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746475665; x=1747080465; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FiBwt70FmwQ/lCDNoKzwSUx8yNzaSD65w5/USA+C5BU=; b=N/SZZTvm0hBpTeGazBz3ik/z+ZMBmfsKocToS6SILJDkQ/LGOKa/tanadpE5GzlMsS gYLt+BelxzQemg4erLbz0ChIzBQzXsaIKwO7E9V9ny+KTdP0qwvbcL9WmhdI6T+MU3Nj DfA+AZbRKDzYoKxAoATtJE6KgZ/cKhEag7J2uAOJ6jLmOlO4TyUzBuuYicHnrwyVDWfv 1/ead6FWXslPFxqTNDbS9XfucXN/Bebf5xadUVtJXB316WmCAMyB7a0Pfhb0hSGfhF+X 4Dlq7sspo/yvUwJcxCYd/9kgJCdPCZhpQTuGrZe0M3I7aNoJQVii13tlurenSk2PI08S HWNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746475665; x=1747080465; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FiBwt70FmwQ/lCDNoKzwSUx8yNzaSD65w5/USA+C5BU=; b=i0CJLDlpVV5AmQ9fWcQ/W4OC2d2Bmu/pUBo9spsD7UVGnqmLioGIpWP9YceGh23SBH vsMObAfPTd5hvpyh5lyR0W0ewAFfw5GoEh+HtXXtmJIOHEGy63nJ9TdqnKZ9a3/jT9Y6 Mf6aEYxtg9ZE1gLZyJ8dWwAVd626n4jLUaFznkk4uTU648QEl1SdoaQGAdACCZfW+Xes UCer4A7JbPmvXjo+fFHZjNeJJtqQiM0pM6R7ZjTssubz/YKZQtXyPvBw0jYKFIB8mLk+ QHUoE02rMemQ7V8HZpfCynFdx4/Y3T1WGm+XXHcwLy5b3pcFnL10tCaz7Y29W7n4kxvA NMhw== X-Gm-Message-State: AOJu0Yxlb6GEQWdLWvYTKZ3j+mlXC0EUHlesobWqjtQBn2wrepHgtNEv WQzXgShY8dZvuun0ySVOGuEKq0R4RDvjxRJPqnplia5fp4QxGqqLccTxzQ== X-Gm-Gg: ASbGncs5eEXg2WjMSP3ehq6NkoFhiiEB+gfDkjBMkYfJTnfPItJYOMWL7Y5GpTzvjD9 Pi+MGNNe4NPKDp7pvcScypo3ydXvuKBiqJBpahP67YdqSyOy9FOS4QXU8oD4HCsJBIiZl1JXN1d TGeW6BW4gZVHTdHcm4UbDy9rKzyG8pZq/9r5+GlS2AtHz4CYcIz1RfrX/7Yei8vf5hQlLxI1jIb hC9ZgJGbI1uDrfhM+CwGLb436SC4ruw5vZ/jGEO7Qdim+LLuTSxhPowN40nfq80R9oFZZRhp7BU 4sXlPrDXSxzN2eaJCJRSznMEgPodaEd5i7bohDPP7ebSsyNRwnpUeAJSOrLL1HABgq26Qx7Bjwf ccRiirnTf3hb3KnMqcXYOy8aNQPzEFCOGbrNQGR2yDrwhRfrdn6ZhxGCMog== X-Google-Smtp-Source: AGHT+IF6MwgILVUmPIqKtKuvP8FLnpu4icLyJqxgebTt0EAIFrLlYHqqyblh6Kb1bxaioLpcZYYwWA== X-Received: by 2002:a05:6000:40cb:b0:391:2e6a:30fe with SMTP id ffacd0b85a97d-3a0ac1ff1f4mr224498f8f.39.1746475665084; Mon, 05 May 2025 13:07:45 -0700 (PDT) Received: from ArmedBeast.fritz.box (p200300cccf18bd00811c809c8443f68f.dip0.t-ipconnect.de. [2003:cc:cf18:bd00:811c:809c:8443:f68f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a099b170b8sm11112590f8f.82.2025.05.05.13.07.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 05 May 2025 13:07:44 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 May 2025 22:07:42 +0200 Message-Id: <20250505200743.5231-1-epirat07@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) MIME-Version: 1.0 Subject: [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: , Reply-To: FFmpeg development discussions and patches Cc: 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: From: Erik Linge Co-authored-by: Marvin Scholz Signed-off-by: Marvin Scholz --- 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) _______________________________________________ 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".