// never drop initial packages, also this could be the first packet after
// MP4 seeking and therefore mess with the timestamp mapping
return false;
}
// get connection
RTMPConnection conn = (RTMPConnection) Red5.getConnectionLocal();
log.trace("Connection: {}", conn);
// get state
RTMP rtmp = conn.getState();
// determine working type
long timestamp = (message.getTimestamp() & 0xFFFFFFFFL);
LiveTimestampMapping mapping = rtmp.getLastTimestampMapping(channelId);
// just get the current time ONCE per packet
long now = System.currentTimeMillis();
if (mapping == null || timestamp < mapping.getLastStreamTime()) {
log.trace("Resetting clock time ({}) to stream time ({})", now, timestamp);
// either first time through, or time stamps were reset
mapping = rtmp.new LiveTimestampMapping(now, timestamp);
rtmp.setLastTimestampMapping(channelId, mapping);
}
mapping.setLastStreamTime(timestamp);
long clockTimeOfMessage = mapping.getClockStartTime() + timestamp - mapping.getStreamStartTime();
//determine tardiness / how late it is
long tardiness = clockTimeOfMessage - now;
//TDJ: EXPERIMENTAL dropping for LIVE packets in future (default false)
if (isLive && dropLiveFuture) {
tardiness = Math.abs(tardiness);
}
//subtract the ping time / latency from the tardiness value
if (conn != null) {
int lastPingTime = conn.getLastPingTime();
log.trace("Last ping time for connection: {} {} ms", conn.getId(), lastPingTime);
if (lastPingTime > 0) {
tardiness -= lastPingTime;
}
//subtract the buffer time
int streamId = conn.getStreamIdForChannel(channelId);
IClientStream stream = conn.getStreamById(streamId);
if (stream != null) {
int clientBufferDuration = stream.getClientBufferDuration();
if (clientBufferDuration > 0) {
//two times the buffer duration seems to work best with vod
if (isLive) {