index.ts 1.59 KB
import type { VideoChannelPlayAddressType, VideoItemRecordType } from './model'
import { defHttp } from '@/utils/http'

enum Api {
  GET_VIDEO_LIST = '/video',
  STREAMING_PLAY_GET_URL = '/video/url',
  GET_VIDEO_ALL_LIST = '/video/list',
  RTSP_CLOSEFLV = '/rtsp.closeFlv',
  GET_VIDEO_CONTROL_START = '/video/control/start',
  GET_VIDEO_CONTROL_STOP = '/video/control/stop',
}

// 获取视频组件--->频流
export const getVideoList = (organizationId?: string) => {
  return defHttp.get<{ items: VideoItemRecordType[] }>({
    url: Api.GET_VIDEO_LIST,
    params: {
      organizationId,
      page: 1,
      pageSize: 100,
    },
  })
}

// 获取流媒体播放地址
export const getStreamingPlayUrl = (entityId: string) => {
  return defHttp.get({
    url: `${Api.STREAMING_PLAY_GET_URL}/${entityId}`,
  })
}

export const getFlvPlayUrl = (url: string, browserId: string) => {
  return `/api/yt/rtsp/openFlv?url=${encodeURIComponent(url)}&browserId=${browserId}`
}

export const closeFlvPlay = (url: string, browserId: string) => {
  return defHttp.get({
    url: `/rtsp/closeFlv?url=${encodeURIComponent(url)}&browserId=${browserId}`,
  })
}

export const getVideoControlStart = ({
  deviceId,
  channelId,
}: Record<'deviceId' | 'channelId', string>) => {
  return defHttp.get<VideoChannelPlayAddressType>(
    {
      url: `${Api.GET_VIDEO_CONTROL_START}/${deviceId}/${channelId}`,
      timeout: 30 * 1000,
    },
    {},
  )
}
export const getCameraList = (params: Record<'organizationId', string>) => {
  return defHttp.get<{ data: VideoItemRecordType[] }>({
    url: Api.GET_VIDEO_ALL_LIST,
    params,
  })
}