private PTZDevice(string name, PTZType type)
        {
            var devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
            var device = devices.Where(d => d.Name == name).FirstOrDefault();

            _device = device;
            _type = type;

            if (_device == null) throw new ApplicationException(String.Format("Couldn't find device named {0}!", name));

            IFilterGraph2 graphBuilder = new FilterGraph() as IFilterGraph2;
            IBaseFilter filter = null;
            IMoniker i = _device.Mon as IMoniker;

            graphBuilder.AddSourceFilterForMoniker(i, null, _device.Name, out filter);
            _camControl = filter as IAMCameraControl;
            _ksPropertySet = filter as IKsPropertySet;

            if (_camControl == null) throw new ApplicationException("Couldn't get ICamControl!");
            if (_ksPropertySet == null) throw new ApplicationException("Couldn't get IKsPropertySet!");

            //TODO: Add Absolute
            if (type == PTZType.Relative &&
                !(SupportFor(KSProperties.CameraControlFeature.KSPROPERTY_CAMERACONTROL_PAN_RELATIVE) &&
                SupportFor(KSProperties.CameraControlFeature.KSPROPERTY_CAMERACONTROL_TILT_RELATIVE)))
            {
                throw new NotSupportedException("This camera doesn't appear to support Relative Pan and Tilt");
            }

            //TODO: Do I through NotSupported when methods are called or throw them now?

            //TODO: Do I check for Zoom or ignore if it's not there?
            InitZoomRanges();
        }
Beispiel #2
0
        private PTZDevice(string name, PTZType type)
        {
            var devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
            var device  = devices.Where(d => d.Name == name).FirstOrDefault();

            _device = device;
            _type   = type;

            if (_device == null)
            {
                throw new ApplicationException(String.Format("Couldn't find device named {0}!", name));
            }

            IFilterGraph2 graphBuilder = new FilterGraph() as IFilterGraph2;
            IBaseFilter   filter       = null;
            IMoniker      i            = _device.Mon as IMoniker;

            graphBuilder.AddSourceFilterForMoniker(i, null, _device.Name, out filter);
            _camControl    = filter as IAMCameraControl;
            _ksPropertySet = filter as IKsPropertySet;

            if (_camControl == null)
            {
                throw new ApplicationException("Couldn't get ICamControl!");
            }
            if (_ksPropertySet == null)
            {
                throw new ApplicationException("Couldn't get IKsPropertySet!");
            }

            //TODO: Add Absolute
            if (type == PTZType.Relative &&
                !(SupportFor(KSProperties.CameraControlFeature.KSPROPERTY_CAMERACONTROL_PAN_RELATIVE) &&
                  SupportFor(KSProperties.CameraControlFeature.KSPROPERTY_CAMERACONTROL_TILT_RELATIVE)))
            {
                throw new NotSupportedException("This camera doesn't appear to support Relative Pan and Tilt");
            }

            //TODO: Do I through NotSupported when methods are called or throw them now?

            //TODO: Do I check for Zoom or ignore if it's not there?
            InitZoomRanges();
        }
Beispiel #3
0
 public static PTZDevice GetDevice(string name, PTZType type)
 {
     return(new PTZDevice(name, type));
 }
 public static PTZDevice GetDevice(string name, PTZType type)
 {
     return new PTZDevice(name, type);
 }