History

libavformat/rtpdec_opus: add fmtp parsing of sprop-maxcapturerate

Erik Linge committed 4 years ago

Commit f5663921 parent 2a180c71 file · +34 −0Browse files

Unified · Split

libavformat/rtpdec_opus.c+34−0
@@ -1,6 +1,7 @@
1/*1/*
2 * RTP Depacketization of Opus, RFC 75872 * RTP Depacketization of Opus, RFC 7587
3 * Copyright (c) 2025 Jonathan Baudanza <jon@jonb.org>3 * Copyright (c) 2025 Jonathan Baudanza <jon@jonb.org>
4 * Copyright (c) 2022 Erik Linge
4 *5 *
5 * This file is part of FFmpeg.6 * This file is part of FFmpeg.
6 *7 *
@@ -21,6 +22,7 @@ · 14 unmodified lines
21 22
22#include "libavcodec/bytestream.h"23#include "libavcodec/bytestream.h"
23#include "libavutil/mem.h"24#include "libavutil/mem.h"
25#include "libavutil/avstring.h"
24#include "rtpdec_formats.h"26#include "rtpdec_formats.h"
25#include "internal.h"27#include "internal.h"
26 28
@@ -108,10 +110,42 @@ static int opus_parse_packet(AVFormatContext *ctx, PayloadContext *data, · 81 unmodified lines
108 return 0;110 return 0;
109}111}
110 112
113static int parse_fmtp(AVFormatContext *s,
114 AVStream *stream, PayloadContext *data,
115 const char *attr, const char *value)
116{
117 if (!strcmp(attr, "sprop-maxcapturerate")) {
118 int rate = atoi(value);
119 if (rate < 8000 || rate > 48000) {
120 av_log(s, AV_LOG_ERROR,
121 "fmtp field 'sprop-maxcapturerate' must be between 8000 to 48000 (provided value: %s)",
122 value);
123 return AVERROR_INVALIDDATA;
124 }
125 stream->codecpar->sample_rate = rate;
126 }
127 return 0;
128}
129
130static int opus_parse_sdp_line(AVFormatContext *s, int st_index,
131 PayloadContext *data, const char *line)
132{
133 const char *p;
134
135 if (st_index < 0)
136 return 0;
137
138 if (av_strstart(line, "fmtp:", &p)) {
139 return ff_parse_fmtp(s, s->streams[st_index], data, p, parse_fmtp);
140 }
141 return 0;
142}
143
111const RTPDynamicProtocolHandler ff_opus_dynamic_handler = {144const RTPDynamicProtocolHandler ff_opus_dynamic_handler = {
112 .enc_name = "opus",145 .enc_name = "opus",
113 .codec_type = AVMEDIA_TYPE_AUDIO,146 .codec_type = AVMEDIA_TYPE_AUDIO,
114 .codec_id = AV_CODEC_ID_OPUS,147 .codec_id = AV_CODEC_ID_OPUS,
115 .parse_packet = opus_parse_packet,148 .parse_packet = opus_parse_packet,
116 .init = opus_init,149 .init = opus_init,
150 .parse_sdp_a_line = opus_parse_sdp_line,
117};151};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t