From e35497f8829a49650e7cdfdb540128b4787389f1 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Wed, 27 Sep 2006 17:07:52 +0000 Subject: [PATCH] simplified dtmf handling removed AmDtmfHandler: Aggregated dtmf event is posted into session's event queue directly. git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@88 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmDtmfDetector.cpp | 14 -------------- core/AmDtmfDetector.h | 17 ----------------- core/AmSession.cpp | 30 +++++++++++++----------------- core/AmSession.h | 19 ------------------- 4 files changed, 13 insertions(+), 67 deletions(-) diff --git a/core/AmDtmfDetector.cpp b/core/AmDtmfDetector.cpp index 57a09154..84a52c54 100644 --- a/core/AmDtmfDetector.cpp +++ b/core/AmDtmfDetector.cpp @@ -606,17 +606,3 @@ int AmInbandDtmfDetector::streamPut(const unsigned char* samples, unsigned int s isdn_audio_calc_dtmf((const signed short *)samples, size / 2); return size; } - -// -// AmDtmfHandler methods -// -void AmDtmfHandler::process(AmEvent *evt) -{ - AmDtmfEvent *event = dynamic_cast(evt); - if (event) - { - DBG("++++ DTMF %d\n", event->event()); - m_session->doDtmf(event->event(), event->duration()); - } - evt->processed = true; -} diff --git a/core/AmDtmfDetector.h b/core/AmDtmfDetector.h index e20c75c9..bba05efd 100644 --- a/core/AmDtmfDetector.h +++ b/core/AmDtmfDetector.h @@ -330,21 +330,4 @@ public: void checkTimeout(); void putDtmfAudio(const unsigned char *, int size, int user_ts); }; - -/** - * \brief DTMF Event handler (aggregated output) - * posts DTMF events to session - */ -class AmDtmfHandler : public AmEventHandler -{ -private: - AmSession *m_session; - - void process(AmEvent *); - -public: - AmDtmfHandler(AmSession *session) : m_session(session) {} - virtual ~AmDtmfHandler() {} -}; - #endif // _AmDtmfDetector_h_ diff --git a/core/AmSession.cpp b/core/AmSession.cpp index 747f2b2d..43ab3f24 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -37,8 +37,6 @@ #include "AmSessionContainer.h" #include "AmSessionScheduler.h" #include "AmDtmfDetector.h" -/* Session Timer: -ssa */ -//#include "AmSessionTimer.h" #include "log.h" @@ -128,7 +126,6 @@ AmSession::AmSession() sess_stopped(false),rtp_str(this),negotiate_onreply(false), input(0), output(0), payload(0), m_dtmfDetector(this), m_dtmfEventQueue(&m_dtmfDetector), - m_dtmfHandler(this), m_dtmfOutputQueue(&m_dtmfHandler), m_dtmfDetectionEnabled(true) { } @@ -369,12 +366,15 @@ void AmSession::postDtmfEvent(AmDtmfEvent *evt) { if (dynamic_cast(evt) || dynamic_cast(evt)) - { + { + // this is a raw event from sip info or rtp m_dtmfEventQueue.postEvent(evt); } - else + else { - m_dtmfOutputQueue.postEvent(evt); + // this is an aggregated event, + // post it into our event queue + postEvent(evt); } } } @@ -384,7 +384,6 @@ void AmSession::processDtmfEvents() if (m_dtmfDetectionEnabled) { m_dtmfEventQueue.processEvents(); - m_dtmfOutputQueue.processEvents(); } } @@ -393,10 +392,6 @@ void AmSession::putDtmfAudio(const unsigned char *buf, int size, int user_ts) m_dtmfEventQueue.putDtmfAudio(buf, size, user_ts); } -void AmSession::doDtmf(int event, int duration_msec) { - postEvent(new AmSessionDtmfEvent(event, duration_msec)); -} - void AmSession::onDtmf(int event, int duration_msec) { DBG("AmSession::onDtmf(%i,%i)\n",event,duration_msec); @@ -426,9 +421,8 @@ void AmSession::process(AmEvent* ev) DBG("AmSession::process\n"); AmSipEvent* sip_ev = dynamic_cast(ev); - if(sip_ev){ - - DBG("received SIP Event\n"); + if(sip_ev){ + DBG("Session received SIP Event\n"); onSipEvent(sip_ev); return; } @@ -439,9 +433,11 @@ void AmSession::process(AmEvent* ev) return; } - AmSessionDtmfEvent* sess_dtmf_ev = dynamic_cast(ev); - if (sess_dtmf_ev) { - onDtmf(sess_dtmf_ev->event_id, sess_dtmf_ev->getDuration()); + AmDtmfEvent* dtmf_ev = dynamic_cast(ev); + if (dtmf_ev) { + DBG("Session received DTMF, event = %d, duration = %d\n", + dtmf_ev->event(), dtmf_ev->duration()); + onDtmf(dtmf_ev->event(), dtmf_ev->duration()); return; } } diff --git a/core/AmSession.h b/core/AmSession.h index c8c2b43b..69dd1ed1 100644 --- a/core/AmSession.h +++ b/core/AmSession.h @@ -52,21 +52,6 @@ using std::pair; class AmSessionFactory; class AmDtmfEvent; -/** - * \brief DTMF Event in Session - * This is a DTMF event that should be processed - * by the Session. - */ -class AmSessionDtmfEvent : public AmEvent { - int duration_msec; -public: - AmSessionDtmfEvent(int key, int duration_msec) - : AmEvent(key), duration_msec(duration_msec) - { } - int getDuration() { return duration_msec; } -}; - - /** * \brief Interface for SIP events signaling plugins implement * @@ -125,8 +110,6 @@ class AmSession : public AmThread, AmDtmfDetector m_dtmfDetector; AmDtmfEventQueue m_dtmfEventQueue; - AmDtmfHandler m_dtmfHandler; - AmEventQueue m_dtmfOutputQueue; bool m_dtmfDetectionEnabled; vector ev_handlers; @@ -304,8 +287,6 @@ public: bool isDtmfDetectionEnabled() { return m_dtmfDetectionEnabled; } void setDtmfDetectionEnabled(bool e) { m_dtmfDetectionEnabled = e; } void putDtmfAudio(const unsigned char *buf, int size, int user_ts); - /** the dtmf detector posts events using this method*/ - void doDtmf(int event, int duration_msec); /** event handler for apps to use*/ virtual void onDtmf(int event, int duration);