diff --git a/daemon/src/audio/audiortp/AudioRtpRecordHandler.cpp b/daemon/src/audio/audiortp/AudioRtpRecordHandler.cpp index 795bebb4e00173b035cc3780717c14f6b66007ce..21a44927f75a70c927c702c7e50fe20e0f9629e6 100644 --- a/daemon/src/audio/audiortp/AudioRtpRecordHandler.cpp +++ b/daemon/src/audio/audiortp/AudioRtpRecordHandler.cpp @@ -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 diff --git a/daemon/src/audio/audiortp/AudioRtpRecordHandler.h b/daemon/src/audio/audiortp/AudioRtpRecordHandler.h index 4709930a6cb0ffe88c09756f3e35d0f322afe192..7d7343d9f9435112c9b3cd5b73bb2cc292b1744e 100644 --- a/daemon/src/audio/audiortp/AudioRtpRecordHandler.h +++ b/daemon/src/audio/audiortp/AudioRtpRecordHandler.h @@ -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 { diff --git a/daemon/src/audio/audiortp/AudioRtpSession.cpp b/daemon/src/audio/audiortp/AudioRtpSession.cpp index 9d7945791df520e3c5fb2451628c68b0ce36ccfb..180ac52de0670d8ab76f2403d33e15661e0f28da 100644 --- a/daemon/src/audio/audiortp/AudioRtpSession.cpp +++ b/daemon/src/audio/audiortp/AudioRtpSession.cpp @@ -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(); - } } diff --git a/daemon/src/audio/audiortp/AudioRtpSession.h b/daemon/src/audio/audiortp/AudioRtpSession.h index 1e737196d301c4df9c98d384a0a41de16b6f6cd6..0a609646fc52e42ba2c0e398542c4caf1fff5ed0 100644 --- a/daemon/src/audio/audiortp/AudioRtpSession.h +++ b/daemon/src/audio/audiortp/AudioRtpSession.h @@ -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 diff --git a/daemon/src/audio/audiortp/AudioSymmetricRtpSession.cpp b/daemon/src/audio/audiortp/AudioSymmetricRtpSession.cpp index f3e6ea95f3372d81d9e8a28b84a2f633db25bf87..a2897ef8443809f69b7f54aa4b9f6bc752aeedf5 100644 --- a/daemon/src/audio/audiortp/AudioSymmetricRtpSession.cpp +++ b/daemon/src/audio/audiortp/AudioSymmetricRtpSession.cpp @@ -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()); diff --git a/daemon/src/audio/audiortp/AudioZrtpSession.cpp b/daemon/src/audio/audiortp/AudioZrtpSession.cpp index 3da3ffd9554e9f897913d3210d060ca185e1c8d0..05c6b260a35b35002b08fb6cf310cd666d21f9b0 100644 --- a/daemon/src/audio/audiortp/AudioZrtpSession.cpp +++ b/daemon/src/audio/audiortp/AudioZrtpSession.cpp @@ -147,11 +147,10 @@ void AudioZrtpSession::run () } // Send session - if (getEventQueueSize() > 0) { - sendDtmfEvent (getEventQueue()->front()); - } else { + if (DtmfPending()) + sendDtmfEvent (); + else sendMicData (); - } setCancel (cancelDeferred); controlReceptionService();