From f2765c0214b521419e7701c7d026763e0fb1edb3 Mon Sep 17 00:00:00 2001 From: Boris Grozev <boris@jitsi.org> Date: Tue, 3 Jun 2014 19:15:11 +0200 Subject: [PATCH] Propagates RTP timestamps. --- .../jitsi/impl/neomedia/audiolevel/AudioLevelEffect.java | 1 + .../jitsi/impl/neomedia/codec/audio/opus/JNIDecoder.java | 9 ++++++++- .../impl/neomedia/protocol/CachingPushBufferStream.java | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/org/jitsi/impl/neomedia/audiolevel/AudioLevelEffect.java b/src/org/jitsi/impl/neomedia/audiolevel/AudioLevelEffect.java index f4b9b652..9f6618a1 100644 --- a/src/org/jitsi/impl/neomedia/audiolevel/AudioLevelEffect.java +++ b/src/org/jitsi/impl/neomedia/audiolevel/AudioLevelEffect.java @@ -214,6 +214,7 @@ public int process(Buffer inputBuffer, Buffer outputBuffer) outputBuffer.setHeader(inputBuffer.getHeader()); outputBuffer.setSequenceNumber(inputBuffer.getSequenceNumber()); outputBuffer.setTimeStamp(inputBuffer.getTimeStamp()); + outputBuffer.setRtpTimeStamp(inputBuffer.getRtpTimeStamp()); outputBuffer.setFlags(inputBuffer.getFlags()); outputBuffer.setDiscard(inputBuffer.isDiscard()); outputBuffer.setEOM(inputBuffer.isEOM()); diff --git a/src/org/jitsi/impl/neomedia/codec/audio/opus/JNIDecoder.java b/src/org/jitsi/impl/neomedia/codec/audio/opus/JNIDecoder.java index fa8fe630..2068b465 100644 --- a/src/org/jitsi/impl/neomedia/codec/audio/opus/JNIDecoder.java +++ b/src/org/jitsi/impl/neomedia/codec/audio/opus/JNIDecoder.java @@ -256,6 +256,13 @@ protected int doProcess(Buffer inBuf, Buffer outBuf) | (((in == null) || (inLength == 0)) ? BUFFER_FLAG_PLC : BUFFER_FLAG_FEC)); + + long ts = inBuf.getRtpTimeStamp(); + ts -= lostSeqNoCount * lastFrameSizeInSamplesPerChannel; + if (ts < 0) + ts += 1L<<32; + outBuf.setRtpTimeStamp(ts); + nbDecodedFec++; } @@ -310,7 +317,7 @@ protected int doProcess(Buffer inBuf, Buffer outBuf) if (outLength > 0) { outBuf.setDuration( - totalFrameSizeInSamplesPerChannel * channels * 1000L * 1000L + totalFrameSizeInSamplesPerChannel * 1000L * 1000L * 1000L / outputSampleRate); outBuf.setFormat(getOutputFormat()); outBuf.setLength(outLength); diff --git a/src/org/jitsi/impl/neomedia/protocol/CachingPushBufferStream.java b/src/org/jitsi/impl/neomedia/protocol/CachingPushBufferStream.java index 9773e279..96b77bf9 100644 --- a/src/org/jitsi/impl/neomedia/protocol/CachingPushBufferStream.java +++ b/src/org/jitsi/impl/neomedia/protocol/CachingPushBufferStream.java @@ -499,6 +499,7 @@ private int read(Buffer in, Buffer out, int outOffset) out.setHeader(in.getHeader()); out.setSequenceNumber(in.getSequenceNumber()); out.setTimeStamp(in.getTimeStamp()); + out.setRtpTimeStamp(in.getRtpTimeStamp()); /* * It's possible that we've split the input into multiple -- GitLab