From 9a0b39a7dd33817f1b5068e0ad719aba4ddc00b7 Mon Sep 17 00:00:00 2001 From: Riza Sulistyo Date: Thu, 18 Feb 2016 03:15:19 +0000 Subject: Misc (Re #1882): Add compile time option (PJMEDIA_HAS_DTMF_FLASH) to enable/disable DTMF flash as specified in rfc2833. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5242 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/include/pjmedia/config.h | 10 ++++++++++ pjmedia/include/pjmedia/stream.h | 3 ++- pjmedia/src/pjmedia/endpoint.c | 4 ++++ pjmedia/src/pjmedia/stream.c | 6 ++++++ pjsip-apps/src/pjsua/pjsua_app_legacy.c | 5 +++++ pjsip/include/pjsua-lib/pjsua.h | 5 +++-- 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pjmedia/include/pjmedia/config.h b/pjmedia/include/pjmedia/config.h index 8d739d2a..0dfd20ea 100644 --- a/pjmedia/include/pjmedia/config.h +++ b/pjmedia/include/pjmedia/config.h @@ -1321,6 +1321,7 @@ # endif #endif + /** * Specify if libyuv is available. * @@ -1330,6 +1331,15 @@ # define PJMEDIA_HAS_LIBYUV 0 #endif + +/** + * Specify if dtmf flash in RFC 2833 is available. + */ +#ifndef PJMEDIA_HAS_DTMF_FLASH +# define PJMEDIA_HAS_DTMF_FLASH 1 +#endif + + /** * @} */ diff --git a/pjmedia/include/pjmedia/stream.h b/pjmedia/include/pjmedia/stream.h index a2e5f207..d0594246 100644 --- a/pjmedia/include/pjmedia/stream.h +++ b/pjmedia/include/pjmedia/stream.h @@ -342,7 +342,8 @@ PJ_DECL(pj_status_t) pjmedia_stream_resume(pjmedia_stream *stream, * * @param stream The media stream. * @param ascii_digit String containing digits to be sent to remote as - * described on RFC 2833 section 3.10. Character 'R' is + * described on RFC 2833 section 3.10. + * If PJMEDIA_HAS_DTMF_FLASH is enabled, character 'R' is * used to represent the event type 16 (flash) as stated * in RFC 4730. * Currently the maximum number of digits are 32. diff --git a/pjmedia/src/pjmedia/endpoint.c b/pjmedia/src/pjmedia/endpoint.c index 9a8dbb22..650c71d8 100644 --- a/pjmedia/src/pjmedia/endpoint.c +++ b/pjmedia/src/pjmedia/endpoint.c @@ -556,7 +556,11 @@ PJ_DEF(pj_status_t) pjmedia_endpt_create_audio_sdp(pjmedia_endpt *endpt, /* Add fmtp */ attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); attr->name = pj_str("fmtp"); +#if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0 attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR " 0-16"); +#else + attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR " 0-15"); +#endif m->attr[m->attr_count++] = attr; } #endif diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c index d799dfd4..1dd63c7d 100644 --- a/pjmedia/src/pjmedia/stream.c +++ b/pjmedia/src/pjmedia/stream.c @@ -1566,7 +1566,11 @@ static void handle_incoming_dtmf( pjmedia_stream *stream, } /* Ignore unknown event. */ +#if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0 if (event->event > 16) { +#else + if (event->event > 15) { +#endif PJ_LOG(5,(stream->port.info.name.ptr, "Ignored RTP pkt with bad DTMF event %d", event->event)); @@ -2786,10 +2790,12 @@ PJ_DEF(pj_status_t) pjmedia_stream_dial_dtmf( pjmedia_stream *stream, { pt = 11; } +#if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0 else if (dig == 'r') { pt = 16; } +#endif else { status = PJMEDIA_RTP_EINDTMF; diff --git a/pjsip-apps/src/pjsua/pjsua_app_legacy.c b/pjsip-apps/src/pjsua/pjsua_app_legacy.c index dab8bfb9..e367eed5 100644 --- a/pjsip-apps/src/pjsua/pjsua_app_legacy.c +++ b/pjsip-apps/src/pjsua/pjsua_app_legacy.c @@ -1215,8 +1215,13 @@ static void ui_send_dtmf_2833() pj_status_t status; char buf[128]; +#if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0 if (!simple_input("DTMF strings to send (0-9*R#A-B)", buf, sizeof(buf))) +#else + if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, + sizeof(buf))) +#endif { return; } diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index c47d4c3c..6b6b5569 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -4811,11 +4811,12 @@ PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id, const pjsua_msg_data *msg_data); /** - * Send DTMF digits to remote using RFC 2833 payload formats. + * Send DTMF digits to remote using RFC 2833 payload formats. * * @param call_id Call identification. * @param digits DTMF string digits to be sent as described on RFC 2833 - * section 3.10. Character 'R' is used to represent the + * section 3.10. If PJMEDIA_HAS_DTMF_FLASH is enabled, + * character 'R' is used to represent the * event type 16 (flash) as stated in RFC 4730. * * @return PJ_SUCCESS on success, or the appropriate error code. -- cgit v1.2.3