|
|
|
|
@ -240,9 +240,13 @@ void AmDtmfDetector::process(AmEvent *evt)
|
|
|
|
|
|
|
|
|
|
void AmDtmfDetector::flushKey(unsigned int event_id) {
|
|
|
|
|
// flush the current key if it corresponds to the one with event_id
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("flushKey\n");
|
|
|
|
|
#endif
|
|
|
|
|
if (m_eventPending && m_current_eventid_i && event_id == m_current_eventid) {
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("flushKey - reportEvent()\n");
|
|
|
|
|
#endif
|
|
|
|
|
reportEvent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -256,7 +260,9 @@ void AmDtmfDetector::registerKeyReleased(int event, Dtmf::EventSource source,
|
|
|
|
|
// push out it now
|
|
|
|
|
if ((m_eventPending && m_currentEvent != event) ||
|
|
|
|
|
(m_eventPending && has_eventid && m_current_eventid_i && (event_id != m_current_eventid))) {
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("event differs - reportEvent()\n");
|
|
|
|
|
#endif
|
|
|
|
|
reportEvent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -287,9 +293,12 @@ void AmDtmfDetector::registerKeyReleased(int event, Dtmf::EventSource source,
|
|
|
|
|
|
|
|
|
|
void AmDtmfDetector::registerKeyPressed(int event, Dtmf::EventSource type, bool has_eventid, unsigned int event_id)
|
|
|
|
|
{
|
|
|
|
|
DBG("registerKeyPressed(%d, .., %s, %u); m_eventPending=%s, m_currentEvent=%d, m_current_eventid=%u,m_current_eventid_i=%s\n",
|
|
|
|
|
event, has_eventid?"true":"false", event_id, m_eventPending?"true":"false", m_currentEvent, m_current_eventid, m_current_eventid_i?"true":"false");
|
|
|
|
|
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("registerKeyPressed(%d, .., %s, %u); m_eventPending=%s, m_currentEvent=%d, "
|
|
|
|
|
"m_current_eventid=%u,m_current_eventid_i=%s\n",
|
|
|
|
|
event, has_eventid?"true":"false", event_id, m_eventPending?"true":"false",
|
|
|
|
|
m_currentEvent, m_current_eventid, m_current_eventid_i?"true":"false");
|
|
|
|
|
#endif
|
|
|
|
|
struct timeval tm;
|
|
|
|
|
gettimeofday(&tm, NULL);
|
|
|
|
|
|
|
|
|
|
@ -306,7 +315,9 @@ void AmDtmfDetector::registerKeyPressed(int event, Dtmf::EventSource type, bool
|
|
|
|
|
// push out it now
|
|
|
|
|
if ((m_currentEvent != event) ||
|
|
|
|
|
(has_eventid && m_current_eventid_i && (event_id != m_current_eventid))) {
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("event differs - reportEvent() from key pressed\n");
|
|
|
|
|
#endif
|
|
|
|
|
reportEvent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -388,14 +399,17 @@ void AmRtpDtmfDetector::process(AmRtpDtmfEvent *evt)
|
|
|
|
|
|
|
|
|
|
if (m_lastTS_i && m_lastTS == evt->ts()) {
|
|
|
|
|
// ignore events from past key press which was already reported
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("ignore RTP event ts ==%u\n", evt->ts());
|
|
|
|
|
#endif
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_eventPending)
|
|
|
|
|
{
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("new m_eventPending, event()==%d, ts=%u\n", evt->event(), evt->ts());
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
gettimeofday(&m_startTime, NULL);
|
|
|
|
|
m_eventPending = true;
|
|
|
|
|
m_currentEvent = evt->event();
|
|
|
|
|
@ -404,14 +418,20 @@ void AmRtpDtmfDetector::process(AmRtpDtmfEvent *evt)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG("RTP event, event()==%d, m_currentEvent == %d, m_currentTS_i=%s, evt->ts=%u, m_currentTS=%u\n",
|
|
|
|
|
evt->event(), m_currentEvent, m_currentTS_i?"true":"false", evt->ts(), m_currentTS);
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("RTP event, event()==%d, m_currentEvent == %d, m_currentTS_i=%s, "
|
|
|
|
|
"evt->ts=%u, m_currentTS=%u\n",
|
|
|
|
|
evt->event(), m_currentEvent, m_currentTS_i?"true":"false",
|
|
|
|
|
evt->ts(), m_currentTS);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if ((evt->event() != m_currentEvent) ||
|
|
|
|
|
(m_currentTS_i && (evt->ts() != m_currentTS)))
|
|
|
|
|
{
|
|
|
|
|
// Previous event does not end correctly so send out it now...
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("flushKey %u\n", m_currentTS);
|
|
|
|
|
#endif
|
|
|
|
|
m_keysink->flushKey(m_currentTS);
|
|
|
|
|
// ... and reinitialize to process current event
|
|
|
|
|
gettimeofday(&m_startTime, NULL);
|
|
|
|
|
@ -421,7 +441,9 @@ void AmRtpDtmfDetector::process(AmRtpDtmfEvent *evt)
|
|
|
|
|
m_currentTS_i = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("registerKeyPressed %d, %u\n", m_currentEvent, m_currentTS);
|
|
|
|
|
#endif
|
|
|
|
|
m_keysink->registerKeyPressed(m_currentEvent, Dtmf::SOURCE_RTP, true, m_currentTS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -432,7 +454,9 @@ void AmRtpDtmfDetector::sendPending()
|
|
|
|
|
{
|
|
|
|
|
struct timeval end_time;
|
|
|
|
|
gettimeofday(&end_time, NULL);
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("registerKeyReleased(%d, ... %u)\n", m_currentEvent, m_currentTS);
|
|
|
|
|
#endif
|
|
|
|
|
m_keysink->registerKeyReleased(m_currentEvent, Dtmf::SOURCE_RTP, m_startTime, end_time, true, m_currentTS);
|
|
|
|
|
m_eventPending = false;
|
|
|
|
|
m_currentTS_i = false;
|
|
|
|
|
@ -445,7 +469,9 @@ void AmRtpDtmfDetector::checkTimeout()
|
|
|
|
|
{
|
|
|
|
|
if (m_eventPending && m_packetCount++ > MAX_PACKET_WAIT)
|
|
|
|
|
{
|
|
|
|
|
#ifdef EXCESSIVE_DTMF_DEBUGINFO
|
|
|
|
|
DBG("idle timeout ... sendPending()\n");
|
|
|
|
|
#endif
|
|
|
|
|
sendPending();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|