stream-push.ts 3.2 KB

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