refactor: video stream service; fix: progress tracker guid
This commit is contained in:
parent
771f5e8e9f
commit
0547bb5a02
|
@ -1,77 +1,22 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.Security.Claims;
|
||||
using Database;
|
||||
using DotNext;
|
||||
|
||||
/// <summary>
|
||||
/// 视频流控制器,支持动态配置摄像头连接
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
public class VideoStreamController : ControllerBase
|
||||
{
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
private readonly server.Services.HttpVideoStreamService _videoStreamService;
|
||||
|
||||
/// <summary>
|
||||
/// 视频流信息结构体
|
||||
/// </summary>
|
||||
public class StreamInfoResult
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public int FrameRate { get; set; }
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public int FrameWidth { get; set; }
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public int FrameHeight { get; set; }
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string Format { get; set; } = "MJPEG";
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string HtmlUrl { get; set; } = "";
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string MjpegUrl { get; set; } = "";
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string SnapshotUrl { get; set; } = "";
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string UsbCameraUrl { get; set; } = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 摄像头配置请求模型
|
||||
/// </summary>
|
||||
public class CameraConfigRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 摄像头地址
|
||||
/// </summary>
|
||||
[Required]
|
||||
[RegularExpression(@"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ErrorMessage = "请输入有效的IP地址")]
|
||||
public string Address { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 摄像头端口
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(1, 65535, ErrorMessage = "端口必须在1-65535范围内")]
|
||||
public int Port { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率配置请求模型
|
||||
/// </summary>
|
||||
|
@ -92,6 +37,14 @@ public class VideoStreamController : ControllerBase
|
|||
public int Height { get; set; }
|
||||
}
|
||||
|
||||
public class AvailableResolutionsResponse
|
||||
{
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Value => $"{Width}x{Height}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化HTTP视频流控制器
|
||||
/// </summary>
|
||||
|
@ -102,6 +55,40 @@ public class VideoStreamController : ControllerBase
|
|||
_videoStreamService = videoStreamService;
|
||||
}
|
||||
|
||||
private Optional<string> TryGetBoardId()
|
||||
{
|
||||
var userName = User.FindFirstValue(ClaimTypes.Name);
|
||||
if (string.IsNullOrEmpty(userName))
|
||||
{
|
||||
logger.Error("User name not found in claims.");
|
||||
return Optional<string>.None;
|
||||
}
|
||||
|
||||
var db = new AppDataConnection();
|
||||
if (db == null)
|
||||
{
|
||||
logger.Error("Database connection failed.");
|
||||
return Optional<string>.None;
|
||||
}
|
||||
|
||||
var userRet = db.GetUserByName(userName);
|
||||
if (!userRet.IsSuccessful || !userRet.Value.HasValue)
|
||||
{
|
||||
logger.Error("User not found.");
|
||||
return Optional<string>.None;
|
||||
}
|
||||
|
||||
var user = userRet.Value.Value;
|
||||
var boardId = user.BoardID;
|
||||
if (boardId == Guid.Empty)
|
||||
{
|
||||
logger.Error("No board bound to this user.");
|
||||
return Optional<string>.None;
|
||||
}
|
||||
|
||||
return boardId.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 HTTP 视频流服务状态
|
||||
/// </summary>
|
||||
|
@ -114,8 +101,6 @@ public class VideoStreamController : ControllerBase
|
|||
{
|
||||
try
|
||||
{
|
||||
logger.Info("GetStatus方法被调用,控制器:{Controller},路径:api/VideoStream/Status", this.GetType().Name);
|
||||
|
||||
// 使用HttpVideoStreamService提供的状态信息
|
||||
var status = _videoStreamService.GetServiceStatus();
|
||||
|
||||
|
@ -129,101 +114,18 @@ public class VideoStreamController : ControllerBase
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 HTTP 视频流信息
|
||||
/// </summary>
|
||||
/// <returns>流信息</returns>
|
||||
[HttpGet("StreamInfo")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(StreamInfoResult), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
|
||||
public IResult GetStreamInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Info("获取 HTTP 视频流信息");
|
||||
var result = new StreamInfoResult
|
||||
{
|
||||
FrameRate = _videoStreamService.FrameRate,
|
||||
FrameWidth = _videoStreamService.FrameWidth,
|
||||
FrameHeight = _videoStreamService.FrameHeight,
|
||||
Format = "MJPEG",
|
||||
HtmlUrl = $"http://{Global.localhost}:{_videoStreamService.ServerPort}/video-feed.html",
|
||||
MjpegUrl = $"http://{Global.localhost}:{_videoStreamService.ServerPort}/video-stream",
|
||||
SnapshotUrl = $"http://{Global.localhost}:{_videoStreamService.ServerPort}/snapshot",
|
||||
UsbCameraUrl = $"http://{Global.localhost}:{_videoStreamService.ServerPort}/usb-camera"
|
||||
};
|
||||
return TypedResults.Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "获取 HTTP 视频流信息失败");
|
||||
return TypedResults.InternalServerError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置摄像头连接参数
|
||||
/// </summary>
|
||||
/// <param name="config">摄像头配置</param>
|
||||
/// <returns>配置结果</returns>
|
||||
[HttpPost("ConfigureCamera")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IResult> ConfigureCamera([FromBody] CameraConfigRequest config)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Info("配置摄像头连接: {Address}:{Port}", config.Address, config.Port);
|
||||
|
||||
var success = await _videoStreamService.ConfigureCameraAsync(config.Address, config.Port);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return TypedResults.Ok(new
|
||||
{
|
||||
success = true,
|
||||
message = "摄像头配置成功",
|
||||
cameraAddress = config.Address,
|
||||
cameraPort = config.Port
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return TypedResults.BadRequest(new
|
||||
{
|
||||
success = false,
|
||||
message = "摄像头配置失败",
|
||||
cameraAddress = config.Address,
|
||||
cameraPort = config.Port
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "配置摄像头连接失败");
|
||||
return TypedResults.InternalServerError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前摄像头配置
|
||||
/// </summary>
|
||||
/// <returns>摄像头配置信息</returns>
|
||||
[HttpGet("CameraConfig")]
|
||||
[HttpGet("MyEndpoint")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
|
||||
public IResult GetCameraConfig()
|
||||
public IResult MyEndpoint()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Info("获取摄像头配置");
|
||||
var cameraStatus = _videoStreamService.GetCameraStatus();
|
||||
var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
|
||||
var endpoint = _videoStreamService.GetVideoEndpoint(boardId);
|
||||
|
||||
return TypedResults.Ok(cameraStatus);
|
||||
return TypedResults.Ok(endpoint);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -232,22 +134,6 @@ public class VideoStreamController : ControllerBase
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制 HTTP 视频流服务开关
|
||||
/// </summary>
|
||||
/// <param name="enabled">是否启用服务</param>
|
||||
/// <returns>操作结果</returns>
|
||||
[HttpPost("SetEnabled")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IResult> SetEnabled([FromQuery] bool enabled)
|
||||
{
|
||||
logger.Info("设置视频流服务开关: {Enabled}", enabled);
|
||||
await _videoStreamService.SetEnable(enabled);
|
||||
return TypedResults.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试 HTTP 视频流连接
|
||||
/// </summary>
|
||||
|
@ -260,32 +146,23 @@ public class VideoStreamController : ControllerBase
|
|||
{
|
||||
try
|
||||
{
|
||||
logger.Info("测试 HTTP 视频流连接");
|
||||
var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
|
||||
var endpoint = _videoStreamService.GetVideoEndpoint(boardId);
|
||||
|
||||
// 尝试通过HTTP请求检查视频流服务是否可访问
|
||||
bool isConnected = false;
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
httpClient.Timeout = TimeSpan.FromSeconds(2); // 设置较短的超时时间
|
||||
var response = await httpClient.GetAsync($"http://{Global.localhost}:{_videoStreamService.ServerPort}/");
|
||||
var response = await httpClient.GetAsync(endpoint.MjpegUrl);
|
||||
|
||||
// 只要能连接上就认为成功,不管返回状态
|
||||
isConnected = response.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
logger.Info("测试摄像头连接");
|
||||
var ret = await _videoStreamService.TestCameraConnection(boardId);
|
||||
|
||||
var (isSuccess, message) = await _videoStreamService.TestCameraConnectionAsync();
|
||||
|
||||
return TypedResults.Ok(new
|
||||
{
|
||||
isConnected = isConnected,
|
||||
success = isSuccess,
|
||||
message = message,
|
||||
cameraAddress = _videoStreamService.CameraAddress,
|
||||
cameraPort = _videoStreamService.CameraPort,
|
||||
timestamp = DateTime.Now
|
||||
});
|
||||
return TypedResults.Ok(ret);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -295,6 +172,23 @@ public class VideoStreamController : ControllerBase
|
|||
}
|
||||
}
|
||||
|
||||
[HttpPost("DisableTransmission")]
|
||||
public async Task<IActionResult> DisableHdmiTransmission()
|
||||
{
|
||||
try
|
||||
{
|
||||
var boardId = TryGetBoardId().OrThrow(() => new ArgumentException("Board ID is required"));
|
||||
|
||||
await _videoStreamService.DisableHdmiTransmissionAsync(boardId.ToString());
|
||||
return Ok($"HDMI transmission for board {boardId} disabled.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"Failed to disable HDMI transmission for board");
|
||||
return StatusCode(500, $"Error disabling HDMI transmission: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置视频流分辨率
|
||||
/// </summary>
|
||||
|
@ -309,16 +203,16 @@ public class VideoStreamController : ControllerBase
|
|||
{
|
||||
try
|
||||
{
|
||||
logger.Info($"设置视频流分辨率为 {request.Width}x{request.Height}");
|
||||
var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
|
||||
|
||||
var (isSuccess, message) = await _videoStreamService.SetResolutionAsync(request.Width, request.Height);
|
||||
var ret = await _videoStreamService.SetResolutionAsync(boardId, request.Width, request.Height);
|
||||
|
||||
if (isSuccess)
|
||||
if (ret.IsSuccessful && ret.Value)
|
||||
{
|
||||
return TypedResults.Ok(new
|
||||
{
|
||||
success = true,
|
||||
message = message,
|
||||
message = $"成功设置分辨率为 {request.Width}x{request.Height}",
|
||||
width = request.Width,
|
||||
height = request.Height,
|
||||
timestamp = DateTime.Now
|
||||
|
@ -329,7 +223,7 @@ public class VideoStreamController : ControllerBase
|
|||
return TypedResults.BadRequest(new
|
||||
{
|
||||
success = false,
|
||||
message = message,
|
||||
message = ret.Error?.ToString() ?? "未知错误",
|
||||
timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
|
@ -341,37 +235,6 @@ public class VideoStreamController : ControllerBase
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前分辨率
|
||||
/// </summary>
|
||||
/// <returns>当前分辨率信息</returns>
|
||||
[HttpGet("Resolution")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||
public IResult GetCurrentResolution()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Info("获取当前视频流分辨率");
|
||||
|
||||
var (width, height) = _videoStreamService.GetCurrentResolution();
|
||||
|
||||
return TypedResults.Ok(new
|
||||
{
|
||||
width = width,
|
||||
height = height,
|
||||
resolution = $"{width}x{height}",
|
||||
timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "获取当前分辨率失败");
|
||||
return TypedResults.InternalServerError($"获取当前分辨率失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取支持的分辨率列表
|
||||
/// </summary>
|
||||
|
@ -382,29 +245,19 @@ public class VideoStreamController : ControllerBase
|
|||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||
public IResult GetSupportedResolutions()
|
||||
{
|
||||
try
|
||||
// (640, 480, "640x480 (VGA)"),
|
||||
// (960, 540, "960x540 (qHD)"),
|
||||
// (1280, 720, "1280x720 (HD)"),
|
||||
// (1280, 960, "1280x960 (SXGA)"),
|
||||
// (1920, 1080, "1920x1080 (Full HD)")
|
||||
return TypedResults.Ok(new AvailableResolutionsResponse[]
|
||||
{
|
||||
logger.Info("获取支持的分辨率列表");
|
||||
|
||||
var resolutions = _videoStreamService.GetSupportedResolutions();
|
||||
|
||||
return TypedResults.Ok(new
|
||||
{
|
||||
resolutions = resolutions.Select(r => new
|
||||
{
|
||||
width = r.Width,
|
||||
height = r.Height,
|
||||
name = r.Name,
|
||||
value = $"{r.Width}x{r.Height}"
|
||||
}),
|
||||
timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "获取支持的分辨率列表失败");
|
||||
return TypedResults.InternalServerError($"获取支持的分辨率列表失败: {ex.Message}");
|
||||
}
|
||||
new AvailableResolutionsResponse { Width = 640, Height = 480, Name = "640x480(VGA)" },
|
||||
new AvailableResolutionsResponse { Width = 960, Height = 480, Name = "960x480(qHD)" },
|
||||
new AvailableResolutionsResponse { Width = 1280, Height = 720, Name = "1280x720(HD)" },
|
||||
new AvailableResolutionsResponse { Width = 1280, Height = 960, Name = "1280x960(SXGA)" },
|
||||
new AvailableResolutionsResponse { Width = 1920, Height = 1080, Name = "1920x1080(Full HD)" }
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -420,9 +273,9 @@ public class VideoStreamController : ControllerBase
|
|||
{
|
||||
try
|
||||
{
|
||||
logger.Info("收到初始化自动对焦请求");
|
||||
var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
|
||||
|
||||
var result = await _videoStreamService.InitAutoFocusAsync();
|
||||
var result = await _videoStreamService.InitAutoFocusAsync(boardId);
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
@ -465,9 +318,9 @@ public class VideoStreamController : ControllerBase
|
|||
{
|
||||
try
|
||||
{
|
||||
logger.Info("收到执行自动对焦请求");
|
||||
var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
|
||||
|
||||
var result = await _videoStreamService.PerformAutoFocusAsync();
|
||||
var result = await _videoStreamService.PerformAutoFocusAsync(boardId);
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
@ -496,61 +349,4 @@ public class VideoStreamController : ControllerBase
|
|||
return TypedResults.InternalServerError($"执行自动对焦失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行一次自动对焦 (GET方式)
|
||||
/// </summary>
|
||||
/// <returns>对焦结果</returns>
|
||||
[HttpGet("Focus")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IResult> Focus()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Info("收到执行一次对焦请求 (GET)");
|
||||
|
||||
// 检查摄像头是否已配置
|
||||
if (!_videoStreamService.IsCameraConfigured())
|
||||
{
|
||||
logger.Warn("摄像头未配置,无法执行对焦");
|
||||
return TypedResults.BadRequest(new
|
||||
{
|
||||
success = false,
|
||||
message = "摄像头未配置,请先配置摄像头连接",
|
||||
timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
|
||||
var result = await _videoStreamService.PerformAutoFocusAsync();
|
||||
|
||||
if (result)
|
||||
{
|
||||
logger.Info("对焦执行成功");
|
||||
return TypedResults.Ok(new
|
||||
{
|
||||
success = true,
|
||||
message = "对焦执行成功",
|
||||
timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Warn("对焦执行失败");
|
||||
return TypedResults.BadRequest(new
|
||||
{
|
||||
success = false,
|
||||
message = "对焦执行失败",
|
||||
timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "执行对焦时发生异常");
|
||||
return TypedResults.InternalServerError($"执行对焦失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System.Net;
|
||||
using DotNext;
|
||||
using Peripherals.PowerClient;
|
||||
using WebProtocol;
|
||||
|
||||
namespace Peripherals.CameraClient;
|
||||
|
@ -16,7 +15,7 @@ static class CameraAddr
|
|||
public const UInt32 CAMERA_POWER = BASE + 0x10; //[0]: rstn, 0 is reset. [8]: power down, 1 is down.
|
||||
}
|
||||
|
||||
class Camera
|
||||
public class Camera
|
||||
{
|
||||
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
|
@ -276,7 +275,7 @@ class Camera
|
|||
{
|
||||
var currentAddress = (UInt16)(baseAddress + i - 1);
|
||||
var data = (byte)cmd[i];
|
||||
|
||||
|
||||
logger.Debug($"ConfigureRegisters: 写入地址=0x{currentAddress:X4}, 数据=0x{data:X2}");
|
||||
|
||||
// 准备I2C数据:16位地址 + 8位数据
|
||||
|
@ -322,14 +321,14 @@ class Camera
|
|||
public async ValueTask<Result<byte>> ReadRegister(UInt16 register)
|
||||
{
|
||||
var i2c = new Peripherals.I2cClient.I2c(this.address, this.port, this.taskID, this.timeout);
|
||||
|
||||
|
||||
// Convert 16-bit register address to byte array
|
||||
var registerBytes = new byte[] { (byte)(register >> 8), (byte)(register & 0xFF) };
|
||||
|
||||
|
||||
var ret = await i2c.ReadData(CAM_I2C_ADDR, registerBytes, 1, CAM_PROTO);
|
||||
if (!ret.IsSuccessful)
|
||||
return new(ret.Error);
|
||||
|
||||
|
||||
return new Result<byte>(ret.Value[0]);
|
||||
}
|
||||
|
||||
|
@ -412,25 +411,25 @@ class Camera
|
|||
[0x3801, unchecked((byte)(hStart & 0xFF))],
|
||||
[0x3802, unchecked((byte)((vStart >> 8) & 0xFF))],
|
||||
[0x3803, unchecked((byte)(vStart & 0xFF))],
|
||||
|
||||
|
||||
// H_END/V_END
|
||||
[0x3804, unchecked((byte)((hEnd >> 8) & 0xFF))],
|
||||
[0x3805, unchecked((byte)(hEnd & 0xFF))],
|
||||
[0x3806, unchecked((byte)((vEnd >> 8) & 0xFF))],
|
||||
[0x3807, unchecked((byte)(vEnd & 0xFF))],
|
||||
|
||||
|
||||
// 输出像素个数
|
||||
[0x3808, unchecked((byte)((dvpHo >> 8) & 0xFF))],
|
||||
[0x3809, unchecked((byte)(dvpHo & 0xFF))],
|
||||
[0x380A, unchecked((byte)((dvpVo >> 8) & 0xFF))],
|
||||
[0x380B, unchecked((byte)(dvpVo & 0xFF))],
|
||||
|
||||
|
||||
// 总像素
|
||||
[0x380C, unchecked((byte)((hts >> 8) & 0xFF))],
|
||||
[0x380D, unchecked((byte)(hts & 0xFF))],
|
||||
[0x380E, unchecked((byte)((vts >> 8) & 0xFF))],
|
||||
[0x380F, unchecked((byte)(vts & 0xFF))],
|
||||
|
||||
|
||||
// H_OFFSET/V_OFFSET
|
||||
[0x3810, unchecked((byte)((hOffset >> 8) & 0xFF))],
|
||||
[0x3811, unchecked((byte)(hOffset & 0xFF))],
|
||||
|
@ -521,7 +520,7 @@ class Camera
|
|||
hOffset: 16, vOffset: 4,
|
||||
hWindow: 2624, vWindow: 1456
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -537,7 +536,7 @@ class Camera
|
|||
hOffset: 16, vOffset: 4,
|
||||
hWindow: 2624, vWindow: 1456
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -637,7 +636,7 @@ class Camera
|
|||
[0x3008, 0x42] // 休眠命令
|
||||
};
|
||||
|
||||
return await ConfigureRegisters(sleepRegisters, customDelayMs: 50);
|
||||
return await ConfigureRegisters(sleepRegisters, customDelayMs: 50);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1305,7 +1304,7 @@ class Camera
|
|||
UInt16 firmwareAddr = 0x8000;
|
||||
var firmwareCommand = new UInt16[1 + OV5640_AF_FIRMWARE.Length];
|
||||
firmwareCommand[0] = firmwareAddr;
|
||||
|
||||
|
||||
// 将固件数据复制到命令数组中
|
||||
for (int i = 0; i < OV5640_AF_FIRMWARE.Length; i++)
|
||||
{
|
||||
|
@ -1425,7 +1424,7 @@ class Camera
|
|||
logger.Error($"自动对焦超时,状态: 0x{readResult.Value:X2}");
|
||||
return new(new Exception($"自动对焦超时,状态: 0x{readResult.Value:X2}"));
|
||||
}
|
||||
|
||||
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class HttpHdmiVideoStreamService : BackgroundService
|
|||
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_httpListener = new HttpListener();
|
||||
_httpListener.Prefixes.Add($"http://*:{_serverPort}/");
|
||||
_httpListener.Prefixes.Add($"http://{Global.localhost}:{_serverPort}/");
|
||||
_httpListener.Start();
|
||||
logger.Info($"HDMI Video Stream Service started on port {_serverPort}");
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,7 +41,7 @@ public class ProgressReporter : ProgressInfo, IProgress<int>
|
|||
private ProgressStatus _status = ProgressStatus.Pending;
|
||||
private string _errorMessage;
|
||||
|
||||
public string TaskId { get; set; } = new Guid().ToString();
|
||||
public string TaskId { get; set; } = Guid.NewGuid().ToString();
|
||||
public int ProgressPercent => _progress * 100 / MaxProgress;
|
||||
public ProgressStatus Status => _status;
|
||||
public string ErrorMessage => _errorMessage;
|
||||
|
|
520
src/APIClient.ts
520
src/APIClient.ts
|
@ -185,12 +185,8 @@ export class VideoStreamClient {
|
|||
return Promise.resolve<any>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 HTTP 视频流信息
|
||||
* @return 流信息
|
||||
*/
|
||||
getStreamInfo( cancelToken?: CancelToken): Promise<StreamInfoResult> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/StreamInfo";
|
||||
myEndpoint( cancelToken?: CancelToken): Promise<any> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/MyEndpoint";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
|
@ -209,208 +205,11 @@ export class VideoStreamClient {
|
|||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processGetStreamInfo(_response);
|
||||
return this.processMyEndpoint(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processGetStreamInfo(response: AxiosResponse): Promise<StreamInfoResult> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
result200 = StreamInfoResult.fromJS(resultData200);
|
||||
return Promise.resolve<StreamInfoResult>(result200);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
let result500: any = null;
|
||||
let resultData500 = _responseText;
|
||||
result500 = Exception.fromJS(resultData500);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result500);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<StreamInfoResult>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置摄像头连接参数
|
||||
* @param config 摄像头配置
|
||||
* @return 配置结果
|
||||
*/
|
||||
configureCamera(config: CameraConfigRequest, cancelToken?: CancelToken): Promise<any> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/ConfigureCamera";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
const content_ = JSON.stringify(config);
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
data: content_,
|
||||
method: "POST",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processConfigureCamera(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processConfigureCamera(response: AxiosResponse): Promise<any> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
result200 = resultData200 !== undefined ? resultData200 : <any>null;
|
||||
|
||||
return Promise.resolve<any>(result200);
|
||||
|
||||
} else if (status === 400) {
|
||||
const _responseText = response.data;
|
||||
let result400: any = null;
|
||||
let resultData400 = _responseText;
|
||||
result400 = resultData400 !== undefined ? resultData400 : <any>null;
|
||||
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
let result500: any = null;
|
||||
let resultData500 = _responseText;
|
||||
result500 = Exception.fromJS(resultData500);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result500);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<any>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前摄像头配置
|
||||
* @return 摄像头配置信息
|
||||
*/
|
||||
getCameraConfig( cancelToken?: CancelToken): Promise<any> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/CameraConfig";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "GET",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processGetCameraConfig(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processGetCameraConfig(response: AxiosResponse): Promise<any> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
result200 = resultData200 !== undefined ? resultData200 : <any>null;
|
||||
|
||||
return Promise.resolve<any>(result200);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
let result500: any = null;
|
||||
let resultData500 = _responseText;
|
||||
result500 = Exception.fromJS(resultData500);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result500);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<any>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制 HTTP 视频流服务开关
|
||||
* @param enabled (optional) 是否启用服务
|
||||
* @return 操作结果
|
||||
*/
|
||||
setEnabled(enabled: boolean | undefined, cancelToken?: CancelToken): Promise<any> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/SetEnabled?";
|
||||
if (enabled === null)
|
||||
throw new Error("The parameter 'enabled' cannot be null.");
|
||||
else if (enabled !== undefined)
|
||||
url_ += "enabled=" + encodeURIComponent("" + enabled) + "&";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "POST",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processSetEnabled(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processSetEnabled(response: AxiosResponse): Promise<any> {
|
||||
protected processMyEndpoint(response: AxiosResponse): Promise<any> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
|
@ -502,6 +301,59 @@ export class VideoStreamClient {
|
|||
return Promise.resolve<boolean>(null as any);
|
||||
}
|
||||
|
||||
disableHdmiTransmission( cancelToken?: CancelToken): Promise<FileResponse | null> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/DisableTransmission";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
responseType: "blob",
|
||||
method: "POST",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/octet-stream"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processDisableHdmiTransmission(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processDisableHdmiTransmission(response: AxiosResponse): Promise<FileResponse | null> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200 || status === 206) {
|
||||
const contentDisposition = response.headers ? response.headers["content-disposition"] : undefined;
|
||||
let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
|
||||
let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
|
||||
if (fileName) {
|
||||
fileName = decodeURIComponent(fileName);
|
||||
} else {
|
||||
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
||||
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
||||
}
|
||||
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<FileResponse | null>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置视频流分辨率
|
||||
* @param request 分辨率配置请求
|
||||
|
@ -576,67 +428,6 @@ export class VideoStreamClient {
|
|||
return Promise.resolve<any>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前分辨率
|
||||
* @return 当前分辨率信息
|
||||
*/
|
||||
getCurrentResolution( cancelToken?: CancelToken): Promise<any> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/Resolution";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "GET",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processGetCurrentResolution(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processGetCurrentResolution(response: AxiosResponse): Promise<any> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
result200 = resultData200 !== undefined ? resultData200 : <any>null;
|
||||
|
||||
return Promise.resolve<any>(result200);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
let result500: any = null;
|
||||
let resultData500 = _responseText;
|
||||
result500 = resultData500 !== undefined ? resultData500 : <any>null;
|
||||
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result500);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<any>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支持的分辨率列表
|
||||
* @return 支持的分辨率列表
|
||||
|
@ -835,75 +626,6 @@ export class VideoStreamClient {
|
|||
}
|
||||
return Promise.resolve<any>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行一次自动对焦 (GET方式)
|
||||
* @return 对焦结果
|
||||
*/
|
||||
focus( cancelToken?: CancelToken): Promise<any> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/Focus";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "GET",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processFocus(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processFocus(response: AxiosResponse): Promise<any> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
result200 = resultData200 !== undefined ? resultData200 : <any>null;
|
||||
|
||||
return Promise.resolve<any>(result200);
|
||||
|
||||
} else if (status === 400) {
|
||||
const _responseText = response.data;
|
||||
let result400: any = null;
|
||||
let resultData400 = _responseText;
|
||||
result400 = resultData400 !== undefined ? resultData400 : <any>null;
|
||||
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
let result500: any = null;
|
||||
let resultData500 = _responseText;
|
||||
result500 = resultData500 !== undefined ? resultData500 : <any>null;
|
||||
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result500);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<any>(null as any);
|
||||
}
|
||||
}
|
||||
|
||||
export class BsdlParserClient {
|
||||
|
@ -7253,134 +6975,6 @@ export interface IException {
|
|||
stackTrace?: string | undefined;
|
||||
}
|
||||
|
||||
/** 视频流信息结构体 */
|
||||
export class StreamInfoResult implements IStreamInfoResult {
|
||||
/** TODO: */
|
||||
frameRate!: number;
|
||||
/** TODO: */
|
||||
frameWidth!: number;
|
||||
/** TODO: */
|
||||
frameHeight!: number;
|
||||
/** TODO: */
|
||||
format!: string;
|
||||
/** TODO: */
|
||||
htmlUrl!: string;
|
||||
/** TODO: */
|
||||
mjpegUrl!: string;
|
||||
/** TODO: */
|
||||
snapshotUrl!: string;
|
||||
/** TODO: */
|
||||
usbCameraUrl!: string;
|
||||
|
||||
constructor(data?: IStreamInfoResult) {
|
||||
if (data) {
|
||||
for (var property in data) {
|
||||
if (data.hasOwnProperty(property))
|
||||
(<any>this)[property] = (<any>data)[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(_data?: any) {
|
||||
if (_data) {
|
||||
this.frameRate = _data["frameRate"];
|
||||
this.frameWidth = _data["frameWidth"];
|
||||
this.frameHeight = _data["frameHeight"];
|
||||
this.format = _data["format"];
|
||||
this.htmlUrl = _data["htmlUrl"];
|
||||
this.mjpegUrl = _data["mjpegUrl"];
|
||||
this.snapshotUrl = _data["snapshotUrl"];
|
||||
this.usbCameraUrl = _data["usbCameraUrl"];
|
||||
}
|
||||
}
|
||||
|
||||
static fromJS(data: any): StreamInfoResult {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
let result = new StreamInfoResult();
|
||||
result.init(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
toJSON(data?: any) {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
data["frameRate"] = this.frameRate;
|
||||
data["frameWidth"] = this.frameWidth;
|
||||
data["frameHeight"] = this.frameHeight;
|
||||
data["format"] = this.format;
|
||||
data["htmlUrl"] = this.htmlUrl;
|
||||
data["mjpegUrl"] = this.mjpegUrl;
|
||||
data["snapshotUrl"] = this.snapshotUrl;
|
||||
data["usbCameraUrl"] = this.usbCameraUrl;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** 视频流信息结构体 */
|
||||
export interface IStreamInfoResult {
|
||||
/** TODO: */
|
||||
frameRate: number;
|
||||
/** TODO: */
|
||||
frameWidth: number;
|
||||
/** TODO: */
|
||||
frameHeight: number;
|
||||
/** TODO: */
|
||||
format: string;
|
||||
/** TODO: */
|
||||
htmlUrl: string;
|
||||
/** TODO: */
|
||||
mjpegUrl: string;
|
||||
/** TODO: */
|
||||
snapshotUrl: string;
|
||||
/** TODO: */
|
||||
usbCameraUrl: string;
|
||||
}
|
||||
|
||||
/** 摄像头配置请求模型 */
|
||||
export class CameraConfigRequest implements ICameraConfigRequest {
|
||||
/** 摄像头地址 */
|
||||
address!: string;
|
||||
/** 摄像头端口 */
|
||||
port!: number;
|
||||
|
||||
constructor(data?: ICameraConfigRequest) {
|
||||
if (data) {
|
||||
for (var property in data) {
|
||||
if (data.hasOwnProperty(property))
|
||||
(<any>this)[property] = (<any>data)[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(_data?: any) {
|
||||
if (_data) {
|
||||
this.address = _data["address"];
|
||||
this.port = _data["port"];
|
||||
}
|
||||
}
|
||||
|
||||
static fromJS(data: any): CameraConfigRequest {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
let result = new CameraConfigRequest();
|
||||
result.init(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
toJSON(data?: any) {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
data["address"] = this.address;
|
||||
data["port"] = this.port;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** 摄像头配置请求模型 */
|
||||
export interface ICameraConfigRequest {
|
||||
/** 摄像头地址 */
|
||||
address: string;
|
||||
/** 摄像头端口 */
|
||||
port: number;
|
||||
}
|
||||
|
||||
/** 分辨率配置请求模型 */
|
||||
export class ResolutionConfigRequest implements IResolutionConfigRequest {
|
||||
/** 宽度 */
|
||||
|
|
10
src/main.ts
10
src/main.ts
|
@ -1,10 +0,0 @@
|
|||
import './assets/main.css'
|
||||
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
|
||||
import App from '@/App.vue'
|
||||
import router from './router'
|
||||
|
||||
const app = createApp(App).use(router).use(createPinia()).mount('#app')
|
||||
|
Loading…
Reference in New Issue