Try   HackMD

尚未定案

Lipoic 課堂功能實作討論

章節

技術

音視訊:WebRTC
文字:Socket.IO

WebRTC Rust 函式庫:https://github.com/webrtc-rs/webrtc
伺服器端範例 (rust):https://github.com/webrtc-rs/webrtc/tree/master/examples/examples/broadcast
SFU 伺服器端實作範例 (rust):https://github.com/webrtc-rs/examples/pull/15
Client 端範例 (js):https://jsfiddle.net/1jc4go7v/

API

課堂資料結構

{
    "id": ObjectId, // 課堂 ID
    "name": String, // 必填,但若跟教室功能串接會直接引用教室的名稱。
    "description": String // 可選
    "created_at": Int, // 課堂建立時的 UNIX 時間
    "create_by": ObjectId, // 此課堂是由誰建立的 (ID)
    "speakers": Vec<ObjectId>,  // 講者 ID
    "state": String, // draft/open/close enum
    "permission": { // 可以加入此課堂的權限
        "permission_type": String, // all (所有人) / classroom (在同個教室的人) / select (手動指定) enum
        "allows": Vec<ObjectId> // 若 type 為 select 時此欄位才有資料,手動指定的使用者 ID
    }
    
    // 額外串接功能
    
    "classroom_id": ObjectId // 可選,用於跟教室串連,等該功能開發完成後再串接進來。
}

菘菘 歡迎大家提供關於此 API 的建議

Payload 實際上是要用 form data,但 highlight 好像不支援,所以暫時用 json 表示。

建立課堂

Path: https://<host>/lesson
Method: POST
Payload

Response

{
    "id": 
}

加入課堂

Path: https://<host>/lesson/<id>/join
Method: POST
Payload

{
    "client_local_description": <base64_description>
}

Response

{
    "server_local_description": <base64_description>
}

Client 可以再利用伺服器給的 description 去加入 WebRTC 拿影像跟音訊資料

結束課堂

舉手

Path: https://<host>/lesson/<id>/user-state

發送課堂訊息

收回課堂訊息

使用者狀態

用於儲存課堂進行中使用者的狀態,像是舉手之類的。

目前有四種實作方式

  • WebRTC (client-client)
  • Webhook (server-client)
  • Rest API (server-client)
    透過資料庫儲存狀態
  • Socket.IO (server-client)
    存在記憶體 or 資料庫

Copyright © 2022 Lipoic. All rights reserved.

Dark Theme License

The MIT License (MIT)

Copyright © 2022-2024 Lumynous

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.