Exemplo n.º 1
0
        /// <summary>
        /// Obtiene los datos necesarios para la conexión streaming hacia un dispositivo de video
        /// </summary>
        public object GetConnectionStreamingPTZ(Guid guid)
        {
            if (LoginGuid() is bool)
            {
                if (EstadoDispositivoPtz(guid) is bool)
                {
                    var objResponseConnectionStreaming = new ResponseConnectionStreaming();
                    var deviceApi = m_DvtelSystem.GetAPI <IDeviceAPI>();
                    var ptzClient = deviceApi.AcquirePTZControl(camera);
                    objResponseConnectionStreaming.guid        = camera.Id;
                    objResponseConnectionStreaming.isPtzOnline = camera.IsPtzOnline;
                    objResponseConnectionStreaming.logicalId   = camera.LogicalId;
                    objResponseConnectionStreaming.name        = camera.Name;
                    objResponseConnectionStreaming.isViewable  = camera.IsViewable;
                    objResponseConnectionStreaming.deviceUrl   = camera.GetCameraGeneralPageUrl();
                    try
                    {
                        objResponseConnectionStreaming.clientsConnectionType = camera.ClientsConnectionType.ToString();
                    }
                    catch
                    {
                        objResponseConnectionStreaming.clientsConnectionType = "";
                    }
                    try
                    {
                        objResponseConnectionStreaming.deviceDriverExternalId = camera.DeviceDriver.ExternalId.ToString();
                    }
                    catch { objResponseConnectionStreaming.deviceDriverExternalId = ""; }
                    objResponseConnectionStreaming.isAccessible = camera.IsAccessible;
                    objResponseConnectionStreaming.isEnabled    = camera.IsEnabled;
                    objResponseConnectionStreaming.isRecording  = camera.IsRecording;
                    try
                    {
                        objResponseConnectionStreaming.linkedUrl = camera.LinkedUrl.Url;
                    }
                    catch { objResponseConnectionStreaming.linkedUrl = ""; }
                    objResponseConnectionStreaming.videoSourceFormat = camera.VideoSourceFormat.ToString();

                    objResponseConnectionStreaming.IsPtzLocked  = camera.IsPtzLocked;
                    objResponseConnectionStreaming.IsPtzEnabled = camera.IsPtzEnabled;
                    objResponseConnectionStreaming.sceneId      = ptzClient.SceneId;
                    objResponseConnectionStreaming.sessionId    = ptzClient.SessionId;
                    objResponseConnectionStreaming.url          = "dvnp://" + usernameSystemDvTel + ":" + passwordSystemDvTel + "@" + ipDirectory + "?id=" + camera.LogicalId + "&Trace=debug";//urlEntity.Url;
                    return(ResponseMethod(CodeStatus.OK, string.Empty, objResponseConnectionStreaming));
                }
            }
            return(objModelResponseMethod);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Obtiene los datos de un dispositivo de video ,sirve de método auxiliar para la obtención de información.
        /// </summary>
        private PTZDevice GetDataPtz(IDvtelSystemId latitudeSystem, IVideoInSceneEntity camera)
        {
            objCameraPTZ = new PTZDevice();
            var deviceApi = latitudeSystem.GetAPI <IDeviceAPI>();
            var ptzClient = deviceApi.AcquirePTZControl(camera);

            var m_playerAPI = latitudeSystem.GetAPI <IPlayerAPI>();

            /*if (ptzClient != null)
             * {*/
            objCameraPTZ.canFocus         = ptzClient != null? ptzClient.CanFocus: false;
            objCameraPTZ.canIris          = ptzClient != null ? ptzClient.CanIris : false;
            objCameraPTZ.canPanTilt       = ptzClient != null ? ptzClient.CanPanTilt : false;
            objCameraPTZ.canZoom          = ptzClient != null ? ptzClient.CanZoom : false;
            objCameraPTZ.isLocked         = ptzClient != null ? ptzClient.IsLocked : false;
            objCameraPTZ.numberOfPatterns = ptzClient != null ? ptzClient.NumberOfPatterns:0;
            objCameraPTZ.numberOfPresets  = ptzClient != null ? ptzClient.NumberOfPresets:0;
            objCameraPTZ.sceneId          = ptzClient != null ? ptzClient.SceneId:Guid.Empty;
            objCameraPTZ.sessionId        = ptzClient != null ? ptzClient.SessionId : Guid.Empty;


            var locationBaseEntity = ptzClient != null?ptzClient.GetCurrentLocation() : null;

            if (locationBaseEntity is IPtzMotorNormalized3DLocationEntity)
            {
                var location = (IPtzMotorNormalized3DLocationEntity)locationBaseEntity;
                objCameraPTZ.panValue  = location.PanValue.ToString();
                objCameraPTZ.tiltValue = location.TiltValue.ToString();
                objCameraPTZ.zoomValue = location.ZoomValue.ToString();
            }

            if (locationBaseEntity is IPtzMotor3DLocationEntity)
            {
                var absLocation = (IPtzMotor3DLocationEntity)locationBaseEntity;
                objCameraPTZ.panValue  = absLocation.PanValue;
                objCameraPTZ.tiltValue = absLocation.TiltValue;
                objCameraPTZ.zoomValue = absLocation.ZoomValue;
            }



            PTZDevice.geoLocation geographicLocation = new PTZDevice.geoLocation();
            entity = m_DvtelSystem.AdministrationAPI.GetCachedEntity(camera.Id);


            var objIPTZMotorEntity2 = entity as IPTZMotorEntity;
            IAdminCenterEntity objIAdminCenterEntity = entity as IAdminCenterEntity;

            bool isReady = false;
            ISceneGeoLocationEntity objISceneGeoLocationEntity;

            objISceneGeoLocationEntity = entity as ISceneGeoLocationEntity;
            if (objISceneGeoLocationEntity != null)
            {
                isReady = true;
            }

            objISceneGeoLocationEntity = camera as ISceneGeoLocationEntity;
            if (objISceneGeoLocationEntity != null)
            {
                isReady = true;
            }
            dynamic ipstream = camera.GetStreamSourceIp();

            var eje = camera.DvtelSystem.CreateEntity <ISceneGeoLocationEntity>();



            if (isReady)
            {
                geographicLocation.latitude     = objISceneGeoLocationEntity.Latitude;
                geographicLocation.altitude     = objISceneGeoLocationEntity.Altitude;
                geographicLocation.longitude    = objISceneGeoLocationEntity.Longitude;
                objCameraPTZ.geographicLocation = geographicLocation;
            }
            eje = entity as ISceneGeoLocationEntity;

            dynamic entityReferencer = entity.GetEntityReferencers()[0].Entity;

            try
            {
                objCameraPTZ.firmware = entityReferencer.FirmwareVersion;
            } catch
            {
                objCameraPTZ.firmware = string.Empty;
            }
            try
            {
                objCameraPTZ.model = entityReferencer != null ? entityReferencer.Model : string.Empty;
            }
            catch
            {
                objCameraPTZ.model = string.Empty;
            }
            try
            {
                objCameraPTZ.pluginName = entityReferencer != null ? entityReferencer.Plugin.Name : string.Empty;
            }
            catch
            {
                objCameraPTZ.pluginName = string.Empty;
            }
            try
            {
                objCameraPTZ.pluginVersion = entityReferencer != null ? entityReferencer.pluginVersion : string.Empty;
            }
            catch
            {
                objCameraPTZ.pluginVersion = string.Empty;
            }



            var DataEntities             = camera.ExternalDataEntities;
            var ExternalPluginWorkspaces = camera.ExternalPluginWorkspaces;
            var GetActiveSchedules       = camera.GetActiveSchedules();
            var extendedTypes            = camera.GetAllExtendedTypes();
            var detetionurl   = camera.GetCameraMotionDetectionSettingsUrl();
            var metadata      = camera.GetEntityMetaData();
            var cam_entityref = camera.GetEntityReferencers();

            var locationCamera = camera.GetPropertyLocalizationEnum(SceneGeoLocationEntityEnum.Altitude);

            locationCamera = camera.GetPropertyLocalizationEnum(SceneGeoLocationEntityEnum.Latitude);
            locationCamera = camera.GetPropertyLocalizationEnum(SceneGeoLocationEntityEnum.Longitude);


            objCameraPTZ.description  = camera.Description;
            objCameraPTZ.guid         = camera.Id;
            objCameraPTZ.isPtzOnline  = camera.IsPtzOnline;
            objCameraPTZ.logicalId    = camera.LogicalId;
            objCameraPTZ.name         = camera.Name;
            objCameraPTZ.creationTime = camera.CreationTime;
            objCameraPTZ.isViewable   = camera.IsViewable;
            objCameraPTZ.deviceUrl    = camera.GetCameraGeneralPageUrl();

            dynamic dyCamera      = camera;
            dynamic dyEntity      = entity;
            dynamic entityDynamic = entity;
            var     logiclaloc    = entityDynamic.LogicalLocation;

            try
            {
                foreach (var vEvent in camera.EventHandlers.Values.ToList())
                {
                    objCameraPTZ.supportedEvents += vEvent.Caption + " ";
                }
            }
            catch
            { objCameraPTZ.supportedEvents = ""; }

            objCameraPTZ.clientsConnectionType = camera.ClientsConnectionType != null?camera.ClientsConnectionType.ToString() : string.Empty;

            objCameraPTZ.detailedInformation    = camera.DetailedInformation;
            objCameraPTZ.deviceDriverExternalId = camera.DeviceDriver != null?camera.DeviceDriver.ExternalId.ToString() : string.Empty;

            objCameraPTZ.isAccessible      = camera.IsAccessible;
            objCameraPTZ.isEnabled         = camera.IsEnabled;
            objCameraPTZ.linkedUrl         = camera.LinkedUrl != null? camera.LinkedUrl.Url:string.Empty;
            objCameraPTZ.videoSourceFormat = camera.VideoSourceFormat.ToString();

            // dynamic dymLoc=GetLoc

            try
            {
                foreach (var vAddress in camera.Addresses.Values.ToList())
                {
                    objCameraPTZ.address += vAddress.Caption + " ";
                }
            }
            catch
            {
                objCameraPTZ.address = "";
            }
            objCameraPTZ.timeZone     = camera.TimeZone.ToString();
            objCameraPTZ.IsPtzLocked  = camera.IsPtzLocked;
            objCameraPTZ.IsPtzEnabled = camera.IsPtzEnabled;
            //}
            return(objCameraPTZ);
        }