机顶盒播放数据流程

机顶盒地址: 172.16.12.42
epg地址: 172.16.199.120
aaa地址: 172.16.199.120
ss地址: 172.16.199.120

1.盒子请求epg页面

盒子请求:
GET /epg/index.html HTTP/1.1
Host: 172.16.199.120:6600

epg 返回: OK

2.盒子请求aaa认证,认证是否为合法的盒子

盒子请求:
POST /aaa/services/rest/V2/AAA/User/Login HTTP/1.1 (application/json)
{
userToken: 979D7C1B0586C8D4E53311BE0E7DC880
terminalType: 2
deviceId: g18ref
timestamp: 89698982
timezone: Asia/Shanghai
random: a0d87557-fd39-4d0f-9c70-7a1f27f17151
isTestUser: 0
sp:
hmac: ZXpcIcdiKCDAh8zacPXQueHqghfBpna3zL7X7wIR+ko=
userId: U00000013
}

aaa认证成功返回:
{
“resultCode”: “0”,
“description”: “ok”,
“userId”: “U00000013”,
“userToken”: “45F051331AFE21F8CB3B0351C95C4AE4”,
“expiration”: “43200000”,
“channelList”: [],
“group”: “EPG_default,User_99”,
“sp”: “”,
“isTestUser”: 0,
“entryList”: [
{
“type”: “epg”,
“url”: “http://172.16.199.120:6600/epg/rest/SPM
}
]
}

3.盒子获取EPG资源

盒子请求:
GET /epg/rest/SPM/V2/Template/Info?group=EPG_default%2CUser_99&epgIdentifier=com.hunantv.operator.hnyd&epgVersion=50034 HTTP/1.1
{
userToken: 45F051331AFE21F8CB3B0351C95C4AE4
terminalType: 2
deviceId: g18ref
timestamp: 89699302
timezone: Asia/Shanghai
random: 5901aa4a-caa0-48dd-b026-050411119915
isTestUser: 0
sp:
hmac: y7MdIe50a9qLAMyNTwqGRt9Hp5CGmhGacBdHWjlyTYw=
userId: U00000013
}

EPG返回:
{
“resultCode”: 0,
“description”: “Success”,
“templateVersion”: 9,
“templateId”: 1
}

4.盒子获取EPG 模板配置

GET /epg/rest/SPM/V2/Template/1/Configuration HTTP/1.1
{
userToken: 45F051331AFE21F8CB3B0351C95C4AE4
…..
}

EPG返回:
{
“configuration”: {
“toolbar”: {
….
}
}
}

5.盒子获取 EPG各项内容

GET /epg/rest/SPM/V2/Media/Label?language=zh_CN&type=1 HTTP/1.1
GET /epg/rest/SPM/V2/EPG/com.hunantv.operator.hnyd/Version/50034/Configuration?group=EPG_default%2CUser_99&version=0 HTTP/1.1
GET /epg/rest/SPM/V2/App/Check/com.hunantv.operator/Version/50034?manufacturer=FONSVIEW&group=EPG_default%2CUser_99&macAddress=00%3A11%3A6D%3A18%3A83%3AA8&identity=00116D1883A8&epgIdentifier=com.hunantv.operator.hnyd&model=F720&stbId=12345678900 HTTP/1.1
GET /epg/rest/SPM/V3/Media/MediaType/2/Content/00000003000000001234000000000017?kid=0&index=0&language=zh_CN HTTP/1.1

6.盒子请求EPG的认证,查看是否可以播放这个资源

POST /epg/rest/SPM/V3/AAA/Content/Single/Authentication HTTP/1.1
{
“contentId”: “00000003000000001234000000000017”,
“index”: “0”,
“mediaType”: “2”
}

EPG认证成功返回 播放地址:
{
“resultCode”: 0,
“contentId”: “00000003000000001234000000000017”,
“description”: “Success”,
“playUrl”: [
{
“subtitles”: null,
“contentId”: “00000003000000001234000000000019”,
“length”: “00042100”,
“format”: 1,
“pId”: “00000003000000001234000000000018”,
“episode”: 1,
“is3D”: 0,
“bitrate”: null,
“playUrl”: “http://172.16.199.120:8112/fonsview_hls/00000003000000001234000000000019
}
]
}

7. 盒子 请求EPG

盒子:
GET /epg/rest/SPM/V2/AD/Scene/HNYD_LOADING?group=EPG_default%2CUser_99&language=zh_CN HTTP/1.1

EPG返回:
{
“ads”: [],
“adrule”: 0,
“totalTime”: 0,
“resultCode”: 1,
“description”: “No advertisement”
}

盒子:
GET /epg/rest/SPM/V2/Recommend/MediaType/2/Content/00000003000000001234000000000017?categoryId=null&programType=1000&begin=0&pageSize=12&language=zh_CN HTTP/1.1

EPG返回:
{
“resultCode”: 0,
“description”: “Success”,
“metadataList”: []
}

8.盒子向ss请求资源 流媒体播放地址

盒子:
GET /fonsview_hls/00000003000000001234000000000019?stbId=12345678900&userID=U00000013&userToken=&usergroup= HTTP/1.1
Host: 172.16.199.120:8112

SS返回 location 让盒子重定向:
Location: http://172.16.199.120:8114/fonsview_hls/00000003000000001234000000000019?stbId=12345678900&userID=U00000013&userToken=&usergroup=&FvSeid=5599584b10b683d0&Fsv_ctype=VODS&Fsv_cid=1008&Fsv_FirstSegID=4&Fsv_BtNum=3&Fsv_filetype=0&Fsv_TBt=6000000&Fsv_otype=1&Provider_id=fonsview_hls&Pcontent_id=00000003000000001234000000000019

注:
这个过程是,盒子请求 cdn的master地址 也就是端口 8112 ,master会根据自己的负载均衡算法,让用户302跳转到 slave节点(端口8114)

9.盒子向ss slave节点请求 媒体文件

盒子请求:
GET /fonsview_hls/00000003000000001234000000000019?stbId=12345678900&userID=U00000013&userToken=&usergroup=&FvSeid=5599584b10b683d0&Fsv_ctype=VODS&Fsv_cid=1008&Fsv_FirstSegID=4&Fsv_BtNum=3&Fsv_filetype=0&Fsv_TBt=6000000&Fsv_otype=1&Provider_id=fonsview_hls&Pcontent_id=00000003000000001
Host: 172.16.199.120:8114

SS返回:

#EXTM3U

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3000000
http://172.16.199.120:8114/VODS/1008_0050000004.m3u8?Fsv_filetype=1&Fsv_cid=1008&Fsv_FirstSegID=50000004&Provider_id=fonsview_hls&Pcontent_id=00000003000000001234000000000019&Fsv_otype=1&FvSeid=5599584b10b683d0&AuthInfo=&version=

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2000000
http://172.16.199.120:8114/VODS/1008_0030000004.m3u8?Fsv_filetype=1&Fsv_cid=1008&Fsv_FirstSegID=30000004&Provider_id=fonsview_hls&Pcontent_id=00000003000000001234000000000019&Fsv_otype=1&FvSeid=5599584b10b683d0&AuthInfo=&version=

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1000000
http://172.16.199.120:8114/VODS/1008_0010000004.m3u8?Fsv_filetype=1&Fsv_cid=1008&Fsv_FirstSegID=10000004&Provider_id=fonsview_hls&Pcontent_id=00000003000000001234000000000019&Fsv_otype=1&FvSeid=5599584b10b683d0&AuthInfo=&version=

根据带宽,不同的带宽 3MB,2MB,1MB 访问不同的码率文件

10.盒子请求播放文件

盒子请求:
GET /VODS/1008_0030000004.m3u8?Fsv_filetype=1&Fsv_cid=1008&Fsv_FirstSegID=30000004&Provider_id=fonsview_hls&Pcontent_id=00000003000000001234000000000019&Fsv_otype=1&FvSeid=5599584b10b683d0&AuthInfo=&version= HTTP/1.1
Host: 172.16.199.120:8114

SS slave节点返回:

#EXTM3U

#EXT-X-MEDIA-SEQUENCE:0

#EXT-X-VERSION:3

#EXT-X-TARGETDURATION:10

#EXTINF:10.000000,
http://172.16.199.120:8114/VODS/1008_140000004_0010000004_0000000000_0002836731.ts?Fsv_Sd=10&Fsv_filetype=2&Provider_id=fonsview_hls&Pcontent_id=00000003000000001234000000000019&FvOPid=00000003000000001234000000000019&Fsv_MBt=0&FvHlsIdx=3&UserID=&Fsv_otype=1&FvSeid=5599584b10b683d0

#EXTINF:10.000000,
http://172.16.199.120:8114/VODS/1008_140000004_0010000004_0002836732_0005661055.ts?Fsv_Sd=10&Fsv_filetype=2&Provider_id=fonsview_hls&Pcontent_id=00000003000000001234000000000019&FvOPid=00000003000000001234000000000019&Fsv_MBt=0&FvHlsIdx=3&UserID=&Fsv_otype=1&FvSeid=5599584b10b683d0

#EXTINF:10.000000,

剩下就是流媒体播放了 …..
世界上最优美的音乐, <<千里之外>> 开始播放了 ……..