|
|
|
@ -122,20 +122,19 @@ namespace IoT.Shared.DeviceServices.Onvif
|
|
|
|
|
InfoId = deviceInfo.Id,
|
|
|
|
|
NodeId = node.Id
|
|
|
|
|
};
|
|
|
|
|
var fileName = $"ffmpeg-{Helper.Instance.GetRunTime()}{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "")}";
|
|
|
|
|
var file = Path.Combine(this._env.WebRootPath, fileName);
|
|
|
|
|
device.AddorUpdateData("ffmpeg.file", file, DeviceDataType.String, "ffmpeg路径", hidden: true);
|
|
|
|
|
device.AddorUpdateData("ffmpeg.args", this._configuration["ffmpeg.args"], DeviceDataType.String, "ffmpeg.args", hidden: true);
|
|
|
|
|
device.AddorUpdateData("mainrtmp", $"rtmp://{this._configuration["stream.rtmp"]}/live/main{ipCamera.Id}", DeviceDataType.String, "主码流rtmp");
|
|
|
|
|
device.AddorUpdateData("mainflv", $"http://{this._configuration["stream.flv"]}/live/main{ipCamera.Id}.flv", DeviceDataType.String, "主码流flv");
|
|
|
|
|
device.AddorUpdateData("mainhls", $"http://{this._configuration["stream.hls"]}/live/main{ipCamera.Id}.m3u8", DeviceDataType.String, "主码流hls");
|
|
|
|
|
device.AddorUpdateData("subrtmp", $"rtmp://{this._configuration["stream.rtmp"]}/live/sub{ipCamera.Id}", DeviceDataType.String, "子码流rtmp");
|
|
|
|
|
device.AddorUpdateData("subflv", $"http://{this._configuration["stream.flv"]}/live/sub{ipCamera.Id}.flv", DeviceDataType.String, "子码流flv");
|
|
|
|
|
device.AddorUpdateData("subhls", $"http://{this._configuration["stream.hls"]}/live/sub{ipCamera.Id}.m3u8", DeviceDataType.String, "子码流hls");
|
|
|
|
|
device.AddorUpdateData("ffmpeg.file", this._configuration["ffmpeg.file"], DeviceDataType.String, "ffmpeg.file", hidden: true);
|
|
|
|
|
device.AddorUpdateData("ffmpeg.args", this._configuration["ffmpeg.args"], DeviceDataType.String, "ffmpeg.args", hidden: true);
|
|
|
|
|
device.AddorUpdateData("CustomFile", "", DeviceDataType.String, "自定义ffmpeg路径", hidden: true);
|
|
|
|
|
device.ConnectId = this._configuration["connectId"];
|
|
|
|
|
device.NodeNumber = this._configuration["node.number"];
|
|
|
|
|
deviceRepo.Add(device);
|
|
|
|
|
deviceRepo.SaveChanges();
|
|
|
|
|
this.SendDevice(device);
|
|
|
|
|
}
|
|
|
|
|
var profiles = this._onvifDeviceManagement.GetProfiles(ipCamera.DeviceUrl, ipCamera.MediaUrl);
|
|
|
|
|
var needAuth = false;
|
|
|
|
@ -189,8 +188,8 @@ namespace IoT.Shared.DeviceServices.Onvif
|
|
|
|
|
device.AddorUpdateData("MainSnapshotUri", ipCamera.MainSnapshotUri, DeviceDataType.String, "主码流截图地址");
|
|
|
|
|
device.AddorUpdateData("SubStreamUri", ipCamera.SubStreamUri, DeviceDataType.String, "子码流地址");
|
|
|
|
|
device.AddorUpdateData("SubSnapshotUri", ipCamera.SubSnapshotUri, DeviceDataType.String, "子码流截图地址");
|
|
|
|
|
var jpgBytes = SubScreenShot(device.Number);
|
|
|
|
|
using (var stream = new MemoryStream(SubScreenShot(device.Number)))
|
|
|
|
|
var jpgBytes = ScreenShot(device);
|
|
|
|
|
using (var stream = new MemoryStream(jpgBytes))
|
|
|
|
|
{
|
|
|
|
|
using (var bigImage = Image.FromStream(stream))
|
|
|
|
|
{
|
|
|
|
@ -304,14 +303,9 @@ namespace IoT.Shared.DeviceServices.Onvif
|
|
|
|
|
var subStreamUri = camera.Data.FirstOrDefault(o => o.Key == "SubStreamUri").Value;
|
|
|
|
|
var subRtspUrl = $"rtsp://{(needAuth ? $"{camera.UserName}:{camera.Password}@" : "")}{subStreamUri.Substring(7)}";
|
|
|
|
|
var fileName = $"ffmpeg-{Helper.Instance.GetRunTime()}{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "")}";
|
|
|
|
|
var file = Path.Combine(this._env.WebRootPath, fileName);
|
|
|
|
|
var file = camera.GetData("ffmpeg.file")?.Value;
|
|
|
|
|
var mainRtmp = camera.Data.FirstOrDefault(o => o.Key == "mainrtmp").Value;
|
|
|
|
|
var subRtmp = camera.Data.FirstOrDefault(o => o.Key == "subrtmp").Value;
|
|
|
|
|
var customFile = camera.GetData("CustomFile")?.Value;
|
|
|
|
|
if (!string.IsNullOrEmpty(customFile))
|
|
|
|
|
{
|
|
|
|
|
file = customFile;
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine(file);
|
|
|
|
|
var arguments = camera.Data.FirstOrDefault(o => o.Key == "ffmpeg.args").Value;
|
|
|
|
|
Process main = null, sub = null;
|
|
|
|
@ -544,6 +538,21 @@ namespace IoT.Shared.DeviceServices.Onvif
|
|
|
|
|
return hc.GetByteDigest(url, camera.UserName, camera.Password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private byte[] ScreenShot(Device camera)
|
|
|
|
|
{
|
|
|
|
|
var url = camera.GetDataValue("SubSnapshotUri");
|
|
|
|
|
if (string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
return new byte[] { };
|
|
|
|
|
}
|
|
|
|
|
var hc = this._httpClientFactory.CreateClient();
|
|
|
|
|
if (camera.GetDataValue("NeedAuth") == "否")
|
|
|
|
|
{
|
|
|
|
|
return hc.GetByteArrayAsync(url).Result;
|
|
|
|
|
}
|
|
|
|
|
return hc.GetByteDigest(url, camera.UserName, camera.Password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Device GetCamera(string number)
|
|
|
|
|
{
|
|
|
|
|
using (var scope = _applicationServices.CreateScope())
|
|
|
|
|