log.trace("Decoding for connection - session id: {}", conn.getSessionId());
try {
// instance list to hold results
result = new LinkedList<Object>();
// get the local decode state
RTMPDecodeState state = conn.getDecoderState();
log.trace("{}", state);
if (!conn.getSessionId().equals(state.getSessionId())) {
log.warn("Session decode overlap: {} != {}", conn.getSessionId(), state.getSessionId());
}
while (buffer.hasRemaining()) {
final int remaining = buffer.remaining();
if (state.canStartDecoding(remaining)) {
log.trace("Can start decoding");
state.startDecoding();
} else {
log.trace("Cannot start decoding");
break;
}
final Object decodedObject = decode(conn, state, buffer);
if (state.hasDecodedObject()) {
log.trace("Has decoded object");
if (decodedObject != null) {
result.add(decodedObject);
}
} else if (state.canContinueDecoding()) {
log.trace("Can continue decoding");
continue;
} else {
log.trace("Cannot continue decoding");
break;