Skip to content
Snippets Groups Projects
Commit 31ba84c0 authored by Damian Minkov's avatar Damian Minkov
Browse files

Adds volume to RFC4733 dtmf packets and handling of an account property to...

Adds volume to RFC4733 dtmf packets and handling of an account property to change default value. Changes the default minimum tone duration.
parent 37eaade2
Branches
Tags
No related merge requests found
......@@ -598,17 +598,20 @@ public void setStreamAudioLevelListener(SimpleAudioLevelListener listener)
* @param dtmfMethod The kind of DTMF used (RTP, SIP-INOF or INBAND).
* @param minimalToneDuration The minimal DTMF tone duration.
* @param maximalToneDuration The maximal DTMF tone duration.
* @param volume The DTMF tone volume.
*
* @throws IllegalArgumentException if <tt>dtmfMethod</tt> is not one of
* {@link DTMFMethod#INBAND_DTMF}, {@link DTMFMethod#RTP_DTMF}, and
* {@link DTMFMethod#SIP_INFO_DTMF}
* @see AudioMediaStream#startSendingDTMF(DTMFTone, DTMFMethod)
* @see AudioMediaStream#startSendingDTMF(
* DTMFTone, DTMFMethod, int, int, int)
*/
public void startSendingDTMF(
DTMFTone tone,
DTMFMethod dtmfMethod,
int minimalToneDuration,
int maximalToneDuration)
int maximalToneDuration,
int volume)
{
switch (dtmfMethod)
{
......@@ -628,7 +631,8 @@ public void startSendingDTMF(
dtmfTransfrmEngine.startSending(
t,
minimalToneDuration,
maximalToneDuration);
maximalToneDuration,
volume);
}
break;
......
......@@ -43,6 +43,11 @@ public class DtmfRawPacket
*/
private int duration;
/**
* The volume of the current packet.
*/
private int volume;
/**
* Creates a <tt>DtmfRawPacket</tt> using the specified buffer.
*
......@@ -72,7 +77,9 @@ public DtmfRawPacket(RawPacket pkt)
int at = getHeaderLength();
code = readByte(at++);
end = (readByte(at++) & 0x80) != 0;
byte b= readByte(at++);
end = (b & 0x80) != 0;
volume = b & 0x7f;
duration = ((readByte(at++) & 0xFF) << 8) | (readByte(at++) & 0xFF);
}
......@@ -85,12 +92,14 @@ public DtmfRawPacket(RawPacket pkt)
* @param marker the RTP Marker flag
* @param duration the DTMF duration
* @param timestamp the RTP timestamp
* @param volume the DTMF volume
*/
public void init(int code,
boolean end,
boolean marker,
int duration,
long timestamp)
long timestamp,
int volume)
{
if(logger.isTraceEnabled())
{
......@@ -106,7 +115,7 @@ public void init(int code,
setTimestamp(timestamp);
// Create the RTP data
setDtmfPayload(code, end, duration);
setDtmfPayload(code, end, duration, volume);
}
/**
......@@ -130,17 +139,19 @@ public void init(int code,
* @param end boolean used to mark the two last packets
* @param duration int increments for each dtmf sending
* updates, stay unchanged at the end for the 2 last packets.
* @param volume describes the power level of the tone, expressed in dBm0
*/
private void setDtmfPayload(int code, boolean end, int duration)
private void setDtmfPayload(int code, boolean end, int duration, int volume)
{
this.code = code;
this.end = end;
this.duration = duration;
this.volume = volume;
int at = getHeaderLength();
writeByte(at++, (byte)code);
writeByte(at++, end ? (byte)0x80 : (byte)0);
writeByte(at++, end ? (byte)(volume | 0x80) : (byte)(volume & 0x7f));
writeByte(at++, (byte)(duration >> 8));
writeByte(at++, (byte)duration);
}
......@@ -171,4 +182,13 @@ public int getDuration()
{
return duration;
}
/**
* The volume of the current event.
* @return the volume
*/
public int getVolume()
{
return volume;
}
}
......@@ -147,6 +147,11 @@ private enum ToneTransmissionState
*/
private int maximalToneDuration;
/**
* The DTMF tone volume.
*/
private int volume;
/**
* Creates an engine instance that will be replacing audio packets
* with DTMF ones upon request.
......@@ -376,7 +381,8 @@ else if(toneTransmissionState
pktEnd,
pktMarker,
pktDuration,
currentTimestamp);
currentTimestamp,
volume);
pkt = dtmfPkt;
return pkt;
......@@ -390,11 +396,13 @@ else if(toneTransmissionState
* @param tone the tone that we'd like to start sending.
* @param minimalToneDuration The minimal DTMF tone duration.
* @param maximalToneDuration The maximal DTMF tone duration.
* @param volume The DTMF tone volume.
*/
public void startSending(
DTMFRtpTone tone,
int minimalToneDuration,
int maximalToneDuration)
int maximalToneDuration,
int volume)
{
synchronized(startStopToneMutex)
{
......@@ -417,6 +425,12 @@ else if(this.maximalToneDuration < this.minimalToneDuration)
{
this.maximalToneDuration = this.minimalToneDuration;
}
if(volume > 0)
this.volume = volume;
else
this.volume = 0; // we used to sent 0 for
// this field, keep it that way if not set.
}
/**
......
......@@ -94,12 +94,15 @@ public void setLocalUserAudioLevelListener(
* @param dtmfMethod The kind of DTMF used (RTP, SIP-INOF or INBAND).
* @param minimalToneDuration The minimal DTMF tone duration.
* @param maximalToneDuration The maximal DTMF tone duration.
* @param volume The DTMF tone volume. Describes the power level of the
* tone, expressed in dBm0 after dropping the sign.
*/
public void startSendingDTMF(
DTMFTone tone,
DTMFMethod dtmfMethod,
int minimalToneDuration,
int maximalToneDuration);
int maximalToneDuration,
int volume);
/**
* Interrupts transmission of a <tt>DTMFTone</tt> started with the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment