stream_push.md 32 KB

文档

推流服务

本地视频推流 Controller

本地视频直接推送到 Cloudflare WHIP:

  • POST /stream/local/start 启动本地视频推流
  • POST /stream/local/stop 停止本地视频推流
  • GET /stream/local/{name} 获取推流状态
  • GET /stream/local/list 获取所有本地视频推流

启动本地视频推流

维护人:TG Live

URL

描述:启动本地视频推流

ContentType:application/json

请求参数

Body Parameter
名称 类型 必填 最大长度 描述 示例值
streamName String - 流名称(唯一标识)
videoPath String - 视频文件路径
loop Boolean - 是否循环播放 true
targetChannelId String - 目标推流通道 ID(可选,不传则使用默认通道)

请求示例

{
    "streamName": "string",
    "videoPath": "string",
    "loop": true,
    "targetChannelId": "string"
}

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data object 响应数据 (ActualType: LocalVideoStreamDTO)
└ streamName String - 流名称
└ sourceType String - 源类型:local_video 或 rtsp_camera
└ sourcePath String - 源路径(视频文件路径或 RTSP URL)
└ rtspUrl String - MediaMTX 提供的 RTSP URL
└ loop Boolean - 是否循环播放 true
└ streamTaskId String - 推流任务 ID(如果已推送到 Cloudflare)
└ playbackUrl String - 播放地址(Cloudflare HLS/WHEP)
└ status String - 状态

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": {
        "streamName": "string",
        "sourceType": "string",
        "sourcePath": "string",
        "rtspUrl": "string",
        "loop": true,
        "streamTaskId": "string",
        "playbackUrl": "string",
        "status": "string"
    }
}

错误码

停止本地视频推流

维护人:TG Live

URL

描述:停止本地视频推流

ContentType:application/x-www-form-urlencoded;charset=UTF-8

请求参数

Query Parameter
名称 类型 必填 最大长度 描述 示例值
streamName string - No comments found.

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data object - 响应数据 (ActualType: Void)

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": {}
}

错误码

获取本地视频推流状态

维护人:TG Live

URL

描述:获取本地视频推流状态

ContentType:application/x-www-form-urlencoded;charset=UTF-8

Path 参数

名称 必填 描述 示例值
streamName No comments found.

请求参数

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data object 响应数据 (ActualType: LocalVideoStreamDTO)
└ streamName String - 流名称
└ sourceType String - 源类型:local_video 或 rtsp_camera
└ sourcePath String - 源路径(视频文件路径或 RTSP URL)
└ rtspUrl String - MediaMTX 提供的 RTSP URL
└ loop Boolean - 是否循环播放 true
└ streamTaskId String - 推流任务 ID(如果已推送到 Cloudflare)
└ playbackUrl String - 播放地址(Cloudflare HLS/WHEP)
└ status String - 状态

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": {
        "streamName": "string",
        "sourceType": "string",
        "sourcePath": "string",
        "rtspUrl": "string",
        "loop": true,
        "streamTaskId": "string",
        "playbackUrl": "string",
        "status": "string"
    }
}

错误码

获取所有本地视频推流

维护人:TG Live

URL

描述:获取所有本地视频推流

ContentType:application/x-www-form-urlencoded;charset=UTF-8

请求参数

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data array 响应数据 (ActualType: List)
└ streamName String - 流名称
└ sourceType String - 源类型:local_video 或 rtsp_camera
└ sourcePath String - 源路径(视频文件路径或 RTSP URL)
└ rtspUrl String - MediaMTX 提供的 RTSP URL
└ loop Boolean - 是否循环播放 true
└ streamTaskId String - 推流任务 ID(如果已推送到 Cloudflare)
└ playbackUrl String - 播放地址(Cloudflare HLS/WHEP)
└ status String - 状态

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": [
        {
            "streamName": "string",
            "sourceType": "string",
            "sourcePath": "string",
            "rtspUrl": "string",
            "loop": true,
            "streamTaskId": "string",
            "playbackUrl": "string",
            "status": "string"
        }
    ]
}

错误码

推流服务 Controller

推流管理 API 接口:

  • POST /stream/start 启动推流任务
  • POST /stream/stop 停止推流任务
  • GET /stream/task/{streamSn} 获取任务状态
  • GET /stream/tasks 获取 LSS 推流任务列表
  • GET /stream/tasks/active 获取所有活动任务
  • GET /stream/channels 获取推流通道列表
  • POST /stream/switch 切换推流源

启动推流任务

维护人:TG Live

URL

描述:启动推流任务

ContentType:application/json

请求参数

