code: private int calculateHeaderSize(final Header header, final Header lastHeader) {
          final byte headerType = getHeaderType(header, lastHeader);
          int channelIdAdd = 0;
          int channelId = header.getChannelId();
          if (channelId > 320) {
              channelIdAdd = 2;
          } else if (channelId > 63) {
              channelIdAdd = 1;
          }
          return RTMPUtils.getHeaderLength(headerType) + channelIdAdd;
      }
docs: Calculate number of bytes necessary to encode the header.
  
  @param header
  RTMP message header
  @param lastHeader
  Previous header
  @return Calculated size