From 2062792139a01be162cac734d9dba013871e1ec4 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 17 Apr 2013 12:00:17 +0200 Subject: [PATCH] add support for dtmfs in SIP INFO --- coreapi/bellesip_sal/sal_op_call.c | 19 +++++++++++++++++-- coreapi/bellesip_sal/sal_op_impl.c | 5 ++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 0bf1f2440..b21a3ea75 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -687,10 +687,25 @@ SalMediaDescription * sal_call_get_final_media_description(SalOp *h){ } return h->result; } + int sal_call_send_dtmf(SalOp *h, char dtmf){ - ms_fatal("sal_call_send_dtmf not implemented yet"); - return -1; + if (h->dialog){ + belle_sip_request_t *req=belle_sip_dialog_create_request(h->dialog,"INFO"); + if (req){ + int bodylen; + char dtmf_body[128]={0}; + + snprintf(dtmf_body, sizeof(dtmf_body)-1, "Signal=%c\r\nDuration=250\r\n", dtmf); + bodylen=strlen(dtmf_body); + belle_sip_message_set_body((belle_sip_message_t*)req,dtmf_body,bodylen); + belle_sip_message_add_header((belle_sip_message_t*)req,(belle_sip_header_t*)belle_sip_header_content_length_create(bodylen)); + belle_sip_message_add_header((belle_sip_message_t*)req,(belle_sip_header_t*)belle_sip_header_content_type_create("application", "dtmf-relay")); + sal_op_send_request(h,req); + }else ms_error("sal_call_send_dtmf(): could not build request"); + }else ms_error("sal_call_send_dtmf(): no dialog"); + return 0; } + int sal_call_terminate(SalOp *op){ belle_sip_dialog_state_t dialog_state=op->dialog?belle_sip_dialog_get_state(op->dialog):BELLE_SIP_DIALOG_NULL; /*no dialog = dialog in NULL state*/ op->state=SalOpStateTerminating; diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index e42c827f1..634e93cd5 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -86,6 +86,7 @@ belle_sip_header_contact_t* sal_op_create_contact(SalOp *op,belle_sip_header_fro belle_sip_object_unref(req_uri); return contact_header; } + belle_sip_request_t* sal_op_build_request(SalOp *op,const char* method) { belle_sip_header_from_t* from_header; belle_sip_header_to_t* to_header; @@ -109,7 +110,6 @@ belle_sip_request_t* sal_op_build_request(SalOp *op,const char* method) { belle_sip_header_via_new(), 70); - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(op->base.root->user_agent)); return req; } @@ -180,6 +180,9 @@ static int _sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* req op->pending_client_trans=client_transaction; /*update pending inv for being able to cancel*/ belle_sip_object_ref(op->pending_client_trans); } + if (belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request),belle_sip_header_user_agent_t)==NULL) + belle_sip_message_add_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(op->base.root->user_agent)); + if (add_contact) { contact = sal_op_create_contact(op,belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request),belle_sip_header_from_t)); belle_sip_message_remove_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_CONTACT);