|
|
|
@ -150,7 +150,7 @@ namespace IoTNode.DeviceServices.Onvif
|
|
|
|
|
}
|
|
|
|
|
deviceRepo.SaveChanges();
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.DeviceUrl, ipCamera.DeviceUrl);
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.DeviceUrl, ipCamera.DeviceUrl);
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.MediaUrl, ipCamera.MediaUrl);
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.PtzAddress, ipCamera.PTZAddress);
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.Ptz3DZoomSupport, ipCamera.Ptz3DZoomSupport ? "1" : "0");
|
|
|
|
|
|
|
|
|
@ -190,19 +190,12 @@ namespace IoTNode.DeviceServices.Onvif
|
|
|
|
|
{
|
|
|
|
|
if (ipCamera.Profiles.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var tokens = ipCamera.Profiles.Select(o => $"{o.Token}:{o.Width}x{o.Height}").ToList();
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.Profiles, string.Join(',', tokens));
|
|
|
|
|
var tokens = ipCamera.Profiles.ToJson();
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.Profiles, tokens);
|
|
|
|
|
var token = this.GetIoTDataValue(device.Id, DataKeys.ProfileToken);
|
|
|
|
|
if (string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
token = ipCamera.Profiles.First().Token;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (string.IsNullOrEmpty(token)|| !ipCamera.Profiles.Any(o => o.Token == token))
|
|
|
|
|
{
|
|
|
|
|
if (!ipCamera.Profiles.Any(o => o.Token == token))
|
|
|
|
|
{
|
|
|
|
|
token = ipCamera.Profiles.First().Token;
|
|
|
|
|
}
|
|
|
|
|
token = (ipCamera.Profiles.FirstOrDefault(o=>o.Width==1280)??ipCamera.Profiles.First()).Token;
|
|
|
|
|
}
|
|
|
|
|
if (needAuth)
|
|
|
|
|
{
|
|
|
|
@ -524,6 +517,43 @@ namespace IoTNode.DeviceServices.Onvif
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ChangeToken(string id,string token)
|
|
|
|
|
{
|
|
|
|
|
var device = this.GetIoTDevice(id);
|
|
|
|
|
if (device != null)
|
|
|
|
|
{
|
|
|
|
|
using var scope = _applicationServices.CreateScope();
|
|
|
|
|
var repo = scope.ServiceProvider.GetRequiredService<IRepository<IoTData>>();
|
|
|
|
|
var profiles = this.GetIoTDataValue(device.Id,DataKeys.Profiles);
|
|
|
|
|
if (!string.IsNullOrEmpty(profiles))
|
|
|
|
|
{
|
|
|
|
|
var tokens = profiles.FromJson<List<Profile>>();
|
|
|
|
|
if(tokens.Any(o=>o.Token==token))
|
|
|
|
|
{
|
|
|
|
|
var currentToken = this.GetIoTDataValue(device.Id, DataKeys.ProfileToken);
|
|
|
|
|
if (!string.IsNullOrEmpty(currentToken) && currentToken != token)
|
|
|
|
|
{
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.ProfileToken, token);
|
|
|
|
|
var deviceUrl = this.GetIoTDataValue(device.Id, DataKeys.DeviceUrl);
|
|
|
|
|
var mediaUrl = this.GetIoTDataValue(device.Id, DataKeys.MediaUrl);
|
|
|
|
|
if (!string.IsNullOrEmpty(deviceUrl) && !string.IsNullOrEmpty(mediaUrl))
|
|
|
|
|
{
|
|
|
|
|
var streamUriXml = this._onvifDeviceManagement.GetStreamUri(deviceUrl, mediaUrl, device.UserName, device.Password, token);
|
|
|
|
|
var snapshotUri = this._onvifDeviceManagement.GetSnapshotUri(deviceUrl, mediaUrl, device.UserName, device.Password, token);
|
|
|
|
|
var ipCamera = new IPCamera { StreamUriXml = streamUriXml, SnapshotUriXml = snapshotUri };
|
|
|
|
|
ipCamera.ParseStreamUri();
|
|
|
|
|
ipCamera.ParseSnapshotUri();
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.StreamUri, ipCamera.StreamUri);
|
|
|
|
|
this.UpdateIoTData(device.Id, DataKeys.SnapshotUri, ipCamera.SnapshotUri);
|
|
|
|
|
this.SetPush(device.Number, false);
|
|
|
|
|
this.SetPush(device.Number, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ZoomIn(string id, float speed)
|
|
|
|
|
{
|
|
|
|
|
this.Move(id, speed, 0, 0);
|
|
|
|
|