stream-push.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**
  2. * 推流服务 API
  3. *
  4. * 本地视频推流 Controller:
  5. * - POST /stream/local/start 启动本地视频推流
  6. * - POST /stream/local/stop 停止本地视频推流
  7. * - GET /stream/local/{name} 获取推流状态
  8. * - GET /stream/local/list 获取所有本地视频推流
  9. *
  10. * 推流服务 Controller:
  11. * - POST /stream/start 启动推流任务
  12. * - POST /stream/stop 停止推流任务
  13. * - GET /stream/task/{streamSn} 获取任务状态
  14. * - GET /stream/tasks 获取 LSS 推流任务列表
  15. * - GET /stream/tasks/active 获取所有活动任务
  16. * - GET /stream/channels 获取推流通道列表
  17. * - GET /stream/playback/{streamSn} 获取播放信息
  18. * - POST /stream/switch 切换推流源
  19. */
  20. import { get, post } from '@/utils/request'
  21. import type { IBaseResponse, IListResponse } from '@/types'
  22. import type {
  23. LocalVideoStreamDTO,
  24. StartLocalStreamRequest,
  25. StreamTaskDTO,
  26. StartStreamTaskRequest,
  27. StopStreamTaskRequest,
  28. SwitchStreamSourceRequest,
  29. StreamPushChannelDTO,
  30. PlaybackInfoDTO
  31. } from '@/types'
  32. // ==================== 本地视频推流 ====================
  33. /**
  34. * 启动本地视频推流
  35. */
  36. export function startLocalStream(data: StartLocalStreamRequest): Promise<IBaseResponse<LocalVideoStreamDTO>> {
  37. return post('/stream/local/start', data)
  38. }
  39. /**
  40. * 停止本地视频推流
  41. */
  42. export function stopLocalStream(streamName: string): Promise<IBaseResponse<void>> {
  43. return post('/stream/local/stop', null, { params: { streamName } })
  44. }
  45. /**
  46. * 获取本地视频推流状态
  47. */
  48. export function getLocalStreamStatus(streamName: string): Promise<IBaseResponse<LocalVideoStreamDTO>> {
  49. return get(`/stream/local/${streamName}`)
  50. }
  51. /**
  52. * 获取所有本地视频推流
  53. */
  54. export function listLocalStreams(): Promise<IListResponse<LocalVideoStreamDTO>> {
  55. return get('/stream/local/list')
  56. }
  57. // ==================== 推流服务 ====================
  58. /**
  59. * 启动推流任务
  60. */
  61. export function startStreamTask(data: StartStreamTaskRequest): Promise<IBaseResponse<StreamTaskDTO>> {
  62. return post('/stream/start', data)
  63. }
  64. /**
  65. * 停止推流任务
  66. */
  67. export function stopStreamTask(data: StopStreamTaskRequest): Promise<IBaseResponse<void>> {
  68. return post('/stream/stop', data)
  69. }
  70. /**
  71. * 获取任务状态
  72. */
  73. export function getStreamTaskStatus(streamSn: string): Promise<IBaseResponse<StreamTaskDTO>> {
  74. return get(`/stream/task/${streamSn}`)
  75. }
  76. /**
  77. * 获取 LSS 推流任务列表
  78. */
  79. export function listLssStreamTasks(lssId: string): Promise<IListResponse<StreamTaskDTO>> {
  80. return get('/stream/tasks', { lssId })
  81. }
  82. /**
  83. * 获取所有活动任务
  84. */
  85. export function listActiveStreamTasks(): Promise<IListResponse<StreamTaskDTO>> {
  86. return get('/stream/tasks/active')
  87. }
  88. /**
  89. * 获取推流通道列表
  90. */
  91. export function listStreamPushChannels(): Promise<IListResponse<StreamPushChannelDTO>> {
  92. return get('/stream/channels')
  93. }
  94. /**
  95. * 获取播放信息
  96. */
  97. export function getStreamPlayback(streamSn: string): Promise<IBaseResponse<PlaybackInfoDTO>> {
  98. return get(`/stream/playback/${streamSn}`)
  99. }
  100. /**
  101. * 切换推流源
  102. */
  103. export function switchStreamSource(data: SwitchStreamSourceRequest): Promise<IBaseResponse<StreamTaskDTO>> {
  104. return post('/stream/switch', data)
  105. }