Body Parameter
名称 类型 必填 最大长度 描述 示例值
name String - 任务名称 投币机 1 号直播
lssId String - LSS 节点 ID(可选,不传则自动选择) lss_001
cameraId String - 摄像头 ID(必填) cam_001
sourceRtspUrl String - 源 RTSP 地址(可选,如不传则从摄像头服务获取) rtsp://admin:password@192.168.1.101:554/stream1
profile String - 推流配置档位: low_latency / standard / file_loop low_latency
whipUrl String - WHIP 推流地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish
playbackUrl String - WebRTC 播放地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/play
remark String - 备注

请求示例

{
    "name": "投币机1号直播",
    "lssId": "lss_001",
    "cameraId": "cam_001",
    "sourceRtspUrl": "rtsp://admin:password@192.168.1.101:554/stream1",
    "profile": "low_latency",
    "whipUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish",
    "playbackUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/play",
    "remark": "string"
}

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data object 响应数据 (ActualType: StreamTaskDTO)
└ streamSn String - 推流任务流水号 stream_abc123def456
└ name String - 任务名称 投币机 1 号直播
└ lssId String - LSS 节点 ID lss_001
└ cameraId String - 摄像头 ID cam_001
└ sourceRtspUrl String - 源 RTSP 地址 rtsp://admin:password@192.168.1.101:554/stream1
└ profile String - 推流配置档位: low_latency / standard / file_loop low_latency
└ whipUrl String - WHIP 推流地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish
└ playbackUrl String - WebRTC 播放地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/play
└ status String - 推流状态: IDLE, STARTING, STREAMING, STOPPED, ERROR STREAMING
└ statusDescription String - 状态描述 推流中
└ errorMessage String - 错误信息
└ retryCount int - 重试次数 0
└ remark String - 备注
└ createdAt LocalDateTime - 创建时间 2024-01-15T10:30:00
└ startedAt LocalDateTime - 开始推流时间 2024-01-15T10:30:05
└ stoppedAt LocalDateTime - 停止推流时间 yyyy-MM-dd HH:mm:ss

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": {
        "streamSn": "stream_abc123def456",
        "name": "投币机1号直播",
        "lssId": "lss_001",
        "cameraId": "cam_001",
        "sourceRtspUrl": "rtsp://admin:password@192.168.1.101:554/stream1",
        "profile": "low_latency",
        "whipUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish",
        "playbackUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/play",
        "status": "STREAMING",
        "statusDescription": "推流中",
        "errorMessage": "string",
        "retryCount": 0,
        "remark": "string",
        "createdAt": "2024-01-15T10:30:00",
        "startedAt": "2024-01-15T10:30:05",
        "stoppedAt": "yyyy-MM-dd HH:mm:ss"
    }
}

错误码

停止推流任务

维护人:TG Live

URL

描述:停止推流任务

ContentType:application/json

请求参数

Body Parameter
名称 类型 必填 最大长度 描述 示例值
taskId String - 推流任务流水号(与 lssId 二选一) stream_abc123def456
lssId String - LSS 节点 ID(与 taskId 二选一,停止该 LSS 所有推流) lss_001

请求示例

{
    "taskId": "stream_abc123def456",
    "lssId": "lss_001"
}

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data object - 响应数据 (ActualType: Void)

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": {}
}

错误码

获取任务状态

维护人:TG Live

URL

描述:获取任务状态

ContentType:application/x-www-form-urlencoded;charset=UTF-8

Path 参数

名称 必填 描述 示例值
streamSn 推流任务流水号 stream_abc123def456

请求参数

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data object 响应数据 (ActualType: StreamTaskDTO)
└ streamSn String - 推流任务流水号 stream_abc123def456
└ name String - 任务名称 投币机 1 号直播
└ lssId String - LSS 节点 ID lss_001
└ cameraId String - 摄像头 ID cam_001
└ sourceRtspUrl String - 源 RTSP 地址 rtsp://admin:password@192.168.1.101:554/stream1
└ profile String - 推流配置档位: low_latency / standard / file_loop low_latency
└ whipUrl String - WHIP 推流地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish
└ playbackUrl String - WebRTC 播放地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/play
└ status String - 推流状态: IDLE, STARTING, STREAMING, STOPPED, ERROR STREAMING
└ statusDescription String - 状态描述 推流中
└ errorMessage String - 错误信息
└ retryCount int - 重试次数 0
└ remark String - 备注
└ createdAt LocalDateTime - 创建时间 2024-01-15T10:30:00
└ startedAt LocalDateTime - 开始推流时间 2024-01-15T10:30:05
└ stoppedAt LocalDateTime - 停止推流时间 yyyy-MM-dd HH:mm:ss

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": {
        "streamSn": "stream_abc123def456",
        "name": "投币机1号直播",
        "lssId": "lss_001",
        "cameraId": "cam_001",
        "sourceRtspUrl": "rtsp://admin:password@192.168.1.101:554/stream1",
        "profile": "low_latency",
        "whipUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish",
        "playbackUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/play",
        "status": "STREAMING",
        "statusDescription": "推流中",
        "errorMessage": "string",
        "retryCount": 0,
        "remark": "string",
        "createdAt": "2024-01-15T10:30:00",
        "startedAt": "2024-01-15T10:30:05",
        "stoppedAt": "yyyy-MM-dd HH:mm:ss"
    }
}

