Skip to content

Commit

Permalink
Merge pull request #25 from alianza-dev/dtmfrtp
Browse files Browse the repository at this point in the history
dtmf packets need to have the same time stamp for same tone
  • Loading branch information
ymartineau authored Jun 27, 2016
2 parents 9f0ebb9 + a9a632a commit 48420dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RtpPacket> createDtmfPackets(char digit) {
Expand Down Expand Up @@ -61,6 +61,7 @@ public List<RtpPacket> 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);
Expand All @@ -71,6 +72,7 @@ public List<RtpPacket> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 48420dd

Please sign in to comment.