Add media mode parameter to sdp_create_file()

This enables call hold implemented by subsequent commits

Prior to this commit, osmo-sip-connector would not send
any media mode attribute in the sdp. After this commit
we will by default always include a=sendrecv.

Given that a media mode attribute of "sendrecv" is default
and implicit it its absense, this does not represent any
functional change.

Change-Id: Ib4212d0174955042e7d80d3744ce632a4942ccb2
changes/93/14993/3
Keith Whyte 3 years ago
parent a35a7e70bb
commit f9a2a414ef
  1. 27
      src/sdp.c
  2. 3
      src/sdp.h
  3. 5
      src/sip.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;
}

@ -1,6 +1,7 @@
#pragma once
#include <sofia-sip/sip.h>
#include <sofia-sip/sdp.h>
#include <stdbool.h>
@ -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);

@ -28,6 +28,7 @@
#include <sofia-sip/sip_status.h>
#include <sofia-sip/su_log.h>
#include <sofia-sip/sdp.h>
#include <talloc.h>
@ -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;

Loading…
Cancel
Save