diff --git a/src/org/jitsi/impl/neomedia/AudioMediaStreamImpl.java b/src/org/jitsi/impl/neomedia/AudioMediaStreamImpl.java index 02e3d1ccf6ca7a4564454cd40722eeaf1aaff9cf..fe001fa911ba0405131d344f8af18464a1ff9a45 100644 --- a/src/org/jitsi/impl/neomedia/AudioMediaStreamImpl.java +++ b/src/org/jitsi/impl/neomedia/AudioMediaStreamImpl.java @@ -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; diff --git a/src/org/jitsi/impl/neomedia/transform/dtmf/DtmfRawPacket.java b/src/org/jitsi/impl/neomedia/transform/dtmf/DtmfRawPacket.java index 8ddcfe7b56be515ec94b3f83f917a70c6ed79eb2..a0ca934cbe285537ee72e48331b676bd608b78b7 100644 --- a/src/org/jitsi/impl/neomedia/transform/dtmf/DtmfRawPacket.java +++ b/src/org/jitsi/impl/neomedia/transform/dtmf/DtmfRawPacket.java @@ -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; + } } diff --git a/src/org/jitsi/impl/neomedia/transform/dtmf/DtmfTransformEngine.java b/src/org/jitsi/impl/neomedia/transform/dtmf/DtmfTransformEngine.java index 10660960582e792a525f378859fc3b3fbcecd1d3..f55e24261807255938d85d342c94d0fd9d48be0a 100644 --- a/src/org/jitsi/impl/neomedia/transform/dtmf/DtmfTransformEngine.java +++ b/src/org/jitsi/impl/neomedia/transform/dtmf/DtmfTransformEngine.java @@ -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. } /** diff --git a/src/org/jitsi/service/neomedia/AudioMediaStream.java b/src/org/jitsi/service/neomedia/AudioMediaStream.java index ddfd8b7e7375e6d2e64d7ebe6e744637cf05f373..092040625e28525398810d607840d0db7b39eaf3 100644 --- a/src/org/jitsi/service/neomedia/AudioMediaStream.java +++ b/src/org/jitsi/service/neomedia/AudioMediaStream.java @@ -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