- cleanup and change speex transcoder to increment timestamp by 20ms.
This commit is contained in:
parent
3fa480baaf
commit
bbd6d1904b
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user