using EC.App.Core;
using EC.App.ThatBLL.Onvif.Intf;
using Furion.DataValidation;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace OnvifWebServer.Controllers.Onvif
{
///
/// Onvif 媒体参数控制
///
[ApiController]
[ApiDescriptionSettings("Onvif")]
[Route("onvif/[controller]")]
public class MediaController : ApiController
{
private readonly IMediaBLL _mediaBLL;
///
///
///
///
public MediaController(IMediaBLL mediaBLL)
{
this._mediaBLL = mediaBLL;
}
///
/// 是否连接
///
///
///
[HttpGet]
public bool IsConnected(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _mediaBLL.IsConnected(ip);
return ret;
}
///
/// 获取播放视频 URL
///
///
///
[HttpGet]
public async Task GetStreamUrl(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
string url = await _mediaBLL.GetStreamUrl(ip);
return url;
}
///
/// 获取抓图 URL
///
///
///
[HttpGet]
public async Task GetSnapshotUrl(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
string url = await _mediaBLL.GetSnapshotUrl(ip);
return url;
}
///
/// 获取抓图 Base64
///
///
///
public async Task GetSnapshot(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
string snapshotBase64 = await _mediaBLL.GetSnapshot(ip);
return snapshotBase64;
}
}
}