* @return Notify
*/
@SuppressWarnings("unchecked")
public Notify decodeStreamMetadata(IoBuffer in) {
Encoding encoding = ((RTMPConnection) Red5.getConnectionLocal()).getEncoding();
Input input = null;
// check to see if the encoding is set to AMF3.
// if it is then check to see if first byte is set to AMF0
byte amfVersion = 0x00;
if (encoding == Encoding.AMF3) {
amfVersion = in.get();
}
// reset the position back to 0
in.position(0);
//make a pre-emptive copy of the incoming buffer here to prevent issues that occur fairly often
IoBuffer copy = in.duplicate();
if (encoding == Encoding.AMF0 || amfVersion != AMF.TYPE_AMF3_OBJECT ) {
input = new org.red5.io.amf.Input(copy);
} else {
org.red5.io.amf3.Input.RefStorage refStorage = new org.red5.io.amf3.Input.RefStorage();
input = new org.red5.io.amf3.Input(copy, refStorage);
}
//get the first datatype
byte dataType = input.readDataType();
if (dataType == DataTypes.CORE_STRING) {
String setData = input.readString(String.class);
if ("@setDataFrame".equals(setData)) {
// get the second datatype
byte dataType2 = input.readDataType();
log.debug("Dataframe method type: {}", dataType2);
String onCueOrOnMeta = input.readString(String.class);
// get the params datatype
byte object = input.readDataType();
log.debug("Dataframe params type: {}", object);
Map<Object, Object> params;
if (object == DataTypes.CORE_MAP) {
// the params are sent as a Mixed-Array. Required to support the RTMP publish provided by ffmpeg/xuggler
params = (Map<Object, Object>) input.readMap(null);
} else {
// read the params as a standard object
params = (Map<Object, Object>) input.readObject(Object.class);
}
log.debug("Dataframe: {} params: {}", onCueOrOnMeta, params.toString());
IoBuffer buf = IoBuffer.allocate(1024);
buf.setAutoExpand(true);
Output out = new Output(buf);
out.writeString(onCueOrOnMeta);
out.writeMap(params);
buf.flip();
return new Notify(buf);
} else if ("onFI".equals(setData)) {
// the onFI request contains 2 items relative to the publishing client application
// sd = system date (12-07-2011)
// st = system time (09:11:33.387)
byte object = input.readDataType();
log.debug("onFI params type: {}", object);
Map<Object, Object> params;
if (object == DataTypes.CORE_MAP) {
// the params are sent as a Mixed-Array
params = (Map<Object, Object>) input.readMap(null);
} else {
// read the params as a standard object
params = (Map<Object, Object>) input.readObject(Object.class);
}
log.debug("onFI params: {}", params.toString());
} else {
log.info("Unhandled request: {}", setData);
if (log.isDebugEnabled()) {
byte object = input.readDataType();
log.debug("Params type: {}", object);
if (object == DataTypes.CORE_MAP) {
Map<Object, Object> params = (Map<Object, Object>) input.readMap(null);
log.debug("Params: {}", params.toString());
} else {
log.debug("The unknown request was did not provide a parameter map");
}
}