Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDP support for <proto> udp #538

Merged
merged 1 commit into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/re_fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ void str_ncpy(char *dst, const char *src, size_t n);
int str_dup(char **dst, const char *src);
int str_x64dup(char **dst, uint64_t val);
int str_cmp(const char *s1, const char *s2);
int str_ncmp(const char *s1, const char *s2, size_t n);
const char *str_str(const char *s1, const char *s2);
int str_casecmp(const char *s1, const char *s2);
size_t str_len(const char *s);
const char *str_error(int errnum, char *buf, size_t sz);
Expand Down
37 changes: 37 additions & 0 deletions src/fmt/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,43 @@ int str_cmp(const char *s1, const char *s2)
}


/**
* Compare two 0-terminated strings up to n positions
*
* @param s1 First string
* @param s2 Second string
*
* @return an integer less than, equal to, or greater than zero if s1 is found
* respectively, to be less than, to match, or be greater than s2 in
* the first n positions
*/
int str_ncmp(const char *s1, const char *s2, size_t n)
{
if (!s1 || !s2)
return 1;

return strncmp(s1, s2, n);
}


/**
* Check if one 0-terminated string contains another
*
* @param s1 First string
* @param s2 Second string
*
* @return a position in s1 where it contains s2 as a substring, or NULL
* if s2 does not occur inside s1
*/
const char *str_str(const char *s1, const char *s2)
{
if (!s1 || !s2)
return NULL;

return strstr(s1, s2);
}


/**
* Compare two 0-terminated strings, ignoring case
*
Expand Down
15 changes: 10 additions & 5 deletions src/sdp/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,18 @@ static int media_encode(const struct sdp_media *m, struct mbuf *mb, bool offer)
if (!fmt->sup && !offer)
continue;

err |= mbuf_printf(mb, "a=rtpmap:%s %s/%u",
fmt->id, fmt->name, fmt->srate);
if ((str_ncmp(m->proto, "RTP/", 4) == 0) ||
(str_str(m->proto, "/RTP/") != NULL)) {

if (fmt->ch > 1)
err |= mbuf_printf(mb, "/%u", fmt->ch);
err |= mbuf_printf(mb, "a=rtpmap:%s %s/%u",
fmt->id, fmt->name, fmt->srate);

err |= mbuf_printf(mb, "\r\n");
if (fmt->ch > 1)
err |= mbuf_printf(mb, "/%u", fmt->ch);

err |= mbuf_printf(mb, "\r\n");

}

if (str_isset(fmt->params))
err |= mbuf_printf(mb, "a=fmtp:%s %s\r\n",
Expand Down