diff --git a/core/AmDtmfDetector.cpp b/core/AmDtmfDetector.cpp index 0b330895..57a09154 100644 --- a/core/AmDtmfDetector.cpp +++ b/core/AmDtmfDetector.cpp @@ -616,7 +616,7 @@ void AmDtmfHandler::process(AmEvent *evt) if (event) { DBG("++++ DTMF %d\n", event->event()); - m_session->onDtmf(event->event(), event->duration()); + m_session->doDtmf(event->event(), event->duration()); } evt->processed = true; } diff --git a/core/AmSession.cpp b/core/AmSession.cpp index 4dc9121a..747f2b2d 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -393,6 +393,10 @@ 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); @@ -434,6 +438,12 @@ void AmSession::process(AmEvent* ev) setStopped(); return; } + + AmSessionDtmfEvent* sess_dtmf_ev = dynamic_cast(ev); + if (sess_dtmf_ev) { + onDtmf(sess_dtmf_ev->event_id, sess_dtmf_ev->getDuration()); + return; + } } diff --git a/core/AmSession.h b/core/AmSession.h index 1efbe47b..9a26fb1c 100644 --- a/core/AmSession.h +++ b/core/AmSession.h @@ -50,9 +50,17 @@ using std::map; using std::pair; class AmSessionFactory; -//class AmDialogState; class AmDtmfEvent; +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; } +}; + /** * Signaling plugins must inherite from this class. @@ -285,10 +293,11 @@ 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); - /** * onStart will be called before everything else. */