Skip to content

Instantly share code, notes, and snippets.

@cuongtvee
Last active December 2, 2024 05:57
Show Gist options
  • Save cuongtvee/1c85ea4ad74436bdddfe1f7ff92919e9 to your computer and use it in GitHub Desktop.
Save cuongtvee/1c85ea4ad74436bdddfe1f7ff92919e9 to your computer and use it in GitHub Desktop.
vms-3rd.MD

Guide to Retrieve Camera Streaming URLs

This guide outlines how to call the necessary API to retrieve a list of camera streams, including their main and sub-stream URLs.

Steps

  1. Retrieve the base RTSP URL.
  2. Define the query parameters (token and id).
  3. Append the query parameters to the RTSP URL.
  4. Final RTSP URL with the required query parameters.

1. Get Access Token

Contact the administrator to get the access_token required for making API requests.


2. Retrieve the Camera List

Endpoint

  • URL: {{vms_api_url}}/3rd/streaming/camera/list
  • Method: POST

Headers

  • Content-Type: application/json
  • Access-Token: <Your Access Token>

Request Body

An empty JSON object is sent in the body:

{}

Example cURL Command

curl -X GET "{{vms_api_url}}/3rd/streaming/camera/list" \
-H "Content-Type: application/json" \
-H "Access-Token: <Your Access Token>" \
-d '{}'

JSON Response Structure

{
    "data": [
        {
            "id": "string",
            "main_stream_url": "string",
            "name": "string",
            "sub_stream_url": "string"
        }
    ],
    "details": null,
    "next_page_token": null,
    "success": boolean
}

Example Response:

{
    "data": [
        {
            "id": "camera_id",
            "main_stream_url": "rtsp://example.com:8554/main",
            "name": "Example camera",
            "sub_stream_url": "rtsp://example.com:8554/sub"
        }
    ],
    "details": null,
    "next_page_token": null,
    "success": true
}

In case of AUTH_FAILED:

{
    "data": "AUTH_FAILED",
    "details": "AUTH_FAILED",
    "next_page_token": null,
    "success": false
}

3. Field Descriptions

  • data (array of objects) > - Type: array

    • Description: An array of camera objects, each containing streaming information for individual cameras.
    • Fields in each camera object: > - main_stream_url (string): The URL for the main stream of the camera. This is usually an RTSP URL used to access the primary video feed.
      • name (string): The name or identifier of the camera (e.g., "2-VP", "TV-cam").
      • sub_stream_url (string): The URL for the sub-stream of the camera. This could be an RTSP URL used for a secondary, lower-quality video feed, often used for viewing at lower bandwidth or for less important streams.
  • details (null or string) > - Type: null or string

    • Description: A field that may contain additional details about the request or response. In this case, it is typically null, but it may be used for additional error information or metadata if needed.
  • next_page_token (null or string) > - Type: null or string

    • Description: A token used for pagination, allowing you to fetch the next set of camera streams if the list is paginated. If there is no pagination, this field is null.
  • success (boolean) > - Type: boolean

    • Description: A boolean value indicating whether the request was successful. A value of true means the request was successful, while false means an error occurred.

4. Play Camera Stream

After retrieving the RTSP URL via the API, you need to append the query parameters (token and id) to the base RTSP URL for playing the camera stream.

Query Parameters:

  • token: The authentication token to be added to the URL.
  • id: The camera ID to be appended.

Modify RTSP URL:

Append the query parameters to the base RTSP URL. The final RTSP URL will look like this:

rtsp://example.com:8554/main?token=xxx&id=camera_id

This modified RTSP URL can then be used for streaming the camera feed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment