videoChannel.ts 1.43 KB
import {
  VideoChannelItemType,
  VideoChannelPlayAddressType,
  VideoChannelQueryParamsType,
  VideoChanneControlType,
  EzvizControlType,
} from './model/videoChannelModel';
import { PaginationResult } from '/#/axios';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  GET_VIDEO_CHANNEL_LIST = '/video/channel',
  GET_VIDEO_CONTROL_START = '/video/control/start',
  GET_VIDEO_CONTROL_STOP = '/video/control/stop',
  SET_VIDEO_CONTROL_CONTROL = '/video/control/control',
  SET_EZVIZ_CONTROL = '/video/ezviz/controlling',
}

export const getVideoChannelList = (params: VideoChannelQueryParamsType) => {
  return defHttp.get<PaginationResult<VideoChannelItemType>>({
    url: Api.GET_VIDEO_CHANNEL_LIST,
    params,
  });
};

export const getVideoControlStart = ({
  deviceId,
  channelId,
}: Record<'deviceId' | 'channelId', string>) => {
  return defHttp.get<VideoChannelPlayAddressType>(
    {
      url: `${Api.GET_VIDEO_CONTROL_START}/${deviceId}/${channelId}`,
      timeout: 30 * 1000,
    },
    {
      withShareToken: true,
    }
  );
};

export const setVideoControl = (tbDeviceId, channelId, params: VideoChanneControlType) => {
  return defHttp.get<VideoChannelPlayAddressType>({
    url: `${Api.SET_VIDEO_CONTROL_CONTROL}/${tbDeviceId}/${channelId}`,
    // timeout: 30 * 1000,
    params,
  });
};

export const setEzvizControl = (params: EzvizControlType) => {
  return defHttp.get({
    url: Api.SET_EZVIZ_CONTROL,
    params,
  });
};