Commit 9a8bc388 authored by Rafaël Carré's avatar Rafaël Carré

* #6675 : send RTP dtmf events only once

parent 51f7409e
......@@ -114,15 +114,7 @@ void AudioRtpRecordHandler::initNoiseSuppress()
void AudioRtpRecordHandler::putDtmfEvent (int digit)
{
sfl::DtmfEvent *dtmf = new sfl::DtmfEvent();
dtmf->payload.event = digit;
dtmf->payload.ebit = false; // end of event bit
dtmf->payload.rbit = false; // reserved bit
dtmf->payload.duration = 1; // duration for this event
dtmf->newevent = true;
dtmf->length = 1000;
getEventQueue()->push_back (dtmf);
_debug ("AudioRtpSession: Put Dtmf Event %d", digit);
_audioRtpRecord._dtmfQueue.push_back(digit);
}
#ifdef DUMP_PROCESS_DATA_ENCODE
......
......@@ -71,15 +71,6 @@ timeval2microtimeout (const timeval& t)
return ( (t.tv_sec * 1000000ul) + t.tv_usec);
}
typedef struct DtmfEvent {
ost::RTPPacket::RFC2833Payload payload;
int factor;
int length;
bool newevent;
} DtmfEvent;
typedef std::list<DtmfEvent *> EventQueue;
/**
* Class meant to store internal data in order to encode/decode,
* resample, process, and packetize audio streams. This class should not be
......@@ -102,7 +93,7 @@ class AudioRtpRecord
int _codecSampleRate;
int _codecFrameSize;
int _converterSamplingRate;
EventQueue _eventQueue;
std::list<int> _dtmfQueue;
SFLDataFormat _micAmplFactor;
AudioProcessing *_audioProcess;
NoiseSuppress *_noiseSuppress;
......@@ -145,12 +136,8 @@ class AudioRtpRecordHandler
return _audioRtpRecord._hasDynamicPayloadType;
}
EventQueue *getEventQueue (void) {
return &_audioRtpRecord._eventQueue;
}
int getEventQueueSize (void) const {
return _audioRtpRecord._eventQueue.size();
int DtmfPending (void) const {
return _audioRtpRecord._dtmfQueue.size() > 0;
}
const unsigned char *getMicDataEncoded (void) const {
......
......@@ -124,12 +124,20 @@ void AudioRtpSession::setSessionMedia (AudioCodec *audioCodec)
}
}
void AudioRtpSession::sendDtmfEvent (sfl::DtmfEvent *dtmf)
void AudioRtpSession::sendDtmfEvent ()
{
const int increment = (_type == Zrtp) ? 160 : _timestampIncrement;
_debug ("AudioRtpSession: Send Dtmf");
ost::RTPPacket::RFC2833Payload payload;
_timestamp += increment;
payload.event = _audioRtpRecord._dtmfQueue.front();
payload.ebit = false; // end of event bit
payload.rbit = false; // reserved bit
payload.duration = 1; // duration for this event
_audioRtpRecord._dtmfQueue.pop_front();
_debug ("AudioRtpSession: Send RTP Dtmf (%d)", payload.event);
_timestamp += (_type == Zrtp) ? 160 : _timestampIncrement;
// discard equivalent size of audio
processDataEncode();
......@@ -137,35 +145,12 @@ void AudioRtpSession::sendDtmfEvent (sfl::DtmfEvent *dtmf)
// change Payload type for DTMF payload
_queue->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) getDtmfPayloadType(), 8000));
// Set marker in case this is a new Event
if (dtmf->newevent)
_queue->setMark (true);
// putData (_timestamp, (const unsigned char*) (& (dtmf->payload)), sizeof (ost::RTPPacket::RFC2833Payload));
_queue->sendImmediate (_timestamp, (const unsigned char *) (& (dtmf->payload)), sizeof (ost::RTPPacket::RFC2833Payload));
// This is no more a new event
if (dtmf->newevent) {
dtmf->newevent = false;
_queue->setMark (false);
}
_queue->setMark (true);
_queue->sendImmediate (_timestamp, (const unsigned char *) (&payload), sizeof (payload));
_queue->setMark (false);
// get back the payload to audio
_queue->setPayloadFormat (ost::StaticPayloadFormat ( (ost::StaticPayloadType) getCodecPayloadType()));
// decrease length remaining to process for this event
dtmf->length -= increment;
dtmf->payload.duration++;
// next packet is going to be the last one
if ( (dtmf->length - increment) < increment)
dtmf->payload.ebit = true;
if (dtmf->length < increment) {
delete dtmf;
getEventQueue()->pop_front();
}
}
......
......@@ -84,7 +84,7 @@ class AudioRtpSession : public AudioRtpRecordHandler
* send the appropriate DTMF digit using this payload, discard coresponding data from mainbuffer and get
* back the codec payload for further audio processing.
*/
void sendDtmfEvent (sfl::DtmfEvent *dtmf);
void sendDtmfEvent ();
/**
* Send encoded data to peer
......
......@@ -87,11 +87,10 @@ void AudioSymmetricRtpSession::AudioRtpThread::run()
while (running) {
// Send session
if (rtpSession->getEventQueueSize() > 0) {
rtpSession->sendDtmfEvent (rtpSession->getEventQueue()->front());
} else {
if (rtpSession->DtmfPending())
rtpSession->sendDtmfEvent ();
else
rtpSession->sendMicData ();
}
Thread::sleep (TimerPort::getTimer());
......
......@@ -147,11 +147,10 @@ void AudioZrtpSession::run ()
}
// Send session
if (getEventQueueSize() > 0) {
sendDtmfEvent (getEventQueue()->front());
} else {
if (DtmfPending())
sendDtmfEvent ();
else
sendMicData ();
}
setCancel (cancelDeferred);
controlReceptionService();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment