Queries the live streaming URL of an IP camera.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | QueryLiveStreaming | The operation that you want to perform. Set the value to QueryLiveStreaming. |
Scheme | String | No | rtmp | The type of the streaming protocol.
|
IotInstanceId | String | No | iot-cn-n6w1y59**** | The ID of the IoT instance. You can obtain the ID of the instance on the Overview page in the IoT Platform console. Important
For more information, see the Overview topic of IoT instances. |
ProductKey | String | No | a1BwAGV**** | The ProductKey of the product to which the IP camera belongs. You can view information about all products within the current Alibaba Cloud account on the Products page of the IoT Platform console or by calling the QueryProductList operation. Important If you specify this parameter, you must also specify the DeviceName parameter. |
DeviceName | String | No | camera1 | The DeviceName of the IP camera. You can obtain the DeviceName of the IP camera on the Devices page of the IoT Platform console. Important If you specify this parameter, you must also specify the ProductKey parameter. |
EnableStun | Boolean | No | false | Specifies whether to enable peer-to-peer (P2P) video streaming.
Note This feature is available only to users in the whitelist. For more information, email Alibaba Cloud at cangyu.fhb@alibaba-inc.com . |
StreamType | Integer | No | 0 | The type of the stream. Valid values:
|
CacheDuration | Integer | No | 0 | The duration of the cached video file. Unit: milliseconds. Valid values: 0 to 10000. Default value: 0. |
IotId | String | No | C47T6xwp6ms4bNlkHRWCg4**** | The ID of the IP camera. IoT Platform allocates a unique ID to each IP camera to identify the IP camera. You can call the QueryDeviceDetail operation of IoT Platform to obtain the ID of the IP camera. Important If you specify this parameter, you do not need to specify the ProductKey and DeviceName parameters. The IotId parameter specifies a GUID for the IP camera. The value of the IotId parameter is equivalent to the combination of the values of the ProductKey and DeviceName parameters. If you specify the IotId, ProductKey, and DeviceName parameters, the value of the IotId parameter takes precedence. |
ShouldEncrypt | Boolean | No | true | Specifies whether to encrypt the video file.
|
UrlValidDuration | Integer | No | 60 | The validity period of the URL. Unit: seconds. Valid values: 10 to 14400. Default value: 10. |
PlayUnLimited | Boolean | No | false | Specifies whether to allow the live streaming URL to be used for unlimited times within the validity period. Valid values:
|
EncryptType | Integer | No | 0 | The encryption type of the video file. Valid values: 1 (default): keyframe encryption. |
ForceIFrame | Boolean | No | false | Specifies whether to send a forced I-frame command to the IP camera. Valid values:
|
In addition to the preceding operation-specific request parameters, you must specify common request parameters when you call this operation. For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
Code | String | 200 | The response code. Valid values:
|
Data | Struct | The information about the live streaming URL. | |
Path | String | rtmp://47.100.***.***:8000/live?token=dc1****120ce394ef94974/Eb****6RBe8l4_0 | The live streaming URL. Note The validity period of the live streaming URL is 10 seconds. |
RelayDecryptKey | String | {\"iv\":\"MDEy**********+Pw==\",\"key\":\"TuqB5bpZ+589v********==\"} | The decryption key. If you set the ShouldEncrypt parameter to true, the decryption key is generated.
|
StunInfo | String | {\"stunUrl\":\"101.***.***.**:3478?key=MuJtPMYxxxxxA&productKey=g2zbxxxxxx&udpRequestTimeout=300&udpRequestRetryNum=5&p2pSessionTimeout=10000&maxPortDetectNum=20&packetsPerSecond=1\"} | The address for the P2P live streaming. |
ErrorMessage | String | stream push failed | The error message returned if the request failed. |
RequestId | String | 06DC77A0-4622-42DB-9EE0-25FIOHS82JK1 | The ID of the request. |
Success | Boolean | true | Indicates whether the request was successful.
|
Examples
Sample requests
http(s)://linkvisual.cn-shanghai.aliyuncs.com/?Action=QueryLiveStreaming
&IotId=C47T6xwp6ms4bNlkHRWCg4****
&ShouldEncrypt=true
&<Common request parameters>
Sample success responses
XML
format
<QueryLiveStreamingResponse>
<RequestId>06DC77A0-4622-42DB-9EE0-25FIOHS82JK1</RequestId>
<Data>
<Path>rtmp://47.100.***.***:8000/live?token=dc1****120ce394ef94974/Eb****6RBe8l4_0</Path>
<StunInfo>{\"stunUrl\":\"101.***.***.**:3478?key=MuJtPMYxxxxxA&productKey=g2zbxxxxxx&udpRequestTimeout=300&udpRequestRetryNum=5&p2pSessionTimeout=10000&maxPortDetectNum=20&packetsPerSecond=1\"}</StunInfo>
<RelayDecryptKey>{\"iv\":\"MDEy**********+Pw==\",\"key\":\"TuqB5bpZ+589v********==\"}</RelayDecryptKey>
</Data>
<Code>200</Code>
<Success>true</Success>
</QueryLiveStreamingResponse>
JSON
format
{
"RequestId": "06DC77A0-4622-42DB-9EE0-25FIOHS82JK1",
"Data": {
"Path": "rtmp://47.100.***.***:8000/live?token=dc1****120ce394ef94974/Eb****6RBe8l4_0",
"StunInfo": "{\\\"stunUrl\\\":\\\"101.***.***.**:3478?key=MuJtPMYxxxxxA&productKey=g2zbxxxxxx&udpRequestTimeout=300&udpRequestRetryNum=5&p2pSessionTimeout=10000&maxPortDetectNum=20&packetsPerSecond=1\\\"}",
"RelayDecryptKey": "{\"iv\":\"MDEy**********+Pw==\",\"key\":\"TuqB5bpZ+589v********==\"}"
},
"Code": 200,
"Success": true
}
Error codes
For a list of error codes, see Service error codes.