diff --git a/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj b/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj index 4e30956..29101b1 100644 --- a/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj +++ b/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj @@ -7,11 +7,13 @@ Common.Shared.Application - 1.0.1 + 1.0.2 zrh-lx zrh-lx 包含所有公共使用的 DTO、契约、接口模型等,供微服务之间共享使用 shared;dto;contracts;microservices https://v4.weienergy.cn/(可选) + true + $(NoWarn);1591 diff --git a/WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs b/WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs index 502f31c..a0e79fe 100644 --- a/WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs +++ b/WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs @@ -92,7 +92,7 @@ namespace Video.API.Controllers.DaHua /// /// [HttpGet("download/dh")] - public async Task DownloadVideoAsync(PlayDownloadReqDto dto) + public async Task DownloadVideoAsync(PlayDownloadReqDto dto) { var remoteUrl = $"https://{_configuration["DahHost"]}/evo-apigw/evo-httpnode/vod/cam/download.mp4" + @@ -103,28 +103,28 @@ namespace Video.API.Controllers.DaHua $"&videoType={dto.VideoType}" + $"&token={dto.Token}" + $"&recordType={dto.RecordType}"; - - try - { - var handler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (_, _, _, _) => true - }; - - using var http = new HttpClient(handler); - var resp = await http.GetAsync(remoteUrl, HttpCompletionOption.ResponseHeadersRead); - - resp.EnsureSuccessStatusCode(); - - var stream = await resp.Content.ReadAsStreamAsync(); - var contentType = "video/mp4"; - - return File(stream, contentType, "video.mp4"); - } - catch (Exception ex) - { - return StatusCode(500, new { success = false, message = "下载失败", error = ex.Message }); - } + return await Task.FromResult(remoteUrl); + //try + //{ + // var handler = new HttpClientHandler + // { + // ServerCertificateCustomValidationCallback = (_, _, _, _) => true + // }; + + // using var http = new HttpClient(handler); + // var resp = await http.GetAsync(remoteUrl, HttpCompletionOption.ResponseHeadersRead); + + // resp.EnsureSuccessStatusCode(); + + // var stream = await resp.Content.ReadAsStreamAsync(); + // var contentType = "video/mp4"; + + // return File(stream, contentType, "video.mp4"); + //} + //catch (Exception ex) + //{ + // return StatusCode(500, new { success = false, message = "下载失败", error = ex.Message }); + //} } /// @@ -146,7 +146,7 @@ namespace Video.API.Controllers.DaHua /// /// [HttpGet("download")] - public async Task Download(DownloadReqDto dto) + public async Task GetDownUrl(DownloadReqDto dto) { return await _rootVideoPlaybackService.Download(dto); } diff --git a/WeiCloud.Fusion/VideoService/Video.API/appsettings.json b/WeiCloud.Fusion/VideoService/Video.API/appsettings.json index f58cfc9..2485a3e 100644 --- a/WeiCloud.Fusion/VideoService/Video.API/appsettings.json +++ b/WeiCloud.Fusion/VideoService/Video.API/appsettings.json @@ -27,6 +27,10 @@ "DahuaAuth": { "Host": "demo.weienergy.cn:15214", "ClientId": "taiyanggong", + "RealRootHost": "192.168.21.18:9100", //RTSP实时播放的icc地址 + "RealReplaceHost": "demo.weienergy.cn:15210", //rtps试试播放的替换地址 + "TimeRootHost": "192.168.21.18:9320", //RTSP历史回放的icc地址 + "TimeReplaceHost": "demo.weienergy.cn:15211", //rtps历史回放的替换地址 "ClientSecret": "6d6c78f8-3d4c-4e76-ab6b-827942a7b725", diff --git a/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs b/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs index 0e2864a..cfa8167 100644 --- a/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs +++ b/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs @@ -71,7 +71,7 @@ namespace Video.DomainService } var result = JsonSerializer.Deserialize>(body); - if (result == null || !result.Success || result.Code != "0") + if (result == null || !result.Success) { _logger.LogWarning("录像请求业务失败: {Body}", body); return new DaHApiResult { Success = false, Code = "1008", Msg = "录像请求失败" }; @@ -124,7 +124,7 @@ namespace Video.DomainService } var result = JsonSerializer.Deserialize>(body); - if (result == null || !result.Success || result.Code != "0") + if (result == null || !result.Success) { _logger.LogWarning("查询录像信息业务失败: {Body}", body); return new DaHApiResult { Success = false, Code = "1008", Msg = "查询录像信息失败" }; @@ -177,7 +177,7 @@ namespace Video.DomainService } var result = JsonSerializer.Deserialize>(body); - if (result == null || !result.Success || result.Code != "0") + if (result == null || !result.Success) { _logger.LogWarning("通道分页查询业务失败: {Body}", body); return new DaHApiResult { Success = false, Code = "1007", Msg = $"通道分页查询失败" }; @@ -232,7 +232,7 @@ namespace Video.DomainService } var result = JsonSerializer.Deserialize>(body); - if (result == null || !result.Success || result.Code != "0") + if (result == null || !result.Success) { _logger.LogWarning("实时流请求业务失败: {Body}", body); return new DaHApiResult { Success = false, Code = "1010", Msg = "实时流请求失败" }; @@ -300,6 +300,7 @@ namespace Video.DomainService /// /// rtsp录像回放 + /// (播放命令:ffplay -rtsp_transport tcp -i "rtsp://demo.weienergy.cn:15211/playback/pu/3?token=3")强制走tcp /// /// /// @@ -337,12 +338,12 @@ namespace Video.DomainService } var result = JsonSerializer.Deserialize>(body); - if (result == null || !result.Success || result.Code != "0") + if (result == null || !result.Success) { _logger.LogWarning("录像请求业务失败: {Body}", body); return new DaHApiResult { Success = false, Code = "1008", Msg = "录像请求失败" }; } - result.Data!.Url = result.Data.Url + "?token=" + token; + result.Data!.Url = result.Data.Url.Replace(_configuration["DahuaAuth:TimeRootHost"], _configuration["DahuaAuth:TimeReplaceHost"]) + "?token=" + result.Data.Token; return result; } catch (Exception ex) @@ -395,7 +396,7 @@ namespace Video.DomainService _logger.LogWarning("实时流请求业务失败: {Body}", body); return new DaHApiResult { Success = false, Code = "1010", Msg = "实时流请求失败" }; } - result.Data!.Url = result.Data.Url + "?token=" + result.Data!.Token; + result.Data!.Url = result.Data.Url.Replace(_configuration["DahuaAuth:RealRootHost"], _configuration["DahuaAuth:RealReplaceHost"]) + "?token=" + result.Data!.Token; return result; } catch (Exception ex) diff --git a/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/RootVideoPlaybackService.cs b/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/RootVideoPlaybackService.cs index ea68a37..b9fd7a8 100644 --- a/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/RootVideoPlaybackService.cs +++ b/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/RootVideoPlaybackService.cs @@ -5,6 +5,9 @@ using WeiCloud.Core.BaseModels; namespace Video.DomainService { + /// + /// todo:这块后续要做一个动态适配,只要修改配置文件就可以自由选择对接的厂商 + /// public class RootVideoPlayBackService : IRootVideoPlaybackService { private readonly ILogger _logger;