aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2024-03-22 06:18:49 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2024-06-15 05:20:19 +0200
commit33cf4047fffbb603a38992ab1e60be9ebf7741bf (patch)
treeda4fbab203e1a0be4f662ef77b3b1c63ca8cd71c
parenta8f3ed9671bbf6b5799f4c0bb9a836aea7996762 (diff)
-rw-r--r--src/libosmo-sdp/sdp_msg.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/libosmo-sdp/sdp_msg.c b/src/libosmo-sdp/sdp_msg.c
index 775cd3ae2..94e4be272 100644
--- a/src/libosmo-sdp/sdp_msg.c
+++ b/src/libosmo-sdp/sdp_msg.c
@@ -170,7 +170,7 @@ int sdp_parse_attrib(struct osmo_sdp_msg *sdp, const char *src)
if (str_is_attrib(src, OSMO_SDP_STR_RTPMAP, ':')) {
/* "a=rtpmap:96 AMR/8000" */
struct token audio_name;
- unsigned int channels = 1;
+ const char *slash;
if (sscanf(src, OSMO_SDP_STR_RTPMAP ":%u", &payload_type) != 1)
return -EINVAL;
@@ -183,16 +183,22 @@ int sdp_parse_attrib(struct osmo_sdp_msg *sdp, const char *src)
if (audio_name.start >= get_line_end(src))
return -EINVAL;
- audio_name.end = strchr(audio_name.start, '/');
- if (!audio_name.end || audio_name.end > line_end)
- audio_name.end = line_end;
+ slash = strchr(audio_name.start, '/');
+
+ audio_name.end = slash ? : line_end;
token_copy(codec, &codec->encoding_name, &audio_name);
- /* '< 1' is enough, the second '/%u' is optional */
- if (sscanf(audio_name.end, "/%u/%u", &codec->rate, &channels) < 1)
- return -EINVAL;
- if (channels != 1)
- return -ENOTSUP;
+ if (audio_name.end >= line_end) {
+ /* There should be a "/8000" here. If it is missing, let's not be strict about it. */
+ codec->rate = 8000;
+ } else {
+ unsigned int channels = 1;
+ if (sscanf(audio_name.end, "/%u/%u", &codec->rate, &channels) < 1)
+ return -EINVAL;
+
+ if (channels != 1)
+ return -ENOTSUP;
+ }
}
else if (str_is_attrib(src, OSMO_SDP_STR_FMTP, ':')) {