diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-12-26 00:11:48 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-12-26 00:11:48 +0000 |
commit | 2fe9c7e503a9599ed0361e10bb6ba1c4bf311e4c (patch) | |
tree | 2c9692b2e847917e2ad7e6a364829943b1623ed0 /pjsip | |
parent | 2c57eaea78b397d120cfe359ff5d8026dae17f60 (diff) |
Added DTMF callback support all the way to PJSUA API (ticket #48)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@863 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsip.h | 4 | ||||
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 46 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 24 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_media.c | 2 |
4 files changed, 72 insertions, 4 deletions
diff --git a/pjsip/include/pjsip.h b/pjsip/include/pjsip.h index ff6af220..32e27cb2 100644 --- a/pjsip/include/pjsip.h +++ b/pjsip/include/pjsip.h @@ -40,9 +40,7 @@ #include <pjsip/sip_transport_udp.h> #include <pjsip/sip_transport_loop.h> #include <pjsip/sip_transport_tcp.h> -#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 -# include <pjsip/sip_transport_tls.h> -#endif +#include <pjsip/sip_transport_tls.h> #include <pjsip/sip_resolve.h> /* Authentication. */ diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index eda850a5..cb8d4643 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -286,11 +286,19 @@ typedef struct pjsua_callback * Notify application when invite state has changed. * Application may then query the call info to get the * detail call states. + * + * @param call_id The call index. + * @param e Event which causes the call state to change. */ void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e); /** * Notify application on incoming call. + * + * @param acc_id The account which match the incoming call. + * @param call_id The call id that has just been created for + * the call. + * @param rdata The incoming INVITE request. */ void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id, pjsip_rx_data *rdata); @@ -299,15 +307,31 @@ typedef struct pjsua_callback * Notify application when media state in the call has changed. * Normal application would need to implement this callback, e.g. * to connect the call's media to sound device. + * + * @param call_id The call index. */ void (*on_call_media_state)(pjsua_call_id call_id); /** + * Notify application upon incoming DTMF digits. + * + * @param call_id The call index. + * @param digit DTMF ASCII digit. + */ + void (*on_dtmf_digit)(pjsua_call_id call_id, int digit); + + /** * Notify application on call being transfered. * Application can decide to accept/reject transfer request * by setting the code (default is 200). When this callback * is not defined, the default behavior is to accept the * transfer. + * + * @param call_id The call index. + * @param dst The destination where the call will be + * transfered to. + * @param code Status code to be returned for the call transfer + * request. On input, it contains status code 200. */ void (*on_call_transfer_request)(pjsua_call_id call_id, const pj_str_t *dst, @@ -372,12 +396,16 @@ typedef struct pjsua_callback * Notify application when registration status has changed. * Application may then query the account info to get the * registration details. + * + * @param acc_id Account ID. */ void (*on_reg_state)(pjsua_acc_id acc_id); /** * Notify application when the buddy state has changed. * Application may then query the buddy into to get the details. + * + * @param buddy_id The buddy id. */ void (*on_buddy_state)(pjsua_buddy_id buddy_id); @@ -385,6 +413,15 @@ typedef struct pjsua_callback * Notify application on incoming pager (i.e. MESSAGE request). * Argument call_id will be -1 if MESSAGE request is not related to an * existing call. + * + * @param call_id Containts the ID of the call where the IM was + * sent, or PJSUA_INVALID_ID if the IM was sent + * outside call context. + * @param from URI of the sender. + * @param to URI of the destination message. + * @param contact The Contact URI of the sender, if present. + * @param mime_type MIME type of the message. + * @param body The message content. */ void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from, const pj_str_t *to, const pj_str_t *contact, @@ -413,6 +450,15 @@ typedef struct pjsua_callback /** * Notify application about typing indication. + * + * @param call_id Containts the ID of the call where the IM was + * sent, or PJSUA_INVALID_ID if the IM was sent + * outside call context. + * @param from URI of the sender. + * @param to URI of the destination message. + * @param contact The Contact URI of the sender, if present. + * @param is_typing Non-zero if peer is typing, or zero if peer + * has stopped typing a message. */ void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from, const pj_str_t *to, const pj_str_t *contact, diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 46abb1f7..b042e935 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -2050,6 +2050,22 @@ static void call_disconnect( pjsip_inv_session *inv, } /* + * DTMF callback from the stream. + */ +static void dtmf_callback(pjmedia_stream *strm, void *user_data, + int digit) +{ + PJ_UNUSED_ARG(strm); + + if (pjsua_var.ua_cfg.cb.on_dtmf_digit) { + pjsua_call_id call_id; + + call_id = (pjsua_call_id)user_data; + pjsua_var.ua_cfg.cb.on_dtmf_digit(call_id, digit); + } +} + +/* * Callback to be called when SDP offer/answer negotiation has just completed * in the session. This function will start/update media if negotiation * has succeeded. @@ -2188,6 +2204,14 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv, return; } + /* If DTMF callback is installed by application, install our + * callback to the session. + */ + if (pjsua_var.ua_cfg.cb.on_dtmf_digit) { + pjmedia_session_set_dtmf_callback(call->session, 0, + &dtmf_callback, + (void*)(call->index)); + } /* Get the port interface of the first stream in the session. * We need the port interface to add to the conference bridge. diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 3c92c0ea..87d7d6df 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -442,7 +442,7 @@ pj_status_t pjsua_media_subsys_destroy(void) } /* Close media transports */ - for (i=0; i<(int)pjsua_var.ua_cfg.max_calls; ++i) { + for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) { if (pjsua_var.calls[i].med_tp) { (*pjsua_var.calls[i].med_tp->op->destroy)(pjsua_var.calls[i].med_tp); pjsua_var.calls[i].med_tp = NULL; |