1 public信令
//create获得session id,attach获得handle id,join获得participant id即user id。
//configure带sdp, type offer, 服务器应答带sdp, type answer。
异步消息:如join、configure都是通过事件event通知的。
同步消息:如create、attach都是直接返回结果。
1 {"janus":"create","transaction":"nhajpmyiqabB"} //client发给服务器janus
{
"janus": "success",
"transaction": "nhajpmyiqabB",
"data": {
"id": 7783258490937719
}
}//服务器应答的
返的id是session id。
janus.js:1059 Created session: 7783258490937719
2 {"janus":"attach","plugin":"janus.plugin.videoroom","opaque_id":"videoroomtest-Aq1igEjqXNtQ","transaction":"P0kZ27HA2TQA"}
{
"janus": "success",
"session_id": 7783258490937719,
"transaction": "P0kZ27HA2TQA",
"data": {
"id": 2494319352475519
}
}
返的id是handle id。
janus.js:1390 Created handle: 2494319352475519
3 {"janus":"message","body":{"request":"join","room":1234,"ptype":"publisher","display":"ashley"},"transaction":"eJBPz33wXfiB"}
{
"janus": "event",
"session_id": 7783258490937719,
"transaction": "eJBPz33wXfiB",
"sender": 2494319352475519,
"plugindata": {
"plugin": "janus.plugin.videoroom",
"data": {
"videoroom": "joined",
"room": 1234,
"description": "Demo Room",
"id": 5957630446341966,
"private_id": 277486824,
"publishers": []
}
}
}
id是participant id: 5957630446341966
4 {"janus":"message","body":{"request":"configure","audio":true,"video":true},"transaction":"cY6kikbFYH97","jsep":{"type":"offer","sdp":"v=0\r\n..."}}
{
"janus": "event",
"session_id": 7783258490937719,
"transaction": "cY6kikbFYH97",
"sender": 2494319352475519,
"plugindata": {
"plugin": "janus.plugin.videoroom",
"data": {
"videoroom": "event",
"room": 1234,
"configured": "ok",
"audio_codec": "opus",
"video_codec": "h264",
"streams": [
{
"type": "audio",
"mindex": 0,
"mid": "0",
"codec": "opus",
"fec": true
},
{
"type": "video",
"mindex": 1,
"mid": "1",
"codec": "h264",
"h264_profile": "42001f"
}
]
}
},
"jsep": {
"type": "answer",
"sdp": "v=0\r\n..."
}
}
//candidate有好几条,有ip、port和type host
5 {"janus":"trickle","candidate":{"candidate":"candidate:253191485 1 udp 2122260223 192.168.0.199 63210 typ host generation 0 ufrag YGDN network-id 1","sdpMid":"0","sdpMLineIndex":0},"transaction":"o6qAgIV2FZwA"}
//Client发给server
{"janus":"trickle","candidate":{"completed":true},"transaction":"7FhMOHytkMpU"}
{
"janus": "ack",
"session_id": 7783258490937719,
"transaction": "7FhMOHytkMpU"
}//Client发给server
6
{
"janus": "webrtcup",
"session_id": 7783258490937719,
"sender": 2494319352475519
}//S-->C
7
{
"janus": "media",
"session_id": 7783258490937719,
"sender": 2494319352475519,
"mid": "0",
"type": "audio",
"receiving": true
}
{
"janus": "media",
"session_id": 7783258490937719,
"sender": 2494319352475519,
"mid": "1",
"type": "video",
"receiving": true
}//S-->C
2 Subcribe信令
1 create 2 attach 3 join–subscriber 4 start
jane public join返回 participant id。
subscriber join 没有返回。join用private_id,private_id是joined返的。
//joined的"publishers"有值,newRemoteFeed(id, display, streams);
{"janus":"message","body":{"request":"join","room":1234,"ptype":"publisher","display":"jane"},"transaction":"ZhMPnUhXkZNQ"}
{
"janus": "event",
"session_id": 2700092514022925,
"transaction": "ZhMPnUhXkZNQ",
"sender": 8617577496500323,
"plugindata": {
"plugin": "janus.plugin.videoroom",
"data": {
"videoroom": "joined",
"room": 1234,
"description": "Demo Room",
"id": 5102721899752203,
"private_id": 888157627,
"publishers": [
{
"id": 5957630446341966,
"display": "ashley",
"audio_codec": "opus",
"video_codec": "h264",
"streams": [
{
"type": "audio",
"mindex": 0,
"mid": "0",
"codec": "opus",
"fec": true,
"talking": false
},
{
"type": "video",
"mindex": 1,
"mid": "1",
"codec": "h264",
"h264_profile": "42001f"
}
],
"talking": false
}
]
}
}
}
//feed是订阅那个的participant id,joined的"publishers"的值
//服务器应答attached,带sdp type offer
3 {"janus":"message","body":{"request":"join","room":1234,"ptype":"subscriber",
"streams":[{"feed":5957630446341966,"mid":"0"},{"feed":5957630446341966,"mid":"1"}],
"use_msid":false,"private_id":888157627},"transaction":"XR2YpVJrXkx3"}
{
"janus": "event",
"session_id": 2700092514022925,
"transaction": "XR2YpVJrXkx3",
"sender": 4702154964343509,
"plugindata": {
"plugin": "janus.plugin.videoroom",
"data": {
"videoroom": "attached",
"room": 1234,
"streams": [
{
"type": "audio",
"active": true,
"mindex": 0,
"mid": "0",
"ready": false,
"send": true,
"feed_id": 5957630446341966,
"feed_display": "ashley",
"feed_mid": "0",
"codec": "opus"
},
{
"type": "video",
"active": true,
"mindex": 1,
"mid": "1",
"ready": false,
"send": true,
"feed_id": 5957630446341966,
"feed_display": "ashley",
"feed_mid": "1",
"codec": "h264",
"h264-profile": "42001f"
}
]
}
},
"jsep": {
"type": "offer",
"sdp": "v=0\r\n ..."
}
}
4 //sdp type answer
{"janus":"message","body":{"request":"start","room":1234},"transaction":"4sZok5Zkbnpv",
"jsep":{"type":"answer","sdp":"v=0\r\n ..."}}
{
"janus": "event",
"session_id": 2700092514022925,
"transaction": "4sZok5Zkbnpv",
"sender": 4702154964343509,
"plugindata": {
"plugin": "janus.plugin.videoroom",
"data": {
"videoroom": "event",
"room": 1234,
"started": "ok"
}
}
}