介紹
RTMP(Real Time Messaging Protocol)協(xié)議是 Adobe 推出的實(shí)時(shí)消息協(xié)議碍侦,通過可靠的流式傳輸協(xié)議(例如 TCP)提供雙向消息多路復(fù)用服務(wù)揽咕,旨在在一對(duì)通信對(duì)等點(diǎn)(a pair of communicating peers)之間傳輸攜帶相關(guān)時(shí)間信息的視頻、音頻和數(shù)據(jù)消息的并行流。
定義
字節(jié)序胞得,對(duì)齊方式和時(shí)間格式
字節(jié)序 : 所有整數(shù)字段按網(wǎng)絡(luò)字節(jié)序進(jìn)行傳輸,地址低位(整型起始地址)存儲(chǔ)整型高位,這種字節(jié)序通常被稱為大端序氏捞。
對(duì)齊方式 :除非另有說明,否則 RTMP 中的所有數(shù)據(jù)都是字節(jié)對(duì)齊的借宵。
時(shí)間格式 : RTMP 中的時(shí)間戳以毫秒的整數(shù)形式給出幌衣,相對(duì)于一個(gè)未指定的紀(jì)元(epoch)矾削。通常壤玫,每個(gè)流的開始時(shí)間戳未 0;不過,如果兩個(gè)端點(diǎn)(endpoint)在紀(jì)元上達(dá)成一致盈包,就可以從指定的紀(jì)元開始匀泊。
由于時(shí)間戳的長度是32位的,因此時(shí)間戳?xí)?9天17時(shí)2分47.296秒滾動(dòng)一次猎贴。因?yàn)榱骺梢赃B續(xù)運(yùn)行班缎,可能連續(xù)運(yùn)行很多年,所以RTMP應(yīng)用程序在處理時(shí)間戳?xí)r應(yīng)使用序列號(hào)算法[ RFC1982 ]她渴,并且應(yīng)該能夠處理包裝达址。
RTMP Chunk Stream
RTMP Chunk Stream 是一個(gè)邏輯通信通道,為更高級(jí)的多媒體流協(xié)議(message)提供多路復(fù)用和打包服務(wù)趁耗。RTMP connection 可以復(fù)用一路或多路 chunk stream沉唠,不同的 message stream 可以被復(fù)用到同一個(gè) chunk stream 中,然后通過不同的 message stream id 被解復(fù)用成不同的 message stream苛败。message stream id 在 chunk header 中占用4個(gè)字節(jié)满葛。
Chunk
RTMP 基于 TCP 傳輸,當(dāng) RTMP 發(fā)送大消息時(shí)罢屈,大的 message (例如 video key frame)將占用信道導(dǎo)致小的 audio message 或 control message 得不到傳輸嘀韧。RTMP 通過 chunking 解決這一問題,保證傳輸?shù)墓叫圆啤hunking 將高級(jí)協(xié)議中的大 message 分解為小 chunk 锄贷。
Chunk Format
每一個(gè) chunk 包含 chunk header 和 chunk data,chunk header 被劃分為三部分:Basic header鄙币,message header 和 extended timestamp 肃叶。
+--------------+----------------+--------------------+--------------+
| Basic Header | Message Header | Extended Timestamp | Chunk Data |
+--------------+----------------+--------------------+--------------+
| |
|<------------------- Chunk Header ----------------->|
Chunk Basic Header
chunk basic header 包含 chunk type(2bits)和 chunk stream ID,長度取決于 chunk stream ID十嘿,其可變長度范圍為 1, 2, 3 bytes 因惭。
1 bytes
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|fmt| cs id |
+-+-+-+-+-+-+-+-+
1 bytes 長度的 chunk basic header 的 cs id 只表示 2-63,保留 0 和 1 分別用于指示 2 bytes 和 3 bytes 的 chunk basic header 绩衷。
2 bytes
0 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|fmt|0 0 0 0 0 0| cs id - 64 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
其中蹦魔,cs id 表示 64-319
cs id = 第二個(gè)字節(jié)表示的值 + 64。
3 bytes
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|fmt|0 0 0 0 0 1| cs id - 64 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
其中咳燕,cs id 表示 64-65599
cs id = 第三個(gè)字節(jié)表示的值 * 256 + 第二個(gè)字節(jié)表示的值 + 64勿决。
fmt
fmt (2 bits) : 標(biāo)識(shí)四種 chunk message header 格式:
- 00 表示 TYPE 0
- 01 表示 TYPE 1
- 10 表示 TYPE 2
- 11 表示 TYPE 3
chunk message header
TYPE0
TYPE 0 包含 message header 的完整信息,chunk stream 必須以 TYPE 0 開始招盲,否則關(guān)于 message header 的信息將不完整低缩。
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| timestamp |message length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| message length (cont) |message type id| msg stream id |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| message stream id (cont) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
timestamp : 消息的絕對(duì)時(shí)間戳。如果時(shí)間戳大于等于16777215 (十六進(jìn)制0xFFFFFF),則該字段為16777215咆繁。0xFFFFFF 時(shí)表明存在 Extended Timestamp 字段來編碼完整的32位時(shí)間戳讳推。
TYPE1
當(dāng)使用 TYPE1 時(shí) 表明 message 和當(dāng)前 chunk stream 的上一個(gè) TYPE0 的 message stream id 相同。
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| timestamp delta |message length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| message length (cont) |message type id|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
timestamp delta : 消息的增量時(shí)間戳玩般∫伲基于相同 chunk stream id 的最新時(shí)間戳進(jìn)行計(jì)算。
TYPE2
當(dāng)使用 TYPE2 時(shí)表明 message 和當(dāng)前 chunk stream 的上一個(gè) message 的 message length坏为,message type id究驴,message stream id 相同。
使用場景:當(dāng)發(fā)送相同 message length匀伏,message type id洒忧,message stream id 的 messages 時(shí)使用。
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| timestamp delta |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
TYPE3
TYPE 3 的 chunk 沒有 message header 够颠。TYPE 3 的 chunks 從相同的 chunk stream id 的前一個(gè)塊中獲取信息跑慕。
TYPE 3 有兩張使用場景:
- 當(dāng)一個(gè) message 被分割成許多 chunks 時(shí),初了第一個(gè) chunk 之外的其余 chunk 都應(yīng)該使用這種類型摧找。接收端根據(jù)第一個(gè) chunk 的 message length 等待后續(xù)的 chunk 并組合成一個(gè)完成的 message 核行。
- 由 message stream id,message length蹬耘,message type芝雪,timestamp delta 相同的 messages 組成的 message stream,在第一個(gè) message 使用 TYPE0 指示 message stream id综苔,message length惩系,message type 和 timestamp,第二個(gè) message 使用 TYPE2 指示 timestamp delta 后如筛,剩下的 message 可以使用 TYPE3 堡牡。
header fields
Message
Message Format
RTMP message 擁有兩部分:header 和 payload 。
Message Header
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message Type | Payload length |
| (1 byte) | (3 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Timestamp |
| (4 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Stream ID |
| (3 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Message Type: 表示消息類型杨刨。
Length: 表示負(fù)載長度晤柄,網(wǎng)絡(luò)字節(jié)序。
Timestamp: 表示消息的時(shí)間戳妖胀,網(wǎng)絡(luò)字節(jié)序芥颈。
Message Stream Id: 表示消息流ID,定義消息流的唯一性赚抡,網(wǎng)絡(luò)字節(jié)序爬坑。
Message Payload
Message 中的數(shù)據(jù)部分,例如:音頻數(shù)據(jù)或視頻數(shù)據(jù)涂臣。Payload 不在 RTMP 的解釋范圍盾计,詳見:FLV,F(xiàn)LV Audio Tag,F(xiàn)LV Video Tag 等署辉。
Message Type
Protocal Control Message
Protocal Control Message 的 message stream ID 必須等于 0 (0表示控制協(xié)議)灼舍,并且 chunk stream ID 必須是 2 。協(xié)議控制消息在收到后需要即刻處理涨薪,其時(shí)間戳可以忽略。
Set Chunk Size
Set Chunk Size Message 用于通知對(duì)端:新的 maximum chunk size, 默認(rèn)的 maximum chunk size 為 128 字節(jié)炫乓,maximum chunk size 至少為 128 字節(jié)刚夺。每個(gè)方向的 maximum chunk size 是獨(dú)立維護(hù)的(即 A發(fā)往B 和 B發(fā)往A 的maximum chunk size 是獨(dú)立維護(hù)的)。
格式:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0| chunk size (31 bits) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
其中:
- 0 : 第 0 位必須為 0 末捣。
- chunk size : 表示新的 maximum chunk size 侠姑,單位為字節(jié)。chunk size 的有效大小為 1 到 2147483647 (0x7FFFFFFF)箩做,但是設(shè)置大于 16777215 (0xFFFFFF) 的 maximum chunk size 均等價(jià)于 16777215 莽红,因?yàn)?message size 是小于等于 16777215 (0xFFFFFF) 的。
Abort Message
Abort Message 用于通知對(duì)端:如果正在等待 chunks 完成一個(gè) message邦邦,則當(dāng)收到 Abort Message 時(shí)請結(jié)束等待 Abort Message 指定的 chunk stream id 的chunks安吁,并且丟棄 chunk stream id 上收到的部分 message 的 chunks。
格式:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| chunk stream id (32 bits) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
其中:
- chunk stream id : 通知對(duì)端中斷 chunk stream id 上的當(dāng)前 message 燃辖。
Acknowledgement
Acknowledgement message 指定 sequence number 表示目前為止接收到的字節(jié)數(shù)鬼店。
當(dāng) client 或 server 在接收到的字節(jié)數(shù)等于 window size 后,必須向?qū)Χ税l(fā)送一個(gè) acknowledgement 黔龟。window size 是發(fā)送端在沒有接收到接收端 acknowledgement 的情況下發(fā)送的最大字節(jié)數(shù)妇智,因此接收端必須給發(fā)送端回 acknowledgement,否則發(fā)送端將不繼續(xù)發(fā)送數(shù)據(jù)氏身。
格式:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| sequence number (4 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
其中:
- sequence number : 接收端迄今為止收到的字節(jié)數(shù) 巍棱。
Window Acknowledgement Size
Window Acknowledgement Size Message 用于通知對(duì)端現(xiàn)在的 Window Acknowledgement Size,對(duì)端在每接收到 window size 個(gè)字節(jié)時(shí)需要發(fā)送一個(gè) Acknowledgement message(從一個(gè)新的 session 或上一個(gè) Acknowledgement message 開始統(tǒng)計(jì))蛋欣。
格式:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgement Window size (4 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Set Peer Bandwidth
Set Peer Bandwidth Message 用于限制對(duì)端的帶寬輸出航徙。接收到此消息的端通過將已發(fā)送但未 ack (未收到 Acknowledgement message)的數(shù)據(jù)大小限制在 Set Peer Bandwidth Message 指示的 Acknowledgement Window size 之內(nèi)來限制其輸出帶寬。
接收到 Set Peer Bandwidth Message 的端需要重新發(fā)送一個(gè) Window Acknowledgement Size Message 指示相同的 Acknowledgement Window size陷虎,否則有可能無法觸發(fā) Acknowledgement 捉偏。
格式:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgement Window size (4 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Limit Type |
+-+-+-+-+-+-+-+-+
其中:
-
Limit Type:
- 0 : HARD,對(duì)端應(yīng)該嚴(yán)格將其輸出帶寬限制為指定的窗口大小泻红。
- 1 : SOFT夭禽, 對(duì)端應(yīng)該將其輸出帶寬限制為指定的窗口大小或已生效的限制中的最小值。
- 2 : DYNIMIC谊路,如果前一個(gè) Limit Type 是 HARD 則為 HARD讹躯,否則無視當(dāng)前消息。
User Control Message
User Control Message 的 message stream ID 應(yīng)該等于 0 (0表示控制協(xié)議)(同 Protocal Control Message ),并且 chunk stream ID 是 2 (同 Protocal Control Message )潮梯。User Control Message 在收到后需要即刻處理骗灶,其時(shí)間戳可以忽略。
格式:
+------------------------------+-------------------------
| Event Type (16 bits) | Event Data
+------------------------------+-------------------------
Audio Message
Audio Message 用于發(fā)送音頻數(shù)據(jù)秉馏,Audio Message Payload 詳見 Audio 文件格式耙旦,例如:FLV Audio Tag 。
Video Message
Video Message 用于發(fā)送視頻數(shù)據(jù)萝究,Video Message Payload 詳見 Video 文件格式免都,例如:FLV Video Tag 。
Data Message
Data Message 通常被用于發(fā)送 MetaData 或任意 user data 到對(duì)端帆竹。Metadata 通常包括音視頻數(shù)據(jù)的 creation time绕娘,duration,theme 等栽连。
Data Message Payload 是 AMF 二進(jìn)制格式數(shù)據(jù)险领。
例如:FLV 中的 Script Tag Data,使用兩個(gè) AMF 包描述 MetaData:
- 第一個(gè) AMF 包是 onMetaData 包秒紧。第 1 個(gè)字節(jié)表示的是 AMF 包的類型绢陌,第一個(gè) AMF 包一般是字符串類型,字符串類型的值表示是 0x02熔恢,之后是 2 字節(jié)表示的長度下面,一般長度總是 10,值是 0x000A绩聘,之后就是 10 字節(jié)長度字符串沥割,值是 onMetaData 。
-
第二個(gè) AMF 包是一個(gè) Objcet 類型的 AMF 包凿菩,Object 類型的值表示是 0x03机杜,Objcet 元素為元素名稱和值組成的對(duì),常見的元素如下:
metadata
Shared Object Message
Shared Object 是一個(gè) Flash Object (一個(gè) name 和 value 對(duì)的集合)衅谷,用于跨多個(gè) 客戶端椒拗、實(shí)例等進(jìn)行同步。
+------+------+-------+-----+-----+------+-----+ +-----+------+-----+
|Header|Shared|Current|Flags|Event|Event |Event|.|Event|Event |Event|
| |Object|Version| |Type |data |data |.|Type |data |data |
| |Name | | | |length| |.| |length| |
+------+------+-------+-----+-----+------+-----+ +-----+------+-----+
| |
|<- - - - - - - - - - - - - - - - - - - - - - - - - - - - - >|
| AMF Shared Object Message body |
Shared Objcet Event :
Aggregate Message
Aggregate Message 是 Message 的一個(gè)聚合體获黔,包含一系列的 message 蚀苛。
Aggregate Message format :
+---------+-------------------------+
| Header | Aggregate Message body |
+---------+-------------------------+
Aggregate Message body format :
+--------+-------+---------+--------+-------+---------+ - - - -
|Header 0|Message|Back |Header 1|Message|Back |
| |Data 0 |Pointer 0| |Data 1 |Pointer 1|
+--------+-------+---------+--------+-------+---------+ - - - -
Back Pointer 包含前一個(gè) message (包含 Header 和 Message Data)的大小,Back Pointer 用于匹配 FLV 文件格式玷氏,用于向后查找堵未。
Aggregate Message 的好處:
- chunk stream 在一個(gè) chunk 內(nèi)最多只能發(fā)送一個(gè)單個(gè)完整的 message。因此盏触,可以合并多個(gè)小的 message 到一個(gè) Aggregate Message 中渗蟹,使用一個(gè) chunk 發(fā)送块饺,便可以減少 chunk 的發(fā)送次數(shù)。
- 子 message 可以連續(xù)存儲(chǔ)在內(nèi)存中雌芽,在系統(tǒng)調(diào)用時(shí)授艰,在網(wǎng)絡(luò)上發(fā)送數(shù)據(jù)效率更高。
Command Messages
Command Message 采用 AMF 編碼世落。
- 發(fā)送端發(fā)送的 command message 包含 command name淮腾,transaction ID 以及包含相關(guān)參數(shù)的 command object (name 和 value 組合的 pair)。
- 接收端處理 command 并且返回 response 攜帶相同的 transaction ID屉佳,response 的字符串可以是 _result, _error, or method name (例如:verifyClient or contactExternalServer)谷朝。
- _result 或 _error 命令字符串表示響應(yīng)。transaction ID 指示響應(yīng)所指的 command忘古。
- method name 表示嘗試在對(duì)端運(yùn)行 method。
下面的對(duì)象是用來發(fā)送不一樣的 command :
- NetConnection: 服務(wù)器和客戶端之間連接的高級(jí)表示形式诅诱。
- NetStream: 表示發(fā)送音頻流髓堪、視頻流和其他相關(guān)數(shù)據(jù)的通道的對(duì)象。當(dāng)然也發(fā)送諸如播放娘荡、暫停等控制數(shù)據(jù)流的命令干旁。
NetConnection Commands
NetConnection 管理客戶端應(yīng)用程序和服務(wù)器之間的雙向連接。此外炮沐,它還提供對(duì)異步遠(yuǎn)程方法調(diào)用的支持争群。
可以在 NetConnection 上發(fā)送以下命令:
- connect
- call
- close
- createStream
connect
client 向 server 發(fā)送 connect 命令請求建連:
+----------------+---------+---------------------------------------+
| Field Name | Type | Description |
+--------------- +---------+---------------------------------------+
| Command Name | String | Name of the command. Set to "connect".|
+----------------+---------+---------------------------------------+
| Transaction ID | Number | Always set to 1. |
+----------------+---------+---------------------------------------+
| Command Object | Object | Command information object which has |
| | | the name-value pairs. |
+----------------+---------+---------------------------------------+
| Optional User | Object | Any optional information |
| Arguments | | |
+----------------+---------+---------------------------------------+
Command Object 包含以下 key/value pairs :
+-----------+--------+-----------------------------+----------------+
| Property | Type | Description | Example Value |
+-----------+--------+-----------------------------+----------------+
| app | String | The Server application name | testapp |
| | | the client is connected to. | |
+-----------+--------+-----------------------------+----------------+
| flashver | String | Flash Player version. It is | FMSc/1.0 |
| | | the same string as returned | |
| | | by the ApplicationScript | |
| | | getversion () function. | |
+-----------+--------+-----------------------------+----------------+
| swfUrl | String | URL of the source SWF file | file://C:/ |
| | | making the connection. | FlvPlayer.swf |
+-----------+--------+-----------------------------+----------------+
| tcUrl | String | URL of the Server. | rtmp://local |
| | | It has the following format.| host:1935/test |
| | | protocol://servername:port/ | app/instance1 |
| | | appName/appInstance | |
+-----------+--------+-----------------------------+----------------+
| fpad | Boolean| True if proxy is being used.| true or false |
+-----------+--------+-----------------------------+----------------+
|audioCodecs| Number | Indicates what audio codecs | SUPPORT_SND |
| | | the client supports. | _MP3 |
+-----------+--------+-----------------------------+----------------+
|videoCodecs| Number | Indicates what video codecs | SUPPORT_VID |
| | | are supported. | _SORENSON |
+-----------+--------+-----------------------------+----------------+
|videoFunct-| Number | Indicates what special video| SUPPORT_VID |
|ion | | functions are supported. | _CLIENT_SEEK |
+-----------+--------+-----------------------------+----------------+
| pageUrl | String | URL of the web page from | http:// |
| | | where the SWF file was | somehost/ |
| | | loaded. | sample.html |
+-----------+--------+-----------------------------+----------------+
| object | Number | AMF encoding method. | AMF3 |
| Encoding | | | |
+-----------+--------+-----------------------------+----------------+
- app 是 client 請求 connect 的 server 的 application name
- tcUrl 是 server 的 url,格式為
protocol://servername:port/appName/appInstance
例如:rtmp://localhost:1935/testapp/instance1
大年。
注意:play 或 publish 時(shí)只需指定 stream_name 换薄,完整的 stream url 將基于 tcUrl 進(jìn)行拼接。
audioCodecs 的值和含義:
+----------------------+----------------------------+--------------+
| Codec Flag | Usage | Value |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_NONE | Raw sound, no compression | 0x0001 |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_ADPCM | ADPCM compression | 0x0002 |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_MP3 | mp3 compression | 0x0004 |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_INTEL | Not used | 0x0008 |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_UNUSED | Not used | 0x0010 |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_NELLY8 | NellyMoser at 8-kHz | 0x0020 |
| | compression | |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_NELLY | NellyMoser compression | 0x0040 |
| | (5, 11, 22, and 44 kHz) | |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_G711A | G711A sound compression | 0x0080 |
| | (Flash Media Server only) | |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_G711U | G711U sound compression | 0x0100 |
| | (Flash Media Server only) | |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_NELLY16 | NellyMouser at 16-kHz | 0x0200 |
| | compression | |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_AAC | Advanced audio coding | 0x0400 |
| | (AAC) codec | |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_SPEEX | Speex Audio | 0x0800 |
+----------------------+----------------------------+--------------+
| SUPPORT_SND_ALL | All RTMP-supported audio | 0x0FFF |
| | codecs | |
+----------------------+----------------------------+--------------+
videoCodecs 的值和含義:
+----------------------+----------------------------+--------------+
| Codec Flag | Usage | Value |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_UNUSED | Obsolete value | 0x0001 |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_JPEG | Obsolete value | 0x0002 |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_SORENSON | Sorenson Flash video | 0x0004 |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_HOMEBREW | V1 screen sharing | 0x0008 |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_VP6 (On2)| On2 video (Flash 8+) | 0x0010 |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_VP6ALPHA | On2 video with alpha | 0x0020 |
| (On2 with alpha | channel | |
| channel) | | |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_HOMEBREWV| Screen sharing version 2 | 0x0040 |
| (screensharing v2) | (Flash 8+) | |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_H264 | H264 video | 0x0080 |
+----------------------+----------------------------+--------------+
| SUPPORT_VID_ALL | All RTMP-supported video | 0x00FF |
| | codecs | |
+----------------------+----------------------------+--------------+
server 向 client 應(yīng)答的 response :
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | _result or _error; indicates whether |
| | | the response is result or error. |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID is 1 for connect |
| ID | | responses |
| | | |
+--------------+----------+----------------------------------------+
| Properties | Object | Name-value pairs that describe the |
| | | properties(fmsver etc.) of the |
| | | connection. |
+--------------+----------+----------------------------------------+
| Information | Object | Name-value pairs that describe the |
| | | response from|the server. ’code’, |
| | | ’level’, ’description’ are names of few|
| | | among such information. |
+--------------+----------+----------------------------------------+
完整消息流(message flow)順序 :
+--------------+ +-------------+
| Client | | | Server |
+------+-------+ | +------+------+
| Handshaking done |
| | |
| | |
| | |
| | |
|----------- Command Message(connect) ------->|
| |
|<------- Window Acknowledgement Size --------|
| |
|<----------- Set Peer Bandwidth -------------|
| |
|-------- Window Acknowledgement Size ------->|
| |
|<------ User Control Message(StreamBegin) ---|
| |
|<------------ Command Message ---------------|
| (_result- connect response) |
| |
- 完成 RTMP Handshake
- client 向 server 發(fā)送 connect 的 Command Message 請求與服務(wù)器的 application instance 建立連接翔试。
- server 向 client 發(fā)送 Window Acknowledgement Size 進(jìn)行 protocol control轻要。
- server 向 client 發(fā)送 Set Peer Bandwidth 進(jìn)行 protocol control。
- client 向 server 發(fā)送 Window Acknowledgement Size 進(jìn)行 protocol control垦缅。
- server 向 client 發(fā)送 User Control Message(StreamBegin) 表明 stream 已經(jīng)可用冲泥,可以開始通信。
- server 向 client 發(fā)送 connect 的 Command Message 的響應(yīng)結(jié)果壁涎。
call
call command message 用于實(shí)現(xiàn)遠(yuǎn)程過程調(diào)用 凡恍。
sender to receiver :
+--------------+----------+----------------------------------------+
|Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Procedure | String | Name of the remote procedure that is |
| Name | | called. |
+--------------+----------+----------------------------------------+
| Transaction | Number | If a response is expected we give a |
| | | transaction Id. Else we pass a value of|
| ID | | 0 |
+--------------+----------+----------------------------------------+
| Command | Object | If there exists any command info this |
| Object | | is set, else this is set to null type. |
+--------------+----------+----------------------------------------+
| Optional | Object | Any optional arguments to be provided |
| Arguments | | |
+--------------+----------+----------------------------------------+
response :
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command. |
| | | |
+--------------+----------+----------------------------------------+
| Transaction | Number | ID of the command, to which the |
| ID | | response belongs. |
+--------------+----------+----------------------------------------+
| Command | Object | If there exists any command info this |
| Object | | is set, else this is set to null type. |
+--------------+----------+----------------------------------------+
| Response | Object | Response from the method that was |
| | | called. |
+------------------------------------------------------------------+
createStream
createStream 用于 client 向 server 請求創(chuàng)建用于消息通信的邏輯通道 message stream 。音頻怔球、視頻和元數(shù)據(jù)的發(fā)布通過使用 createStream 命令來創(chuàng)建的 stream channel 進(jìn)行嚼酝。
NetConnection 是默認(rèn)的通信通道,其流 ID 為 0 竟坛。Protocol Control Message革半、User Control Message 以及 NetConnection Command Message 使用默認(rèn)的通信通道 NetConnection 碑定。
NetStream Commands 將使用 createStream 創(chuàng)建的 stream channel 進(jìn)行傳輸。
client to server :
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command. Set to |
| | | "createStream". |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID of the command. |
| ID | | |
+--------------+----------+----------------------------------------+
| Command | Object | If there exists any command info this |
| Object | | is set, else this is set to null type. |
+--------------+----------+----------------------------------------+
command object :
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | _result or _error; indicates whether |
| | | the response is result or error. |
+--------------+----------+----------------------------------------+
| Transaction | Number | ID of the command that response belongs|
| ID | | to. |
+--------------+----------+----------------------------------------+
| Command | Object | If there exists any command info this |
| Object | | is set, else this is set to null type. |
+--------------+----------+----------------------------------------+
| Stream | Number | The return value is either a stream ID |
| ID | | or an error information object. |
+--------------+----------+----------------------------------------+
NetStream Commands
在發(fā)送 NetStream Commands 前需要通過 createStream 的 NetConnection Command 創(chuàng)建 NetStream 的邏輯通信通道又官。
client 可以通過 NetStream 向 server 發(fā)送以下命令:
- play
- play2
- deleteStream
- closeStream
- receiveAudio
- receiveVideo
- publish
- seek
- pause
server 通過 onStatus
命令通知客戶端 NetStream 狀態(tài)更新延刘,onStatus
被用于各個(gè) NetStream Commands 的響應(yīng)中。
onStatus
command 的 message 格式:
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | The command name "onStatus". |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID set to 0. |
| ID | | |
+--------------+----------+----------------------------------------+
| Command | Null | There is no command object for |
| Object | | onStatus messages. |
+--------------+----------+----------------------------------------+
| Info Object | Object | An AMF object having at least the |
| | | following three properties: "level" |
| | | (String): the level for this message, |
| | | one of "warning", "status", or "error";|
| | | "code" (String): the message code, for |
| | | example "NetStream.Play.Start"; and |
| | | "description" (String): a human- |
| | | readable description of the message. |
| | | The Info object MAY contain other |
| | | properties as appropriate to the code. |
+--------------+----------+----------------------------------------+
play
client 通過 play command 向 server 請求播放流六敬。client 可以通過多次使用 play command 創(chuàng)建播放列表碘赖。
如果 client 想要?jiǎng)?chuàng)建一個(gè)動(dòng)態(tài)播放列表,并且希望在不同的 live 或 recorded 流之間切換外构,可多次調(diào)用 play command普泡,并將字段 reset 的值設(shè)置為 false 。
如果 client 要立即播放指定的流审编,清楚排隊(duì)等待播放的任何其他流撼班,則將字段 reset 的值設(shè)置為 true 進(jìn)行重置。
play command 格式:
+--------------+----------+-----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+-----------------------------------------+
| Command Name | String | Name of the command. Set to "play". |
+--------------+----------+-----------------------------------------+
| Transaction | Number | Transaction ID set to 0. |
| ID | | |
+--------------+----------+-----------------------------------------+
| Command | Null | Command information does not exist. |
| Object | | Set to null type. |
+--------------+----------+-----------------------------------------+
| Stream Name | String | |
+--------------+----------+-----------------------------------------+
| Start | Number | |
+--------------+----------+-----------------------------------------+
| Duration | Number | |
+--------------+----------+-----------------------------------------+
| Reset | Boolean | |
+--------------+----------+-----------------------------------------+
其中:
-
Stream Name :播放的流的名稱(將和 connect 中的 tcUrl 拼接成 stream url)
- 播放視頻文件(FLV)垒酬,需指定不帶文件擴(kuò)展名的流名稱(如
sample
) - 播放 MP3 或 ID3 標(biāo)簽砰嘁,必須在流名稱前加上
mp3:
(如mp3:sample
) - 播放 H.264/AAC 文件,必須在流名稱前加上
mp4:
并加上文件擴(kuò)展名 (如mp4:sample.m4v1
)
- 播放視頻文件(FLV)垒酬,需指定不帶文件擴(kuò)展名的流名稱(如
-
Start :一個(gè)可選參數(shù)勘究,以秒為單位指定開始時(shí)間矮湘。
- -2 (默認(rèn)值),表示訂閱者首先嘗試播放 Stream Name 字段中指定的直播流口糕。如果沒有找到同名的直播流缅阳,則播放同名的錄制流。如果沒有具有該名稱的錄制流景描,則訂閱者等待具有該名稱的新直播流并在可用時(shí)播放十办。
- -1,僅播放 Stream Name 字段中指定的直播流超棺。
- 0 或 正數(shù)橘洞,播放 Stream Name 字段中指定的錄制流,從 Start 字段中指定的時(shí)間開始播放说搅。如果沒有找到錄制的流炸枣,則播放播放列表中的下一個(gè)項(xiàng)目。
-
Duration :
- 負(fù)數(shù)弄唧,解釋為 -1 适肠。
- -1,表示直播流一直播放到不再可用候引,或者播放錄制的流直到結(jié)束侯养。
- 0,假設(shè) start 字段中指定的值等于或大于0澄干,從 Start 字段中指定的時(shí)間開始播放單幀(一幀)
- 正數(shù)逛揩,播放 Duration 時(shí)長的直播流或錄制流(如果流在 Duration 字段中指定的時(shí)間之前結(jié)束柠傍,則播發(fā)結(jié)束時(shí)結(jié)束)。
- Reset :一個(gè)可選的布爾值或數(shù)字辩稽,指定是否刷新任何以前的播放列表惧笛。
play command 完整的交互流程:
+-------------+ +------------+
| Play Client | | | Server |
+------+------+ | +------+-----+
| Handshaking and Application |
| connect done |
| | |
| | |
| | |
| | |
---+---- |----- Command Message(createStream) ----->|
Create| | |
Stream| | |
---+---- |<---------- Command Message --------------|
| (_result- createStream response) |
| |
---+---- |------ Command Message (play) ----------->|
| | |
| |<------------- SetChunkSize --------------|
| | |
| |<---- User Control (StreamIsRecorded) ----|
Play | | |
| |<---- UserControl (StreamBegin) ----------|
| | |
| |<- Command Message(onStatus-play reset) --|
| | |
| |<- Command Message(onStatus-play start) --|
| | |
| |<------------ Audio Message --------------|
| | |
| |<------------ Video Message --------------|
| | | |
play 部分流程為:
- client 在收到 createStream 的 response 成功后,向 server 發(fā)送 play
- server 收到 play 后逞泄,發(fā)送 Set Chunk Size 來設(shè)置塊大小患整。
- server 發(fā)送 User control message 指示 StreamIsRecorded
- server 發(fā)送 User control message 指示 StreamBegin
- 如果 play 在 server 中執(zhí)行成功,則 server 發(fā)送 onStatus Message 表示 NetStream.Play.reset 和 NetStream.Play.start 喷众,其中 NetStream.Play.reset 只有在 client 發(fā)送的 play command 設(shè)置 reset = true 時(shí)才會(huì)發(fā)生和響應(yīng)各谚。如果沒有找到要播放的流,則 server 發(fā)生 onStatus Message 表示 NetStream.Play.StreamNotFound到千。
- 此后昌渤,server 向 client 發(fā)送 audio message 和 video message 。
play2
play2 與 play 命令不同:play2 可以切換到不同的比特率憔四,而無需更改播放內(nèi)容的時(shí)間線膀息。
play2 command 格式:
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command, set to "play2". |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID set to 0. |
| ID | | |
+--------------+----------+----------------------------------------+
| Command | Null | Command information does not exist. |
| Object | | Set to null type. |
+--------------+----------+----------------------------------------+
| Parameters | Object | An AMF encoded object whose properties |
| | | are the public properties described |
| | | for the flash.net.NetStreamPlayOptions |
| | | ActionScript object. |
+--------------+----------+----------------------------------------+
play2 交互流程:
+--------------+ +-------------+
| Play2 Client | | | Server |
+--------+-----+ | +------+------+
| Handshaking and Application |
| connect done |
| | |
| | |
| | |
| | |
---+---- |---- Command Message(createStream) --->|
Create | | |
Stream | | |
---+---- |<---- Command Message (_result) -------|
| |
---+---- |------ Command Message (play) -------->|
| | |
| |<------------ SetChunkSize ------------|
| | |
| |<--- UserControl (StreamIsRecorded)----|
Play | | |
| |<------- UserControl (StreamBegin)-----|
| | |
| |<- Command Message(onStatus-playstart)-|
| | |
| |<---------- Audio Message -------------|
| | |
| |<---------- Video Message -------------|
| | |
| |
---+---- |-------- Command Message(play2) ------>|
| | |
| |<------- Audio Message (new rate) -----|
Play2 | | |
| |<------- Video Message (new rate) -----|
| | | |
| | | |
| Keep receiving audio and video stream till finishes
|
deleteStream
NetStream 在 NetStream 對(duì)象被銷毀時(shí)發(fā)送 deleteStream Command
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command, set to |
| | | "deleteStream". |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID set to 0. |
| ID | | |
+--------------+----------+----------------------------------------+
| Command | Null | Command information object does not |
| Object | | exist. Set to null type. |
+--------------+----------+----------------------------------------+
| Stream ID | Number | The ID of the stream that is destroyed |
| | | on the server. |
+--------------+----------+----------------------------------------+
receiveAudio
NetStream 發(fā)送 receiveAudio Command,通知 server 是否發(fā)送音頻數(shù)據(jù)到 client 加矛。
client 向 server 發(fā)送的 receiveAudio Command 結(jié)構(gòu):
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command, set to |
| | | "receiveAudio". |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID set to 0. |
| ID | | |
+--------------+----------+----------------------------------------+
| Command | Null | Command information object does not |
| Object | | exist. Set to null type. |
+--------------+----------+----------------------------------------+
| Bool Flag | Boolean | true or false to indicate whether to |
| | | receive audio or not. |
+--------------+----------+----------------------------------------+
如果 receiveAudio 的 Bool Flag 設(shè)置為 false履婉,則 server 不會(huì)發(fā)送任何 response煤篙,如果 Bool Flag 設(shè)置為 true斟览,則 server 將使用 status message 的 NetStream.Seek.Notify 和 NetStream.Play.Start 進(jìn)行響應(yīng)。
receiveVideo
NetStream 發(fā)送 receiveVideo Command辑奈,通知 server 是否發(fā)送視頻數(shù)據(jù)到 client 苛茂。
client 向 server 發(fā)送的 receiveVideo Command 結(jié)構(gòu):
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command, set to |
| | | "receiveVideo". |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID set to 0. |
| ID | | |
+--------------+----------+----------------------------------------+
| Command | Null | Command information object does not |
| Object | | exist. Set to null type. |
+--------------+----------+----------------------------------------+
| Bool Flag | Boolean | true or false to indicate whether to |
| | | receive video or not. |
+--------------+----------+----------------------------------------+
如果 receiveVideo 的 Bool Flag 設(shè)置為 false,則 server 不會(huì)發(fā)送任何 response鸠窗,如果 Bool Flag 設(shè)置為 true妓羊,則 server 將使用 status message 的 NetStream.Seek.Notify 和 NetStream.Play.Start 進(jìn)行響應(yīng)。
publish
client 發(fā)送 publish 命令用于將一個(gè)命名的 stream (Publishing Name)發(fā)布到 server稍计≡瓿瘢客戶端可以 play 該 stream 并receive已發(fā)布的音頻、視頻和數(shù)據(jù)消息臣嚣。
client 向 server 發(fā)送的 publish Command 結(jié)構(gòu):
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command, set to "publish". |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID set to 0. |
| ID | | |
+--------------+----------+----------------------------------------+
| Command | Null | Command information object does not |
| Object | | exist. Set to null type. |
+--------------+----------+----------------------------------------+
| Publishing | String | Name with which the stream is |
| Name | | published. |
+--------------+----------+----------------------------------------+
| Publishing | String | Type of publishing. Set to "live", |
| Type | | "record", or "append". |
| | | record: The stream is published and the|
| | | data is recorded to a new file.The file|
| | | is stored on the server in a |
| | | subdirectory within the directory that |
| | | contains the server application. If the|
| | | file already exists, it is overwritten.|
| | | append: The stream is published and the|
| | | data is appended to a file. If no file |
| | | is found, it is created. |
| | | live: Live data is published without |
| | | recording it in a file. |
+--------------+----------+----------------------------------------+
server 響應(yīng) onStatus 命令用于標(biāo)記 publish 的開始净刮。
seek
client 發(fā)送 seek command 來尋找媒體文件或播放列表中的偏移量(以毫秒為單位)。
client 向 server 發(fā)送的 seek Command 結(jié)構(gòu):
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command, set to "seek". |
+--------------+----------+----------------------------------------+
| Transaction | Number | Transaction ID set to 0. |
| ID | | |
+--------------+----------+----------------------------------------+
| Command | Null | There is no command information object |
| Object | | for this command. Set to null type. |
+--------------+----------+----------------------------------------+
| milliSeconds | Number | Number of milliseconds to seek into |
| | | the playlist. |
+--------------+----------+----------------------------------------+
server 使用 onStatus 命令 NetStream.Seek.Notify 表示成功硅则,_error message 表示失敗淹父。
pause
client 發(fā)送 pause command 來告知 server 停止(Pause Flag=true)或(Pause Flag = false)播放。
client 向 server 發(fā)送的 pause Command 結(jié)構(gòu):
+--------------+----------+----------------------------------------+
| Field Name | Type | Description |
+--------------+----------+----------------------------------------+
| Command Name | String | Name of the command, set to "pause". |
+--------------+----------+----------------------------------------+
| Transaction | Number | There is no transaction ID for this |
| ID | | command. Set to 0. |
+--------------+----------+----------------------------------------+
| Command | Null | Command information object does not |
| Object | | exist. Set to null type. |
+--------------+----------+----------------------------------------+
|Pause/Unpause | Boolean | true or false, to indicate pausing or |
| Flag | | resuming play |
+--------------+----------+----------------------------------------+
| milliSeconds | Number | Number of milliseconds at which the |
| | | the stream is paused or play resumed. |
| | | This is the current stream time at the |
| | | Client when stream was paused. When the|
| | | playback is resumed, the server will |
| | | only send messages with timestamps |
| | | greater than this value. |
+--------------+----------+----------------------------------------+
server 使用 onStatus 命令 NetStream.Pause.Notify 表示暫停怎虫,NetStream.Unpause.Notify 表示不暫停暑认,_error message 表示失敗困介。
Message Exchange Examples
Publish Recorded Video
+--------------------+ +-----------+
| Publisher Client | | | Server |
+----------+---------+ | +-----+-----+
| Handshaking Done |
| | |
| | |
---+---- |----- Command Message(connect) ----->|
| | |
| |<----- Window Acknowledge Size ------|
Connect | | |
| |<------ Set Peer BandWidth ----------|
| | |
| |------ Window Acknowledge Size ----->|
| | |
| |<----- User Control(StreamBegin) ----|
| | |
---+---- |<-------- Command Message -----------|
| (_result- connect response) |
| |
---+---- |--- Command Message(createStream) -->|
Create | | |
Stream | | |
---+---- |<------- Command Message ------------|
| (_result- createStream response) |
| |
---+---- |---- Command Message(publish) ------>|
| | |
| |<----- User Control(StreamBegin) ----|
| | |
| |---- Data Message (Metadata) ------->|
| | |
Publishing| |------------ Audio Data ------------>|
Content | | |
| |------------ SetChunkSize ---------->|
| | |
| |<--------- Command Message ----------|
| | (_result- publish result) |
| | |
| |------------- Video Data ----------->|
| | | |
| | | |
| Until the stream is complete |
| | |
Broadcast a Shared Object Message
+----------+ +----------+
| Client | | | Server |
+-----+----+ | +-----+----+
| Handshaking and Application |
| connect done |
| | |
| | |
| | |
| | |
Create and ---+---- |---- Shared Object Event(Use)---->|
connect | | |
Shared Object | | |
---+---- |<---- Shared Object Event --------|
| (UseSuccess,Clear) |
| |
---+---- |------ Shared Object Event ------>|
Shared object | | (RequestChange) |
Set Property | | |
---+---- |<------ Shared Object Event ------|
| (Success) |
| |
---+---- |------- Shared Object Event ----->|
Shared object| | (SendMessage) |
Message | | |
Broadcast ---+---- |<------- Shared Object Event -----|
| (SendMessage) |
| |
| |
Publish Metadata from Recorded Stream
+------------------+ +---------+
| Publisher Client | | | FMS |
+---------+--------+ | +----+----+
| Handshaking and Application |
| connect done |
| | |
| | |
---+--- |-- Command Messsage (createStream) ->|
Create | | |
Stream | | |
---+--- |<-------- Command Message -----------|
| (_result - command response) |
| |
---+--- |---- Command Message (publish) ----->|
Publishing | | |
metadata | |<----- UserControl (StreamBegin) ----|
from file | | |
| |---- Data Message (Metadata) ------->|
| |