保利威文档中心

幫助中心

獲取 CDN 頻道的直播即時推流資訊(阿里、騰訊 CDN)

更新時間:2023-05-11 18:18:29

介面描述

1、获取cdn频道的直播实时推流信息(阿里、腾讯cdn)
2、接口支持https协议

介面 URL

http://api.polyv.net/live/v4/channel/monitor/list-stream-info

請求方式

GET

介面限制

1、介面同時支援 HTTP 與 HTTPS,建議使用 HTTPS 以確保介面安全,介面呼叫有頻率限制,詳細請查看

請求參數說明

參數名 必選 類型 說明
appId true String 帳號 appId【詳見取得金鑰
sign true String 簽名,為 32 位大寫的 MD5 值,產生簽名的 appSecret 金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有 API 都必須透過客戶自己的伺服器中轉呼叫 POLYV 伺服器以取得回應資料【詳見簽名產生規則
timestamp true String 目前 13 位毫秒級時間戳記,3 分鐘內有效
channelId true String 頻道號
endTime false String 結束時間
startTime false String 開始時間

範例

http://api.polyv.net/live/v4/channel/monitor/list-stream-info?appId=frlr1zazn3&sign=4815DC1E0AA6F22AC5D38D38924BEFDB&startTime=&endTime=&channelId=3889955&timestamp=1683799860694

回應參數說明

參數名 類型 說明
code Integer 狀態碼,與 HTTP 狀態碼相同,用於確定基本的回應狀態
data Array 成功回應的資料【詳見Data 參數說明
error Object 狀態碼非 200 時的錯誤資訊【詳見Error 參數說明
requestId String 請求 ID,每次請求產生的唯一 UUID,僅可用於排查、除錯,不應與業務掛鉤
status String 回應結果,由業務決定,成功回傳 success,失敗回傳 error
success Boolean 是否成功回應

Data 參數說明

參數名 類型 說明
audioFrameRate String 直播流的音訊幀率
bitRate String 直播流的碼率
streamUrl String 直播流的 URL
time String 統計時刻 UTC 時間
timestamp Integer 目前 13 位毫秒級時間戳記
videoFrameRate String 直播流的視訊幀率

Error 參數說明

參數名 類型 說明
code Integer 錯誤代碼,用於確定具體的錯誤原因
desc String 錯誤描述,與 error.code 對應

Java 請求範例

快速接入基礎程式碼請下載相關依賴原始碼點擊下載原始碼,下載後加入自己的原始碼工程中即可。測試案例中的 HttpUtil.javaLiveSignUtil.java 都包含在下載檔案中。

強烈建議您使用直播 Java SDK 完成 API 的功能對接,直播 Java SDK 對 API 呼叫邏輯、異常處理、資料簽名、HTTP 請求執行緒池進行了統一封裝和最佳化。

private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 获取cdn频道的直播实时推流信息(阿里、腾讯cdn)
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void monitorListStreamInfoTest() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String timestamp = String.valueOf(System.currentTimeMillis());

    //业务参数
    String url = "http://api.polyv.net/live/v4/channel/monitor/list-stream-info";
    String channelId = "3889955";
    String endTime = "";
    String startTime = "";

    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("channelId", channelId);
    requestMap.put("endTime", endTime);
    requestMap.put("startTime", startTime);

    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));

    String response = HttpUtil.get(url, requestMap);

    log.info("测试获取cdn频道的直播实时推流信息(阿里、腾讯cdn)成功:{}", response);
    //do somethings

}

回應範例

系統全域錯誤說明詳見全域錯誤說明

成功範例

{
    "code": 200,
    "status": "success",
    "requestId": "63181d5d82fc4dd785a33de52375bd48.71.16837998896517145",
    "data": [
        {
            "streamUrl": "rtmp://push-d1.videocc.net/recordf/1b448be32316811158957436c19",
            "bitRate": "1176815.9",
            "audioFrameRate": "46.9",
            "videoFrameRate": "15.016666",
            "time": "2023-05-11T10:09:00Z",
            "timestamp": 1683799740000
        }
    ],
    "success": true
}

異常範例

{
    "code": 400,
    "status": "error",
    "requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
    "error": {
        "code": 20001,
        "desc": "application not found."
    },
    "success": false
}
联系客服,在线咨询