Table of Contents
4. Technical documentation
4.1. Protocols
RTMP server handles a wide range of protocols. This protocols can be interconnected, providing a chain of protocols or a protocol stack. This protocol stack in turn provides a communication channel between 2 endpoints. Here is a block schema of such protocol chain:
- P1 to Pn are some protocols
- Any protocol has at least one neighbor protocol
- Left side of a protocol (the side nearest to the outside world) is called FAR protocol
- Right side of a protocol (the side opposite to the outside world) is called NEAR protocol protocol. For example P2 has P1 as FAR protocol and P3 as NEAR protocol
- Every chain has a FAR endpoint and a NEAR endpoint. The FAR endpoint is the FAR-most protocol and the NEAR endpoint is the NEAR-most protocol. In our example P1 is a FAR endpoint and Pn is a NEAR endpoint
- Data flowing from the outside world to the server is called Inbound Data and in the server flows from the FAR endpoint to the NEAR endpoint through the protocol stack
- Data flowing from the server to the outside world is called Outbound Data and in the server flows from the NEAR endpoint to the FAR endpoint through the protocol stack
4.1.1. List of protocols
4.1.1.1. NEAR Application protocols
Data that flows between RTMP server and app server is composed from 2 types of messages:
- RTMP messages.
- Custom control messages.
We can transfer all this messages by using 2 kinds of serializers:
- RTMP/AMF
- VARIANT
Any RTMP messages can be transposed into a VARIANT structure. In turn VARIANT structure can be serialized using a wide range of methods:
- XML
- Free text
- AMF
- VARIANT binary
- and the list continues
You wonder now: "Why should I transform a RTMP/AMF into Variant and after that serialize it using AMF?". The answer is simple: the original message (the RTMP/AMF) contains a RTMP header too. Which is RTMP specific (not AMF).
We can identify 2 kinds of protocols:
- Human-Readable protocols (XML, Free text, etc)
- RTMP messages will be transposed into a VARIANT structure.
- Custom messages are already a VARIANT structure
- Having both kinds of messages transposed into VARIANT structures, we can serialize them using any Human-Readable protocol that VARIANT offers
- Binary protocols
- RTMP messages are already in binary format
- Control messages are VARIANT structures so we can choose a binary serializer (including AMF)
- Having both kinds of messages in binary form, we must pad them with a serializer identifier because the receiving part must know how to read them.
Finally, the binary protocol will look like this:
| Bytes position | Meaning and/or possible values |
| 0 | Protocol type: 0 – RTMP/AMF; 1 – VARIANT BINARY; 2 – AMF; This list can grow |
| 1..n | The payload data which is self describing in terms of length |
TO BE CONTINUED
4.1.2. Protocols compatibility grid
NOT EDITED YET
Attachments
-
ProtocolStack.PNG
(9.6 KB) - added by shiretu
11 months ago.