Expand description
§The RTMP Messages
After handshake, both are required to negosiate what are needed for sending/receiving. It consists of following steps:
§connect
Exchanges informations about their applications each other. In this case, next format is required:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "connect" |
Transaction ID | Number | 1 |
Command Object | Object | See Command Object. |
In the command message, we negotiate by using the Action Message Format (v0).
Command Object
The Command Object is written detailed informations of both applications. Concretely, several of following pair is exchanged:
Key | AMF Type | Description |
---|---|---|
app | String | Server application name. |
flashVer | String | Either a flash player version(client) or an FLV encoder version(server). |
swfUrl | String | The source SWF file URL. |
tcURL | String | The URL to connect server as the TCP. app value is included in this value. |
fpad | Boolean | Whether a proxy is used. |
audioCodecs | Number | Supported audio codecs. |
videoCodecs | Number | Supported video codecs. |
videoFunctions | Number | Supported video functions. |
pageUrl | String | The URL of web page which SWF file is loaded. |
objectEncoding | Number | A version of the Action Message Format. |
Note: Something not in above can be exchanged.
Against, the result for connect request is required to be next format:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "_result" or "_error" |
Transaction ID | Number | Same as the connect request |
Properties | Object | e.g. server-side informations. |
Information | Object | Contents for describing its response. |
§releaseStream
Tells “Play Path” to the parter. In this case, next format is required:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "releaseStream" |
Transaction ID | Number | A number which is next of the connect. |
Null | Nothing but an AMF’s type marker is in. | |
Play Path | String | Any string is in if it is specified. |
For example, Play Path is defined as some file name in FFmpeg.
Against, the result for releaseStream request is required to be next format:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "_result" or "_error" |
Transaction ID | Number | Same as the releaseStream request. |
Null | Nothing but an AMF’s type marker is in. |
§FCPublish
Tells to the partner what is same as the releaseStream request. In this case, next format is required:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "FCPublish" |
Transaction ID | Number | A number which is next of the releaseStream. |
Null | Nothing but an AMF’s type marker is in. | |
Play Path | String | (Probably) Same as the releaseStream request. |
Against, the result for FCPublish request is required to be next format:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "onFCPublish" |
§createStream
Requests to create a new Message Stream ID to the partner. In this case, next format is required:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "createStream" |
Transaction ID | Number | A number which is next of the FCPublish. |
Null | Nothing but an AMF’s type marker is in. |
Against, the result for createStream request is required to be next format:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "_result" or "_error" |
Transaction ID | Number | Same as the createStream request. |
Null | Nothing but an AMF’s type marker is in. | |
Message ID | Number | A Message Stream ID which is assigned by the partner. |
§publish
Tells to the partner what is an way to publish its stream. In this case, next format is required:
Field | AMF Type | Value |
---|---|---|
Command Name | String | "publish" |
Transaction ID | Number | A number which is next of the createStream. |
Null | Nothing but an AMF’s type marker is in. | |
Publishing Name | String | A name for publishing its stream to the partner. |
Publishing Type | String | Either "live" , "record" or "append" . See Publishing Type. |
Against, results for publish request are required to be next format:
§Stream Begin
This is an event message of the User Control Message. This has following data:
- Event Type (2 bytes /
0
) - A Message ID (4 bytes.)
§onStatus
Field | AMF Type | Value |
---|---|---|
Command Name | String | "onStatus" |
Transaction ID | Number | 0 |
Null | Nothing but an AMF’s type marker is in. | |
Info Object | Object | Similar to the information of connect result. |
Publishing Type
The publish command requires you to specify one of “Publishing Type” in its request. Publishing Type means:
"live"
Only streaming. Media data will never be stored.
"record"
Media data will be stored. If publishing name duplicated, it is rewritten as a new file.
"append"
Same as "record"
excepts is appended media data if publishing name duplicated.
Every chunk has the chunk headers.
See sheave_core::messages::headers
about them.
After negotiation, the server receives actual audio/video data from clients.
However also FLV metadata is received as the AMF (v0).
The message what contains FLV metadata is called SetDataFrame
.
§SetDataFrame
Modules§
- The Action Message Formats
- The Chunk Headers
Structs§
- The message to tell that some message length has exceeded the server-side bandwidth range. Note this must be input the total message length in receiving. (it’s not bytes received.)
- Tells a size to chunk its stream to the partner.
- The command to tell the information that where connects from/to.
- The response message for Connect requests.
- The command to request emitting a message ID to a server.
- The response message for CreateStream requests.
- The command to request to delete its message ID.
- The command to tell the playpath. Typically, this becomes same as the releaseStream’s one.
- This command is same as
FcPublish
except this requests to delete the playpath. - An error means that some command name differs you expect.
- An error means that some event type differs you expect.
- An error that some publishing type differs you expect.
- An error that some chunk size is negative.
- The response message for FcPublish requests.
- The response message for Publish requests.
- The message to tell the client-side bandwidth. This has 2 ways of comparision by which field you specifies.
- The command to tell publishing information.
- An error that publishing has failed by something cause.
- The command to tell the Play Path (e.g. something file name).
- The response message for ReleaseStream requests.
- The message to handle something data.
- The event to tell that the stream is ready to a client.
- The message to tell the server-side bandwidth. Almost RTMP tools are specifying it 2500000 in bits as their defaults.
Enums§
- The IDs which are assigned every roles of chunks. This is mainly used for the
BasicHeader
’s chunk ID. - The IDs which are types of user control messages.
Traits§
- Uniforms chunk data by a channel numbers and a message type.
- Uniforms user control messages by an event type.
Functions§
- A utility function of constructing an
InconsistentCommand
error. - A utility function of constructing an
InconsistentEventType
error. - A utility function of constructing an
InvalidPublishingType
error. - A utility function of constructing a
NegativeChunkSize
error. - A utility function of constructing a
PublishingFailure
error.