From bbd6d1904be8aabc703c13badaf02866a324bf6a Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Sun, 22 Aug 2010 10:08:16 -0400 Subject: [PATCH] - cleanup and change speex transcoder to increment timestamp by 20ms. --- .../red5/media/SipToFlashAudioStream.java | 22 ++----------- .../SpeexSipToFlashTranscoderImp.java | 32 +++---------------- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/bbb-voice/src/main/java/org/bigbluebutton/voiceconf/red5/media/SipToFlashAudioStream.java b/bbb-voice/src/main/java/org/bigbluebutton/voiceconf/red5/media/SipToFlashAudioStream.java index 8c1041b501..62e6b5b3f8 100755 --- a/bbb-voice/src/main/java/org/bigbluebutton/voiceconf/red5/media/SipToFlashAudioStream.java +++ b/bbb-voice/src/main/java/org/bigbluebutton/voiceconf/red5/media/SipToFlashAudioStream.java @@ -51,17 +51,8 @@ public class SipToFlashAudioStream implements TranscodedAudioDataListener, RtpSt private final String listenStreamName; private RtpStreamReceiver rtpStreamReceiver; private StreamObserver observer; - private long startTimestamp; private SipToFlashTranscoder transcoder; - private final byte[] speexSilence = new byte[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0 - }; - public SipToFlashAudioStream(IScope scope, SipToFlashTranscoder transcoder, DatagramSocket socket) { this.scope = scope; this.transcoder = transcoder; @@ -104,10 +95,7 @@ public class SipToFlashAudioStream implements TranscodedAudioDataListener, RtpSt throw new RuntimeException("could not register broadcast stream"); } - startTimestamp = 0; - //startTimestamp = System.currentTimeMillis(); - audioBroadcastStream.start(); - + audioBroadcastStream.start(); processAudioData = true; audioDataProcessor = new Runnable() { @@ -145,8 +133,6 @@ public class SipToFlashAudioStream implements TranscodedAudioDataListener, RtpSt // TODO Auto-generated catch block e.printStackTrace(); } - -// transcoder.transcode(audioData, this); } @Override @@ -172,10 +158,8 @@ public class SipToFlashAudioStream implements TranscodedAudioDataListener, RtpSt buffer.flip(); AudioData audioData = new AudioData(buffer); - startTimestamp += 20; - System.out.println("Sending RTMP = " + startTimestamp); - audioData.setTimestamp((int) startTimestamp); - // audioData.setTimestamp((int)timestamp); + System.out.println("Sending RTMP = " + timestamp); + audioData.setTimestamp((int)timestamp); audioBroadcastStream.dispatchEvent(audioData); audioData.release(); } diff --git a/bbb-voice/src/main/java/org/bigbluebutton/voiceconf/red5/media/transcoder/SpeexSipToFlashTranscoderImp.java b/bbb-voice/src/main/java/org/bigbluebutton/voiceconf/red5/media/transcoder/SpeexSipToFlashTranscoderImp.java index 037bfb245b..f07f4c6617 100755 --- a/bbb-voice/src/main/java/org/bigbluebutton/voiceconf/red5/media/transcoder/SpeexSipToFlashTranscoderImp.java +++ b/bbb-voice/src/main/java/org/bigbluebutton/voiceconf/red5/media/transcoder/SpeexSipToFlashTranscoderImp.java @@ -29,10 +29,9 @@ public class SpeexSipToFlashTranscoderImp implements SipToFlashTranscoder { private static final int SPEEX_CODEC = 178; /* 1011 1111 (see flv spec) */ private Codec audioCodec = null; - private byte[] buffer1; - private byte[] buffer2; - private byte[] buffer3; - private int freebuffer = 1; + + private long timestamp = 0; + private static final int TS_INCREMENT = 20; public SpeexSipToFlashTranscoderImp(Codec codec) { this.audioCodec = codec; @@ -41,30 +40,7 @@ public class SpeexSipToFlashTranscoderImp implements SipToFlashTranscoder { @Override public void transcode(AudioByteData audioData, TranscodedAudioDataListener listener) { byte[] codedBuffer = audioData.getData(); -/* - if (freebuffer == 1) { - buffer1 = new byte[codedBuffer.length]; - System.arraycopy(codedBuffer, 0, buffer1, 0, codedBuffer.length); - freebuffer = 2; -// buffer3 = null; - } else if (freebuffer == 2) { - buffer2 = new byte[codedBuffer.length]; - System.arraycopy(codedBuffer, 0, buffer2, 0, codedBuffer.length); - freebuffer = 3; - } else if (freebuffer == 3) { - buffer3 = new byte[buffer1.length + buffer2.length + codedBuffer.length]; - System.arraycopy(buffer1, 0, buffer3, 0, buffer1.length); - System.arraycopy(buffer2, 0, buffer3, buffer1.length - 1, buffer2.length); - System.arraycopy(codedBuffer, 0, buffer3, buffer1.length + buffer2.length - 1, codedBuffer.length); - freebuffer = 1; - listener.handleTranscodedAudioData(buffer3); -// buffer1 = null; -// buffer2 = null; - } else { - log.warn("Illegal state for transcoding buffer: {}", freebuffer); - } -*/ - listener.handleTranscodedAudioData(codedBuffer, audioData.getTimestamp()); + listener.handleTranscodedAudioData(codedBuffer, timestamp += TS_INCREMENT); } @Override