code: public Object decode(RTMPConnection conn, RTMPDecodeState state, IoBuffer in) throws ProtocolException {
          //if (log.isTraceEnabled()) {
              //log.trace("Decoding for {}", conn.getSessionId());
          //}
          try {
              final byte connectionState = conn.getStateCode();
              switch (connectionState) {
                  case RTMP.STATE_CONNECTED:
                      return decodePacket(conn, state, in);
                  case RTMP.STATE_ERROR:
                  case RTMP.STATE_DISCONNECTING:
                  case RTMP.STATE_DISCONNECTED:
                      // throw away any remaining input data:
                      in.clear();
                      return null;
                  default:
                      throw new IllegalStateException("Invalid RTMP state: " + connectionState);
              }
          } catch (ProtocolException pe) {
              // raise to caller unmodified
              throw pe;
          } catch (RuntimeException e) {
              throw new ProtocolException("Error during decoding", e);
          } finally {
              //if (log.isTraceEnabled()) {
                  //log.trace("Decoding finished for {}", conn.getSessionId());
              //}
          }
      }
docs: Decodes the buffer data.
  
  @param conn
  RTMP connection
  @param state
  Stores state for the protocol, ProtocolState is just a marker interface
  @param in
  IoBuffer of data to be decoded
  @return one of three possible values:
  
  <pre>
  1. null : the object could not be decoded, or some data was skipped, just continue
  2. ProtocolState : the decoder was unable to decode the whole object, refer to the protocol state
  3. Object : something was decoded, continue
  </pre>
  @throws ProtocolException
  on error