switch (subscriberStream.getState()) {
case PAUSED:
case STOPPED:
// we send a single snapshot on pause
if (sendCheckVideoCM(msgIn)) {
IMessage msg = null;
do {
try {
msg = msgIn.pullMessage();
} catch (Throwable err) {
log.error("Error while pulling message", err);
msg = null;
}
if (msg instanceof RTMPMessage) {
RTMPMessage rtmpMessage = (RTMPMessage) msg;
IRTMPEvent body = rtmpMessage.getBody();
if (body instanceof VideoData && ((VideoData) body).getFrameType() == FrameType.KEYFRAME) {
//body.setTimestamp(seekPos);
doPushMessage(rtmpMessage);
rtmpMessage.getBody().release();
messageSent = true;
lastMessageTs = body.getTimestamp();
break;
}
}
} while (msg != null);
}
}
// seeked past end of stream
if (currentItem.getLength() >= 0 && (position - streamOffset) >= currentItem.getLength()) {
stop();
}
// if no message has been sent by this point send an audio packet
if (!messageSent) {
// Send blank audio packet to notify client about new position
log.debug("Sending blank audio packet");
AudioData audio = new AudioData();
audio.setTimestamp(seekPos);
audio.setHeader(new Header());
audio.getHeader().setTimer(seekPos);
RTMPMessage audioMessage = RTMPMessage.build(audio);
lastMessageTs = seekPos;
doPushMessage(audioMessage);
audioMessage.getBody().release();
}
if (!messageSent && subscriberStream.getState() == StreamState.PLAYING) {
boolean isRTMPTPlayback = subscriberStream.getConnection() instanceof RTMPTConnection;
// send all frames from last keyframe up to requested position and fill client buffer
if (sendCheckVideoCM(msgIn)) {
final long clientBuffer = subscriberStream.getClientBufferDuration();
IMessage msg = null;
int msgSent = 0;
do {
try {
msg = msgIn != null ? msgIn.pullMessage() : null;