From 6e4667475bf2117c11c801c543e7b69465abe201 Mon Sep 17 00:00:00 2001 From: lgd Date: Fri, 13 Jun 2025 09:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E7=9B=B8=E5=85=B3=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirportMaintenanceController.cs | 269 ++++++++++++++++++ 1 file changed, 269 insertions(+) diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs index 06bd4fc..58005e0 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs @@ -71,5 +71,274 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers return result; } + + /// + /// 切换相机 + /// + /// + [HttpPost] + public async Task> ExchangeCamera(string camera,int position,string videoId) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_camera_change", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + camera_position = position, + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply"; + var requestData1 = new + { + bid = Guid.NewGuid().ToString(), + method = "live_camera_change", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + result = 0 + } + }; + string payload1 = JsonSerializer.Serialize(requestData1); + await _mqttClientManager.PublishAsync(topicRequest1, payload1); + + response.Result = 1; + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; ; + + } + + + + /// + /// 设置直播镜头 + /// + /// + [HttpPost] + public async Task> SetCamera(string cameraType, string videoId) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_lens_change", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + video_type = cameraType, + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply"; + var requestData1 = new + { + bid = Guid.NewGuid().ToString(), + method = "live_lens_change", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + result = 0 + } + }; + string payload1 = JsonSerializer.Serialize(requestData1); + await _mqttClientManager.PublishAsync(topicRequest1, payload1); + + response.Result = 1; + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; + + } + + + /// + /// 设置直播清晰度 + /// + /// + [HttpPost] + public async Task> SetCameraVideo(int videoQuality, string videoId) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_set_quality", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + video_quality = videoQuality, + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply"; + var requestData1 = new + { + bid = Guid.NewGuid().ToString(), + method = "live_set_quality", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + result = 0 + } + }; + string payload1 = JsonSerializer.Serialize(requestData1); + await _mqttClientManager.PublishAsync(topicRequest1, payload1); + + response.Result = 1; + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; + + } + + + /// + /// 停止直播 + /// + /// + [HttpPost] + public async Task> EndLive( string videoId) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_stop_push", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply"; + var requestData1 = new + { + bid = Guid.NewGuid().ToString(), + method = "live_start_push", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + result = 0 + } + }; + string payload1 = JsonSerializer.Serialize(requestData1); + await _mqttClientManager.PublishAsync(topicRequest1, payload1); + + response.Result = 1; + + + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; + + } + + + + /// + /// 开始直播 + /// + /// + [HttpPost] + public async Task> StartLive(string videoId,int urlType,string url,int quality) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_start_push", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + url_type = urlType, + url = url, + video_quality = quality, + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + + + response.Result = 1; + + + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; + + } } }