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
sayer/1.4-spce2.6
Stefan Sayer 20 years ago
parent a4a513624c
commit e35497f882

@ -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<AmDtmfEvent *>(evt);
if (event)
{
DBG("++++ DTMF %d\n", event->event());
m_session->doDtmf(event->event(), event->duration());
}
evt->processed = true;
}

@ -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_

@ -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<AmSipDtmfEvent *>(evt) ||
dynamic_cast<AmRtpDtmfEvent *>(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<AmSipEvent*>(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<AmSessionDtmfEvent*>(ev);
if (sess_dtmf_ev) {
onDtmf(sess_dtmf_ev->event_id, sess_dtmf_ev->getDuration());
AmDtmfEvent* dtmf_ev = dynamic_cast<AmDtmfEvent*>(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;
}
}

@ -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<AmSessionEventHandler*> 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);

Loading…
Cancel
Save