All Products
Search
Document Center

:QueryLiveStreaming

Last Updated:Feb 28, 2024

Queries the live streaming URL of an IP camera.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesQueryLiveStreaming

The operation that you want to perform. Set the value to QueryLiveStreaming.

SchemeStringNortmp

The type of the streaming protocol.

  • rtmp (default): the Real-Time Messaging Protocol (RTMP).
  • hls: the HTTP Live Streaming (HLS) protocol.
  • flv: the HTTP Flash Video (HTTP-FLV) protocol.
IotInstanceIdStringNoiot-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
  • If the instance has an ID, you must specify this parameter. If you do not specify this parameter, the request fails.
  • If the Overview page is not displayed or the instance does not have an ID, you do not need to specify this parameter.

For more information, see the Overview topic of IoT instances.

ProductKeyStringNoa1BwAGV****

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.
DeviceNameStringNocamera1

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.
EnableStunBooleanNofalse

Specifies whether to enable peer-to-peer (P2P) video streaming.

  • true
  • false (default)
Note This feature is available only to users in the whitelist. For more information, email Alibaba Cloud at cangyu.fhb@alibaba-inc.com.
StreamTypeIntegerNo0

The type of the stream. Valid values:

  • 0 (default): major stream.
  • 1: minor stream.
CacheDurationIntegerNo0

The duration of the cached video file. Unit: milliseconds. Valid values: 0 to 10000. Default value: 0.

IotIdStringNoC47T6xwp6ms4bNlkHRWCg4****

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.
ShouldEncryptBooleanNotrue

Specifies whether to encrypt the video file.

  • true
  • false (default)
UrlValidDurationIntegerNo60

The validity period of the URL. Unit: seconds. Valid values: 10 to 14400. Default value: 10.

PlayUnLimitedBooleanNofalse

Specifies whether to allow the live streaming URL to be used for unlimited times within the validity period. Valid values:

  • true: allows the live streaming URL to be used for unlimited times within the validity period.
  • false (default): does not allow the live streaming URL to be used for unlimited times within the validity period.
EncryptTypeIntegerNo0

The encryption type of the video file. Valid values:

1 (default): keyframe encryption.

ForceIFrameBooleanNofalse

Specifies whether to send a forced I-frame command to the IP camera. Valid values:

  • true: sends a forced I-frame command to the IP camera.
  • false (default): does not send a forced I-frame command to the IP camera.

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

ParameterTypeExampleDescription
CodeString200

The response code. Valid values:

  • 200: The request was successful.
  • Other codes: The request failed. For more information about error codes, see Error codes.
DataStruct

The information about the live streaming URL.

PathStringrtmp://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.
RelayDecryptKeyString{\"iv\":\"MDEy**********+Pw==\",\"key\":\"TuqB5bpZ+589v********==\"}

The decryption key.

If you set the ShouldEncrypt parameter to true, the decryption key is generated.

  • iv: the initialization vector.
  • key: the decryption key.
StunInfoString{\"stunUrl\":\"101.***.***.**:3478?key=MuJtPMYxxxxxA&productKey=g2zbxxxxxx&udpRequestTimeout=300&udpRequestRetryNum=5&p2pSessionTimeout=10000&maxPortDetectNum=20&packetsPerSecond=1\"}

The address for the P2P live streaming.

ErrorMessageStringstream push failed

The error message returned if the request failed.

RequestIdString06DC77A0-4622-42DB-9EE0-25FIOHS82JK1

The ID of the request.

SuccessBooleantrue

Indicates whether the request was successful.

  • true
  • false

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&amp;productKey=g2zbxxxxxx&amp;udpRequestTimeout=300&amp;udpRequestRetryNum=5&amp;p2pSessionTimeout=10000&amp;maxPortDetectNum=20&amp;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&amp;productKey=g2zbxxxxxx&amp;udpRequestTimeout=300&amp;udpRequestRetryNum=5&amp;p2pSessionTimeout=10000&amp;maxPortDetectNum=20&amp;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.