- Summary and Disclaimer
- Design Description
2.1 Introduction to LPH Protocol
2.2 Description of the interaction process of the LPH protocol
2.2.1 Communication interaction process
2.2.2 LPH protocol API calling process - LPH protocol API description
3.1 Login request /link/user/lph_login
3.2 Logout request /link/user/lph_logout
3.3 Get system state information /link/system/get_sys_state
3.4 Get system network state /link/system/get_net_state
3.5 Get HDMI/SDI channel interface status/link/system/get_vi_state
3.6 Get network configuration information /link/system/get_network
3.7 Set network configuration /link/system/set_network
3.8 Get system time /link/system/get_sys_date
3.9 Set system time /link/system/set_sys_date
3.10 Get ntp service information /link/system/get_ntpd
3.11 Set ntp service /link/system/set_ntpd
3.12 Get video channel encoding information/link/encoder/get_enc_confs
3.13 Update network input source parameters /link/encoder/set_net_chns
3.14 Set input source encoding parameters /link/encoder/set_enc_chns
3.15 Set HDMI/SDI crop and rotate video parameters/link/encoder/set_cap_chns
2.16 Set audio encoding parameters /link/encoder/set_audio_chns
3.17 Get video stream output configuration /link/stream/get_stream_confs
3.18 Set video stream output configuration /link/stream/set_stream_confs
3.19 Get hls ndi ts configuration information/link/stream/get_hls_ndi_ts
3.20 Set hls ndi ts configuration information/link/stream/set_hls_ndi_ts
3.21 Get multi-platform live broadcast configuration information/link/stream/get_platform_lives
3.22 Set multi-platform live broadcast configuration information/link/stream/set_platform_lives
3.23 Multi-platform live start /link/stream/start_platform_lives
3.24 Multi-platform live stop /link/stream/stop_platform_lives
3.25 Get multi-platform live status /link/stream/get_platform_lives_state
3.26 Get watermark configuration parameters /link/overlay/get_overlay_confs
3.27 Set watermark configuration parameters /link/overlay/set_overlay_confs
3.28 Get all preset layout information /link/layout/get_deflay_confs
3.29 Get the video layout and mix information used/link/layout/get_layout_confs
3.30 Video layout switching, audio mixing/link/layout/set_layout_confs
3.31 Get HDMI, VGA output configuration information/link/output/get_output_confs
3.32 Set HDMI, VGA output configuration information/link/output/set_output_confs
3.33 Get recording parameters /link/record/get_record_confs
3.34 Set global recording parameters /link/record/set_record_confs
3.35 Start recording /link/record/start_rec
3.36 Stop recording all /link/record/stop_rec
原文链接:灵派编码器HTTP API接口说明_LinkPi的博客-CSDN博客_灵派编码器
- Summary and Disclaimer
The background of LinkPi encoder is implemented in PHP. If you have customization requirements, you can modify its source code by yourself. For the background source program of LinkPi encoder, see Encoder: 通用编码器源码 - Gitee.com . Some users need to control the encoder in their own server or software written by themselves, which can be done by calling the Lingpai encoder HTTP API interface. For the convenience of discussion, we define the LPH encoder HTTP API interface as the LPH interface .
Due to product version upgrades or other reasons, the contents of this document will be continuously updated. Unless otherwise agreed, this document is only used as a guide for use, and all statements and suggestions in this document do not constitute any express or implied warranty.
2. Design Description
2.1 Introduction to LPH Protocol
The LPH protocol is an API interface defined on top of HTTP, and its essence still belongs to the HTTP protocol. Based on HTTP, the LPH protocol adds the interactive process of Digest authentication and login authentication.
2.2 Description of the interaction process of the LPH protocol
2.2.1 Communication interaction process
The main differences between the HTTP interaction process with Digest authentication of the LPH command and the standard HTTP interaction process are as follows:
The LPH protocol currently only supports the Digest authentication process, and the default authentication user name and password are both admin.
Next, we use postman as the client to illustrate a communication process. Here we take login (/link/user/lph_login) as an example.
(1) First, we start postman, and open the postman console tool as shown below, and clear the console information
(2) Create a request, the url is /link/usr/lph_login, the request method can be GET/POST, and set the delivery Here, take the GET request as an example, as shown in the figure below
(3) Set the postman Http authentication method, and set the user name and password, as shown in the figure below
(4) Click the Send button to send the request, and then open the postman console tool, you can see 2 The request record, as shown in Figure
5 below, through comparison, we can see that the first time the client sends a request to the server, the server returns 401, and carries the
WWW-Authenticate authentication information in the response header, and the postman client gets the authentication information After that, calculate the Authenticate and add it to the request header, and send it again.
(6) After the server authentication is passed, the request result will be returned, if the following figure
2.2.2 LPH protocol API calling process
Through the example of 2.2.1, it is known that the Authorization header information is required in the communication process, but the request headers other than the login request must not only carry the Authorization information but also the three sets of HASH values obtained by the login, in order for the request to succeed.
Here is a brief description of the interaction process by obtaining video channel information:
(1) To send a request, first log in to the server /link/user/lph_login
(2) After logging in, send /link/encoder/get_channels to obtain video channel information
(3) After obtaining the information logout /link/user/lph_logout
As shown in the figure below, after the login is successful, add 3 HASH values to the request header of the call to get the video channel information interface, and then you can get the correct request result.
3. LPH protocol API description
3.1 Login request /link/user/lph_login
Request Type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
username | string | Yes | The login user name, which is the same as the login web user name |
passwd | string | Yes | The login password, which is the same as the login web password, needs to be encrypted with md5 before transmission. |
response
{
"data": {
"L-HASH": "0b3bb1f7fcdffc5ea1077090b9bbc43314fa4268",
"P-HASH": "29a07d69a3e5f9b8ef42eee9d5a837af2ff0f403",
"H-HASH": "9d181efb0c1b606f5a7fef2a45b1385a447794f3"
},
"status": "success",
"msg": "登录成功"
}
3.2 Logout request /link/user/lph_logout
Request Type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": "",
"status": "success",
"msg": "登出成功"
}
3.3 Get system state information /link/system/get_sys_state
Request Type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": {
"cpu": 17, //cpu百分比使用率
"mem": 41, //内存百分比使用率
"temperature": 42 //核心温度,摄氏度
},
"status": "success",
"msg": "执行完成"
}
3.4 Get system network state /link/system/get_net_state
Request Type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": {
"rx": 0, //网络下行
"tx": 0 //网络上行
},
"status": "success",
"msg": "执行完成"
}
3.5 Get HDMI/SDI channel interface status/link/system/get_vi_state
Request Type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": [
{
"avalible": true, //Whether there is hdm/sdi input source access
"framerate": 50, //frame rate
"full": false,
"height": 1080, //video high
"interlace": false, //whether interlace scanning
"protocol": "HDMI", //Input source type
"samplerate": 48000, //Audio sample rate
"width": 1920 //video width
},
…………
],
"status": "success",
"msg": "执行完成"
}
3.6 Get network configuration information /link/system/get_network
Request Type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": {
"ip": "192.168.1.213",
"mask": "255.255.252.0", //掩码
"gateway": "192.168.1.1", //网关
"dns": "8.8.8.8",
"mac": "886570e99627"
"dhcp": false
},
"status": "success",
"msg": "执行完成"
}
3.7 Set network configuration /link/system/set_network
Request Type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
ip | string | no | ip address |
mask | string | no | subnet mask |
gateway | string | no | gateway |
dns | string | no | dns |
dhcp | bool | no | Whether to automatically obtain the ip, when the value is true, other parameters will be ignored |
Response
no return value
3.8 Get system time /link/system/get_sys_date
Request Type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
none | none | none | none |
response
{
"data": "2021-11-11 03:37:28",
"status": "success",
"msg": "执行完成"
}
3.9 Set system time /link/system/set_sys_date
Request Type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
sysDate | string | Yes | The parameter format is and only is: “yyyy/MM/dd/hh/mm/ss” |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.10 Get ntp service information /link/system/get_ntpd
Request Type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
none | none | none | none |
response
{
"data": {
"server": "cn.pool.ntp.org", //ntp server address
"enable": false //Whether to synchronize the time of the ntp server when booting
},
"status": "success",
"msg": "执行完成"
}
3.11 Set ntp service /link/system/set_ntpd
Request Type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
server | string | no | NTP server address, such as cn.pool.ntp.org |
enable | bool | no | Whether to synchronize ntp time when booting |
sync | bool | no | Whether to synchronize ntp time immediately |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.12 Get video channel encoding information/link/encoder/get_enc_confs
Request Type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
none | none | none | none |
response
{
"data": [
{
"id": 0, //channel id
"name": "HDMI", //channel name
"type": "vi", //channel type,There are 4 kinds of vi usb net mix
"enable": true, //Channel master switch, main stream encoding switch
"enable2": false, //Substream encoding switch
"encv": { //Main stream encoding parameters
"Iqp": 25, //Iframe quantizer
"Pqp": 25, //P帧量化因子
"bitrate": 4000, //码率 kb/s
"codec": "h264", //编码格式
"framerate": 30, //帧率
"gop": 2, //gop length
"gopmode": 0, //HiSilicon gop mode,0--Normal 1--SmarP 2--DualP 3--Bipred
"height": 1080, //视频高
"lowLatency": false, //是否低延时编码
"maxqp": 36, //最大量化因子
"minqp": 22, //最小量化因子
"profile": "main", //Code compression method
"rcmode": "cbr", //rate control
"width": 1920 //视频宽
},
"encv2": { //Substream parameters, same as encv
"Iqp": 25,
"Pqp": 25,
"bitrate": 1000,
"codec": "h264",
"framerate": 30,
"gop": 1,
"gopmode": 0,
"height": 360,
"lowLatency": false,
"maxqp": 36,
"minqp": 22,
"profile": "high",
"rcmode": "avbr",
"width": 640
},
"enca": { //Audio encoding parameters
"audioSrc": "hdmi", //audio source used
"bitrate": 128, // 码率 kb/s
"channels": 1, //Channel 1 stands for mono, 2 stands for stereo
"codec": "aac", //audio coding format
"gain": 6, //sound gain
"samplerate": 48000 //采样率
},
"cap": { //Video parameters, this attribute is a unique attribute of vi channel (HDMI/SDI), other channels do not exist
"crop": {
"B": 0, //video below collection,unit pixel
"L": 0, //视频左采集,unit pixel
"R": 0, //视频右采集,unit pixel
"T": 0 //视频上采集,unit pixel
},
"deinterlace": false, //Whether to deinterlace the full frame
"rotate": 0 //Rotation angle
},
"net": { //Network input, this property is unique to the net channel, other channels do not exist
"bufferMode": 0, //buffer mode
"decodeA": false, //Whether to decode audio
"decodeV": false, //Whether video decoding
"framerate": -1, //framerate
"minDelay": 500, //Buffer time, in milliseconds
"path": "rtsp://192.168.2.182/1", //network stream address
"protocol": "tcp" //Transfer Protocol
}
},
…………
],
"status": "success",
"msg": "执行完成"
}
3.13 Update network input source parameters /link/encoder/set_net_chns
Request Type: POST
Parameters
Parameter Type | describe |
---|---|
string | The parameter is a JsonArray string, the example is as follows |
Parameter example
[
{
"id":2,
"path":"rtsp://192.168.2.180/1",
"decodeV":true,
"enable":true
},
…………
NetObject,
NetObject
]
NetObject object properties are shown in the following table
property name | Field Type | Is it mandatory | describe |
---|---|---|---|
id | int | Yes | channel id |
name | string | no | channel name |
path | string | no | network stream address |
bufferMode | int | no | Buffer Mode 0: Normal 1: Real Time 2: Synchronous |
minDelay | int | no | Buffer time, in milliseconds |
protocol | string | no | Transport protocol, tcp\upd |
framerate | int | no | frame rate |
decodeV | bool | no | Whether video decoding |
decodeA | bool | no | Whether to decode audio |
enable | bool | no | Channel master switch, whether to enable streaming |
enable2 | bool | no | Whether to enable sub-stream, valid when video decoding is enabled |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.14 Set input source encoding parameters /link/encoder/set_enc_chns
Request Type: POST
Parameters
Parameter Type | describe |
---|---|
string | The parameter is a JsonArray string, the example is as follows |
Parameter example
[
{
"id":2,
"name":"HDMI",
"enable":true,
"enable2":false,
"encv":{
"width":1920,
"height":1080,
"codec":"h264",
"profile":"main",
"rcmode":"cbr"
},
"encv2":{
"width":640,
"height":360
}
},
…………
ChnObject
]
The properties of the ChnObject object are shown in the following table
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
id | int | Yes | channel id |
name | string | no | channel name |
enable | bool | no | Channel master switch, main stream encoding switch |
enable2 | bool | no | Substream encoding switch |
encv | EncObject | no | Main stream encoding parameters, object type, properties are shown in the following table |
env2 | EncObject | no | Substream encoding parameters, object type, properties are shown in the following table |
EncObject
property name | Field Type | Is it mandatory | describe |
---|---|---|---|
width | int | no | Video width, when the value is -1, the default width of the input source is used |
height | int | no | Video high, when the value is -1, the default high input source is used |
codec | string | no | Encoding method, optional value: h264 h265 close |
profile | string | no | Encoding compression method, optional value: base main high |
rcmode | string | no | rate control, optional value cbr vbr avbr fixqp |
bitrate | string | no | Bit rate kb/s |
framerate | string | no | frame rate |
gop | int | no | gop length |
gopmode | int | no | HiSilicon GOP mode, 0–Normal 1–SmarP 2–DualP 3–BipredB |
minqp | Int | no | Minimum quantization factor |
maxqp | int | no | Maximum quantization factor |
Iqp | int | no | I frame quantization factor |
why | int | no | P-frame quantization factor |
lowLatency | bool | no | Whether low-latency encoding |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.15 Set HDMI/SDI crop and rotate video parameters/link/encoder/set_cap_chns
Request Type: POST
Parameters
Parameter Type | describe |
---|---|
string | The parameter is a JsonArray string, the example is as follows |
Parameter example
[
{
"id":2,
"L":"200",
"rotate":90,
},
…………
CapObject
]
CapObject object properties are shown in the following table
property name | Field Type | describe |
---|---|---|
id | int | channel id |
deinterlace | bool | Whether to deinterlace the full frame |
rotate | int | Video rotation, optional value 0 90 180 270 |
L | int | Video ruling left, in pixels |
R | int | Video adjudication right, in pixels |
T | int | Video adjudication, unit pixel |
B | int | Under video adjudication, unit pixel |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
2.16 Set audio encoding parameters /link/encoder/set_audio_chns
Request Type: POST
Parameters
Parameter Type | describe |
---|---|
string | The parameter is a JsonArray string, the example is as follows |
Parameter example
[
{
"id":2,
"codec":"aac",
" audioSrc":"hdmi",
" gain":"6"
},
…………
AudioObject
]
AudioObject object properties are shown in the following table
property name | Field Type | describe |
---|---|---|
id | int | channel id |
codec | string | Encoding format, optional value aac pcma mp2 mp3 opus close |
audioSrc | string | Audio source, optional value hdmi sdi line |
gain | int | Sound gain, optional value -24 -18 -12 -6 0 6 12 18 24 |
samplerate | int | Sampling rate, optional value 16000 32000 44100 48000 -1 (-1 means automatic) |
channels | int | Channel, optional value 1—mono 2—stereo |
bitrate | int | Bit rate kb/s |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.17 Get video stream output configuration /link/stream/get_stream_confs
Request Type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": [
{
"id": 0, //通道id
"name": "HDMI", //通道名称
"type": "vi", //通道类型
"enable": true, //通道总开关,主码流开关
"enable2": false, //子码流开关
"stream": { //主码流输出
"hls": false, //输出hls流开关
"http": true, //输出tsHttp流开关
"push": { //推流参数
"enable": false, //是否开启推流
"format": "auto", //封装格式
"hevc_id": 12, //rtmp输出时,h265数据使用的id号
"path": "rtmp://127.0.0.1/live/test_main0" //推流地址
},
"rtmp": true, //输出rtmp流开关
"rtsp": true, //输出rtsp流开关
"srt": { //srt流参数
"enable": false, //是否开启rtsp流
"ip": "127.0.0.1", //ip地址
"latency": 50, //延时
"mode": "listener", //模式
"passwd": "", //密码
"port": 9001, //端口
"streamid": "" // stream id
},
"udp": { //组播参数
"bandwidth": 100, //流控最大带宽
"enable": false, //是否开启组播
"flowCtrl": true, //是否开启流控
"ip": "233.233.2.1", //地址
"port": 3000, //端口
"rtp": false, //是否增加rtp头
"ttl": 5 //ttl
}
},
"stream2": { //子码流输出,参数主码流输出
"hls": false,
"http": true,
"push": {
"enable": false,
"format": "auto",
"hevc_id": 12,
"path": "rtmp://127.0.0.1/live/test_sub0"
},
"rtmp": true,
"rtsp": true,
"srt": {
"enable": false,
"ip": "127.0.0.1",
"latency": 50,
"mode": "listener",
"passwd": "",
"port": 9101,
"streamid": ""
},
"udp": {
"bandwidth": 100,
"enable": false,
"flowCtrl": true,
"ip": "233.233.3.1",
"port": 3000,
"rtp": false,
"ttl": 5
}
}
},
…………
],
"status": "success",
"msg": "执行完成"
}
3.18 Set video stream output configuration /link/stream/set_stream_confs
Request Type: POST
Parameters
Parameter Type | describe |
---|---|
string | The parameter is a JsonArray string, the example is as follows |
Parameter example
[
{
"id":0,
"stream":{
"hls":true,
"http": false,
"rtsp":true,
"udp":{
"enable":true
}
},
"stream2":{
"rtmp":true,
"http":false,
"hls":false,
"push":{
"enable":true,
"path":"rtmp://192.168.2.110/live/main"
},
"udp":{
"enable":false
}
}
},
ChnObject,
ChnObject,
ChnObject,
…………
]
ChnObject
property name | Field Type | Is it mandatory | describe |
---|---|---|---|
id | int | Yes | channel id |
stream | StreamObject | no | Main stream output parameters |
Stream2 | StreamObject | no | Substream output parameters |
StreamObject
property name | Field Type | Is it mandatory | describe |
---|---|---|---|
hls | bool | no | whether to output hls stream |
http | bool | no | whether to output http stream |
rtmp | bool | no | Whether to output rtmp stream |
rtsp | bool | no | Whether to output rtsp stream |
push | PushObject | no | Push stream configuration parameters |
udp | UdpObject | no | udp multicast configuration parameters |
srt | SrtObject | no | srt stream configuration parameters |
PushObject
property name | Field Type | Is it mandatory | describe |
---|---|---|---|
enable | bool | no | Whether to enable push streaming |
format | string | no | Package format, the value can be auto flv rtsp rtp mpegts rtp_mpegts |
hevc_id | int | no | When rtmp is output, the id number used by h265 data |
path | string | no | Push URL |
UdpObject
property name | Field Type | Is it mandatory | describe |
---|---|---|---|
bandwidth | int | no | Flow control maximum bandwidth, in Mb |
enable | bool | no | Whether to enable multicast |
flowCtrl | bool | no | Flow control, so that the stream is sent more evenly, preventing packet loss, but consuming some performance |
ip | string | no | address |
port | int | no | port |
rtp | bool | no | whether to add rtp header |
ttl | int | no | ttl |
SrtObject
property name | Field Type | Is it mandatory | describe |
---|---|---|---|
latency | int | no | delay |
enable | bool | no | Whether to enable srt stream |
mode | string | no | mode, caller listener rendezvous |
ip | string | no | address |
port | int | no | port |
passwd | string | no | password |
streamid | int | no | stream id |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.19 Get hls ndi ts configuration information/link/stream/get_hls_ndi_ts
Request Type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": [
{
"id": 0, //通道id
"name": "HDMI", //通道名称
"type": "vi", //通道类型
"enable": true, //通道总开关,主码流编码是否启用
"enable2": true, //子码流编码否启用
"hls": {
"hls_base_url": "/hls/", //url前缀
"hls_filename": "-%06d.ts", //文件名后缀
"hls_list_size": 5, //列表长度
"hls_time": 5 //分片长度
},
"ndi": {
"enable": false, //开关
"group": "", //NDI 分组
"name": "stream0" //NDI 名称
},
"ts": {
"mpegts_original_network_id": 1, //network id
"mpegts_pmt_start_pid": 4096, //pmt pid
"mpegts_service_id": 1, // service id
"mpegts_start_pid": 100, // pid
"mpegts_transport_stream_id": 1, //stream id
"tsSize": 1316 //packet size
}
}
],
"status": "success",
"msg": "执行完成"
}
3.20 Set hls ndi ts configuration information/link/stream/set_hls_ndi_ts
Request Type: POST
Parameters
Parameter Type | describe |
---|---|
string | The parameter is a JsonArray string, the example is as follows |
Parameter example
[
{
"id":0,
"hls":{
"hls_time":5,
"hls_list_size":5
},
"ndi": {
"enable":true,
"name":"stream0"
},
"ts": {
"mpegts_pmt_start_pid":4096,
"mpegts_original_network_id":1,
"mpegts_start_pid":100
}
}
,
ChnObject,
ChnObject,
ChnObject,
…………
]