RTMP Part 4 - Command Message
This part will describe RTMP command message. Server and client in RTMP communicate and request for RPC using command message. Command messages are encoded using Action Message Format (AMF)
Command Message - AMF 0 have a message type id 20 and AMF 3 have a message type id 17.
A command message consist of command name, transaction id and command object.
These command messages can be used to perform connect, createStream, play, etc... It will also be used to update status for the command.
Data Message - AMF 0 have message type id 18 and AMF 3 have message type id 15
These data message are used to send meta data regarding the information of the stream. The meta data can be the configuration data for video and audio.
Shared Object Message - AMF 0 have kMessageContainerEx=19 and AMF 3 have kMessageContainerEx=16
These shared object message are Flash share objects. A flash share object is a collection of value pair information for synchronization across multiple clients.
The following event type are supported
Audio Message - AMF 0 and AMF 3 message type is 8
This message is used to send audio data to peers
Video Message - AMF 0 and AMF 3 message type is 9
This message is used to send video data to peers. As video message is huge and would delay sending of other type of messages, it should set with low priority
Aggregate Message - AMF 0 and AMF 3 message type is 22
It is a single message that contains many sub-messages
There are many type of commands for exchanging communication between peers. The following are the general rules
1. Sender will send a command with a transaction ID and some parameters
2. Receiver process the command and reply a response with same transaction ID
3. The response string can be _result, _error or a method name
2 class objects are used to send various commands
1. NetConnection - it gives a high level representation of connection between server and client
2. NetStream - it represents the channel (video/audio/data) over which data are sent. Control flow command (play, pause, etc...) are sent via NetStream
Reference: Adobe Official RTMP Specification