关于ping(英文)

来源:互联网 发布:合作社软件 编辑:程序博客网 时间:2024/04/29 11:50
 
Ping is the most mysterious message in RTMP and till now we haven't fully interpreted it yet. In summary, Ping message is used as a special command that are exchanged between client and server. This page aims to document all known Ping messages. Expect the list to grow.

The type of Ping packet is 0x4 and contains two mandatory parameters and two optional parameters. The first parameter is the type of Ping and in short integer. The second parameter is the target of the ping. As Ping is always sent in Channel 2 (control channel) and the target object in RTMP header is always 0 which means the Connection object, it's necessary to put an extra parameter to indicate the exact target object the Ping is sent to. The second parameter takes this responsibility. The value has the same meaning as the target object field in RTMP header. (The second value could also be used as other purposes, like RTT Ping/Pong. It is used as the timestamp.) The third and fourth parameters are optional and could be looked upon as the parameter of the Ping packet. Below is an unexhausted list of Ping messages.

  • type 0: Clear the stream. No third and fourth parameters. The second parameter could be 0. After the connection is established, a Ping 0,0 will be sent from server to client. The message will also be sent to client on the start of Play and in response of a Seek or Pause/Resume request. This Ping tells client to re-calibrate the clock with the timestamp of the next packet server sends.
  • type 1: Tell the stream to clear the playing buffer.
  • type 3: Buffer time of the client. The third parameter is the buffer time in millisecond.
  • type 4: Reset a stream. Used together with type 0 in the case of VOD. Often sent before type 0.
  • type 6: Ping the client from server. The second parameter is the current time.
  • type 7: Pong reply from client. The second parameter is the time the server sent with his ping request.