using Application.Models; using IoTNode.DeviceServices.Onvif; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; using System; namespace IoTNode.Controllers { [SwaggerTag("摄像头")] public class OnvifController : BaseDeviceController { private readonly OnvifService _deviceService; public OnvifController(IServiceProvider applicationServices, OnvifService deviceService) : base(applicationServices) { this._deviceService = deviceService; } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("截屏")] public ApiResponse ScreenShot([SwaggerParameter("设备编号")]string number) { return this.Action(() => { var data = this._deviceService.ScreenShot(number); return new ApiResponse { code = 0, format = "image/jpeg", data = data }; }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("上")] public ApiResponse Up([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.Up(number, 0.5f); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("下")] public ApiResponse Down([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.Down(number, 0.5f); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("左")] public ApiResponse Left([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.Left(number, 0.5f); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("右")] public ApiResponse Right([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.Right(number, 0.5f); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("大")] public ApiResponse Zoomin([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.ZoomIn(number, 0.5f); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("小")] public ApiResponse Zoomout([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.ZoomOut(number, 0.5f); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("停")] public ApiResponse Stop([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.Stop(number); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("开始推流")] public ApiResponse StartPush([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetPush(number, true); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("停止推流")] public ApiResponse StopPush([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetPush(number, false); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("开始录制")] public ApiResponse StartRecord([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetRecord(number, true); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("停止录制")] public ApiResponse StopRecord([SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetRecord(number, false); }); } } }