Skip to content
Snippets Groups Projects
Commit 9a8bc388 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

* #6675 : send RTP dtmf events only once

parent 51f7409e
Branches
Tags
No related merge requests found
...@@ -114,15 +114,7 @@ void AudioRtpRecordHandler::initNoiseSuppress() ...@@ -114,15 +114,7 @@ void AudioRtpRecordHandler::initNoiseSuppress()
void AudioRtpRecordHandler::putDtmfEvent (int digit) void AudioRtpRecordHandler::putDtmfEvent (int digit)
{ {
sfl::DtmfEvent *dtmf = new sfl::DtmfEvent(); _audioRtpRecord._dtmfQueue.push_back(digit);
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);
} }
#ifdef DUMP_PROCESS_DATA_ENCODE #ifdef DUMP_PROCESS_DATA_ENCODE
......
...@@ -71,15 +71,6 @@ timeval2microtimeout (const timeval& t) ...@@ -71,15 +71,6 @@ timeval2microtimeout (const timeval& t)
return ( (t.tv_sec * 1000000ul) + t.tv_usec); 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, * Class meant to store internal data in order to encode/decode,
* resample, process, and packetize audio streams. This class should not be * resample, process, and packetize audio streams. This class should not be
...@@ -102,7 +93,7 @@ class AudioRtpRecord ...@@ -102,7 +93,7 @@ class AudioRtpRecord
int _codecSampleRate; int _codecSampleRate;
int _codecFrameSize; int _codecFrameSize;
int _converterSamplingRate; int _converterSamplingRate;
EventQueue _eventQueue; std::list<int> _dtmfQueue;
SFLDataFormat _micAmplFactor; SFLDataFormat _micAmplFactor;
AudioProcessing *_audioProcess; AudioProcessing *_audioProcess;
NoiseSuppress *_noiseSuppress; NoiseSuppress *_noiseSuppress;
...@@ -145,12 +136,8 @@ class AudioRtpRecordHandler ...@@ -145,12 +136,8 @@ class AudioRtpRecordHandler
return _audioRtpRecord._hasDynamicPayloadType; return _audioRtpRecord._hasDynamicPayloadType;
} }
EventQueue *getEventQueue (void) { int DtmfPending (void) const {
return &_audioRtpRecord._eventQueue; return _audioRtpRecord._dtmfQueue.size() > 0;
}
int getEventQueueSize (void) const {
return _audioRtpRecord._eventQueue.size();
} }
const unsigned char *getMicDataEncoded (void) const { const unsigned char *getMicDataEncoded (void) const {
......
...@@ -124,12 +124,20 @@ void AudioRtpSession::setSessionMedia (AudioCodec *audioCodec) ...@@ -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; ost::RTPPacket::RFC2833Payload payload;
_debug ("AudioRtpSession: Send Dtmf");
_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 // discard equivalent size of audio
processDataEncode(); processDataEncode();
...@@ -137,35 +145,12 @@ void AudioRtpSession::sendDtmfEvent (sfl::DtmfEvent *dtmf) ...@@ -137,35 +145,12 @@ void AudioRtpSession::sendDtmfEvent (sfl::DtmfEvent *dtmf)
// change Payload type for DTMF payload // change Payload type for DTMF payload
_queue->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) getDtmfPayloadType(), 8000)); _queue->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) getDtmfPayloadType(), 8000));
// Set marker in case this is a new Event
if (dtmf->newevent)
_queue->setMark (true); _queue->setMark (true);
_queue->sendImmediate (_timestamp, (const unsigned char *) (&payload), sizeof (payload));
// 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 (false);
}
// get back the payload to audio // get back the payload to audio
_queue->setPayloadFormat (ost::StaticPayloadFormat ( (ost::StaticPayloadType) getCodecPayloadType())); _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 ...@@ -84,7 +84,7 @@ class AudioRtpSession : public AudioRtpRecordHandler
* send the appropriate DTMF digit using this payload, discard coresponding data from mainbuffer and get * send the appropriate DTMF digit using this payload, discard coresponding data from mainbuffer and get
* back the codec payload for further audio processing. * back the codec payload for further audio processing.
*/ */
void sendDtmfEvent (sfl::DtmfEvent *dtmf); void sendDtmfEvent ();
/** /**
* Send encoded data to peer * Send encoded data to peer
......
...@@ -87,11 +87,10 @@ void AudioSymmetricRtpSession::AudioRtpThread::run() ...@@ -87,11 +87,10 @@ void AudioSymmetricRtpSession::AudioRtpThread::run()
while (running) { while (running) {
// Send session // Send session
if (rtpSession->getEventQueueSize() > 0) { if (rtpSession->DtmfPending())
rtpSession->sendDtmfEvent (rtpSession->getEventQueue()->front()); rtpSession->sendDtmfEvent ();
} else { else
rtpSession->sendMicData (); rtpSession->sendMicData ();
}
Thread::sleep (TimerPort::getTimer()); Thread::sleep (TimerPort::getTimer());
......
...@@ -147,11 +147,10 @@ void AudioZrtpSession::run () ...@@ -147,11 +147,10 @@ void AudioZrtpSession::run ()
} }
// Send session // Send session
if (getEventQueueSize() > 0) { if (DtmfPending())
sendDtmfEvent (getEventQueue()->front()); sendDtmfEvent ();
} else { else
sendMicData (); sendMicData ();
}
setCancel (cancelDeferred); setCancel (cancelDeferred);
controlReceptionService(); controlReceptionService();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment