接口URL
http://api.polyv.net/live/v3/channel/monitor/get-stream-info
接口说明
1、接口用于获取频道的实时推流信息
2、接口支持https
3、deployAddress、inAddress、lfr信息可能无法获取,返回值为null
支持格式
JSON
请求方式
GET
请求参数
参数名 | 必选 | 类型 | 说明 |
---|---|---|---|
appId | 是 | string | 管理员的appId |
timestamp | 是 | long | 13位当前时间戳 |
sign | 是 | string | 签名值 |
channelId | 是 | int | 频道号 |
响应成功JSON示例:
{
"code": 200,
"status": "success",
"message": "",
"data": {
"deployAddress": "110.88.149.24",
"inAddress": "110.43.33.126",
"streamName": "push2.videocc.net/record/edvf2fpec920180705234706134",
"fps": "15",
"lfr": "0.0",
"inBandWidth": "641829"
}
}
// 暂时未能获取推流信息,请稍后重试
{
"code": 200,
"status": "success",
"message": "",
"data": {
"deployAddress": null,
"inAddress": null,
"streamName": null
"fps": null,
"lfr": null,
"inBandWidth": null
}
}
响应失败JSON示例:
未输入appId
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
appId不正确
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
时间戳错误
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
频道当前暂无直播
{
"code": 400,
"status": "error",
"message": "channel status not live",
"data": ""
}
签名错误
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
字段说明
参数名 | 说明 |
---|---|
code | 响应代码,成功为200,失败为400,签名错误为403,异常错误500 |
status | 成功为success,失败为error |
message | 错误时为错误提示消息 |
data.deployAddress | 推送的CDN节点IP,可能会为null |
data.inAddress | 推流出口ip,可能会为null |
data.streamName | 流名 |
data.fps | 推流帧率 |
data.lfr | 推流丢帧率,可能会为null |
data.inBandWidth | 推流码率 |
请求示例
<?php
//引用config.php
include 'config.php';
//接口URL上变量
$channelId = "123456";
//接口需要的参数(非sign)赋值
$params = array(
'appId'=>$appId,
'timestamp'=>$timestamp,
'channelId'=>$channelId
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
//接口请求url
$url = "http://api.polyv.net/live/v3/channel/monitor/get-stream-info?appId=".$appId."&sign=".$sign."×tamp=".$timestamp."&channelId=".$channelId;
//输出接口请求结果
echo file_get_contents($url);
?>