timestamp = 0;
}
public void queueSipDtmfDigits(String dtmfDigits) {
byte[] dtmfbuf = new byte[transcoder.getOutgoingEncodedFrameSize() + RTP_HEADER_SIZE];
RtpPacket dtmfpacket = new RtpPacket(dtmfbuf, 0);
dtmfpacket.setPayloadType(dtmf2833Type);
dtmfpacket.setPayloadLength(transcoder.getOutgoingEncodedFrameSize());
byte[] blankbuf = new byte[transcoder.getOutgoingEncodedFrameSize() + RTP_HEADER_SIZE];
RtpPacket blankpacket = new RtpPacket(blankbuf, 0);
blankpacket.setPayloadType(transcoder.getCodecId());
blankpacket.setPayloadLength(transcoder.getOutgoingEncodedFrameSize());
for (int d = 0; d < dtmfDigits.length(); d++) {
char digit = dtmfDigits.charAt(d);
if (digit == '*') {
dtmfbuf[startPayloadPos] = 10;
}
else if (digit == '#') {
dtmfbuf[startPayloadPos] = 11;
}
else if (digit >= 'A' && digit <= 'D') {
dtmfbuf[startPayloadPos] = (byte) (digit - 53);
}
else {
dtmfbuf[startPayloadPos] = (byte) (digit - 48);
}
// notice we are bumping times/seqn just like audio packets
try {
// send start event packet 3 times
dtmfbuf[startPayloadPos + 1] = 0; // start event flag
// and volume
dtmfbuf[startPayloadPos + 2] = 1; // duration 8 bits
dtmfbuf[startPayloadPos + 3] = -32; // duration 8 bits
for (int r = 0; r < 3; r++) {
dtmfpacket.setSequenceNumber(sequenceNum++);
dtmfpacket.setTimestamp(transcoder.getOutgoingEncodedFrameSize());
doRtpDelay();
rtpSocketSend(dtmfpacket);
}
// send end event packet 3 times
dtmfbuf[startPayloadPos + 1] = -128; // end event flag
dtmfbuf[startPayloadPos + 2] = 3; // duration 8 bits
dtmfbuf[startPayloadPos + 3] = 116; // duration 8 bits
for (int r = 0; r < 3; r++) {
dtmfpacket.setSequenceNumber(sequenceNum++);
dtmfpacket.setTimestamp(transcoder.getOutgoingEncodedFrameSize() );
doRtpDelay();
rtpSocketSend(dtmfpacket);
}
// send 200 ms of blank packets
for (int r = 0; r < 200 / transcoder.getOutgoingPacketization(); r++) {
blankpacket.setSequenceNumber(sequenceNum++);
blankpacket.setTimestamp(transcoder.getOutgoingEncodedFrameSize());
doRtpDelay();
rtpSocketSend(blankpacket);
}
}
catch (Exception e) {