sip: origin: do not use hardcoded ports for RTP

This commit is contained in:
Evangelos Ribeiro Tzaras
2021-02-26 17:29:21 +01:00
parent 6681077886
commit a53f07dfd3
4 changed files with 22 additions and 4 deletions

View File

@@ -53,3 +53,17 @@ protocol_is_valid (const gchar *protocol)
g_strcmp0 (protocol, "TCP") == 0 ||
g_strcmp0 (protocol, "TLS") == 0;
}
#define RTP_PORT_MIN 20000
#define RTP_PORT_MAX 65534
guint
get_port_for_rtp (void)
{
const guint rand_range = RTP_PORT_MAX - RTP_PORT_MIN;
guint rand = (g_random_int () % rand_range) + RTP_PORT_MIN;
/* RTP ports must be even */
return rand % 2 == 0 ? rand : rand + 1;
}
#undef RTP_PORT_MIN
#undef RTP_PORT_MAX