sdp_msg: s/_name_/_to_str_/g
foo_name is intended for a short id, foo_to_str is more accurate naming here. Related: SYS#5066 Change-Id: I21d73b2e2633dd4841ff69a0c5fdf9b1a4c0615fchanges/81/28781/2
parent
90933d46ba
commit
9a515e5db0
|
@ -52,17 +52,17 @@ void sdp_audio_codecs_intersection(struct sdp_audio_codecs *ac_dest, const struc
|
|||
bool translate_payload_type_numbers);
|
||||
void sdp_audio_codecs_select(struct sdp_audio_codecs *ac, struct sdp_audio_codec *codec);
|
||||
|
||||
int sdp_msg_to_str(char *dst, size_t dst_size, const struct sdp_msg *sdp);
|
||||
int sdp_msg_from_str(struct sdp_msg *sdp, const char *src);
|
||||
int sdp_msg_to_sdp_str_buf(char *dst, size_t dst_size, const struct sdp_msg *sdp);
|
||||
int sdp_msg_from_sdp_str(struct sdp_msg *sdp, const char *src);
|
||||
|
||||
int sdp_audio_codec_name_buf(char *buf, size_t buflen, const struct sdp_audio_codec *codec);
|
||||
char *sdp_audio_codec_name_c(void *ctx, const struct sdp_audio_codec *codec);
|
||||
const char *sdp_audio_codec_name(const struct sdp_audio_codec *codec);
|
||||
int sdp_audio_codec_to_str_buf(char *buf, size_t buflen, const struct sdp_audio_codec *codec);
|
||||
char *sdp_audio_codec_to_str_c(void *ctx, const struct sdp_audio_codec *codec);
|
||||
const char *sdp_audio_codec_to_str(const struct sdp_audio_codec *codec);
|
||||
|
||||
int sdp_audio_codecs_name_buf(char *buf, size_t buflen, const struct sdp_audio_codecs *ac);
|
||||
char *sdp_audio_codecs_name_c(void *ctx, const struct sdp_audio_codecs *ac);
|
||||
const char *sdp_audio_codecs_name(const struct sdp_audio_codecs *ac);
|
||||
int sdp_audio_codecs_to_str_buf(char *buf, size_t buflen, const struct sdp_audio_codecs *ac);
|
||||
char *sdp_audio_codecs_to_str_c(void *ctx, const struct sdp_audio_codecs *ac);
|
||||
const char *sdp_audio_codecs_to_str(const struct sdp_audio_codecs *ac);
|
||||
|
||||
int sdp_msg_name_buf(char *buf, size_t buflen, const struct sdp_msg *sdp);
|
||||
char *sdp_msg_name_c(void *ctx, const struct sdp_msg *sdp);
|
||||
const char *sdp_msg_name(const struct sdp_msg *sdp);
|
||||
int sdp_msg_to_str_buf(char *buf, size_t buflen, const struct sdp_msg *sdp);
|
||||
char *sdp_msg_to_str_c(void *ctx, const struct sdp_msg *sdp);
|
||||
const char *sdp_msg_to_str(const struct sdp_msg *sdp);
|
||||
|
|
|
@ -163,7 +163,7 @@ int sdp_audio_codec_remove(struct sdp_audio_codecs *ac, const struct sdp_audio_c
|
|||
}
|
||||
|
||||
/* Convert struct sdp_msg to the actual SDP protocol representation */
|
||||
int sdp_msg_to_str(char *dst, size_t dst_size, const struct sdp_msg *sdp)
|
||||
int sdp_msg_to_sdp_str_buf(char *dst, size_t dst_size, const struct sdp_msg *sdp)
|
||||
{
|
||||
const struct sdp_audio_codec *codec;
|
||||
struct osmo_strbuf sb = { .buf = dst, .len = dst_size };
|
||||
|
@ -383,7 +383,7 @@ static int sdp_parse_connection_info(struct sdp_msg *sdp, const char *src)
|
|||
}
|
||||
|
||||
/* Parse SDP string into struct sdp_msg. Return 0 on success, negative on error. */
|
||||
int sdp_msg_from_str(struct sdp_msg *sdp, const char *src)
|
||||
int sdp_msg_from_sdp_str(struct sdp_msg *sdp, const char *src)
|
||||
{
|
||||
const char *pos;
|
||||
*sdp = (struct sdp_msg){};
|
||||
|
@ -505,7 +505,7 @@ void sdp_audio_codecs_select(struct sdp_audio_codecs *ac, struct sdp_audio_codec
|
|||
|
||||
/* Short single-line representation of an SDP audio codec, convenient for logging.
|
||||
* Like "AMR/8000:octet-align=1#122" */
|
||||
int sdp_audio_codec_name_buf(char *buf, size_t buflen, const struct sdp_audio_codec *codec)
|
||||
int sdp_audio_codec_to_str_buf(char *buf, size_t buflen, const struct sdp_audio_codec *codec)
|
||||
{
|
||||
struct osmo_strbuf sb = { .buf = buf, .len = buflen };
|
||||
OSMO_STRBUF_PRINTF(sb, "%s", codec->subtype_name);
|
||||
|
@ -514,18 +514,18 @@ int sdp_audio_codec_name_buf(char *buf, size_t buflen, const struct sdp_audio_co
|
|||
return sb.chars_needed;
|
||||
}
|
||||
|
||||
char *sdp_audio_codec_name_c(void *ctx, const struct sdp_audio_codec *codec)
|
||||
char *sdp_audio_codec_to_str_c(void *ctx, const struct sdp_audio_codec *codec)
|
||||
{
|
||||
OSMO_NAME_C_IMPL(ctx, 32, "sdp_audio_codec_name_c-ERROR", sdp_audio_codec_name_buf, codec)
|
||||
OSMO_NAME_C_IMPL(ctx, 32, "sdp_audio_codec_to_str_c-ERROR", sdp_audio_codec_to_str_buf, codec)
|
||||
}
|
||||
|
||||
const char *sdp_audio_codec_name(const struct sdp_audio_codec *codec)
|
||||
const char *sdp_audio_codec_to_str(const struct sdp_audio_codec *codec)
|
||||
{
|
||||
return sdp_audio_codec_name_c(OTC_SELECT, codec);
|
||||
return sdp_audio_codec_to_str_c(OTC_SELECT, codec);
|
||||
}
|
||||
|
||||
/* Short single-line representation of a list of SDP audio codecs, convenient for logging */
|
||||
int sdp_audio_codecs_name_buf(char *buf, size_t buflen, const struct sdp_audio_codecs *ac)
|
||||
int sdp_audio_codecs_to_str_buf(char *buf, size_t buflen, const struct sdp_audio_codecs *ac)
|
||||
{
|
||||
struct osmo_strbuf sb = { .buf = buf, .len = buflen };
|
||||
const struct sdp_audio_codec *codec;
|
||||
|
@ -535,23 +535,23 @@ int sdp_audio_codecs_name_buf(char *buf, size_t buflen, const struct sdp_audio_c
|
|||
bool first = (codec == ac->codec);
|
||||
if (!first)
|
||||
OSMO_STRBUF_PRINTF(sb, ",");
|
||||
OSMO_STRBUF_APPEND(sb, sdp_audio_codec_name_buf, codec);
|
||||
OSMO_STRBUF_APPEND(sb, sdp_audio_codec_to_str_buf, codec);
|
||||
}
|
||||
return sb.chars_needed;
|
||||
}
|
||||
|
||||
char *sdp_audio_codecs_name_c(void *ctx, const struct sdp_audio_codecs *ac)
|
||||
char *sdp_audio_codecs_to_str_c(void *ctx, const struct sdp_audio_codecs *ac)
|
||||
{
|
||||
OSMO_NAME_C_IMPL(ctx, 128, "sdp_audio_codecs_name_c-ERROR", sdp_audio_codecs_name_buf, ac)
|
||||
OSMO_NAME_C_IMPL(ctx, 128, "sdp_audio_codecs_to_str_c-ERROR", sdp_audio_codecs_to_str_buf, ac)
|
||||
}
|
||||
|
||||
const char *sdp_audio_codecs_name(const struct sdp_audio_codecs *ac)
|
||||
const char *sdp_audio_codecs_to_str(const struct sdp_audio_codecs *ac)
|
||||
{
|
||||
return sdp_audio_codecs_name_c(OTC_SELECT, ac);
|
||||
return sdp_audio_codecs_to_str_c(OTC_SELECT, ac);
|
||||
}
|
||||
|
||||
/* Short single-line representation of an SDP message, convenient for logging */
|
||||
int sdp_msg_name_buf(char *buf, size_t buflen, const struct sdp_msg *sdp)
|
||||
int sdp_msg_to_str_buf(char *buf, size_t buflen, const struct sdp_msg *sdp)
|
||||
{
|
||||
struct osmo_strbuf sb = { .buf = buf, .len = buflen };
|
||||
if (!sdp) {
|
||||
|
@ -561,17 +561,17 @@ int sdp_msg_name_buf(char *buf, size_t buflen, const struct sdp_msg *sdp)
|
|||
|
||||
OSMO_STRBUF_PRINTF(sb, OSMO_SOCKADDR_STR_FMT, OSMO_SOCKADDR_STR_FMT_ARGS(&sdp->rtp));
|
||||
OSMO_STRBUF_PRINTF(sb, "{");
|
||||
OSMO_STRBUF_APPEND(sb, sdp_audio_codecs_name_buf, &sdp->audio_codecs);
|
||||
OSMO_STRBUF_APPEND(sb, sdp_audio_codecs_to_str_buf, &sdp->audio_codecs);
|
||||
OSMO_STRBUF_PRINTF(sb, "}");
|
||||
return sb.chars_needed;
|
||||
}
|
||||
|
||||
char *sdp_msg_name_c(void *ctx, const struct sdp_msg *sdp)
|
||||
char *sdp_msg_to_str_c(void *ctx, const struct sdp_msg *sdp)
|
||||
{
|
||||
OSMO_NAME_C_IMPL(ctx, 128, "sdp_msg_name_c-ERROR", sdp_msg_name_buf, sdp)
|
||||
OSMO_NAME_C_IMPL(ctx, 128, "sdp_msg_to_str_c-ERROR", sdp_msg_to_str_buf, sdp)
|
||||
}
|
||||
|
||||
const char *sdp_msg_name(const struct sdp_msg *sdp)
|
||||
const char *sdp_msg_to_str(const struct sdp_msg *sdp)
|
||||
{
|
||||
return sdp_msg_name_c(OTC_SELECT, sdp);
|
||||
return sdp_msg_to_str_c(OTC_SELECT, sdp);
|
||||
}
|
||||
|
|
|
@ -134,10 +134,10 @@ void test_parse_and_compose()
|
|||
printf("\n[%d]\n", i);
|
||||
dump_sdp(t->sdp_input, "sdp input: ");
|
||||
|
||||
sdp_msg_from_str(&sdp, t->sdp_input);
|
||||
sdp_msg_to_str(str, sizeof(str), &sdp);
|
||||
sdp_msg_from_sdp_str(&sdp, t->sdp_input);
|
||||
sdp_msg_to_sdp_str_buf(str, sizeof(str), &sdp);
|
||||
|
||||
dump_sdp(str, "sdp_msg_to_str: ");
|
||||
dump_sdp(str, "sdp_msg_to_sdp_str_buf: ");
|
||||
if (strcmp(str, t->expect_sdp_str)) {
|
||||
int j;
|
||||
ok = false;
|
||||
|
@ -344,7 +344,7 @@ struct sdp_intersect_test_data sdp_intersect_tests[] = {
|
|||
const char *sdp_msg_logstr(const struct sdp_msg *sdp)
|
||||
{
|
||||
static char buf[1024];
|
||||
sdp_msg_to_str(buf, sizeof(buf), sdp);
|
||||
sdp_msg_to_sdp_str_buf(buf, sizeof(buf), sdp);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -365,20 +365,20 @@ static void test_intersect()
|
|||
dump_sdp(t->sdp_a, "SDP A: ");
|
||||
dump_sdp(t->sdp_b, " SDP B: ");
|
||||
|
||||
rc = sdp_msg_from_str(&sdp_a, t->sdp_a);
|
||||
rc = sdp_msg_from_sdp_str(&sdp_a, t->sdp_a);
|
||||
if (rc) {
|
||||
printf("ERROR parsing SDP A: %d\n", rc);
|
||||
break;
|
||||
}
|
||||
dump_sdp(sdp_msg_logstr(&sdp_a), "parsed SDP A: ");
|
||||
rc = sdp_msg_from_str(&sdp_b, t->sdp_b);
|
||||
rc = sdp_msg_from_sdp_str(&sdp_b, t->sdp_b);
|
||||
if (rc) {
|
||||
printf("ERROR parsing SDP A: %d\n", rc);
|
||||
break;
|
||||
}
|
||||
dump_sdp(sdp_msg_logstr(&sdp_b), "parsed SDP B: ");
|
||||
sdp_audio_codecs_intersection(&sdp_a.audio_codecs, &sdp_b.audio_codecs, false);
|
||||
sdp_msg_to_str(str, sizeof(str), &sdp_a);
|
||||
sdp_msg_to_sdp_str_buf(str, sizeof(str), &sdp_a);
|
||||
|
||||
dump_sdp(str, "sdp_msg_intersection(a,b): ");
|
||||
if (strcmp(str, t->expect_intersection)) {
|
||||
|
@ -525,20 +525,20 @@ static void test_select()
|
|||
struct sdp_audio_codec *codec;
|
||||
char buf[1024];
|
||||
printf("\n[%d]\n", i);
|
||||
rc = sdp_msg_from_str(&sdp, t->sdp);
|
||||
rc = sdp_msg_from_sdp_str(&sdp, t->sdp);
|
||||
if (rc) {
|
||||
printf("ERROR parsing SDP: %d\n", rc);
|
||||
break;
|
||||
}
|
||||
printf("SDP: %s\n", sdp_audio_codecs_name(&sdp.audio_codecs));
|
||||
printf("SDP: %s\n", sdp_audio_codecs_to_str(&sdp.audio_codecs));
|
||||
codec = sdp_audio_codec_by_payload_type(&sdp.audio_codecs, t->select_payload_type, false);
|
||||
OSMO_ASSERT(codec);
|
||||
printf("Select: %s\n", sdp_audio_codec_name(codec));
|
||||
printf("Select: %s\n", sdp_audio_codec_to_str(codec));
|
||||
|
||||
sdp_audio_codecs_select(&sdp.audio_codecs, codec);
|
||||
|
||||
printf("SDP: %s\n", sdp_audio_codecs_name(&sdp.audio_codecs));
|
||||
sdp_msg_to_str(buf, sizeof(buf), &sdp);
|
||||
printf("SDP: %s\n", sdp_audio_codecs_to_str(&sdp.audio_codecs));
|
||||
sdp_msg_to_sdp_str_buf(buf, sizeof(buf), &sdp);
|
||||
|
||||
if (strcmp(buf, t->expect_sdp ? : t->sdp)) {
|
||||
int j;
|
||||
|
|
|
@ -23,25 +23,25 @@ sdp input: a=rtpmap:101 telephone-event/8000\r\n
|
|||
sdp input: a=fmtp:101 0-15\r\n
|
||||
sdp input: a=ptime:20\r\n
|
||||
sdp input: a=sendrecv\r\n
|
||||
sdp_msg_to_str: v=0\r\n
|
||||
sdp_msg_to_str: o=OsmoMSC 0 0 IN IP4 192.168.11.121\r\n
|
||||
sdp_msg_to_str: s=GSM Call\r\n
|
||||
sdp_msg_to_str: c=IN IP4 192.168.11.121\r\n
|
||||
sdp_msg_to_str: t=0 0\r\n
|
||||
sdp_msg_to_str: m=audio 10020 RTP/AVP 18 0 2 4 8 96 97 98 100 101\r\n
|
||||
sdp_msg_to_str: a=rtpmap:18 G729/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:0 PCMU/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:2 G726-32/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:4 G723/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:8 PCMA/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:96 G726-40/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:97 G726-24/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:98 G726-16/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:100 NSE/8000\r\n
|
||||
sdp_msg_to_str: a=fmtp:100 192-193\r\n
|
||||
sdp_msg_to_str: a=rtpmap:101 telephone-event/8000\r\n
|
||||
sdp_msg_to_str: a=fmtp:101 0-15\r\n
|
||||
sdp_msg_to_str: a=ptime:20\r\n
|
||||
sdp_msg_to_sdp_str_buf: v=0\r\n
|
||||
sdp_msg_to_sdp_str_buf: o=OsmoMSC 0 0 IN IP4 192.168.11.121\r\n
|
||||
sdp_msg_to_sdp_str_buf: s=GSM Call\r\n
|
||||
sdp_msg_to_sdp_str_buf: c=IN IP4 192.168.11.121\r\n
|
||||
sdp_msg_to_sdp_str_buf: t=0 0\r\n
|
||||
sdp_msg_to_sdp_str_buf: m=audio 10020 RTP/AVP 18 0 2 4 8 96 97 98 100 101\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:18 G729/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:0 PCMU/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:2 G726-32/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:4 G723/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:8 PCMA/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:96 G726-40/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:97 G726-24/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:98 G726-16/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:100 NSE/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=fmtp:100 192-193\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:101 telephone-event/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=fmtp:101 0-15\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=ptime:20\r\n
|
||||
[0] ok
|
||||
|
||||
[1]
|
||||
|
@ -55,15 +55,15 @@ sdp input: a=rtpmap:98 AMR/8000\r\n
|
|||
sdp input: a=fmtp:98 octet-align=1; mode-set=4\r\n
|
||||
sdp input: a=ptime:20\r\n
|
||||
sdp input: a=rtcp:16399 IN IP4 192.168.11.151\r\n
|
||||
sdp_msg_to_str: v=0\r\n
|
||||
sdp_msg_to_str: o=OsmoMSC 0 0 IN IP4 192.168.11.151\r\n
|
||||
sdp_msg_to_str: s=GSM Call\r\n
|
||||
sdp_msg_to_str: c=IN IP4 192.168.11.151\r\n
|
||||
sdp_msg_to_str: t=0 0\r\n
|
||||
sdp_msg_to_str: m=audio 16398 RTP/AVP 98\r\n
|
||||
sdp_msg_to_str: a=rtpmap:98 AMR/8000\r\n
|
||||
sdp_msg_to_str: a=fmtp:98 octet-align=1; mode-set=4\r\n
|
||||
sdp_msg_to_str: a=ptime:20\r\n
|
||||
sdp_msg_to_sdp_str_buf: v=0\r\n
|
||||
sdp_msg_to_sdp_str_buf: o=OsmoMSC 0 0 IN IP4 192.168.11.151\r\n
|
||||
sdp_msg_to_sdp_str_buf: s=GSM Call\r\n
|
||||
sdp_msg_to_sdp_str_buf: c=IN IP4 192.168.11.151\r\n
|
||||
sdp_msg_to_sdp_str_buf: t=0 0\r\n
|
||||
sdp_msg_to_sdp_str_buf: m=audio 16398 RTP/AVP 98\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:98 AMR/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=fmtp:98 octet-align=1; mode-set=4\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=ptime:20\r\n
|
||||
[1] ok
|
||||
|
||||
[2]
|
||||
|
@ -82,19 +82,19 @@ sdp input: a=fmtp:101 0-15\r\n
|
|||
sdp input: a=sendrecv\r\n
|
||||
sdp input: a=rtcp:30437\r\n
|
||||
sdp input: a=ptime:20\r\n
|
||||
sdp_msg_to_str: v=0\r\n
|
||||
sdp_msg_to_str: o=OsmoMSC 0 0 IN IP4 192.168.11.140\r\n
|
||||
sdp_msg_to_str: s=GSM Call\r\n
|
||||
sdp_msg_to_str: c=IN IP4 192.168.11.140\r\n
|
||||
sdp_msg_to_str: t=0 0\r\n
|
||||
sdp_msg_to_str: m=audio 30436 RTP/AVP 18 0 4 8 101\r\n
|
||||
sdp_msg_to_str: a=rtpmap:18 G729/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:0 PCMU/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:4 G723/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:8 PCMA/8000\r\n
|
||||
sdp_msg_to_str: a=rtpmap:101 telephone-event/8000\r\n
|
||||
sdp_msg_to_str: a=fmtp:101 0-15\r\n
|
||||
sdp_msg_to_str: a=ptime:20\r\n
|
||||
sdp_msg_to_sdp_str_buf: v=0\r\n
|
||||
sdp_msg_to_sdp_str_buf: o=OsmoMSC 0 0 IN IP4 192.168.11.140\r\n
|
||||
sdp_msg_to_sdp_str_buf: s=GSM Call\r\n
|
||||
sdp_msg_to_sdp_str_buf: c=IN IP4 192.168.11.140\r\n
|
||||
sdp_msg_to_sdp_str_buf: t=0 0\r\n
|
||||
sdp_msg_to_sdp_str_buf: m=audio 30436 RTP/AVP 18 0 4 8 101\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:18 G729/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:0 PCMU/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:4 G723/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:8 PCMA/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=rtpmap:101 telephone-event/8000\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=fmtp:101 0-15\r\n
|
||||
sdp_msg_to_sdp_str_buf: a=ptime:20\r\n
|
||||
[2] ok
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue