From 2a7cfb5c93ed4ceb4f193d7cca037e894a4d5212 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 31 Mar 2016 16:28:21 +0200 Subject: [PATCH] sip/sdp: Hack to get a GSM codec call connected Extract IP and port once we have received the INVITE. In the near future we need to improve this! --- src/sdp.c | 4 ++-- src/sdp.h | 2 +- src/sip.c | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/sdp.c b/src/sdp.c index 2193ab9..ccd000d 100644 --- a/src/sdp.c +++ b/src/sdp.c @@ -90,7 +90,7 @@ success: return true; } -bool sdp_extract_sdp(struct sip_call_leg *leg, const sip_t *sip) +bool sdp_extract_sdp(struct sip_call_leg *leg, const sip_t *sip, bool any_codec) { sdp_connection_t *conn; sdp_session_t *sdp; @@ -139,7 +139,7 @@ bool sdp_extract_sdp(struct sip_call_leg *leg, const sip_t *sip) continue; for (map = media->m_rtpmaps; map; map = map->rm_next) { - if (strcasecmp(map->rm_encoding, leg->wanted_codec) != 0) + if (!any_codec && strcasecmp(map->rm_encoding, leg->wanted_codec) != 0) continue; leg->base.port = media->m_port; diff --git a/src/sdp.h b/src/sdp.h index aad736d..d716644 100644 --- a/src/sdp.h +++ b/src/sdp.h @@ -8,6 +8,6 @@ struct sip_call_leg; struct call_leg; bool sdp_screen_sdp(const sip_t *sip); -bool sdp_extract_sdp(struct sip_call_leg *leg, const sip_t *sip); +bool sdp_extract_sdp(struct sip_call_leg *leg, const sip_t *sip, bool any_codec); char *sdp_create_file(struct sip_call_leg *, struct call_leg *); diff --git a/src/sip.c b/src/sip.c index 5c2b5ab..36e4967 100644 --- a/src/sip.c +++ b/src/sip.c @@ -60,7 +60,7 @@ static void call_connect(struct sip_call_leg *leg, const sip_t *sip) return; } - if (!sdp_extract_sdp(leg, sip)) { + if (!sdp_extract_sdp(leg, sip, false)) { LOGP(DSIP, LOGL_ERROR, "leg(%p) incompatible audio, releasing\n", leg); nua_cancel(leg->nua_handle, TAG_END()); other->release_call(other); @@ -113,6 +113,21 @@ static void new_call(struct sip_agent *agent, nua_handle_t *nh, leg->state = SIP_CC_DLG_CNFD; leg->dir = SIP_DIR_MO; + /* + * FIXME/TODO.. we need to select the codec at some point. But it is + * not this place. It starts with the TCH/F vs. TCH/H selection based + * on the offered codecs, and then RTP_CREATE should have it. So both + * are GSM related... and do not belong here. Just pick the first codec + * so the IP addresss port and payload type is set. + */ + if (!sdp_extract_sdp(leg, sip, true)) { + LOGP(DSIP, LOGL_ERROR, "leg(%p) no audio, releasing\n", leg); + nua_respond(nh, SIP_406_NOT_ACCEPTABLE, TAG_END()); + nua_handle_destroy(nh); + call_leg_release(&leg->base); + return; + } + leg->base.release_call = sip_release_call; leg->base.ring_call = sip_ring_call; leg->base.connect_call = sip_connect_call;