code: private byte getHeaderType(final Header header, final Header lastHeader) {
          //int lastFullTs = ((RTMPConnection) Red5.getConnectionLocal()).getState().getLastFullTimestampWritten(header.getChannelId());
          if (lastHeader == null || header.getStreamId() != lastHeader.getStreamId() || header.getTimer() < lastHeader.getTimer()) {
              // new header mark if header for another stream
              return HEADER_NEW;
          } else if (header.getSize() != lastHeader.getSize() || header.getDataType() != lastHeader.getDataType()) {
              // same source header if last header data type or size differ
              return HEADER_SAME_SOURCE;
          } else if (header.getTimer() != lastHeader.getTimer()) {
              // timer change marker if there's time gap between header time stamps
              return HEADER_TIMER_CHANGE;
          }
          // continue encoding
          return  HEADER_CONTINUE;
      }
docs: Determine type of header to use.
  
  @param header RTMP message header
  @param lastHeader Previous header
  @return Header type to use