1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-06-28 14:49:30 +00:00

sip: sdp: Honour per media connections

Otherwise we might miss the IP of the remote peer leaving us unable to
establish a connection for RTP.

From https://datatracker.ietf.org/doc/html/rfc4566#section-5.7

   A session description MUST contain either at least one "c=" field in
   each media description or a single "c=" field at the session level.
   It MAY contain a single session-level "c=" field and additional "c="
   field(s) per media description, in which case the per-media values
   override the session-level settings for the respective media.
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-09-16 13:58:13 +02:00
parent cf3face6cc
commit 929d76708a

View file

@ -513,25 +513,31 @@ sip_i_state (int status,
CALLS_EMIT_MESSAGE (origin, "DNS error", GTK_MESSAGE_ERROR);
}
/* XXX making some assumptions about the received SDP message here...
* namely: that there is only the session wide connection c= line
* and no individual connections per media stream.
* also: rtcp port = rtp port + 1
* namely: rtcp port = rtp port + 1
*/
if (r_sdp) {
g_autoptr (GList) codecs =
calls_sip_media_manager_get_codecs_from_sdp (origin->media_manager,
r_sdp->sdp_media);
const char *remote_ip = NULL;
if (r_sdp->sdp_connection && r_sdp->sdp_connection->c_address) {
remote_ip = r_sdp->sdp_connection->c_address;
} else {
const char *session_ip = NULL;
const char *media_ip = NULL;
if (r_sdp->sdp_connection && r_sdp->sdp_connection->c_address)
session_ip = r_sdp->sdp_connection->c_address;
if (r_sdp->sdp_media && r_sdp->sdp_media->m_connections &&
r_sdp->sdp_media->m_connections->c_address)
media_ip = r_sdp->sdp_media->m_connections->c_address;
if (!session_ip && !media_ip) {
g_warning ("Could not determine IP of remote peer. Hanging up");
calls_call_hang_up (CALLS_CALL (call));
return;
}
calls_sip_call_set_codecs (call, codecs);
calls_sip_call_setup_remote_media_connection (call,
remote_ip,
media_ip ? : session_ip,
r_sdp->sdp_media->m_port,
r_sdp->sdp_media->m_port + 1);
}