/** * Read remoting headers. * * @param in Input data as byte buffer * @return header map */ @SuppressWarnings("unchecked") protected Map<String, Object> readHeaders(IoBuffer in) { int version = in.getUnsignedShort(); // skip the version int count = in.getUnsignedShort(); log.debug("Read headers - version: {} count: {}", version, count); if (count == 0) { // No headers present return Collections.EMPTY_MAP; } Input input; if (version == 3) { input = new org.red5.io.amf3.Input(in); } else { input = new org.red5.io.amf.Input(in); } Map<String, Object> result = new HashMap<String, Object>(); for (int i = 0; i < count; i++) { String name = input.getString(); boolean required = in.get() == 0x01; int size = in.getInt(); Object value = Deserializer.deserialize(input, Object.class); log.debug( "Header: {} Required: {} Size: {} Value: {}", new Object[] {name, required, size, value}); result.put(name, value); } return result; }