错误码

获取 LSS 推流任务列表

维护人:TG Live

URL

描述:获取 LSS 推流任务列表

ContentType:application/x-www-form-urlencoded;charset=UTF-8

请求参数

Query Parameter
名称 类型 必填 最大长度 描述 示例值
lssId string - LSS 节点 ID lss_001

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data array 响应数据 (ActualType: List)
└ streamSn String - 推流任务流水号 stream_abc123def456
└ name String - 任务名称 投币机 1 号直播
└ lssId String - LSS 节点 ID lss_001
└ cameraId String - 摄像头 ID cam_001
└ sourceRtspUrl String - 源 RTSP 地址 rtsp://admin:password@192.168.1.101:554/stream1
└ profile String - 推流配置档位: low_latency / standard / file_loop low_latency
└ whipUrl String - WHIP 推流地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish
└ playbackUrl String - WebRTC 播放地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/play
└ status String - 推流状态: IDLE, STARTING, STREAMING, STOPPED, ERROR STREAMING
└ statusDescription String - 状态描述 推流中
└ errorMessage String - 错误信息
└ retryCount int - 重试次数 0
└ remark String - 备注
└ createdAt LocalDateTime - 创建时间 2024-01-15T10:30:00
└ startedAt LocalDateTime - 开始推流时间 2024-01-15T10:30:05
└ stoppedAt LocalDateTime - 停止推流时间 yyyy-MM-dd HH:mm:ss

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": [
        {
            "streamSn": "stream_abc123def456",
            "name": "投币机1号直播",
            "lssId": "lss_001",
            "cameraId": "cam_001",
            "sourceRtspUrl": "rtsp://admin:password@192.168.1.101:554/stream1",
            "profile": "low_latency",
            "whipUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish",
            "playbackUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/play",
            "status": "STREAMING",
            "statusDescription": "推流中",
            "errorMessage": "string",
            "retryCount": 0,
            "remark": "string",
            "createdAt": "2024-01-15T10:30:00",
            "startedAt": "2024-01-15T10:30:05",
            "stoppedAt": "yyyy-MM-dd HH:mm:ss"
        }
    ]
}

错误码

获取所有活动任务

维护人:TG Live

URL

描述:获取所有活动任务

ContentType:application/x-www-form-urlencoded;charset=UTF-8

请求参数

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data array 响应数据 (ActualType: List)
└ streamSn String - 推流任务流水号 stream_abc123def456
└ name String - 任务名称 投币机 1 号直播
└ lssId String - LSS 节点 ID lss_001
└ cameraId String - 摄像头 ID cam_001
└ sourceRtspUrl String - 源 RTSP 地址 rtsp://admin:password@192.168.1.101:554/stream1
└ profile String - 推流配置档位: low_latency / standard / file_loop low_latency
└ whipUrl String - WHIP 推流地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish
└ playbackUrl String - WebRTC 播放地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/play
└ status String - 推流状态: IDLE, STARTING, STREAMING, STOPPED, ERROR STREAMING
└ statusDescription String - 状态描述 推流中
└ errorMessage String - 错误信息
└ retryCount int - 重试次数 0
└ remark String - 备注
└ createdAt LocalDateTime - 创建时间 2024-01-15T10:30:00
└ startedAt LocalDateTime - 开始推流时间 2024-01-15T10:30:05
└ stoppedAt LocalDateTime - 停止推流时间 yyyy-MM-dd HH:mm:ss

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": [
        {
            "streamSn": "stream_abc123def456",
            "name": "投币机1号直播",
            "lssId": "lss_001",
            "cameraId": "cam_001",
            "sourceRtspUrl": "rtsp://admin:password@192.168.1.101:554/stream1",
            "profile": "low_latency",
            "whipUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish",
            "playbackUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/play",
            "status": "STREAMING",
            "statusDescription": "推流中",
            "errorMessage": "string",
            "retryCount": 0,
            "remark": "string",
            "createdAt": "2024-01-15T10:30:00",
            "startedAt": "2024-01-15T10:30:05",
            "stoppedAt": "yyyy-MM-dd HH:mm:ss"
        }
    ]
}

错误码

获取推流通道列表

维护人:TG Live

URL

描述:获取推流通道列表

ContentType:application/x-www-form-urlencoded;charset=UTF-8

