完善部分

pull/10/head
刘鑫 3 months ago
parent 07447b2115
commit 3a2c90460f
  1. 4
      WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj
  2. 48
      WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs
  3. 4
      WeiCloud.Fusion/VideoService/Video.API/appsettings.json
  4. 15
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs
  5. 3
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/RootVideoPlaybackService.cs

@ -7,11 +7,13 @@
</PropertyGroup>
<PropertyGroup>
<PackageId>Common.Shared.Application</PackageId>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<Authors>zrh-lx</Authors>
<Company>zrh-lx</Company> <!-- 可选 -->
<Description>包含所有公共使用的 DTO、契约、接口模型等,供微服务之间共享使用</Description>
<PackageTags>shared;dto;contracts;microservices</PackageTags> <!-- 可选但推荐 -->
<RepositoryUrl>https://v4.weienergy.cn/(可选)</RepositoryUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn> <!-- 可选:忽略未注释警告 -->
</PropertyGroup>
</Project>

@ -92,7 +92,7 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param>
/// <returns></returns>
[HttpGet("download/dh")]
public async Task<IActionResult> DownloadVideoAsync(PlayDownloadReqDto dto)
public async Task<string> 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 });
//}
}
/// <summary>
@ -146,7 +146,7 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param>
/// <returns></returns>
[HttpGet("download")]
public async Task<string> Download(DownloadReqDto dto)
public async Task<string> GetDownUrl(DownloadReqDto dto)
{
return await _rootVideoPlaybackService.Download(dto);
}

@ -27,6 +27,10 @@
"DahuaAuth": {
"Host": "demo.weienergy.cn:15214",
"ClientId": "taiyanggong",
"RealRootHost": "192.168.21.18:9100", //RTSPicc
"RealReplaceHost": "demo.weienergy.cn:15210", //rtps
"TimeRootHost": "192.168.21.18:9320", //RTSPicc
"TimeReplaceHost": "demo.weienergy.cn:15211", //rtps
"ClientSecret": "6d6c78f8-3d4c-4e76-ab6b-827942a7b725",

@ -71,7 +71,7 @@ namespace Video.DomainService
}
var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body);
if (result == null || !result.Success || result.Code != "0")
if (result == null || !result.Success)
{
_logger.LogWarning("录像请求业务失败: {Body}", body);
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" };
@ -124,7 +124,7 @@ namespace Video.DomainService
}
var result = JsonSerializer.Deserialize<DaHApiResult<RecordsResDto>>(body);
if (result == null || !result.Success || result.Code != "0")
if (result == null || !result.Success)
{
_logger.LogWarning("查询录像信息业务失败: {Body}", body);
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1008", Msg = "查询录像信息失败" };
@ -177,7 +177,7 @@ namespace Video.DomainService
}
var result = JsonSerializer.Deserialize<DaHApiResult<PageInfoDto>>(body);
if (result == null || !result.Success || result.Code != "0")
if (result == null || !result.Success)
{
_logger.LogWarning("通道分页查询业务失败: {Body}", body);
return new DaHApiResult<PageInfoDto> { Success = false, Code = "1007", Msg = $"通道分页查询失败" };
@ -232,7 +232,7 @@ namespace Video.DomainService
}
var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body);
if (result == null || !result.Success || result.Code != "0")
if (result == null || !result.Success)
{
_logger.LogWarning("实时流请求业务失败: {Body}", body);
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1010", Msg = "实时流请求失败" };
@ -300,6 +300,7 @@ namespace Video.DomainService
/// <summary>
/// rtsp录像回放
/// (播放命令:ffplay -rtsp_transport tcp -i "rtsp://demo.weienergy.cn:15211/playback/pu/3?token=3")强制走tcp
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
@ -337,12 +338,12 @@ namespace Video.DomainService
}
var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body);
if (result == null || !result.Success || result.Code != "0")
if (result == null || !result.Success)
{
_logger.LogWarning("录像请求业务失败: {Body}", body);
return new DaHApiResult<UrlDataDto> { 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<UrlDataDto> { 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)

@ -5,6 +5,9 @@ using WeiCloud.Core.BaseModels;
namespace Video.DomainService
{
/// <summary>
/// todo:这块后续要做一个动态适配,只要修改配置文件就可以自由选择对接的厂商
/// </summary>
public class RootVideoPlayBackService : IRootVideoPlaybackService
{
private readonly ILogger<RootVideoPlayBackService> _logger;

Loading…
Cancel
Save