You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
6.4 KiB
174 lines
6.4 KiB
using Common.Shared.Application.DaHua; |
|
using Microsoft.Extensions.Configuration; |
|
using Microsoft.Extensions.Logging; |
|
using WeiCloud.Core.BaseModels; |
|
|
|
namespace Video.DomainService |
|
{ |
|
/// <summary> |
|
/// todo:这块后续要做一个动态适配,只要修改配置文件就可以自由选择对接的厂商 |
|
/// </summary> |
|
public class RootVideoPlayBackService : IRootVideoPlaybackService |
|
{ |
|
private readonly ILogger<RootVideoPlayBackService> _logger; |
|
private readonly IConfiguration _cfg; |
|
|
|
private readonly IDahuaGeneralCtlService _dahuaGeneralCtlService; |
|
|
|
/// <summary> |
|
/// 构造函数 |
|
/// </summary> |
|
/// <param name="logger"></param> |
|
public RootVideoPlayBackService(ILogger<RootVideoPlayBackService> logger, IConfiguration configuration, IDahuaGeneralCtlService dahuaGeneralCtlService) |
|
{ |
|
_logger = logger; |
|
_cfg = configuration; |
|
|
|
_dahuaGeneralCtlService = dahuaGeneralCtlService; |
|
} |
|
|
|
#region 大华视频处理 |
|
|
|
/// <summary> |
|
/// 大华回放接口 |
|
/// </summary> |
|
/// <param name="dto"></param> |
|
/// <returns></returns> |
|
/// <exception cref="NotImplementedException"></exception> |
|
public async Task<ApiResult<UrlDataDto>> GetDaHRecordVideoUrl(PlaybackReqDto dto, string? ipaddress) |
|
{ |
|
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; |
|
|
|
var urlReult = await _dahuaGeneralCtlService.RecordVideoUrl(dto, ipaddress); |
|
if (!urlReult.Success) |
|
{ |
|
result.Code = 500; |
|
result.Msg = urlReult.Msg; |
|
_logger.LogWarning("大华录像回放接口调用失败:{Msg}", urlReult.Msg); |
|
} |
|
|
|
result.Data = urlReult.Data; |
|
|
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 大华实时 |
|
/// </summary> |
|
/// <param name="dto"></param> |
|
/// <returns></returns> |
|
/// <exception cref="NotImplementedException"></exception> |
|
public async Task<ApiResult<UrlDataDto>> GetRealtimeUrl(StreamReqDto dto, string? ipaddress) |
|
{ |
|
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; |
|
var urlReult = await _dahuaGeneralCtlService.RealtimeStreamUrl(dto, ipaddress); |
|
if (!urlReult.Success) |
|
{ |
|
result.Code = 500; |
|
result.Msg = urlReult.Msg; |
|
_logger.LogWarning("大华实时视频接口调用失败:{Msg}", urlReult.Msg); |
|
} |
|
result.Data = urlReult.Data; |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 大华设备通道分页查询 |
|
/// </summary> |
|
/// <param name="dto"></param> |
|
/// <returns></returns> |
|
public async Task<ApiResult<PageInfoDto>> GetChannelCodes(ChannelPageReqDto dto) |
|
{ |
|
ApiResult<PageInfoDto> result = new ApiResult<PageInfoDto>() { Code = 200, Msg = "接口调用成功" }; |
|
var pageResult = await _dahuaGeneralCtlService.GetChannelPageList(dto); |
|
if (!pageResult.Success) |
|
{ |
|
result.Code = 500; |
|
result.Msg = pageResult.Msg; |
|
_logger.LogWarning("大华设备通道分页查询接口调用失败:{Msg}", pageResult.Msg); |
|
} |
|
result.Data = pageResult.Data; |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 大华登出 |
|
/// </summary> |
|
/// <param name="authorization"></param> |
|
/// <param name="openId"></param> |
|
/// <param name="userClient"></param> |
|
/// <returns></returns> |
|
/// <exception cref="NotImplementedException"></exception> |
|
public async Task<ApiResult<object>> Logout(string authorization, string? openId, int? userClient) |
|
{ |
|
var result = new ApiResult<object>(); |
|
var logoutResult = await _dahuaGeneralCtlService.Logout(authorization, openId, userClient); |
|
if (!logoutResult.Success) |
|
{ |
|
result.Code = 500; |
|
result.Msg = logoutResult.Msg; |
|
_logger.LogWarning("大华登出接口调用失败:{Msg}", logoutResult.Msg); |
|
} |
|
else |
|
{ |
|
result.Code = 200; |
|
result.Msg = "登出成功"; |
|
} |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// rtsp实时预览接口方式 |
|
/// </summary> |
|
/// <param name="dto"></param> |
|
/// <returns></returns> |
|
/// <exception cref="NotImplementedException"></exception> |
|
public async Task<ApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto, string? ipaddress) |
|
{ |
|
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; |
|
var urlReult = await _dahuaGeneralCtlService.RtspStartVideoUrl(dto, ipaddress); |
|
if (!urlReult.Success) |
|
{ |
|
result.Code = 500; |
|
result.Msg = urlReult.Msg; |
|
_logger.LogWarning("大华实时视频接口调用失败:{Msg}", urlReult.Msg); |
|
} |
|
result.Data = urlReult.Data; |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// rtsp录像回放 |
|
/// </summary> |
|
/// <param name="dto"></param> |
|
/// <returns></returns> |
|
public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto, string? ipaddress) |
|
{ |
|
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; |
|
|
|
var urlReult = await _dahuaGeneralCtlService.RtspPlaybackByTime(dto, ipaddress); |
|
if (!urlReult.Success) |
|
{ |
|
result.Code = 500; |
|
result.Msg = urlReult.Msg; |
|
_logger.LogWarning("大华录像回放接口调用失败:{Msg}", urlReult.Msg); |
|
} |
|
|
|
result.Data = urlReult.Data; |
|
|
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 返回下载地址 |
|
/// </summary> |
|
/// <param name="dto"></param> |
|
/// <returns></returns> |
|
public async Task<string> Download(DownloadReqDto dto) |
|
{ |
|
return await _dahuaGeneralCtlService.Download(dto); |
|
} |
|
|
|
#endregion 大华视频处理 |
|
} |
|
} |