请求参数

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data array 响应数据 (ActualType: List)
└ channelId String - 通道 ID cf_channel_001
└ name String - 通道名称 主推流通道
└ mode String - 推流模式: WHIP, RTMPS WHIP
└ hlsPlaybackUrl String - HLS 播放地址 https://customer-xxx.cloudflarestream.com/xxx/manifest/video.m3u8
└ recordingEnabled boolean - 是否启用录制 false

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": [
        {
            "channelId": "cf_channel_001",
            "name": "主推流通道",
            "mode": "WHIP",
            "hlsPlaybackUrl": "https://customer-xxx.cloudflarestream.com/xxx/manifest/video.m3u8",
            "recordingEnabled": false
        }
    ]
}

错误码

获取播放信息

维护人:TG Live

URL

描述:获取播放信息

ContentType:application/x-www-form-urlencoded;charset=UTF-8

Path 参数

名称 必填 描述 示例值
streamSn 推流任务流水号 stream_abc123def456

请求参数

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data object 响应数据 (ActualType: PlaybackInfoDTO)
└ streamSn String - 推流任务流水号 stream_abc123def456
└ name String - 任务名称 投币机 1 号直播
└ status String - 推流状态 STREAMING
└ whepUrl String - WHEP 播放地址(WebRTC 低延迟) https://customer-pj89kn2ke2tcuh19.cloudflarestream.com/xxx/webRTC/play
└ hlsUrl String - HLS 播放地址 https://customer-pj89kn2ke2tcuh19.cloudflarestream.com/xxx/manifest/video.m3u8
└ iframeCode String - iframe 嵌入代码
└ isLive Boolean - 是否正在推流 true

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": {
        "streamSn": "stream_abc123def456",
        "name": "投币机1号直播",
        "status": "STREAMING",
        "whepUrl": "https://customer-pj89kn2ke2tcuh19.cloudflarestream.com/xxx/webRTC/play",
        "hlsUrl": "https://customer-pj89kn2ke2tcuh19.cloudflarestream.com/xxx/manifest/video.m3u8",
        "iframeCode": "<iframe src=... allow=accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture; allowfullscreen=true></iframe>",
        "isLive": true
    }
}

错误码

切换推流源

维护人:TG Live

URL

描述:切换推流源

ContentType:application/json

请求参数

Body Parameter
名称 类型 必填 最大长度 描述 示例值
streamSn String - 推流任务流水号 stream_abc123def456
newCameraId String - 新的摄像头 ID cam_001
newRtspUrl String - 新的 RTSP 地址 rtsp://admin:password@192.168.1.101:554/stream1

请求示例

{
    "streamSn": "stream_abc123def456",
    "newCameraId": "cam_001",
    "newRtspUrl": "rtsp://admin:password@192.168.1.101:554/stream1"
}

响应参数

名称 类型 必填 最大长度 描述 示例值
success Boolean - 请求是否成功 true
errCode String - 错误码(失败时返回)
errMessage String - 错误信息(失败时返回)
data object 响应数据 (ActualType: StreamTaskDTO)
└ streamSn String - 推流任务流水号 stream_abc123def456
└ name String - 任务名称 投币机 1 号直播
└ lssId String - LSS 节点 ID lss_001
└ cameraId String - 摄像头 ID cam_001
└ sourceRtspUrl String - 源 RTSP 地址 rtsp://admin:password@192.168.1.101:554/stream1
└ profile String - 推流配置档位: low_latency / standard / file_loop low_latency
└ whipUrl String - WHIP 推流地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish
└ playbackUrl String - WebRTC 播放地址 https://customer-xxx.cloudflarestream.com/xxx/webRTC/play
└ status String - 推流状态: IDLE, STARTING, STREAMING, STOPPED, ERROR STREAMING
└ statusDescription String - 状态描述 推流中
└ errorMessage String - 错误信息
└ retryCount int - 重试次数 0
└ remark String - 备注
└ createdAt LocalDateTime - 创建时间 2024-01-15T10:30:00
└ startedAt LocalDateTime - 开始推流时间 2024-01-15T10:30:05
└ stoppedAt LocalDateTime - 停止推流时间 yyyy-MM-dd HH:mm:ss

响应示例

{
    "success": true,
    "errCode": "string",
    "errMessage": "string",
    "data": {
        "streamSn": "stream_abc123def456",
        "name": "投币机1号直播",
        "lssId": "lss_001",
        "cameraId": "cam_001",
        "sourceRtspUrl": "rtsp://admin:password@192.168.1.101:554/stream1",
        "profile": "low_latency",
        "whipUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/publish",
        "playbackUrl": "https://customer-xxx.cloudflarestream.com/xxx/webRTC/play",
        "status": "STREAMING",
        "statusDescription": "推流中",
        "errorMessage": "string",
        "retryCount": 0,
        "remark": "string",
        "createdAt": "2024-01-15T10:30:00",
        "startedAt": "2024-01-15T10:30:05",
        "stoppedAt": "yyyy-MM-dd HH:mm:ss"
    }
}

错误码