diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2024-03-22 06:18:49 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2024-06-15 05:20:19 +0200 |
commit | 33cf4047fffbb603a38992ab1e60be9ebf7741bf (patch) | |
tree | da4fbab203e1a0be4f662ef77b3b1c63ca8cd71c | |
parent | a8f3ed9671bbf6b5799f4c0bb9a836aea7996762 (diff) |
wipneels/sdp
Change-Id: I4e3fbcf85f3e1867aeb577681c7e32a01e56f2c4
-rw-r--r-- | src/libosmo-sdp/sdp_msg.c | 24 |
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, ':')) { |