Module: sems Branch: master Commit: 959f880f8f47d576c5d4537fcb331196df456d41 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=959f880f8f47d576c5d4537fcb331196df456d41
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Fri Feb 24 22:27:34 2012 +0100 support for receiving RTP DTMF while not processing RTP based on a patch by Robert Szokovacs --- apps/dsm/DSMCoreModule.cpp | 24 ++++++++++++++++++++ apps/dsm/DSMCoreModule.h | 5 ++++ apps/ivr/IvrDialogBase.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++ core/AmRtpStream.cpp | 9 +++++++ core/AmRtpStream.h | 3 ++ core/AmSession.h | 3 ++ doc/dsm/dsm_syntax.txt | 24 ++++++++++++------- 7 files changed, 111 insertions(+), 9 deletions(-) diff --git a/apps/dsm/DSMCoreModule.cpp b/apps/dsm/DSMCoreModule.cpp index b9ea4bd..c252086 100644 --- a/apps/dsm/DSMCoreModule.cpp +++ b/apps/dsm/DSMCoreModule.cpp @@ -70,6 +70,10 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) { DEF_CMD("addSeparator", SCAddSeparatorAction); DEF_CMD("connectMedia", SCConnectMediaAction); DEF_CMD("disconnectMedia", SCDisconnectMediaAction); + DEF_CMD("enableReceiving", SCEnableReceivingAction); + DEF_CMD("disableReceiving", SCDisableReceivingAction); + DEF_CMD("enableForceDTMFReceiving", SCEnableForceDTMFReceiving); + DEF_CMD("disableForceDTMFReceiving", SCDisableForceDTMFReceiving); DEF_CMD("mute", SCMuteAction); DEF_CMD("unmute", SCUnmuteAction); DEF_CMD("enableDTMFDetection", SCEnableDTMFDetection); @@ -363,6 +367,26 @@ EXEC_ACTION_START(SCDisconnectMediaAction) { sc_sess->disconnectMedia(); } EXEC_ACTION_END; +EXEC_ACTION_START(SCEnableReceivingAction) { + DBG("enabling RTP receving in session\nb"); + sess->setReceiving(true); +} EXEC_ACTION_END; + +EXEC_ACTION_START(SCDisableReceivingAction) { + DBG("disabling RTP receving in session\nb"); + sess->setReceiving(false); +} EXEC_ACTION_END; + +EXEC_ACTION_START(SCEnableForceDTMFReceiving) { + DBG("enabling forced DTMF RTP receving in session\nb"); + sess->setForceDtmfReceiving(true); +} EXEC_ACTION_END; + +EXEC_ACTION_START(SCDisableForceDTMFReceiving) { + DBG("disabling forced DTMF RTP receving in session\nb"); + sess->setForceDtmfReceiving(false); +} EXEC_ACTION_END; + EXEC_ACTION_START(SCMuteAction) { sc_sess->mute(); } EXEC_ACTION_END; diff --git a/apps/dsm/DSMCoreModule.h b/apps/dsm/DSMCoreModule.h index c1648c5..db680fa 100644 --- a/apps/dsm/DSMCoreModule.h +++ b/apps/dsm/DSMCoreModule.h @@ -59,6 +59,10 @@ DEF_ACTION_1P(SCSetInOutPlaylistAction); DEF_ACTION_1P(SCStopAction); DEF_ACTION_1P(SCConnectMediaAction); DEF_ACTION_1P(SCDisconnectMediaAction); +DEF_ACTION_1P(SCEnableReceivingAction); +DEF_ACTION_1P(SCDisableReceivingAction); +DEF_ACTION_2P(SCEnableForceDTMFReceiving); +DEF_ACTION_2P(SCDisableForceDTMFReceiving); DEF_ACTION_1P(SCMuteAction); DEF_ACTION_1P(SCUnmuteAction); DEF_ACTION_1P(SCEnableDTMFDetection); @@ -66,6 +70,7 @@ DEF_ACTION_1P(SCDisableDTMFDetection); DEF_ACTION_2P(SCSendDTMFAction); DEF_ACTION_2P(SCSendDTMFSequenceAction); + DEF_ACTION_1P(SCSetPromptsAction); DEF_ACTION_2P(SCAddSeparatorAction); diff --git a/apps/ivr/IvrDialogBase.cpp b/apps/ivr/IvrDialogBase.cpp index 30ac3ba..f731c8e 100644 --- a/apps/ivr/IvrDialogBase.cpp +++ b/apps/ivr/IvrDialogBase.cpp @@ -214,6 +214,46 @@ static PyObject* IvrDialogBase_unmute(IvrDialogBase* self, PyObject* args) return Py_None; } +static PyObject* IvrDialogBase_enableReceiving(IvrDialogBase* self, PyObject* args) +{ + assert(self->p_dlg); + + self->p_dlg->setReceiving(true); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject* IvrDialogBase_disableReceiving(IvrDialogBase* self, PyObject* args) +{ + assert(self->p_dlg); + + self->p_dlg->setReceiving(false); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject* IvrDialogBase_enableDTMFReceiving(IvrDialogBase* self, PyObject* args) +{ + assert(self->p_dlg); + + self->p_dlg->setForceDtmfReceiving(true); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject* IvrDialogBase_disableDTMFReceiving(IvrDialogBase* self, PyObject* args) +{ + assert(self->p_dlg); + + self->p_dlg->setForceDtmfReceiving(false); + + Py_INCREF(Py_None); + return Py_None; +} + static PyObject* IvrDialogBase_remove_mediaprocessor(IvrDialogBase* self, PyObject* args) { @@ -502,6 +542,18 @@ static PyMethodDef IvrDialogBase_methods[] = { {"unmute", (PyCFunction)IvrDialogBase_unmute, METH_NOARGS, "unmute the RTP stream (send packets)" }, + {"enableReceiving", (PyCFunction)IvrDialogBase_enableReceiving, METH_NOARGS, + "enable receiving of RTP packets" + }, + {"disableReceiving", (PyCFunction)IvrDialogBase_disableReceiving, METH_NOARGS, + "disable receiving of RTP packets" + }, + {"enableDTMFReceiving", (PyCFunction)IvrDialogBase_enableDTMFReceiving, METH_NOARGS, + "enable receiving of RFC-2833 DTMF packets even if RTP receiving is disabled" + }, + {"disableDTMFReceiving", (PyCFunction)IvrDialogBase_disableDTMFReceiving, METH_NOARGS, + "disable receiving of RFC-2833 DTMF packets when RTP receiving is disabled" + }, {"connectMedia", (PyCFunction)IvrDialogBase_add_mediaprocessor, METH_NOARGS, "enable the processing of audio and RTP" }, diff --git a/core/AmRtpStream.cpp b/core/AmRtpStream.cpp index 2538aff..0e1809b 100644 --- a/core/AmRtpStream.cpp +++ b/core/AmRtpStream.cpp @@ -658,6 +658,15 @@ void AmRtpStream::bufferPacket(AmRtpPacket* p) memcpy(&last_recv_time, &p->recv_time, sizeof(struct timeval)); if (!receiving && !passive) { + if (force_receive_dtmf && local_telephone_event_pt.get() && + p->payload == local_telephone_event_pt->payload_type) + { + dtmf_payload_t* dpl = (dtmf_payload_t*)p->getData(); + + DBG("DTMF: event=%i; e=%i; r=%i; volume=%i; duration=%i; ts=%u\n", + dpl->event,dpl->e,dpl->r,dpl->volume,ntohs(dpl->duration),p->timestamp); + session->postDtmfEvent(new AmRtpDtmfEvent(dpl, getLocalTelephoneEventRate(), p->timestamp)); + } mem.freePacket(p); return; } diff --git a/core/AmRtpStream.h b/core/AmRtpStream.h index 7bcfb56..dd16dbe 100644 --- a/core/AmRtpStream.h +++ b/core/AmRtpStream.h @@ -250,6 +250,9 @@ public: /** should we receive packets? if not -> drop */ bool receiving; + /** should we receive RFC-2833-style DTMF even when receiving is disabled? */ + bool force_receive_dtmf; + /** Allocates resources for future use of RTP. */ AmRtpStream(AmSession* _s, int _if); diff --git a/core/AmSession.h b/core/AmSession.h index 01ba788..baee1d9 100644 --- a/core/AmSession.h +++ b/core/AmSession.h @@ -340,6 +340,9 @@ public: /** setter for rtp_str->receiving */ void setReceiving(bool receive) { RTPStream()->receiving = receive; } + /** setter for rtp_str->force_receive_dtmf*/ + void setForceDtmfReceiving(bool receive) { RTPStream()->force_receive_dtmf = receive; } + /* ---- SIP dialog attributes ---- */ /** Gets the Session's call ID */ diff --git a/doc/dsm/dsm_syntax.txt b/doc/dsm/dsm_syntax.txt index 075bc07..f56707f 100644 --- a/doc/dsm/dsm_syntax.txt +++ b/doc/dsm/dsm_syntax.txt @@ -148,15 +148,21 @@ Playing prompts and file I/O set playlist as input and output addSeparator(id [, bool front]) fires event when playlist hits it ; front=[true|false] - connectMedia() - set playlist as input and output of session, and connect to mediaprocessor - disconnectMedia() - disconnect from mediaprocessor - - mute() - set RTP stream to muted (don't send and receive RTP packets) - unmute() - set RTP stream to unmuted (send and receive RTP packets) + connectMedia() - set playlist as input and output of session, + and start processing of RTP and audio + (connect to mediaprocessor) + disconnectMedia() - stop processing of RTP and audio (disconnect from mediaprocessor) + + enableReceiving() - enable processing of received RTP + disableReceiving() - disable processing of received RTP + + enableForceDTMFReceiving() - enable/disable RTP DTMF packets processing even + disableForceDTMFReceiving() if received RTP is not processed, e.g. after + disableReceiving() or in passive mode + (only for RFC2833/4733 DTMF, *no* in-band) + + mute() - set RTP stream to muted (don't send RTP packets) + unmute() - set RTP stream to unmuted (do send RTP packets) DTMF ---- _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
