Changeset 863 for pjproject/trunk
- Timestamp:
- Dec 26, 2006 12:11:48 AM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/session.h
r518 r863 322 322 323 323 /** 324 * Set callback to be called upon receiving DTMF digits. If callback is 325 * registered, the stream will not buffer incoming DTMF but rather call 326 * the callback as soon as DTMF digit is received completely. 327 * 328 * @param session The media session. 329 * @param index The stream index. 330 * @param cb Callback to be called upon receiving DTMF digits. 331 * The DTMF digits will be given to the callback as 332 * ASCII digits. 333 * @param user_data User data to be returned back when the callback 334 * is called. 335 * 336 * @return PJ_SUCCESS on success. 337 */ 338 PJ_DECL(pj_status_t) 339 pjmedia_session_set_dtmf_callback(pjmedia_session *session, 340 unsigned index, 341 void (*cb)(pjmedia_stream*, 342 void *user_data, 343 int digit), 344 void *user_data); 345 346 /** 324 347 * Destroy media session. 325 348 * -
pjproject/trunk/pjmedia/include/pjmedia/stream.h
r568 r863 278 278 279 279 /** 280 * Set callback to be called upon receiving DTMF digits. If callback is 281 * registered, the stream will not buffer incoming DTMF but rather call 282 * the callback as soon as DTMF digit is received completely. 283 * 284 * @param stream The media stream. 285 * @param cb Callback to be called upon receiving DTMF digits. 286 * The DTMF digits will be given to the callback as 287 * ASCII digits. 288 * @param user_data User data to be returned back when the callback 289 * is called. 290 * 291 * @return PJ_SUCCESS on success. 292 */ 293 PJ_DECL(pj_status_t) 294 pjmedia_stream_set_dtmf_callback(pjmedia_stream *stream, 295 void (*cb)(pjmedia_stream*, 296 void *user_data, 297 int digit), 298 void *user_data); 299 300 /** 280 301 * @} 281 302 */ -
pjproject/trunk/pjmedia/src/pjmedia/session.c
r637 r863 734 734 size); 735 735 } 736 737 /* 738 * Install DTMF callback. 739 */ 740 PJ_DEF(pj_status_t) 741 pjmedia_session_set_dtmf_callback(pjmedia_session *session, 742 unsigned index, 743 void (*cb)(pjmedia_stream*, 744 void *user_data, 745 int digit), 746 void *user_data) 747 { 748 PJ_ASSERT_RETURN(session && index < session->stream_cnt, PJ_EINVAL); 749 return pjmedia_stream_set_dtmf_callback(session->stream[index], cb, 750 user_data); 751 } 752 -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r846 r863 114 114 unsigned rx_dtmf_count; /**< # of digits in dtmf rx buf.*/ 115 115 char rx_dtmf_buf[32];/**< Incoming DTMF buffer. */ 116 117 /* DTMF callback */ 118 void (*dtmf_cb)(pjmedia_stream*, void*, int); 119 void *dtmf_cb_user_data; 116 120 }; 117 121 … … 380 384 pj_mutex_unlock(stream->jb_mutex); 381 385 382 if (stream->tx_dtmf_count) 386 if (stream->tx_dtmf_count) { 383 387 PJ_LOG(5,(stream->port.info.name.ptr, 384 388 "Sending DTMF digit id %c", 385 389 digitmap[stream->tx_dtmf_buf[0].event])); 390 } 386 391 387 392 } else if (duration == 0) { … … 664 669 stream->last_dtmf_dur = pj_ntohs(event->duration); 665 670 666 /* By convention, we use jitter buffer's mutex to access shared667 * DTMF variables.671 /* If DTMF callback is installed, call the callback, otherwise keep 672 * the DTMF digits in the buffer. 668 673 */ 669 pj_mutex_lock(stream->jb_mutex); 670 if (stream->rx_dtmf_count >= PJ_ARRAY_SIZE(stream->rx_dtmf_buf)) { 671 /* DTMF digits overflow. Discard the oldest digit. */ 672 pj_array_erase(stream->rx_dtmf_buf, sizeof(stream->rx_dtmf_buf[0]), 673 stream->rx_dtmf_count, 0); 674 --stream->rx_dtmf_count; 675 } 676 stream->rx_dtmf_buf[stream->rx_dtmf_count++] = digitmap[event->event]; 677 pj_mutex_unlock(stream->jb_mutex); 674 if (stream->dtmf_cb) { 675 676 stream->dtmf_cb(stream, stream->dtmf_cb_user_data, 677 digitmap[event->event]); 678 679 } else { 680 /* By convention, we use jitter buffer's mutex to access shared 681 * DTMF variables. 682 */ 683 pj_mutex_lock(stream->jb_mutex); 684 if (stream->rx_dtmf_count >= PJ_ARRAY_SIZE(stream->rx_dtmf_buf)) { 685 /* DTMF digits overflow. Discard the oldest digit. */ 686 pj_array_erase(stream->rx_dtmf_buf, 687 sizeof(stream->rx_dtmf_buf[0]), 688 stream->rx_dtmf_count, 0); 689 --stream->rx_dtmf_count; 690 } 691 stream->rx_dtmf_buf[stream->rx_dtmf_count++] = digitmap[event->event]; 692 pj_mutex_unlock(stream->jb_mutex); 693 } 678 694 } 679 695 … … 1369 1385 return PJ_SUCCESS; 1370 1386 } 1387 1388 1389 /* 1390 * Set callback to be called upon receiving DTMF digits. 1391 */ 1392 PJ_DEF(pj_status_t) 1393 pjmedia_stream_set_dtmf_callback(pjmedia_stream *stream, 1394 void (*cb)(pjmedia_stream*, 1395 void *user_data, 1396 int digit), 1397 void *user_data) 1398 { 1399 PJ_ASSERT_RETURN(stream, PJ_EINVAL); 1400 1401 /* By convention, we use jitter buffer's mutex to access DTMF 1402 * digits resources. 1403 */ 1404 pj_mutex_lock(stream->jb_mutex); 1405 1406 stream->dtmf_cb = cb; 1407 stream->dtmf_cb_user_data = user_data; 1408 1409 pj_mutex_unlock(stream->jb_mutex); 1410 1411 return PJ_SUCCESS; 1412 } 1413 -
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r861 r863 1623 1623 } 1624 1624 1625 /* 1626 * DTMF callback. 1627 */ 1628 static void call_on_dtmf_callback(pjsua_call_id call_id, int dtmf) 1629 { 1630 PJ_LOG(3,(THIS_FILE, "Incoming DTMF on call %d: %c", call_id, dtmf)); 1631 } 1625 1632 1626 1633 /* … … 2819 2826 app_config.cfg.cb.on_call_media_state = &on_call_media_state; 2820 2827 app_config.cfg.cb.on_incoming_call = &on_incoming_call; 2828 app_config.cfg.cb.on_dtmf_digit = &call_on_dtmf_callback; 2821 2829 app_config.cfg.cb.on_reg_state = &on_reg_state; 2822 2830 app_config.cfg.cb.on_buddy_state = &on_buddy_state; -
pjproject/trunk/pjsip/include/pjsip.h
r849 r863 41 41 #include <pjsip/sip_transport_loop.h> 42 42 #include <pjsip/sip_transport_tcp.h> 43 #if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 44 # include <pjsip/sip_transport_tls.h> 45 #endif 43 #include <pjsip/sip_transport_tls.h> 46 44 #include <pjsip/sip_resolve.h> 47 45 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r861 r863 287 287 * Application may then query the call info to get the 288 288 * detail call states. 289 * 290 * @param call_id The call index. 291 * @param e Event which causes the call state to change. 289 292 */ 290 293 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e); … … 292 295 /** 293 296 * Notify application on incoming call. 297 * 298 * @param acc_id The account which match the incoming call. 299 * @param call_id The call id that has just been created for 300 * the call. 301 * @param rdata The incoming INVITE request. 294 302 */ 295 303 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id, … … 300 308 * Normal application would need to implement this callback, e.g. 301 309 * to connect the call's media to sound device. 310 * 311 * @param call_id The call index. 302 312 */ 303 313 void (*on_call_media_state)(pjsua_call_id call_id); 314 315 /** 316 * Notify application upon incoming DTMF digits. 317 * 318 * @param call_id The call index. 319 * @param digit DTMF ASCII digit. 320 */ 321 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit); 304 322 305 323 /** … … 309 327 * is not defined, the default behavior is to accept the 310 328 * transfer. 329 * 330 * @param call_id The call index. 331 * @param dst The destination where the call will be 332 * transfered to. 333 * @param code Status code to be returned for the call transfer 334 * request. On input, it contains status code 200. 311 335 */ 312 336 void (*on_call_transfer_request)(pjsua_call_id call_id, … … 373 397 * Application may then query the account info to get the 374 398 * registration details. 399 * 400 * @param acc_id Account ID. 375 401 */ 376 402 void (*on_reg_state)(pjsua_acc_id acc_id); … … 379 405 * Notify application when the buddy state has changed. 380 406 * Application may then query the buddy into to get the details. 407 * 408 * @param buddy_id The buddy id. 381 409 */ 382 410 void (*on_buddy_state)(pjsua_buddy_id buddy_id); … … 386 414 * Argument call_id will be -1 if MESSAGE request is not related to an 387 415 * existing call. 416 * 417 * @param call_id Containts the ID of the call where the IM was 418 * sent, or PJSUA_INVALID_ID if the IM was sent 419 * outside call context. 420 * @param from URI of the sender. 421 * @param to URI of the destination message. 422 * @param contact The Contact URI of the sender, if present. 423 * @param mime_type MIME type of the message. 424 * @param body The message content. 388 425 */ 389 426 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from, … … 414 451 /** 415 452 * Notify application about typing indication. 453 * 454 * @param call_id Containts the ID of the call where the IM was 455 * sent, or PJSUA_INVALID_ID if the IM was sent 456 * outside call context. 457 * @param from URI of the sender. 458 * @param to URI of the destination message. 459 * @param contact The Contact URI of the sender, if present. 460 * @param is_typing Non-zero if peer is typing, or zero if peer 461 * has stopped typing a message. 416 462 */ 417 463 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from, -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r847 r863 2051 2051 2052 2052 /* 2053 * DTMF callback from the stream. 2054 */ 2055 static void dtmf_callback(pjmedia_stream *strm, void *user_data, 2056 int digit) 2057 { 2058 PJ_UNUSED_ARG(strm); 2059 2060 if (pjsua_var.ua_cfg.cb.on_dtmf_digit) { 2061 pjsua_call_id call_id; 2062 2063 call_id = (pjsua_call_id)user_data; 2064 pjsua_var.ua_cfg.cb.on_dtmf_digit(call_id, digit); 2065 } 2066 } 2067 2068 /* 2053 2069 * Callback to be called when SDP offer/answer negotiation has just completed 2054 2070 * in the session. This function will start/update media if negotiation … … 2189 2205 } 2190 2206 2207 /* If DTMF callback is installed by application, install our 2208 * callback to the session. 2209 */ 2210 if (pjsua_var.ua_cfg.cb.on_dtmf_digit) { 2211 pjmedia_session_set_dtmf_callback(call->session, 0, 2212 &dtmf_callback, 2213 (void*)(call->index)); 2214 } 2191 2215 2192 2216 /* Get the port interface of the first stream in the session. -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r833 r863 443 443 444 444 /* Close media transports */ 445 for (i=0; i< (int)pjsua_var.ua_cfg.max_calls; ++i) {445 for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) { 446 446 if (pjsua_var.calls[i].med_tp) { 447 447 (*pjsua_var.calls[i].med_tp->op->destroy)(pjsua_var.calls[i].med_tp);
Note: See TracChangeset
for help on using the changeset viewer.