|
|
|
|
@ -38,7 +38,7 @@ namespace Video.DomainService |
|
|
|
|
/// <param name="dto"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
/// <exception cref="NotImplementedException"></exception> |
|
|
|
|
public async Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto) |
|
|
|
|
public async Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto, string? ipaddress) |
|
|
|
|
{ |
|
|
|
|
// 1) 参数校验 + 早退 |
|
|
|
|
if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId)) |
|
|
|
|
@ -57,15 +57,15 @@ namespace Video.DomainService |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
} |
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/video/stream/record"; |
|
|
|
|
if (dto.IpAddress != null) |
|
|
|
|
if (ipaddress != null) |
|
|
|
|
{ |
|
|
|
|
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/video/stream/record"; |
|
|
|
|
url = $"https://{ipaddress}/evo-apigw/admin/API/video/stream/record"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 3) 构造请求(把 dto 放进 Body),并用 SendAsync 发送,才能带上头 |
|
|
|
|
using var req = new HttpRequestMessage(HttpMethod.Post, url) |
|
|
|
|
{ |
|
|
|
|
Content = JsonContent.Create(dto) // 关键:别再丢 body 了 |
|
|
|
|
Content = JsonContent.Create(dto.Data) // 关键:别再丢 body 了 |
|
|
|
|
}; |
|
|
|
|
req.Headers.TryAddWithoutValidation("Authorization", token); |
|
|
|
|
|
|
|
|
|
@ -86,7 +86,7 @@ namespace Video.DomainService |
|
|
|
|
} |
|
|
|
|
result.Data!.Url = UrlHostReplacer.ReplaceHost( |
|
|
|
|
result.Data.Url, |
|
|
|
|
dto.IpAddress, |
|
|
|
|
ipaddress, |
|
|
|
|
_configuration, |
|
|
|
|
"Time" |
|
|
|
|
) + "?token=" + result.Data.Token; |
|
|
|
|
@ -122,13 +122,10 @@ namespace Video.DomainService |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
} |
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Record/QueryRecords"; |
|
|
|
|
if (dto.IpAddress != null) |
|
|
|
|
{ |
|
|
|
|
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/SS/Record/QueryRecords"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using var req = new HttpRequestMessage(HttpMethod.Post, url) |
|
|
|
|
{ |
|
|
|
|
Content = JsonContent.Create(dto) // 关键:把 dto 放进请求体 |
|
|
|
|
Content = JsonContent.Create(dto.Data) // 关键:把 dto 放进请求体 |
|
|
|
|
}; |
|
|
|
|
req.Headers.TryAddWithoutValidation("Authorization", token); |
|
|
|
|
|
|
|
|
|
@ -223,7 +220,7 @@ namespace Video.DomainService |
|
|
|
|
/// <param name="dto"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
/// <exception cref="NotImplementedException"></exception> |
|
|
|
|
public async Task<DaHApiResult<UrlDataDto>> RealtimeStreamUrl(StreamReqDto dto) |
|
|
|
|
public async Task<DaHApiResult<UrlDataDto>> RealtimeStreamUrl(StreamReqDto dto, string? ipaddress) |
|
|
|
|
{ |
|
|
|
|
// 1) 参数校验 + 早退 |
|
|
|
|
if (dto == null || dto.Data == null) |
|
|
|
|
@ -245,15 +242,15 @@ namespace Video.DomainService |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/video/stream/realtime"; |
|
|
|
|
|
|
|
|
|
if (dto.IpAddress != null) |
|
|
|
|
if (ipaddress != null) |
|
|
|
|
{ |
|
|
|
|
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/video/stream/realtime"; |
|
|
|
|
url = $"https://{ipaddress}/evo-apigw/admin/API/video/stream/realtime"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 3) 用 HttpRequestMessage 发送,才能带上自定义头 |
|
|
|
|
using var req = new HttpRequestMessage(HttpMethod.Post, url) |
|
|
|
|
{ |
|
|
|
|
Content = JsonContent.Create(dto) // 等价 PostAsJsonAsync,但不会丢头 |
|
|
|
|
Content = JsonContent.Create(dto.Data) // 等价 PostAsJsonAsync,但不会丢头 |
|
|
|
|
}; |
|
|
|
|
req.Headers.TryAddWithoutValidation("Authorization", token); |
|
|
|
|
|
|
|
|
|
@ -274,7 +271,7 @@ namespace Video.DomainService |
|
|
|
|
} |
|
|
|
|
result.Data!.Url = UrlHostReplacer.ReplaceHost( |
|
|
|
|
result.Data.Url, |
|
|
|
|
dto.IpAddress, |
|
|
|
|
ipaddress, |
|
|
|
|
_configuration, |
|
|
|
|
"Real" |
|
|
|
|
) + "?token=" + result.Data.Token; |
|
|
|
|
@ -345,7 +342,7 @@ namespace Video.DomainService |
|
|
|
|
/// <param name="dto"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
/// <exception cref="NotImplementedException"></exception> |
|
|
|
|
public async Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto) |
|
|
|
|
public async Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto, string? ipaddress) |
|
|
|
|
{ |
|
|
|
|
// 参数校验 + 早退 |
|
|
|
|
if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId)) |
|
|
|
|
@ -364,14 +361,14 @@ namespace Video.DomainService |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"; |
|
|
|
|
if (dto.IpAddress != null) |
|
|
|
|
if (ipaddress != null) |
|
|
|
|
{ |
|
|
|
|
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"; |
|
|
|
|
url = $"https://{ipaddress}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using var req = new HttpRequestMessage(HttpMethod.Post, url) |
|
|
|
|
{ |
|
|
|
|
Content = JsonContent.Create(dto) // 关键:把 dto 放进请求体 |
|
|
|
|
Content = JsonContent.Create(dto.Data) // 关键:把 dto 放进请求体 |
|
|
|
|
}; |
|
|
|
|
req.Headers.TryAddWithoutValidation("Authorization", token); |
|
|
|
|
|
|
|
|
|
@ -394,7 +391,7 @@ namespace Video.DomainService |
|
|
|
|
} |
|
|
|
|
result.Data!.Url = UrlHostReplacer.ReplaceHost( |
|
|
|
|
result.Data.Url, |
|
|
|
|
dto.IpAddress, |
|
|
|
|
ipaddress, |
|
|
|
|
_configuration, |
|
|
|
|
"Time" |
|
|
|
|
) + "?token=" + result.Data.Token; |
|
|
|
|
@ -414,7 +411,7 @@ namespace Video.DomainService |
|
|
|
|
/// <param name="dto"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
/// <exception cref="NotImplementedException"></exception> |
|
|
|
|
public async Task<DaHApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto) |
|
|
|
|
public async Task<DaHApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto, string? ipaddress) |
|
|
|
|
{ |
|
|
|
|
if (dto == null || dto.Data == null) |
|
|
|
|
{ |
|
|
|
|
@ -431,9 +428,9 @@ namespace Video.DomainService |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/MTS/Video/StartVideo"; |
|
|
|
|
if (dto.IpAddress != null) |
|
|
|
|
if (ipaddress != null) |
|
|
|
|
{ |
|
|
|
|
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/MTS/Video/StartVideo"; |
|
|
|
|
url = $"https://{ipaddress}/evo-apigw/admin/API/MTS/Video/StartVideo"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using var req = new HttpRequestMessage(HttpMethod.Post, url) |
|
|
|
|
@ -461,7 +458,7 @@ namespace Video.DomainService |
|
|
|
|
} |
|
|
|
|
result.Data!.Url = UrlHostReplacer.ReplaceHost( |
|
|
|
|
result.Data.Url, |
|
|
|
|
dto.IpAddress, |
|
|
|
|
ipaddress, |
|
|
|
|
_configuration, |
|
|
|
|
"Real" |
|
|
|
|
) + "?token=" + result.Data.Token; |
|
|
|
|
|