diff --git a/src/sdp.c b/src/sdp.c index 17eb577..9bb55d4 100644 --- a/src/sdp.c +++ b/src/sdp.c @@ -163,16 +163,35 @@ bool sdp_extract_sdp(struct sip_call_leg *leg, const sip_t *sip, bool any_codec) return true; } -char *sdp_create_file(struct sip_call_leg *leg, struct call_leg *other) +char *sdp_create_file(struct sip_call_leg *leg, struct call_leg *other, sdp_mode_t mode) { struct in_addr net = { .s_addr = htonl(other->ip) }; char *fmtp_str = NULL, *sdp; + char *mode_attribute; leg->wanted_codec = app_media_name(other->payload_msg_type); if (strcmp(leg->wanted_codec, "AMR") == 0) fmtp_str = talloc_asprintf(leg, "a=fmtp:%d octet-align=1\r\n", other->payload_type); + switch (mode) { + case sdp_inactive: + mode_attribute = "a=inactive\r\n"; + break; + case sdp_sendrecv: + mode_attribute = "a=sendrecv\r\n"; + break; + case sdp_sendonly: + mode_attribute = "a=sendonly\r\n"; + break; + case sdp_recvonly: + mode_attribute = "a=recvonly\r\n"; + break; + default: + OSMO_ASSERT(false); + break; + } + sdp = talloc_asprintf(leg, "v=0\r\n" "o=Osmocom 0 0 IN IP4 %s\r\n" @@ -181,12 +200,14 @@ char *sdp_create_file(struct sip_call_leg *leg, struct call_leg *other) "t=0 0\r\n" "m=audio %d RTP/AVP %d\r\n" "%s" - "a=rtpmap:%d %s/8000\r\n", + "a=rtpmap:%d %s/8000\r\n" + "%s", inet_ntoa(net), inet_ntoa(net), /* never use diff. addr! */ other->port, other->payload_type, fmtp_str ? fmtp_str : "", other->payload_type, - leg->wanted_codec); + leg->wanted_codec, + mode_attribute); talloc_free(fmtp_str); return sdp; } diff --git a/src/sdp.h b/src/sdp.h index d716644..72ff6b7 100644 --- a/src/sdp.h +++ b/src/sdp.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include @@ -10,4 +11,4 @@ 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 any_codec); -char *sdp_create_file(struct sip_call_leg *, struct call_leg *); +char *sdp_create_file(struct sip_call_leg *, struct call_leg *, sdp_mode_t mode); diff --git a/src/sip.c b/src/sip.c index adf20d8..21401c6 100644 --- a/src/sip.c +++ b/src/sip.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -385,7 +386,7 @@ static void sip_connect_call(struct call_leg *_leg) return; } - sdp = sdp_create_file(leg, other); + sdp = sdp_create_file(leg, other, sdp_sendrecv); leg->state = SIP_CC_CONNECTED; nua_respond(leg->nua_handle, SIP_200_OK, @@ -425,7 +426,7 @@ static int send_invite(struct sip_agent *agent, struct sip_call_leg *leg, called_num, agent->app->sip.remote_addr, agent->app->sip.remote_port); - char *sdp = sdp_create_file(leg, other); + char *sdp = sdp_create_file(leg, other, sdp_sendrecv); leg->state = SIP_CC_INITIAL; leg->dir = SIP_DIR_MT;