当前位置:文档之家› RTMP协议

RTMP协议

RTMP Protocol

Connect

NetConnect.connect()

Flash Play 通过NetConnect.connect连接到RTMP Server时,首先进行握手,再发送connect的参数.

1) 握手过程有三步:

Step 1,

Flash Player 至RTMP Server : 1个byte(0x03)+1536个byte数据.

Step 2,

RTMP Server至Flash Player : 1个byte(0x03)+1536个byte数据(Server的握手数据) + 1536个byte数据(通过和随机数hash得出, 详见附录)

Step 3,

Flash Player 至RTMP Server : 1536个byte数据(RTMP Server计算出来的). 注意:这个数据块没有1个byte的0x03.

2) 接下是connect参数

RTMP Server <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

RTMP包格式,详见TheAMF.pdf

3) RTMP Server给Flash Player的返回包(TOCHECK: 是否需要0x04的ping包)

RTMP Server >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Flash Player RTMP协议步骤

Step 1

发送一个0x05的包,即ServerBW, (channel 0x02)

(0x00 26 25 a0)

Step 2

发送一个0x06的包,即ClientBW, (channel 0x02)

(0x00 26 25 a0) + (0x02)

Step 3

发送一个0x14的包,即Invoke, (channel 0x03) (body超过128的长度就要分包, 用0xc3来) string (“_result”)

+ number (0x3F F0 00 00 00 00 00 00)

+ Object string (“capabilities”) ; number (31.0)

string (“fmsV er”) ; string (随便填) (“RubyIZUMI/0,1,2,0”)

End Of Object (0x00 00 09)

//(connect status)

+ Object string (“code”) ; string (“NetConnection.Connect.Success”)

string (“level”) ; string (“status”)

string (“description”) ; string (“Connection Succeeded.”)

End Of Object (0x00 00 09)

RTMP Server <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

(0x00 26 25 a0)

Stream Functions

1. CreateStream: NetStream(nc)

RTMP Server <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

string (“CreateStream”)

+ number (0x40 00 00 00 00 00 00 00)

+ null (0x05)

RTMP Server >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Flash Player 2) RTMP Server返回Flash Player一个0x14的包,即Invoke (channel 0x03)

string (“_result”)

+ number (0x40 00 00 00 00 00 00 00)

+ null (0x05)

+ number(0x3F F0 00 00 00 00 00)

RTMP Server <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

V alue1 (0x00 03) 表示buffer time的请求

V alue2 (0x00 00 00 01) 表示streamId

V alue3 (0x00 00 00 00) 表示buffer time

2. Play: NetStream.play()

RTMP Server <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Play file:

NetStream.Play(“test.mp4”);

string (“play”)

+ number(0x00 00 00 00 00 00 00 00)

+ null(0x05)

+ string (“test.mp4”)

Play live:

NetStream.Play(“red5StreamDemo_video”);

string (“play”)

+ number(0x00 00 00 00 00 00 00 00)

+ null(0x05)

+ string (“red5StreamDemo_video”)

Play file with parameters:

NetStream.Play(“red5StreamDemo_video”, -1);

string (“play”)

+ number(0x00 00 00 00 00 00 00 00)

+ null(0x05)

+ string (“red5StreamDemo_video”)

相关主题