跳轉到

網路

ArctosLinks.Media 提供了一套 API 來設定或獲取會議過程中的網路狀況

Android 註冊頻寬資訊的回呼函式

功能:使用 registerBandwidthCallback 可接收本地與遠端的封包統計資訊,幫助監控媒體傳輸品質

回呼函式參數:

參數名稱 型別 說明
friendId String 遠端使用者 ID
localSent Int 本地端送出的資料量,單位 Bytes
localRecv Int 本地端接收到的資料量,單位 Bytes
localLoss Int 本地端丟失的資料量,單位 Bytes
remoteSent Int 遠端送出的資料量,單位 Bytes
remoteRecv Int 遠端接收到的資料量,單位 Bytes
remoteLoss Int 遠端丟失的資料量,單位 Bytes
localStartTime Long 本地統計的起始時間(UNIX 時間戳),單位 ms
remoteStartTime Long 遠端統計的起始時間(UNIX 時間戳),單位 ms

返回值:若是使用時發生例外狀況,則返回錯誤。

    import com.arctos.sdk.links.core.application.ArctosLinks

    ArctosLinks.getInstance(context).mediaManager.registerBandwidthCallback { friendId, localSent, localRecv, localLoss, remoteSent, remoteRecv, remoteLoss, localStartTime, remoteStartTime ->
        ...
    }

iOS 註冊頻寬資訊的回呼函式

功能:

可接收本地與遠端的封包統計資訊,幫助監控媒體傳輸品質,其內容主要在 ConnectInfo 物件中。

細節可參考 章節 - iOS 自訂螢幕佈局 -> 物件介紹與名詞解釋 -> ConnectInfo

回呼函式參數:

參數名稱 型別 說明
localSentBytes UInt 本地端送出的資料量,單位 Bytes
localRecvBytes UInt 本地端接收到的資料量,單位 Bytes
localLostBytes UInt 本地端丟失的資料量,單位 Bytes
localStartTimestamp_ms UInt 本地統計的起始時間(UNIX 時間戳),單位 ms
remoteSentBytes UInt 遠端送出的資料量,單位 Bytes
remoteRecvBytes UInt 遠端接收到的資料量,單位 Bytes
remoteLossBytes UInt 遠端丟失的資料量,單位 Bytes
remoteStartTimestamp_ms UInt 遠端統計的起始時間(UNIX 時間戳),單位 ms

ConnectInfo

class ConnectInfo { 
    /// 本地端接資料接收量,單位 Bytes
    let localRecvBytes: UInt
    let localRecvBytes_Subject: BehaviorSubject<UInt>

    /// 本地端接資料發送量,單位 Bytes
    let localSentBytes: UInt
    let localSentBytes_Subject: BehaviorSubject<UInt>

    /// 本地端接資料遺失量,單位 Bytes
    let localLostBytes: UInt
    let localLostBytes_Subject: BehaviorSubject<UInt>

    /// 本地端,單位統計起始時間,單位 ms
    let localStartTimestamp_ms: UInt
    let localStartTimestamp_ms_Subject: BehaviorSubject<UInt>

    /// 遠端接資料接收量,單位 Bytes
    let remoteRecvBytes: UInt
    let remoteRecvBytes_Subject: BehaviorSubject<UInt>

    /// 遠端接資料發送量,單位 Bytes
    let remoteSentBytes: UInt
    let remoteSentBytes_Subject: BehaviorSubject<UInt>

    /// 遠端接資料遺失量,單位 Bytes
    let remoteLostBytes: UInt
    let remoteLostBytes_Subject: BehaviorSubject<UInt>

    /// 遠端,單位統計起始時間,單位 ms
    let remoteStartTimestamp_ms: UInt
    let remoteStartTimestamp_ms_Subject: BehaviorSubject<UInt>
}

單位計算

SDK 所提供之頻寬數據內容都相對單純,若開發者想要做單位換算,這邊有推薦的公式與方法:

  • Byte = 8 bits

  • kbits = 1024 bits

  • Mbits = 1024 * 1024 bits

  • 封包遺失率 % = (remoteSent - localRecv) / remoteSent * 100%

Windows 註冊頻寬資訊的回呼函式

功能

接收 avBandwidthStatus 事件, 就可以接收到以下資訊:

參數名稱 型別 說明
id QString 對方的 carrier_id
local_sent UInt32 本地端送出的資料量,單位 Bytes
local_recv UInt32 本地端接收到的資料量,單位 Bytes
local_lost UInt32 本地端丟失的資料量,單位 Bytes
local_start_timestamp_ms UInt32 本地統計的起始時間(UNIX 時間戳),單位 ms
remote_sent UInt32 遠端送出的資料量,單位 Bytes
remote_recv UInt32 遠端接收到的資料量,單位 Bytes
remote_lost UInt32 遠端丟失的資料量,單位 Bytes
remote_start_timestamp_ms UInt32 遠端統計的起始時間(UNIX 時間戳),單位 ms
  • 如果是會議主持人,會收到所有 Client 的資訊,請以 id 辨識是與哪一個 Client 的資訊。
  • 如果是 Client,則只會收到跟 Switch 的資訊,其他與會者的資訊不會接收到。

單位計算

SDK 所提供之頻寬數據內容都相對單純,若開發者想要做單位換算,這邊有推薦的公式與方法:

  • Byte = 8 bits

  • kbits = 1024 bits

  • Mbits = 1024 * 1024 bits

  • local_recv / (local_recv + local_lost) => 遠端接受總量,此數字就是 MBps,需乘以 8 才是 Mbps

  • remote_recv / (remote_recv + remote_lost) => 本端接受總量,此數字就是 MBps,需乘以 8 才是 Mbps