Skip to content

Commit 18595ca

Browse files
authored
Add API to get number of queued DTMF transmission digits (#4645)
1 parent 3a2e7a7 commit 18595ca

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

pjmedia/include/pjmedia/stream.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,17 @@ pjmedia_stream_set_dtmf_event_callback(pjmedia_stream *stream,
453453
void *user_data);
454454

455455

456+
/**
457+
* Get the number of queued DTMF digits for transmission.
458+
*
459+
* @param stream The media stream.
460+
*
461+
* @return Number of DTMF digits queued for transmission,
462+
* or 0 if stream is NULL.
463+
*/
464+
PJ_DECL(unsigned) pjmedia_get_queued_dtmf_digits(pjmedia_stream *stream);
465+
466+
456467
/**
457468
* Send RTCP SDES for the media stream.
458469
*

pjmedia/src/pjmedia/stream.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,6 +2841,26 @@ PJ_DEF(pj_status_t) pjmedia_stream_set_dtmf_event_callback(pjmedia_stream *strea
28412841
return PJ_SUCCESS;
28422842
}
28432843

2844+
/*
2845+
* Get the number of queued DTMF digits for transmission.
2846+
*/
2847+
PJ_DEF(unsigned) pjmedia_get_queued_dtmf_digits(pjmedia_stream *stream)
2848+
{
2849+
pjmedia_stream_common *c_strm = (pjmedia_stream_common *)stream;
2850+
unsigned count;
2851+
2852+
PJ_ASSERT_RETURN(stream, 0);
2853+
2854+
/* By convention, we use jitter buffer's mutex to access DTMF
2855+
* digits resources.
2856+
*/
2857+
pj_mutex_lock(c_strm->jb_mutex);
2858+
count = stream->tx_dtmf_count;
2859+
pj_mutex_unlock(c_strm->jb_mutex);
2860+
2861+
return count;
2862+
}
2863+
28442864
/*
28452865
* Send RTCP SDES.
28462866
*/

pjsip/include/pjsua-lib/pjsua.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6546,6 +6546,18 @@ PJ_DECL(pj_status_t) pjsua_call_dial_dtmf2(pjsua_call_id call_id,
65466546
PJ_DECL(pj_status_t) pjsua_call_send_dtmf(pjsua_call_id call_id,
65476547
const pjsua_call_send_dtmf_param *param);
65486548

6549+
/**
6550+
* Get the number of queued DTMF digits for transmission in the call.
6551+
*
6552+
* @param call_id Call identification.
6553+
* @param digits On return, will contain the number of DTMF digits
6554+
* queued for transmission.
6555+
*
6556+
* @return PJ_SUCCESS on success, or the appropriate error code.
6557+
*/
6558+
PJ_DECL(pj_status_t) pjsua_call_get_queued_dtmf_digits(pjsua_call_id call_id,
6559+
unsigned *digits);
6560+
65496561
/**
65506562
* Send real-time text to remote via RTP stream. This only works if the call
65516563
* has text media.

pjsip/src/pjsua-lib/pjsua_aud.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,37 @@ PJ_DEF(pj_status_t) pjsua_call_dial_dtmf2( pjsua_call_id call_id,
172172
return status;
173173
}
174174

175+
/*
176+
* Get the number of queued DTMF digits for transmission in the call.
177+
*/
178+
PJ_DEF(pj_status_t) pjsua_call_get_queued_dtmf_digits(pjsua_call_id call_id,
179+
unsigned *digits)
180+
{
181+
pjsua_call *call;
182+
pjsip_dialog *dlg = NULL;
183+
pj_status_t status;
184+
185+
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls &&
186+
digits, PJ_EINVAL);
187+
188+
status = acquire_call("pjsua_call_get_queued_dtmf_digits()", call_id,
189+
&call, &dlg);
190+
if (status != PJ_SUCCESS)
191+
goto on_return;
192+
193+
if (!pjsua_call_has_media(call_id)) {
194+
status = PJ_EINVALIDOP;
195+
goto on_return;
196+
}
197+
198+
*digits = pjmedia_get_queued_dtmf_digits(
199+
call->media[call->audio_idx].strm.a.stream);
200+
201+
on_return:
202+
if (dlg) pjsip_dlg_dec_lock(dlg);
203+
return status;
204+
}
205+
175206

176207
/*****************************************************************************
177208
*

0 commit comments

Comments
 (0)