From a9a632a636782b87d6fc11e694300e70472bd808 Mon Sep 17 00:00:00 2001 From: Bryce Ford Date: Fri, 24 Jun 2016 11:10:07 -0600 Subject: [PATCH] dtmf packets need to have the same time stamp for same tone, added option to not change the time stamp --- .../java/net/sourceforge/peers/media/DtmfFactory.java | 8 +++++--- .../main/java/net/sourceforge/peers/media/RtpSender.java | 5 ++++- .../main/java/net/sourceforge/peers/rtp/RtpPacket.java | 8 ++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/peers-lib/src/main/java/net/sourceforge/peers/media/DtmfFactory.java b/peers-lib/src/main/java/net/sourceforge/peers/media/DtmfFactory.java index 1b517587..3d22db01 100644 --- a/peers-lib/src/main/java/net/sourceforge/peers/media/DtmfFactory.java +++ b/peers-lib/src/main/java/net/sourceforge/peers/media/DtmfFactory.java @@ -19,12 +19,12 @@ package net.sourceforge.peers.media; -import java.util.ArrayList; -import java.util.List; - import net.sourceforge.peers.rtp.RFC4733; import net.sourceforge.peers.rtp.RtpPacket; +import java.util.ArrayList; +import java.util.List; + public class DtmfFactory { public List createDtmfPackets(char digit) { @@ -61,6 +61,7 @@ public List createDtmfPackets(char digit) { data[2] = 1; data[3] = 64; rtpPacket.setData(data); + rtpPacket.setIncrementTimeStamp(false); rtpPacket.setMarker(false); rtpPacket.setPayloadType(RFC4733.PAYLOAD_TYPE_TELEPHONE_EVENT); packets.add(rtpPacket); @@ -71,6 +72,7 @@ public List createDtmfPackets(char digit) { data[2] = 1; data[3] = -32; rtpPacket.setData(data); + rtpPacket.setIncrementTimeStamp(false); rtpPacket.setMarker(false); rtpPacket.setPayloadType(RFC4733.PAYLOAD_TYPE_TELEPHONE_EVENT); packets.add(rtpPacket); diff --git a/peers-lib/src/main/java/net/sourceforge/peers/media/RtpSender.java b/peers-lib/src/main/java/net/sourceforge/peers/media/RtpSender.java index 287891a6..093ec30f 100644 --- a/peers-lib/src/main/java/net/sourceforge/peers/media/RtpSender.java +++ b/peers-lib/src/main/java/net/sourceforge/peers/media/RtpSender.java @@ -134,6 +134,7 @@ public void run() { RtpPacket pushedPacket = pushedPackets.remove(0); rtpPacket.setMarker(pushedPacket.isMarker()); rtpPacket.setPayloadType(pushedPacket.getPayloadType()); + rtpPacket.setIncrementTimeStamp(pushedPacket.isIncrementTimeStamp()); byte[] data = pushedPacket.getData(); rtpPacket.setData(data); } else { @@ -145,7 +146,9 @@ public void run() { } rtpPacket.setSequenceNumber(sequenceNumber++); - timestamp += buf_size; + if (rtpPacket.isIncrementTimeStamp()) { + timestamp += buf_size; + } rtpPacket.setTimestamp(timestamp); if (firstTime) { rtpSession.send(rtpPacket); diff --git a/peers-lib/src/main/java/net/sourceforge/peers/rtp/RtpPacket.java b/peers-lib/src/main/java/net/sourceforge/peers/rtp/RtpPacket.java index 1f598f04..058153d7 100644 --- a/peers-lib/src/main/java/net/sourceforge/peers/rtp/RtpPacket.java +++ b/peers-lib/src/main/java/net/sourceforge/peers/rtp/RtpPacket.java @@ -32,6 +32,7 @@ public class RtpPacket { private long ssrc; private long[] csrcList; private byte[] data; + private boolean incrementTimeStamp = true; public int getVersion() { return version; @@ -121,4 +122,11 @@ public void setData(byte[] data) { this.data = data; } + public boolean isIncrementTimeStamp() { + return incrementTimeStamp; + } + + public void setIncrementTimeStamp(boolean incrementTimeStamp) { + this.incrementTimeStamp = incrementTimeStamp; + } }