Skip to content

Commit

Permalink
Modified SDP merge in core to use IP6 instead of IP4 in c-lines, when…
Browse files Browse the repository at this point in the history
… needed
  • Loading branch information
meetecho committed Mar 13, 2015
1 parent 365eb79 commit ba8dfe3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
17 changes: 9 additions & 8 deletions sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
a = a->a_next;
}
}
gboolean ipv6 = strstr(janus_get_public_ip(), ":") != NULL;
/* Media lines now */
if(anon->sdp_media) {
int audio = 0, video = 0;
Expand All @@ -800,7 +801,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
g_strlcat(sdp, "m=audio 0 RTP/SAVPF 0\r\n", BUFSIZE);
/* FIXME Adding a c-line anyway because otherwise Firefox complains? ("c= connection line not specified for every media level, validation failed") */
g_snprintf(buffer, 512,
"c=IN IP4 %s\r\n", janus_get_public_ip());
"c=IN %s %s\r\n", ipv6 ? "IP6" : "IP4", janus_get_public_ip());
g_strlcat(sdp, buffer, BUFSIZE);
m = m->m_next;
continue;
Expand All @@ -812,7 +813,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
g_strlcat(sdp, "m=audio 0 RTP/SAVPF 0\r\n", BUFSIZE);
/* FIXME Adding a c-line anyway because otherwise Firefox complains? ("c= connection line not specified for every media level, validation failed") */
g_snprintf(buffer, 512,
"c=IN IP4 %s\r\n", janus_get_public_ip());
"c=IN %s %s\r\n", ipv6 ? "IP6" : "IP4", janus_get_public_ip());
g_strlcat(sdp, buffer, BUFSIZE);
m = m->m_next;
continue;
Expand All @@ -829,7 +830,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
g_strlcat(sdp, "m=video 0 RTP/SAVPF 0\r\n", BUFSIZE);
/* FIXME Adding a c-line anyway because otherwise Firefox complains? ("c= connection line not specified for every media level, validation failed") */
g_snprintf(buffer, 512,
"c=IN IP4 %s\r\n", janus_get_public_ip());
"c=IN %s %s\r\n", ipv6 ? "IP6" : "IP4", janus_get_public_ip());
g_strlcat(sdp, buffer, BUFSIZE);
m = m->m_next;
continue;
Expand All @@ -841,7 +842,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
g_strlcat(sdp, "m=video 0 RTP/SAVPF 0\r\n", BUFSIZE);
/* FIXME Adding a c-line anyway because otherwise Firefox complains? ("c= connection line not specified for every media level, validation failed") */
g_snprintf(buffer, 512,
"c=IN IP4 %s\r\n", janus_get_public_ip());
"c=IN %s %s\r\n", ipv6 ? "IP6" : "IP4", janus_get_public_ip());
g_strlcat(sdp, buffer, BUFSIZE);
m = m->m_next;
continue;
Expand All @@ -864,7 +865,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
g_strlcat(sdp, buffer, BUFSIZE);
/* FIXME Adding a c-line anyway because otherwise Firefox complains? ("c= connection line not specified for every media level, validation failed") */
g_snprintf(buffer, 512,
"c=IN IP4 %s\r\n", janus_get_public_ip());
"c=IN %s %s\r\n", ipv6 ? "IP6" : "IP4", janus_get_public_ip());
g_strlcat(sdp, buffer, BUFSIZE);
m = m->m_next;
continue;
Expand All @@ -879,7 +880,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
g_strlcat(sdp, buffer, BUFSIZE);
/* FIXME Adding a c-line anyway because otherwise Firefox complains? ("c= connection line not specified for every media level, validation failed") */
g_snprintf(buffer, 512,
"c=IN IP4 %s\r\n", janus_get_public_ip());
"c=IN %s %s\r\n", ipv6 ? "IP6" : "IP4", janus_get_public_ip());
g_strlcat(sdp, buffer, BUFSIZE);
m = m->m_next;
continue;
Expand All @@ -903,7 +904,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
g_strlcat(sdp, buffer, BUFSIZE);
/* FIXME Adding a c-line anyway because otherwise Firefox complains? ("c= connection line not specified for every media level, validation failed") */
g_snprintf(buffer, 512,
"c=IN IP4 %s\r\n", janus_get_public_ip());
"c=IN %s %s\r\n", ipv6 ? "IP6" : "IP4", janus_get_public_ip());
g_strlcat(sdp, buffer, BUFSIZE);
m = m->m_next;
continue;
Expand Down Expand Up @@ -933,7 +934,7 @@ char *janus_sdp_merge(janus_ice_handle *handle, const char *origsdp) {
g_strlcat(sdp, "\r\n", BUFSIZE);
/* Media connection c= */
g_snprintf(buffer, 512,
"c=IN IP4 %s\r\n", janus_get_public_ip());
"c=IN %s %s\r\n", ipv6 ? "IP6" : "IP4", janus_get_public_ip());
g_strlcat(sdp, buffer, BUFSIZE);
/* Any bandwidth? */
if(m->m_bandwidths) {
Expand Down
13 changes: 9 additions & 4 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,19 @@ int janus_get_vp8_pt(const char *sdp) {
}

gboolean janus_is_ip_valid(const char *ip, int *family) {
if(ip == NULL)
return FALSE;

struct sockaddr_in addr4;
struct sockaddr_in6 addr6;

if (inet_pton(AF_INET, ip, &addr4) > 0) {
*family = AF_INET;
if(inet_pton(AF_INET, ip, &addr4) > 0) {
if(family != NULL)
*family = AF_INET;
return TRUE;
} else if (inet_pton(AF_INET6, ip, &addr6) > 0) {
*family = AF_INET6;
} else if(inet_pton(AF_INET6, ip, &addr6) > 0) {
if(family != NULL)
*family = AF_INET6;
return TRUE;
} else {
return FALSE;
Expand Down
5 changes: 4 additions & 1 deletion utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ int janus_get_opus_pt(const char *sdp);
* @returns The VP8 payload type, if found, -1 otherwise */
int janus_get_vp8_pt(const char *sdp);

/*! \brief Check if the given IP address is valid. Family is set to the address family if the IP is valid. */
/*! \brief Check if the given IP address is valid: family is set to the address family if the IP is valid
* @param ip The IP address to check
* @param[in,out] The address family of the address, set by the method if valid
* @returns true if the address is valid, false otherwise */
gboolean janus_is_ip_valid(const char *ip, int *family);
#endif

0 comments on commit ba8dfe3

Please sign in to comment.