diff options
author | Alfred E. Heggestad <aeh@db.org> | 2014-04-21 14:27:37 +0200 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2014-04-21 14:27:37 +0200 |
commit | 309ba2242ce410c72ef7b9e22e33c8cf8aaab6c3 (patch) | |
tree | a20defd05514dc1f5716ada68d9584ba8fd112b7 /src/call.c | |
parent | 397f660e1461168f2edaa9bd519bf9c794a4c18f (diff) |
call: check common audio codecs for incoming call
for incoming calls, check that we have at least 1 common audio
codec. if there are no common audio codecs, reject the call
with 488 status code.
Suggested and Tested by Juha Heinanen -- thanks!
Diffstat (limited to 'src/call.c')
-rw-r--r-- | src/call.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -1171,6 +1171,21 @@ static void sipsess_close_handler(int err, const struct sip_msg *msg, } +static bool have_common_audio_codecs(const struct call *call) +{ + const struct sdp_format *sc; + struct aucodec *ac; + + sc = sdp_media_rformat(stream_sdpmedia(audio_strm(call->audio)), NULL); + if (!sc) + return false; + + ac = sc->data; + + return ac != NULL; +} + + int call_accept(struct call *call, struct sipsess_sock *sess_sock, const struct sip_msg *msg) { @@ -1199,6 +1214,21 @@ int call_accept(struct call *call, struct sipsess_sock *sess_sock, return err; call->got_offer = true; + + /* Check if we have any common audio codecs, after + * the SDP offer has been parsed + */ + if (!have_common_audio_codecs(call)) { + info("call: no common audio codecs - rejected\n"); + + sip_treply(NULL, uag_sip(), msg, + 488, "Not Acceptable Here"); + + call_event_handler(call, CALL_EVENT_CLOSED, + "No audio codecs"); + + return 0; + } } err = sipsess_accept(&call->sess, sess_sock, msg, 180, "Ringing", |