feat: 支持HDMI关闭传输
This commit is contained in:
@@ -60,4 +60,38 @@ public class HdmiVideoStreamController : ControllerBase
|
||||
var endpoint = _videoStreamService.GetVideoEndpoint(boardId.ToString());
|
||||
return Ok(endpoint);
|
||||
}
|
||||
|
||||
// 禁用指定板子的 HDMI 传输
|
||||
[HttpPost("DisableHdmiTransmission")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> DisableHdmiTransmission()
|
||||
{
|
||||
var userName = User.FindFirstValue(ClaimTypes.Name);
|
||||
if (string.IsNullOrEmpty(userName))
|
||||
return Unauthorized("User name not found in claims.");
|
||||
|
||||
var db = new AppDataConnection();
|
||||
if (db == null)
|
||||
return NotFound("Database connection failed.");
|
||||
|
||||
var userRet = db.GetUserByName(userName);
|
||||
if (!userRet.IsSuccessful || !userRet.Value.HasValue)
|
||||
return NotFound("User not found.");
|
||||
|
||||
var user = userRet.Value.Value;
|
||||
var boardId = user.BoardID;
|
||||
if (boardId == Guid.Empty)
|
||||
return NotFound("No board bound to this user.");
|
||||
|
||||
try
|
||||
{
|
||||
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 {boardId}");
|
||||
return StatusCode(500, $"Error disabling HDMI transmission: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user