Skip to content

Instantly share code, notes, and snippets.

@johanlantz
Created April 25, 2017 16:28
Show Gist options
  • Save johanlantz/7e405581792c6ac6ef287a80661b4b45 to your computer and use it in GitHub Desktop.
Save johanlantz/7e405581792c6ac6ef287a80661b4b45 to your computer and use it in GitHub Desktop.
//IF RFC2833 is used, we must add dtmf support also for 16000 and 48000 frequencies. Otherwise the SBC will not be able to transcode
void on_call_sdp_created(pjsua_call_id call_id, pjmedia_sdp_session *sdp, pj_pool_t *pool,
const pjmedia_sdp_session *rem_sdp)
{
if (dtmf_mode == TU_DTMF_RFC_2833_MULTI_FREQ) {
pj_status_t status = PJ_SUCCESS;
pj_str_t rtpmap_16 = pj_str("126 telephone-event/16000");
pj_str_t fmtp_16 = pj_str("126 0-15");
pj_str_t rtpmap_48 = pj_str("127 telephone-event/48000");
pj_str_t fmtp_48 = pj_str("127 0-15");
sdp->media[0]->desc.fmt[sdp->media[0]->desc.fmt_count++] = pj_str("127");
status = pjmedia_sdp_media_add_attr(sdp->media[0], pjmedia_sdp_attr_create(pool, "rtpmap", &rtpmap_16));
if (status != PJ_SUCCESS) {
TU_LOG(4,(THIS_FILE,"Error: Failed to add rtpmap for telephone-event 16000 with error %d", status));
return;
}
status = pjmedia_sdp_media_add_attr(sdp->media[0], pjmedia_sdp_attr_create(pool, "fmtp", &fmtp_16));
if (status != PJ_SUCCESS) {
TU_LOG(4,(THIS_FILE,"Error: Failed to add fmtp for telephone-event 16000 with error %d", status));
return;
}
sdp->media[0]->desc.fmt[sdp->media[0]->desc.fmt_count++] = pj_str("126");
status = pjmedia_sdp_media_add_attr(sdp->media[0], pjmedia_sdp_attr_create(pool, "rtpmap", &rtpmap_48));
if (status != PJ_SUCCESS) {
TU_LOG(4,(THIS_FILE,"Error: Failed to add rtpmap for telephone-event 48000 with error %d", status));
return;
}
status = pjmedia_sdp_media_add_attr(sdp->media[0], pjmedia_sdp_attr_create(pool, "fmtp", &fmtp_48));
if (status != PJ_SUCCESS) {
TU_LOG(4,(THIS_FILE,"Error: Failed to add fmtp for telephone-event 48000 with error %d", status));
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment