蓝色的表示包头,红色的表示ObjType,绿色的表示数据。上面一段数据由2个RTMP包组成,2个RTMP包头分别用蓝色表示,第一个蓝色的是12字节的包头,后面一个蓝色的C3是一个字节的包头,绿色部分是数据,红色的是AMF数据类型,整个RTMP解码过程如下
[2008-06-18 16:59:20] DecodeInvoke:
[2008-06-18 16:59:20] InvokeName:String:connect
[2008-06-18 16:59:20] InvokeID:Double:0
[2008-06-18 16:59:20] Map:MapNum:0
[2008-06-18 16:59:20] Params:{
[2008-06-18 16:59:20] Key:String:objectEncoding
[2008-06-18 16:59:20] Value:Double:0
[2008-06-18 16:59:20] Key:String:app
[2008-06-18 16:59:20] Value:String:mediaserver
[2008-06-18 16:59:20] Key:String:fpda
[2008-06-18 16:59:20] Value:Bool:0
[2008-06-18 16:59:20] Key:String:tcUrl
[2008-06-18 16:59:20] Value:String:rtmp://127.0.0.1/mediaserver
[2008-06-18 16:59:20] Key:String:audioCodecs
[2008-06-18 16:59:20] Value:Double:615
[2008-06-18 16:59:20] Key:String:videoCodecs
[2008-06-18 16:59:20] Value:Double:76
[2008-06-18 16:59:20] }End Params
[2008-06-18 16:59:20] InvokeParams:String:PUBLISHER
[2008-06-18 16:59:20] InvokeParams:String:streamRecode
FMS3中为了实现H.264数据的直播而增加了一个数据类型,这个类型的值为0x16,这个类型不在下表中,如果需要请参看http://www.cnweblog.com/fly2700/archive/2009/02/06/297957.html
详细的ObjType数据类型如下:,参考Red5
enum AMF
{
/**
* Boolean value marker constant
*/
TYPE_BOOLEAN = 0x01, /**
* String marker constant
*/
TYPE_STRING = 0x02,
/**
* Object marker constant
*/
TYPE_OBJECT = 0x03,
/**
* Movieclip marker constant
*/
TYPE_MOVIECLIP = 0x04 ,
/**
* Null marker constant
*/
TYPE_NULL = 0x05,
/**
* Undefined marker constant
*/
TYPE_UNDEFINED = 0x06,
/**
* Object reference marker constant
*/
TYPE_REFERENCE = 0x07,
/**
* Mixed array marker constant
*/
TYPE_MIXED_ARRAY = 0x08,
/**
* End of object marker constant
*/
TYPE_END_OF_OBJECT = 0x09,
/**
* Array marker constant
*/
TYPE_ARRAY = 0x0A,
/**
* Date marker constant
*/
TYPE_DATE = 0x0B,
/**
* Long string marker constant
*/
TYPE_LONG_STRING = 0x0C,
/**
* Unsupported type marker constant
*/
TYPE_UNSUPPORTED = 0x0D,
/**
* Recordset marker constant
*/
TYPE_RECORDSET = 0x0E,
/**
* XML marker constant
*/
TYPE_XML = 0x0F,
/**
* Class marker constant
*/
TYPE_CLASS_OBJECT = 0x10,
/**
* Object marker constant (for AMF3)
*/
TYPE_AMF3_OBJECT = 0x11,
/**
* true marker constant
*/
VALUE_TRUE = 0x01,
/**
* false marker constant
*/
VALUE_FALSE = 0x00
};
RTMP协议分析 一、RTMP包头 :http://www.cnweblog.com/fly2700/archive/2008/04/09/281431.html
程序下载
http://www.cnweblog.com/fly2700/archive/2008/04/02/280641.html