• Janus VideoRoom信令分析--public、subscribe


    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123

    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"
             }
          }
       }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
  • 相关阅读:
    行为型模式-策略模式
    SpringMVC源码分析(三)HandlerExceptionResolver启动和异常处理源码分析
    事务+事务并发+事务隔离级别【Interview Question】
    聊聊SQL注入
    【Java学习挑战】
    vue-cli + APIcloud
    尝试使用php给pdf添加水印
    EditPlus汉化
    CentOS 7 上划分vlan复用接口配置多个ip地址——筑梦之路
    路由器二次开发一步一步把工业路由器变成一个高端的可指定出网、节点和链路的路由器,包含详细过程及快捷脚本(五)
  • 原文地址:https://blog.csdn.net/chenquangobeijing/article/details/126711927