Skip to content
Snippets Groups Projects
Commit 59f66532 authored by Vincent Lucas's avatar Vincent Lucas
Browse files

Corrects exception when rapid succession of RTP DTMFs are sent.

parent 6c8ef536
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
*/
package org.jitsi.impl.neomedia.transform.dtmf;
import java.util.*;
import javax.media.*;
import org.jitsi.impl.neomedia.*;
......@@ -25,7 +26,6 @@ public class DtmfTransformEngine
implements TransformEngine,
PacketTransformer
{
/**
* The <tt>AudioMediaStreamImpl</tt> that this transform engine was created
* by and that it's going to deliver DTMF packets for.
......@@ -42,13 +42,6 @@ private enum ToneTransmissionState
*/
IDLE,
/**
* Indicates that the user has just called the {@link
* #startSending(DTMFRtpTone)} method and we haven't yet sent any of the
* packets corresponding to that particular tone.
*/
SEND_PENDING,
/**
* Indicates that we are currently in the process of sending a DTMF
* tone, and we have already sent at least one packet.
......@@ -95,7 +88,7 @@ private enum ToneTransmissionState
/**
* The tone that we are supposed to be currently transmitting.
*/
private DTMFRtpTone currentTone = null;
private Vector<DTMFRtpTone> currentTone = new Vector<DTMFRtpTone>(1, 1);
/**
* The duration (in timestamp units or in other words ms*8) that we have
......@@ -223,12 +216,12 @@ public RawPacket reverseTransform(RawPacket pkt)
*/
public RawPacket transform(RawPacket pkt)
{
if (this.toneTransmissionState.equals(ToneTransmissionState.IDLE)
|| currentTone == null)
if(currentTone.isEmpty())
{
return pkt;
}
byte toneCode = currentTone.firstElement().getCode();
byte currentDtmfPayload = mediaStream.getDynamicRTPPayloadType(
Constants.TELEPHONE_EVENT);
......@@ -247,7 +240,7 @@ public RawPacket transform(RawPacket pkt)
boolean pktMarker = false;
int pktDuration = 0;
if(toneTransmissionState == ToneTransmissionState.SEND_PENDING)
if(toneTransmissionState == ToneTransmissionState.IDLE)
{
currentDuration = 0;
currentDuration += getCurrentSpacingDuration();
......@@ -296,11 +289,14 @@ else if(toneTransmissionState == ToneTransmissionState.END_SEQUENCE_INITIATED)
remainingsEndPackets--;
if(remainingsEndPackets == 0)
{
toneTransmissionState = ToneTransmissionState.IDLE;
currentTone.remove(0);
}
}
dtmfPkt.init(
currentTone.getCode(),
toneCode,
pktEnd,
pktMarker,
pktDuration,
......@@ -319,12 +315,7 @@ else if(toneTransmissionState == ToneTransmissionState.END_SEQUENCE_INITIATED)
*/
public void startSending(DTMFRtpTone tone)
{
if(toneTransmissionState != ToneTransmissionState.IDLE)
throw new IllegalStateException(
"Calling start before stopping previous transmission");
currentTone = tone;
toneTransmissionState = ToneTransmissionState.SEND_PENDING;
currentTone.add(tone);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment