import request from '@/config/axios'

// 查询监控设备通道信息列表
export async function listChannel(query) {
  return await request.get({
    url: '/rq/yf-sip-device-channel/page',
    params: query
  })
}

// 查询监控设备通道信息详细
export function getChannel(channelId) {
  return request.get({
    url: '/sip/channel/' + channelId
  })
}

// 新增监控设备通道信息
export function addChannel(createNum, data) {
  return request.post({
    url: '/rq/yf-sip-device-channel/' + createNum,

    data
  })
}

// 修改监控设备通道信息
export function updateChannel(data) {
  return request.put({
    url: '/sip/channel',

    data: data
  })
}

// 删除监控设备通道信息
export function delChannel(channelId) {
  return request.delete({
    url: '/sip/channel/' + channelId
  })
}

// 开始播放
export function startPlay(deviceId, channelId) {
  return request.get({
    url: '/rq/sip/player/play/' + deviceId + '/' + channelId // /rq/sip/player/play
  })
}

// 获取流信息
export function getStreaminfo(deviceId, channelId) {
  return request.get({
    url: '/sip/player/playstream/' + deviceId + '/' + channelId
  })
}

export function playbackvideo(deviceId, channelId, query) {
  return request.get({
    url: '/rq/sip/player/playback/' + deviceId + '/' + channelId,

    params: query
  })
}

export function closeStream(deviceId, channelId, streamId) {
  return request.get({
    url: '/rq/sip/player/closeStream/' + deviceId + '/' + channelId + '/' + streamId
  })
}

export function playbackPause(deviceId, channelId, streamId) {
  return request.get({
    url: '/sip/player/playbackPause/' + deviceId + '/' + channelId + '/' + streamId
  })
}

export function playbackReplay(deviceId, channelId, streamId) {
  return request.get({
    url: '/sip/player/playbackReplay/' + deviceId + '/' + channelId + '/' + streamId
  })
}

export function playbackSeek(deviceId, channelId, streamId, query) {
  return request.get({
    url: '/rq/sip/player/playbackSeek/' + deviceId + '/' + channelId + '/' + streamId,

    params: query
  })
}

export function playbackSpeed(deviceId, channelId, streamId, query) {
  return request.get({
    url: '/sip/player/playbackSpeed/' + deviceId + '/' + channelId + '/' + streamId,

    params: query
  })
}

// 监控设备绑定设备或场景
export function binding(data) {
  return request.post({
    url: '/iot/relation/addOrUp',

    data
  })
}
// 通过设备或场景查询监控设备通道信息
export function listRelDeviceOrScene(query) {
  return request.get({
    url: '/sip/channel/listRelDeviceOrScene',

    params: query
  })
}

// 告警图片
export function getAlarmPic(id) {
  return request.download({
    url: '/rq/iot-video-alarm/pic' + '/' + id
  })
}
