添加说明
This commit is contained in:
parent
97298b76f9
commit
957f96305e
|
|
@ -0,0 +1,580 @@
|
|||
WVP 推流相关接口
|
||||
1️⃣ 推流列表接口
|
||||
接口:GET /api/push/list 路径:StreamPushController.java:73-95 完整 URL:
|
||||
GET http://114.67.89.4:9090/api/push/list
|
||||
参数:
|
||||
page: 当前页(可选)
|
||||
count: 每页查询数量(可选)
|
||||
query: 查询内容(可选)
|
||||
pushing: 是否正在推流(可选,true/false)
|
||||
mediaServerId: 流媒体ID(可选)
|
||||
返回示例:
|
||||
{
|
||||
"list": [
|
||||
{
|
||||
"id": 1,
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"gbId": "34020000001320000001",
|
||||
"name": "测试推流",
|
||||
"pushing": true,
|
||||
"mediaServerId": "polaris",
|
||||
"createTime": "2025-12-09 16:00:00"
|
||||
}
|
||||
],
|
||||
"total": 1,
|
||||
"pageNum": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
2️⃣ 开始播放接口(获取流地址)
|
||||
接口:GET /api/push/start 路径:StreamPushController.java:258-286 完整 URL:
|
||||
GET http://114.67.89.4:9090/api/push/start?id=1
|
||||
参数:
|
||||
id: 推流ID(必填,从推流列表中获取)
|
||||
返回示例:
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"mediaServerId": "polaris",
|
||||
"flv": "http://114.67.89.4:8778/live/prod.live.flv",
|
||||
"https_flv": "https://114.67.89.4:443/live/prod.live.flv",
|
||||
"ws_flv": "ws://114.67.89.4:8778/live/prod.live.flv",
|
||||
"wss_flv": "wss://114.67.89.4:443/live/prod.live.flv",
|
||||
"fmp4": "http://114.67.89.4:8778/live/prod.live.mp4",
|
||||
"https_fmp4": "https://114.67.89.4:443/live/prod.live.mp4",
|
||||
"ws_fmp4": "ws://114.67.89.4:8778/live/prod.live.mp4",
|
||||
"wss_fmp4": "wss://114.67.89.4:443/live/prod.live.mp4",
|
||||
"hls": "http://114.67.89.4:8778/live/prod/hls.m3u8",
|
||||
"https_hls": "https://114.67.89.4:443/live/prod/hls.m3u8",
|
||||
"ts": "http://114.67.89.4:8778/live/prod.live.ts",
|
||||
"https_ts": "https://114.67.89.4:443/live/prod.live.ts",
|
||||
"ws_ts": "ws://114.67.89.4:8778/live/prod.live.ts",
|
||||
"wss_ts": "wss://114.67.89.4:443/live/prod.live.ts",
|
||||
"rtmp": "rtmp://114.67.89.4:10001/live/prod",
|
||||
"rtsp": "rtsp://114.67.89.4:10002/live/prod",
|
||||
"rtc": "http://114.67.89.4:8778/index/api/webrtc?app=live&stream=prod&type=play",
|
||||
"rtc_https": "https://114.67.89.4:443/index/api/webrtc?app=live&stream=prod&type=play"
|
||||
}
|
||||
}
|
||||
关键字段说明:
|
||||
rtc: WebRTC 播放地址(HTTP)
|
||||
rtc_https: WebRTC 播放地址(HTTPS)
|
||||
flv: HTTP-FLV 播放地址
|
||||
hls: HLS 播放地址
|
||||
rtmp: RTMP 播放地址
|
||||
rtsp: RTSP 播放地址
|
||||
完整使用流程
|
||||
步骤 1:查询推流列表
|
||||
curl 'http://114.67.89.4:9090/api/push/list?page=1&count=10&pushing=true'
|
||||
返回:
|
||||
{
|
||||
"list": [
|
||||
{
|
||||
"id": 123,
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"pushing": true
|
||||
}
|
||||
]
|
||||
}
|
||||
步骤 2:获取播放地址(包括 WebRTC)
|
||||
curl 'http://114.67.89.4:9090/api/push/start?id=123'
|
||||
返回:
|
||||
{
|
||||
"code": 0,
|
||||
"data": {
|
||||
"rtc": "http://114.67.89.4:8778/index/api/webrtc?app=live&stream=prod&type=play",
|
||||
"flv": "http://114.67.89.4:8778/live/prod.live.flv",
|
||||
"hls": "http://114.67.89.4:8778/live/prod/hls.m3u8",
|
||||
"rtmp": "rtmp://114.67.89.4:10001/live/prod",
|
||||
"rtsp": "rtsp://114.67.89.4:10002/live/prod"
|
||||
}
|
||||
}
|
||||
步骤 3:使用 WebRTC 播放
|
||||
WebRTC 播放地址:
|
||||
http://114.67.89.4:8778/index/api/webrtc?app=live&stream=prod&type=play
|
||||
这个地址可以直接用于 WebRTC 播放器,例如:
|
||||
在网页中使用 WebRTC 播放器
|
||||
使用 ZLM 提供的 WebRTC 客户端
|
||||
测试接口
|
||||
让我测试一下这些接口:
|
||||
Bash Test WVP push list API
|
||||
IN
|
||||
curl -s 'http://114.67.89.4:9090/api/push/list?page=1&count=10' | python3 -m json.tool | head -50
|
||||
OUT
|
||||
{
|
||||
"code": 401,
|
||||
"msg": "\u8bf7\u767b\u5f55\u540e\u91cd\u65b0\u8bf7\u6c42"
|
||||
}
|
||||
看到了,WVP 的接口需要登录认证。让我帮你获取登录 token,然后测试接口。
|
||||
Bash Login to WVP and get token
|
||||
IN
|
||||
ssh ZTE "curl -s -X POST 'http://127.0.0.1:18978/api/user/login' -H 'Content-Type: application/json' -d '{\"username\":\"admin\",\"password\":\"admin\"}' | python3 -m json.tool"
|
||||
OUT
|
||||
{
|
||||
"code": 400,
|
||||
"msg": "\u53c2\u6570\u6216\u65b9\u6cd5\u9519\u8bef",
|
||||
"data": null
|
||||
}
|
||||
让我查找正确的登录接口:
|
||||
Grep "@PostMapping.*login|@GetMapping.*login" (in /Users/sunpeng/workspace/stream-deploy/docker/wvp/wvpcode/src/main/java/com/genersoft/iot/vmp, glob: **/*Controller.java)
|
||||
41 lines of output
|
||||
好的,我看到登录接口需要 MD5 加密的密码。让我测试完整的流程:
|
||||
Bash Calculate MD5 of admin password and login to WVP
|
||||
IN
|
||||
ssh ZTE "
|
||||
# 计算 admin 的 MD5
|
||||
PASSWORD_MD5=\$(echo -n 'admin' | md5sum | awk '{print \$1}')
|
||||
echo \"Password MD5: \$PASSWORD_MD5\"
|
||||
|
||||
# 登录获取 token
|
||||
curl -s 'http://127.0.0.1:18978/api/user/login?username=admin&password='\$PASSWORD_MD5 | python3 -m json.tool
|
||||
"
|
||||
OUT
|
||||
Password MD5: 21232f297a57a5a743894a0e4a801fc3
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "\u6210\u529f",
|
||||
"data": {
|
||||
"accessToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjNlNzk2NDZjNGRiYzQwODM4M2E5ZWVkMDlmMmI4NWFlIn0.eyJqdGkiOiJ6Skw2Rzd4X2NNRXZRT0FiWTV3dkl3IiwiaWF0IjoxNzY1MjcyODA2LCJleHAiOjE3NjUyNzY0MDYsIm5iZiI6MTc2NTI3MjgwNiwic3ViIjoibG9naW4iLCJhdWQiOiJBdWRpZW5jZSIsInVzZXJOYW1lIjoiYWRtaW4ifQ.kYBL6VC7hAiYWsX9_MoRXwZmwnpcAt5oi1ZHCtZDTHCoAIUxl_VkNCee7M6L1v2bdmjFxH_PXVygK2jaiLTyPjZloIesHgocFJwikgMAAtxeTZreuEd1Kw7r2nPNHxmZadgjHDqz-gyz2O1E9xOtYTmwMyZYaftOUhZfogAxIbNkt18X2Umdt7mRuIDLsFw0LP0Hcp2273C56F4-hVfF5lxsHtcLPtbq7HppTFMYQwC0KaZBbST6WMjhzbby5Vr3LIcA2BEvOflUigD5goQSM47q-fu87fpx4VFkPzS8pkRWHIGM1Vvjry0jPCW1b6Lk_FhV5Z3IjjUa_Ju4ds6GlA",
|
||||
"serverId": "000000",
|
||||
"id": 1,
|
||||
"enabled": true,
|
||||
"password": null,
|
||||
"role": {
|
||||
"id": 1,
|
||||
"name": "admin",
|
||||
"authority": "0",
|
||||
"createTime": "2021-04-13 14:14:57",
|
||||
"updateTime": "2021-04-13 14:14:57"
|
||||
},
|
||||
"username": "admin",
|
||||
"pushKey": "3e80d1762a324d5b0ff636e0bd16f1e3",
|
||||
"authorities": null,
|
||||
"accountNonExpired": true,
|
||||
"accountNonLocked": true,
|
||||
"credentialsNonExpired": true
|
||||
}
|
||||
}
|
||||
完美!登录成功了。现在让我使用这个 token 测试推流列表和播放接口:
|
||||
Bash Test WVP push list API with token
|
||||
IN
|
||||
ssh ZTE "
|
||||
TOKEN='eyJhbGciOiJSUzI1NiIsImtpZCI6IjNlNzk2NDZjNGRiYzQwODM4M2E5ZWVkMDlmMmI4NWFlIn0.eyJqdGkiOiJ6Skw2Rzd4X2NNRXZRT0FiWTV3dkl3IiwiaWF0IjoxNzY1MjcyODA2LCJleHAiOjE3NjUyNzY0MDYsIm5iZiI6MTc2NTI3MjgwNiwic3ViIjoibG9naW4iLCJhdWQiOiJBdWRpZW5jZSIsInVzZXJOYW1lIjoiYWRtaW4ifQ.kYBL6VC7hAiYWsX9_MoRXwZmwnpcAt5oi1ZHCtZDTHCoAIUxl_VkNCee7M6L1v2bdmjFxH_PXVygK2jaiLTyPjZloIesHgocFJwikgMAAtxeTZreuEd1Kw7r2nPNHxmZadgjHDqz-gyz2O1E9xOtYTmwMyZYaftOUhZfogAxIbNkt18X2Umdt7mRuIDLsFw0LP0Hcp2273C56F4-hVfF5lxsHtcLPtbq7HppTFMYQwC0KaZBbST6WMjhzbby5Vr3LIcA2BEvOflUigD5goQSM47q-fu87fpx4VFkPzS8pkRWHIGM1Vvjry0jPCW1b6Lk_FhV5Z3IjjUa_Ju4ds6GlA'
|
||||
|
||||
echo '=== 1. 查询推流列表 ==='
|
||||
curl -s 'http://127.0.0.1:18978/api/push/list?page=1&count=10' -H 'access-token: '\$TOKEN | python3 -m json.tool
|
||||
"
|
||||
OUT
|
||||
=== 1. 查询推流列表 ===
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "\u6210\u529f",
|
||||
"data": {
|
||||
"total": 1,
|
||||
"list": [
|
||||
{
|
||||
"gbId": 0,
|
||||
"gbDeviceId": null,
|
||||
"gbName": null,
|
||||
"gbManufacturer": null,
|
||||
"gbModel": null,
|
||||
"gbOwner": null,
|
||||
"gbCivilCode": null,
|
||||
"gbBlock": null,
|
||||
"gbAddress": null,
|
||||
"gbParental": null,
|
||||
"gbParentId": null,
|
||||
"gbSafetyWay": null,
|
||||
"gbRegisterWay": null,
|
||||
"gbCertNum": null,
|
||||
"gbCertifiable": null,
|
||||
"gbErrCode": null,
|
||||
"gbEndTime": null,
|
||||
"gbSecrecy": null,
|
||||
"gbIpAddress": null,
|
||||
"gbPort": null,
|
||||
"gbPassword": null,
|
||||
"gbStatus": null,
|
||||
"gbLongitude": null,
|
||||
"gbLatitude": null,
|
||||
"gpsAltitude": null,
|
||||
"gpsSpeed": null,
|
||||
"gpsDirection": null,
|
||||
"gpsTime": null,
|
||||
"gbBusinessGroupId": null,
|
||||
"gbPtzType": null,
|
||||
"gbPositionType": null,
|
||||
"gbRoomType": null,
|
||||
"gbUseType": null,
|
||||
"gbSupplyLightType": null,
|
||||
"gbDirectionType": null,
|
||||
"gbResolution": null,
|
||||
"gbDownloadSpeed": null,
|
||||
"gbSvcSpaceSupportMod": null,
|
||||
"gbSvcTimeSupportMode": null,
|
||||
"recordPLan": null,
|
||||
"dataType": 2,
|
||||
"dataDeviceId": 4,
|
||||
"createTime": "2025-12-09 16:06:23",
|
||||
"updateTime": "2025-12-09 16:06:23",
|
||||
"streamId": null,
|
||||
"enableBroadcast": null,
|
||||
"mapLevel": null,
|
||||
"id": 4,
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"mediaServerId": "polaris",
|
||||
"serverId": "000000",
|
||||
"pushTime": "2025-12-09 16:06:23",
|
||||
"pushing": true,
|
||||
"startOfflinePush": false,
|
||||
"uniqueKey": null
|
||||
}
|
||||
],
|
||||
"pageNum": 1,
|
||||
"pageSize": 10,
|
||||
"size": 1,
|
||||
"startRow": 1,
|
||||
"endRow": 1,
|
||||
"pages": 1,
|
||||
"prePage": 0,
|
||||
"nextPage": 0,
|
||||
"isFirstPage": true,
|
||||
"isLastPage": true,
|
||||
"hasPreviousPage": false,
|
||||
"hasNextPage": false,
|
||||
"navigatePages": 8,
|
||||
"navigatepageNums": [
|
||||
1
|
||||
],
|
||||
"navigateFirstPage": 1,
|
||||
"navigateLastPage": 1
|
||||
}
|
||||
}
|
||||
完美!推流列表查询成功了。现在让我测试播放接口,获取包括 WebRTC 在内的所有播放地址:
|
||||
Bash Test WVP play start API to get stream URLs including WebRTC
|
||||
IN
|
||||
ssh ZTE "
|
||||
TOKEN='eyJhbGciOiJSUzI1NiIsImtpZCI6IjNlNzk2NDZjNGRiYzQwODM4M2E5ZWVkMDlmMmI4NWFlIn0.eyJqdGkiOiJ6Skw2Rzd4X2NNRXZRT0FiWTV3dkl3IiwiaWF0IjoxNzY1MjcyODA2LCJleHAiOjE3NjUyNzY0MDYsIm5iZiI6MTc2NTI3MjgwNiwic3ViIjoibG9naW4iLCJhdWQiOiJBdWRpZW5jZSIsInVzZXJOYW1lIjoiYWRtaW4ifQ.kYBL6VC7hAiYWsX9_MoRXwZmwnpcAt5oi1ZHCtZDTHCoAIUxl_VkNCee7M6L1v2bdmjFxH_PXVygK2jaiLTyPjZloIesHgocFJwikgMAAtxeTZreuEd1Kw7r2nPNHxmZadgjHDqz-gyz2O1E9xOtYTmwMyZYaftOUhZfogAxIbNkt18X2Umdt7mRuIDLsFw0LP0Hcp2273C56F4-hVfF5lxsHtcLPtbq7HppTFMYQwC0KaZBbST6WMjhzbby5Vr3LIcA2BEvOflUigD5goQSM47q-fu87fpx4VFkPzS8pkRWHIGM1Vvjry0jPCW1b6Lk_FhV5Z3IjjUa_Ju4ds6GlA'
|
||||
|
||||
echo '=== 2. 获取播放地址(包括 WebRTC) ==='
|
||||
curl -s 'http://127.0.0.1:18978/api/push/start?id=4' -H 'access-token: '\$TOKEN | python3 -m json.tool
|
||||
"
|
||||
OUT
|
||||
=== 2. 获取播放地址(包括 WebRTC) ===
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "\u6210\u529f",
|
||||
"data": {
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"ip": null,
|
||||
"flv": "http://114.67.89.4:8778/live/prod.live.flv?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"https_flv": "https://114.67.89.4:443/live/prod.live.flv?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"ws_flv": "ws://114.67.89.4:8778/live/prod.live.flv?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"wss_flv": "wss://114.67.89.4:443/live/prod.live.flv?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"fmp4": "http://114.67.89.4:8778/live/prod.live.mp4?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"https_fmp4": "https://114.67.89.4:443/live/prod.live.mp4?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"ws_fmp4": "ws://114.67.89.4:8778/live/prod.live.mp4?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"wss_fmp4": "wss://114.67.89.4:443/live/prod.live.mp4?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"hls": "http://114.67.89.4:8778/live/prod/hls.m3u8?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"https_hls": "https://114.67.89.4:443/live/prod/hls.m3u8?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"ws_hls": "ws://114.67.89.4:8778/live/prod/hls.m3u8?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"wss_hls": "wss://114.67.89.4:443/live/prod/hls.m3u8?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"ts": "http://114.67.89.4:8778/live/prod.live.ts?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"https_ts": "https://114.67.89.4:443/live/prod.live.ts?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"ws_ts": "ws://114.67.89.4:8778/live/prod.live.ts?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"wss_ts": null,
|
||||
"rtmp": "rtmp://114.67.89.4:10001/live/prod?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"rtmps": null,
|
||||
"rtsp": "rtsp://114.67.89.4:10002/live/prod?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"rtsps": null,
|
||||
"rtc": "http://114.67.89.4:8778/index/api/webrtc?app=live&stream=prod&type=play&originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"rtcs": "https://114.67.89.4:443/index/api/webrtc?app=live&stream=prod&type=play&originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"mediaServerId": "polaris",
|
||||
"mediaInfo": {
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"mediaServer": {
|
||||
"id": "polaris",
|
||||
"ip": "polaris-media",
|
||||
"hookIp": "polaris-wvp",
|
||||
"sdpIp": "114.67.89.4",
|
||||
"streamIp": "114.67.89.4",
|
||||
"httpPort": 8778,
|
||||
"httpSSlPort": 443,
|
||||
"rtmpPort": 10001,
|
||||
"flvPort": 9090,
|
||||
"flvSSLPort": 443,
|
||||
"mp4Port": 0,
|
||||
"wsFlvPort": 9090,
|
||||
"wsFlvSSLPort": 443,
|
||||
"rtmpSSlPort": 0,
|
||||
"rtpProxyPort": 10003,
|
||||
"jttProxyPort": 0,
|
||||
"rtspPort": 10002,
|
||||
"rtspSSLPort": 0,
|
||||
"autoConfig": true,
|
||||
"secret": "su6TiedN2rVAmBbIDX0aa0QTiBJLBdcf",
|
||||
"hookAliveInterval": 10.0,
|
||||
"rtpEnable": true,
|
||||
"status": true,
|
||||
"rtpPortRange": "30000,30500",
|
||||
"sendRtpPortRange": "50502,50506",
|
||||
"recordAssistPort": 0,
|
||||
"createTime": "2025-12-09 11:02:16",
|
||||
"updateTime": "2025-12-09 11:02:16",
|
||||
"lastKeepaliveTime": null,
|
||||
"defaultServer": true,
|
||||
"recordDay": 7,
|
||||
"recordPath": "/opt/media/bin/www/record/",
|
||||
"type": "zlm",
|
||||
"transcodeSuffix": null,
|
||||
"serverId": "000000"
|
||||
},
|
||||
"schema": "rtsp",
|
||||
"readerCount": 6,
|
||||
"videoCodec": "H264",
|
||||
"width": 1280,
|
||||
"height": 720,
|
||||
"fps": 30,
|
||||
"loss": -1,
|
||||
"audioCodec": "AAC",
|
||||
"audioChannels": 1,
|
||||
"audioSampleRate": 24000,
|
||||
"duration": 5258065,
|
||||
"online": null,
|
||||
"originType": 1,
|
||||
"originTypeStr": "rtmp_push",
|
||||
"originUrl": null,
|
||||
"aliveSecond": 5262,
|
||||
"bytesSpeed": 319956,
|
||||
"callId": null,
|
||||
"paramMap": {
|
||||
"sign": "41db35390ddad33f83944f44b8b75ded"
|
||||
},
|
||||
"serverId": "000000"
|
||||
},
|
||||
"startTime": null,
|
||||
"endTime": null,
|
||||
"duration": null,
|
||||
"downLoadFilePath": null,
|
||||
"transcodeStream": null,
|
||||
"progress": 0.0,
|
||||
"key": null,
|
||||
"serverId": "000000"
|
||||
}
|
||||
}
|
||||
完美!测试成功了。现在让我为你整理完整的 WVP 推流接口文档。
|
||||
WVP 推流接口完整文档
|
||||
📋 1. 登录接口
|
||||
接口:GET/POST /api/user/login 参数:
|
||||
username: 用户名(例如:admin)
|
||||
password: 密码的 MD5 值(例如:admin 的 MD5 是 21232f297a57a5a743894a0e4a801fc3)
|
||||
示例:
|
||||
# 计算密码的 MD5
|
||||
echo -n "admin" | md5
|
||||
# 输出: 21232f297a57a5a743894a0e4a801fc3
|
||||
|
||||
# 登录
|
||||
curl 'http://114.67.89.4:9090/api/user/login?username=admin&password=21232f297a57a5a743894a0e4a801fc3'
|
||||
返回:
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "成功",
|
||||
"data": {
|
||||
"accessToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjNlNzk2NDZjNGRiYzQwODM4M2E5ZWVkMDlmMmI4NWFlIn0...",
|
||||
"username": "admin",
|
||||
"pushKey": "3e80d1762a324d5b0ff636e0bd16f1e3"
|
||||
}
|
||||
}
|
||||
重要:后续所有接口都需要在请求头中添加 access-token:
|
||||
-H 'access-token: eyJhbGciOiJSUzI1NiIsImtpZCI6IjNlNzk2NDZjNGRiYzQwODM4M2E5ZWVkMDlmMmI4NWFlIn0...'
|
||||
📋 2. 推流列表接口
|
||||
接口:GET /api/push/list 参数:
|
||||
page: 当前页(可选)
|
||||
count: 每页数量(可选)
|
||||
query: 查询内容(可选)
|
||||
pushing: 是否正在推流(可选,true/false)
|
||||
mediaServerId: 流媒体ID(可选)
|
||||
示例:
|
||||
curl 'http://114.67.89.4:9090/api/push/list?page=1&count=10&pushing=true' \
|
||||
-H 'access-token: YOUR_TOKEN'
|
||||
返回:
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "成功",
|
||||
"data": {
|
||||
"total": 1,
|
||||
"list": [
|
||||
{
|
||||
"id": 4,
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"mediaServerId": "polaris",
|
||||
"pushing": true,
|
||||
"pushTime": "2025-12-09 16:06:23",
|
||||
"createTime": "2025-12-09 16:06:23"
|
||||
}
|
||||
],
|
||||
"pageNum": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
}
|
||||
关键字段:
|
||||
id: 推流ID(用于后续获取播放地址)
|
||||
app: 应用名
|
||||
stream: 流ID
|
||||
pushing: 是否正在推流
|
||||
📋 3. 获取播放地址接口(包括 WebRTC)
|
||||
接口:GET /api/push/start 参数:
|
||||
id: 推流ID(必填,从推流列表中获取)
|
||||
示例:
|
||||
curl 'http://114.67.89.4:9090/api/push/start?id=4' \
|
||||
-H 'access-token: YOUR_TOKEN'
|
||||
返回:
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "成功",
|
||||
"data": {
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"flv": "http://114.67.89.4:8778/live/prod.live.flv?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"ws_flv": "ws://114.67.89.4:8778/live/prod.live.flv?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"hls": "http://114.67.89.4:8778/live/prod/hls.m3u8?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"rtmp": "rtmp://114.67.89.4:10001/live/prod?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"rtsp": "rtsp://114.67.89.4:10002/live/prod?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"rtc": "http://114.67.89.4:8778/index/api/webrtc?app=live&stream=prod&type=play&originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"rtcs": "https://114.67.89.4:443/index/api/webrtc?app=live&stream=prod&type=play&originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"mediaInfo": {
|
||||
"videoCodec": "H264",
|
||||
"width": 1280,
|
||||
"height": 720,
|
||||
"fps": 30,
|
||||
"audioCodec": "AAC",
|
||||
"audioChannels": 1,
|
||||
"audioSampleRate": 24000
|
||||
}
|
||||
}
|
||||
}
|
||||
播放地址字段说明:
|
||||
字段 协议 说明
|
||||
rtc WebRTC (HTTP) 低延迟播放,推荐
|
||||
rtcs WebRTC (HTTPS) 低延迟播放(HTTPS)
|
||||
flv HTTP-FLV HTTP 流式播放
|
||||
ws_flv WebSocket-FLV WebSocket 流式播放
|
||||
hls HLS M3U8 播放
|
||||
rtmp RTMP RTMP 播放
|
||||
rtsp RTSP RTSP 播放
|
||||
fmp4 HTTP-FMP4 FMP4 流式播放
|
||||
ts HTTP-TS TS 流式播放
|
||||
完整使用流程
|
||||
步骤 1:登录获取 Token
|
||||
# 计算密码 MD5
|
||||
PASSWORD_MD5=$(echo -n "admin" | md5)
|
||||
|
||||
# 登录
|
||||
curl 'http://114.67.89.4:9090/api/user/login?username=admin&password='$PASSWORD_MD5
|
||||
返回:
|
||||
{
|
||||
"data": {
|
||||
"accessToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjNlNzk2NDZjNGRiYzQwODM4M2E5ZWVkMDlmMmI4NWFlIn0..."
|
||||
}
|
||||
}
|
||||
保存 accessToken 用于后续请求。
|
||||
步骤 2:查询推流列表
|
||||
TOKEN="eyJhbGciOiJSUzI1NiIsImtpZCI6IjNlNzk2NDZjNGRiYzQwODM4M2E5ZWVkMDlmMmI4NWFlIn0..."
|
||||
|
||||
curl 'http://114.67.89.4:9090/api/push/list?page=1&count=10&pushing=true' \
|
||||
-H "access-token: $TOKEN"
|
||||
返回:
|
||||
{
|
||||
"data": {
|
||||
"list": [
|
||||
{
|
||||
"id": 4,
|
||||
"app": "live",
|
||||
"stream": "prod",
|
||||
"pushing": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
记录 id 字段(例如:4)。
|
||||
步骤 3:获取播放地址(包括 WebRTC)
|
||||
curl 'http://114.67.89.4:9090/api/push/start?id=4' \
|
||||
-H "access-token: $TOKEN"
|
||||
返回:
|
||||
{
|
||||
"data": {
|
||||
"rtc": "http://114.67.89.4:8778/index/api/webrtc?app=live&stream=prod&type=play&originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"flv": "http://114.67.89.4:8778/live/prod.live.flv?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"hls": "http://114.67.89.4:8778/live/prod/hls.m3u8?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264",
|
||||
"rtmp": "rtmp://114.67.89.4:10001/live/prod?originTypeStr=rtmp_push&audioCodec=AAC&videoCodec=H264"
|
||||
}
|
||||
}
|
||||
步骤 4:使用播放地址
|
||||
WebRTC 播放(推荐,低延迟)
|
||||
http://114.67.89.4:8778/index/api/webrtc?app=live&stream=prod&type=play
|
||||
HTTP-FLV 播放
|
||||
http://114.67.89.4:8778/live/prod.live.flv
|
||||
HLS 播放
|
||||
http://114.67.89.4:8778/live/prod/hls.m3u8
|
||||
Python 示例代码
|
||||
import requests
|
||||
import hashlib
|
||||
|
||||
# 配置
|
||||
BASE_URL = "http://114.67.89.4:9090"
|
||||
USERNAME = "admin"
|
||||
PASSWORD = "admin"
|
||||
|
||||
# 1. 登录
|
||||
password_md5 = hashlib.md5(PASSWORD.encode()).hexdigest()
|
||||
response = requests.get(f"{BASE_URL}/api/user/login", params={
|
||||
"username": USERNAME,
|
||||
"password": password_md5
|
||||
})
|
||||
token = response.json()["data"]["accessToken"]
|
||||
print(f"Token: {token}")
|
||||
|
||||
# 2. 查询推流列表
|
||||
headers = {"access-token": token}
|
||||
response = requests.get(f"{BASE_URL}/api/push/list", headers=headers, params={
|
||||
"page": 1,
|
||||
"count": 10,
|
||||
"pushing": True
|
||||
})
|
||||
push_list = response.json()["data"]["list"]
|
||||
print(f"推流列表: {push_list}")
|
||||
|
||||
# 3. 获取播放地址
|
||||
if push_list:
|
||||
push_id = push_list[0]["id"]
|
||||
response = requests.get(f"{BASE_URL}/api/push/start", headers=headers, params={
|
||||
"id": push_id
|
||||
})
|
||||
play_urls = response.json()["data"]
|
||||
print(f"\n播放地址:")
|
||||
print(f"WebRTC: {play_urls['rtc']}")
|
||||
print(f"HTTP-FLV: {play_urls['flv']}")
|
||||
print(f"HLS: {play_urls['hls']}")
|
||||
print(f"RTMP: {play_urls['rtmp']}")
|
||||
print(f"RTSP: {play_urls['rtsp']}")
|
||||
总结
|
||||
WVP 推流接口特点
|
||||
✅ 统一的接口:通过推流 ID 获取所有播放地址
|
||||
✅ 包含 WebRTC:支持低延迟播放
|
||||
✅ 多种协议:FLV、HLS、RTMP、RTSP、WebRTC 等
|
||||
✅ 媒体信息:返回视频编码、分辨率、帧率等详细信息
|
||||
✅ 需要认证:所有接口都需要 access-token
|
||||
关键接口
|
||||
接口 说明
|
||||
/api/user/login 登录获取 token
|
||||
/api/push/list 查询推流列表
|
||||
/api/push/start 获取播放地址(包括 WebRTC)
|
||||
这就是完整的 WVP 推流接口文档!
|
||||
Loading…
Reference in New Issue