Janus流媒体服务器信令分析
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Janus流媒体服务器信令分析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                Janus流媒體服務器信令分析
目錄
video room文檔:https://janus.conf.meetecho.com/docs/videoroom.html
1. 房間配置文件
room-<unique room ID>: {# 房間描述description = This is my awesome room# 是否是私有房間,當提出“list”請求時,私人房間不會出現is_private = true|false (private rooms don't appear when you do a 'list' request, default=false)# 密碼,操作房間時需要攜帶secret = <optional password needed for manipulating (e.g. destroying) the room># 密碼,加?房間時使?pin = <optional password needed for joining the room># 訂閱者是否需要提供?個有效的與發布者關聯的有效private_idrequire_pvtid = true|false (whether subscriptions are required to provide a valid private_idto associate with a publisher, default=false)# 房間內最?的發布者數量publishers = <max number of concurrent senders> (e.g., 6 for a videoconference or 1 for a webinar, default=3)# 發送者最?的視頻?特率bitrate = <max video bitrate for senders> (e.g., 128000)bitrate_cap = <true|false, whether the above cap should act as a limit to dynamic bitrate changes by publishers, default=false>,# FIR指令fir_freq = <send a FIR to publishers every fir_freq seconds> (0=disable)# ?頻編碼器,從左到右的優先級audiocodec = opus|g722|pcmu|pcma|isac32|isac16 (audio codec to force on publishers, default=opuscan be a comma separated list in order of preference, e.g., opus,pcmu)# 視頻編碼器,從左到右的優先級videocodec = vp8|vp9|h264|av1|h265 (video codec to force on publishers, default=vp8can be a comma separated list in order of preference, e.g., vp9,vp8,h264)vp9_profile = VP9-specific profile to prefer (e.g., "2" for "profile-id=2")h264_profile = H.264-specific profile to prefer (e.g., "42e01f" for "profile-level-id=42e01f")# 是否使?內置FECopus_fec = true|false (whether inband FEC must be negotiated; only works for Opus, default=false)# 是否?持編碼SVC模式,?前只?持VP9video_svc = true|false (whether SVC support must be enabled; only works for VP9, default=false)audiolevel_ext = true|false (whether the ssrc-audio-level RTP extension must benegotiated/used or not for new publishers, default=true)audiolevel_event = true|false (whether to emit event to other users or not, default=false)# 音頻級別的包數audio_active_packets = 100 (number of packets with audio level, default=100, 2 seconds)# ?頻?量基本平均值audio_level_average = 25 (average value of audio level, 127=muted, 0='too loud', default=25)videoorient_ext = true|false (whether the video-orientation RTP extension must benegotiated/used or not for new publishers, default=true)playoutdelay_ext = true|false (whether the playout-delay RTP extension must benegotiated/used or not for new publishers, default=true)transport_wide_cc_ext = true|false (whether the transport wide CC RTP extension must benegotiated/used or not for new publishers, default=true)# 是否錄制record = true|false (whether this room should be recorded, default=false)# 錄制?錄rec_dir = <folder where recordings should be stored, when enabled>lock_record = true|false (whether recording can only be started/stopped if the secretis provided, or using the global enable_recording request, default=false)# 當新?加?時是否通知所有的參會者notify_joining = true|false (optional, whether to notify all participants when a newparticipant joins the room. The Videoroom plugin by design only notifiesnew feeds (publishers), and enabling this may result extra notificationtraffic. This flag is particularly useful when enabled with require_pvtidfor admin to manage listening only participants. default=false)# 是否使?端對端加密require_e2ee = true|false (whether all participants are required to publish and subscribeusing end-to-end media encryption, e.g., via Insertable Streams; default=false) }2. API分類
1. 同步請求
2. 異步請求
3. Video Room房間管理
1. create-創建房間
1. 請求body
{"request" : "create","room" : <unique numeric ID, optional, chosen by plugin if missing>,"permanent" : <true|false, whether the room should be saved in the config file, default=false>,"description" : "<pretty name of the room, optional>","secret" : "<password required to edit/destroy the room, optional>","pin" : "<password required to join the room, optional>","is_private" : <true|false, whether the room should appear in a list request>,"allowed" : [ array of string tokens users can use to join this room, optional],... }2. 成功響應-created
{"videoroom" : "created","room" : <unique numeric ID>,"permanent" : <true if saved to config file, false if not> }3. 失敗回調 event
{"videoroom" : "event","error_code" : <numeric ID, check Macros below>,"error" : "<error description as a string>" }2. edit-編輯房間
1. 請求body
{"request" : "edit","room" : <unique numeric ID of the room to edit>,"secret" : "<room secret, mandatory if configured>","new_description" : "<new pretty name of the room, optional>","new_secret" : "<new password required to edit/destroy the room, optional>","new_pin" : "<new password required to join the room, optional>","new_is_private" : <true|false, whether the room should appear in a list request>,"new_require_pvtid" : <true|false, whether the room should require private_id from subscribers>,"new_bitrate" : <new bitrate cap to force on all publishers (except those with custom overrides)>,"new_fir_freq" : <new period for regular PLI keyframe requests to publishers>,"new_publishers" : <new cap on the number of concurrent active WebRTC publishers>,"new_lock_record" : <true|false, whether recording state can only be changed when providing the room secret>,"permanent" : <true|false, whether the room should be also removed from the config file, default=false> }2. 成功響應-edited
{"videoroom" : "edited","room" : <unique numeric ID> }3. destroy-銷毀房間
1. 請求body
{"request" : "destroy","room" : <unique numeric ID of the room to destroy>,"secret" : "<room secret, mandatory if configured>","permanent" : <true|false, whether the room should be also removed from the config file, default=false> }2. 成功響應-destroyed
{"videoroom" : "destroyed","room" : <unique numeric ID> }3. 房間用戶接收的事件-event
4. exist-房間是否存在
1. 請求body
{"request" : "exists","room" : <unique numeric ID of the room to check> }2. 成功響應-success
{"videoroom" : "success","room" : <unique numeric ID>,"exists" : <true|false> }5. allowd-出入管理
1. 請求body
{"request" : "allowed","secret" : "<room secret, mandatory if configured>","action" : "enable|disable|add|remove","room" : <unique numeric ID of the room to update>,"allowed" : [// Array of strings (tokens users might pass in "join", only for add|remove)] }2. 成功響應-success
{"videoroom" : "success","room" : <unique numeric ID>,"allowed" : [// Updated, complete, list of allowed tokens (only for enable|add|remove)] }6. kick-踢出房間
1. 請求body
{"request" : "kick","secret" : "<room secret, mandatory if configured>","room" : <unique numeric ID of the room>,"id" : <unique numeric ID of the participant to kick> }2. 成功響應-success
{"videoroom" : "success", }7. list-房間列表
1. 請求body
{"request" : "list" }2. 成功響應-success
{"videoroom" : "success","list" : [ // Array of room objects{ // Room #1"room" : <unique numeric ID>,"description" : "<Name of the room>","pin_required" : <true|false, whether a PIN is required to join this room>,"is_private" : <true|false, whether this room is 'private' (as in hidden) or not>,"max_publishers" : <how many publishers can actually publish via WebRTC at the same time>,"bitrate" : <bitrate cap that should be forced (via REMB) on all publishers by default>,"bitrate_cap" : <true|false, whether the above cap should act as a limit to dynamic bitrate changes by publishers (optional)>,"fir_freq" : <how often a keyframe request is sent via PLI/FIR to active publishers>,"require_pvtid": <true|false, whether subscriptions in this room require a private_id>,"require_e2ee": <true|false, whether end-to-end encrypted publishers are required>,"notify_joining": <true|false, whether an event is sent to notify all participants if a new participant joins the room>,"audiocodec" : "<comma separated list of allowed audio codecs>","videocodec" : "<comma separated list of allowed video codecs>","opus_fec": <true|false, whether inband FEC must be negotiated (note: only available for Opus) (optional)>,"video_svc": <true|false, whether SVC must be done for video (note: only available for VP9 right now) (optional)>,"record" : <true|false, whether the room is being recorded>,"rec_dir" : "<if recording, the path where the .mjr files are being saved>","lock_record" : <true|false, whether the room recording state can only be changed providing the secret>,"num_participants" : <count of the participants (publishers, active or not; not subscribers)>"audiolevel_ext": <true|false, whether the ssrc-audio-level extension must be negotiated or not for new publishers>,"audiolevel_event": <true|false, whether to emit event to other users about audiolevel>,"audio_active_packets": <amount of packets with audio level for checkup (optional, only if audiolevel_event is true)>,"audio_level_average": <average audio level (optional, only if audiolevel_event is true)>,"videoorient_ext": <true|false, whether the video-orientation extension must be negotiated or not for new publishers>,"playoutdelay_ext": <true|false, whether the playout-delay extension must be negotiated or not for new publishers>,"transport_wide_cc_ext": <true|false, whether the transport wide cc extension must be negotiated or not for new publishers>},// Other rooms] }8. listparticipants列出房間的參與者
1. 請求body
{"request" : "listparticipants","room" : <unique numeric ID of the room> }2. 成功響應-participants
{"videoroom" : "participants","room" : <unique numeric ID of the room>,"participants" : [ // Array of participant objects{ // Participant #1"id" : <unique numeric ID of the participant>,"display" : "<display name of the participant, if any; optional>","publisher" : "<true|false, whether user is an active publisher in the room>","talking" : <true|false, whether user is talking or not (only if audio levels are used)>},// Other participants] }4. VideoRoom Publishers
1. join-加入房間
1. 請求body
{"request" : "join","ptype" : "publisher","room" : <unique ID of the room to join>,"id" : <unique ID to register for the publisher; optional, will be chosen by the plugin if missing>,"display" : "<display name for the publisher; optional>","token" : "<invitation token, in case the room has an ACL; optional>" }2. 成功響應-joined
3. 關于不活躍的發布者進出通知
2. publish-發布
1. 請求body
{"request" : "publish","audiocodec" : "<audio codec to prefer among the negotiated ones; optional>","videocodec" : "<video codec to prefer among the negotiated ones; optional>","bitrate" : <bitrate cap to return via REMB; optional, overrides the global room value if present>,"record" : <true|false, whether this publisher should be recorded or not; optional>,"filename" : "<if recording, the base path/file to use for the recording files; optional>","display" : "<new display name to use in the room; optional>","audio_level_average" : "<if provided, overrided the room audio_level_average for this user; optional>","audio_active_packets" : "<if provided, overrided the room audio_active_packets for this user; optional>","display" : "<new display name to use in the room; optional>","descriptions" : [ // Optional{"mid" : "<unique mid of a stream being published>","description" : "<text description of the stream (e.g., My front webcam)>"},// Other descriptions, if any]}2. 成功響應-event
{"videoroom" : "event","configured" : "ok" }3. configure-配置(開始發布)
1. 請求body
{"request" : "configure","bitrate" : <bitrate cap to return via REMB; optional, overrides the global room value if present (unless bitrate_cap is set)>,"keyframe" : <true|false, whether we should send this publisher a keyframe request>,"record" : <true|false, whether this publisher should be recorded or not; optional>,"filename" : "<if recording, the base path/file to use for the recording files; optional>","display" : "<new display name to use in the room; optional>","audio_active_packets" : "<new audio_active_packets to overwrite in the room one; optional>","audio_level_average" : "<new audio_level_average to overwrite the room one; optional>","mid" : <mid of the m-line to refer to for this configure request; optional>,"send" : <true|false, depending on whether the media addressed by the above mid should be relayed or not; optional>,"descriptions" : [// Updated descriptions for the published streams; see "publish" for syntax; optional] }2. 成功響應-event
{"videoroom" : "event","configured" : "ok" }4. joinandconfigure-加入并配置(加入并且發布)
1. 請求body
2. 成功響應-joined
5. 發布成功后推送
6. unpublish-停止發布
1. 請求body
{"request" : "unpublish" }2. 成功響應-event
{"videoroom" : "event","unpublished" : "ok" }3. 其他成員通知
7. RTP轉發器
參與者通常也可以通過configure請求來更改??的錄制狀態:這樣做是為了獲得最?的靈活性,可能希望單獨記錄?些流,?不是全局或?動記錄?些內容,到特定?件。
就是說,如果希望確保在啟?全局錄制后參與者不能停?其錄制,或者在不應該錄制該會議室的情況下啟動它,那么您應該確保在創建會議室時使?lock_record屬性,將其設置為true。這樣,只有在提供了房間密碼的情況下,才能更改錄制狀態,從?確保只有管理員才能執?此操作。
最后,您可以使? leave 請求離開會議室。如果您是會議室中的活動發布者,這也將隱式取消你的發布。該leave請求如下所示
5. VideoRoom Subscribers
1. join-加入房間
1. 請求body
{"request" : "join","ptype" : "subscriber","room" : <unique ID of the room to subscribe in>,"feed" : <unique ID of the publisher to subscribe to; mandatory>,"private_id" : <unique ID of the publisher that originated this request; optional, unless mandated by the room configuration>,"streams" : [{"feed" : <unique ID of publisher owning the stream to subscribe to>,"mid" : "<unique mid of the publisher stream to subscribe to; optional>"// Optionally, simulcast or SVC targets (defaults if missing)},// Other streams to subscribe to] }2. 成功響應-attached(Offer)
2. start-開始訂閱(Answer 對 attached 的訂閱者響應)
1. 請求body
{"request" : "start" }2. 成功響應-event
{"videoroom" : "event","started" : "ok" }3. pause-暫停訂閱
1. 請求body
2. 成功響應-event
{"videoroom" : "event","paused" : "ok" }4. configure-配置
1. 請求body
{"request" : "configure","mid" : <mid of the m-line to refer to for this configure request; optional>,"send" : <true|false, depending on whether the mindex media should be relayed or not; optional>,"substream" : <substream to receive (0-2), in case simulcasting is enabled; optional>,"temporal" : <temporal layers to receive (0-2), in case simulcasting is enabled; optional>,"fallback" : <How much time (in us, default 250000) without receiving packets will make us drop to the substream below>,"spatial_layer" : <spatial layer to receive (0-2), in case VP9-SVC is enabled; optional>,"temporal_layer" : <temporal layers to receive (0-2), in case VP9-SVC is enabled; optional>,"audio_level_average" : "<if provided, overrides the room audio_level_average for this user; optional>","audio_active_packets" : "<if provided, overrides the room audio_active_packets for this user; optional>","restart" : <trigger an ICE restart; optional> }5. switch-切換
1. 請求body
{"request" : "switch","streams" : [{"feed" : <unique ID of the publisher the new source is from>,"mid" : "<unique mid of the source we want to switch to>","sub_mid" : "<unique mid of the stream we want to pipe the new source to>"},{// Other updates, if any}] }2. 成功響應-event
{"videoroom" : "event","switched" : "ok","room" : <room ID>,"changes" : <number of successful changes (may be smaller than the size of the streams array provided in the request)>,"streams" : [// Current configuration of the subscription, same format as when subscribing// Will contain info on all streams, not only those that have been updated] }6. leave-離開房間
1. 請求body
{"request" : "leave" }2. 成功響應-event
{"videoroom" : "event","left" : "ok", }總結
以上是生活随笔為你收集整理的Janus流媒体服务器信令分析的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: Janus流媒体服务器框架分析
 - 下一篇: SRS流媒体服务器——单机环境搭建和源码