Esempio n. 1
0
        public Camera BuildCamera(CameraProfile profile, CameraConfig config, byte[] thumbnail)
        {
            lock (_accessLock)
              {
            // 检查给定的源是否存在
            if (profile.FilterType == FilterType.LocalCamera
              || profile.FilterType == FilterType.LocalDesktop)
            {
              if (!Locator.Get<IFilterManager>().IsFilterExist(profile.FilterType, profile.FilterId))
              {
            throw new FilterNotFoundException(string.Format(CultureInfo.InvariantCulture,
              "Cannot find filter by type [{0}] and id [{1}].",
              profile.FilterType, profile.FilterId));
              }
            }

            Camera camera = _cameras.Find(c => c.Id == profile.Id);
            if (camera == null)
            {
              camera = CameraBuilder.Create(profile, config);
              _cameras.Add(camera);

              camera.Thumbnail = thumbnail;
            }

            return camera;
              }
        }
Esempio n. 2
0
        public Camera(CameraProfile profile, CameraConfig config, IVideoSource videoSource)
        {
            if (profile == null)
            throw new ArgumentNullException("profile");
              if (config == null)
            throw new ArgumentNullException("config");
              if (videoSource == null)
            throw new ArgumentNullException("videoSource");

              _profile = profile;
              _config = config;
              _videoSource = videoSource;
        }
Esempio n. 3
0
 internal static Camera Create(CameraProfile profile, CameraConfig config)
 {
     switch (profile.FilterType)
       {
     case FilterType.LocalCamera:
       return Create(profile, config,
     new VideoCaptureDeviceVideoSource(config.OriginalSourceString)
     {
       DesiredFrameRate = 10000000 / config.FrameRate, // 1 fps, 30 fps = 10000000 / 30 = 333333
       DesiredFrameSize = new System.Drawing.Size(config.Resolution.Width, config.Resolution.Height),
       DesiredSnapshotSize = new System.Drawing.Size(config.Resolution.Width, config.Resolution.Height),
     });
     case FilterType.LocalDesktop:
       return Create(profile, config,
     new DesktopVideoSource(int.Parse(config.OriginalSourceString, CultureInfo.InvariantCulture))
     {
       FrameInterval = config.FrameInterval, // default 1000 == 1 fps, 30 fps = 1000 / 30 = 33
       IsResized = true,
       ResizeWidth = config.Resolution.Width,
       ResizeHeight = config.Resolution.Height,
     });
     case FilterType.LocalAVIFile:
       return Create(profile, config,
     new FileVideoSource(config.OriginalSourceString));
     case FilterType.NetworkJPEG:
       return Create(profile, config,
     new JpegVideoSource(config.OriginalSourceString)
     {
       FrameInterval = config.FrameInterval,
       HttpUserAgent = config.UserAgent,
       Login = config.UserName,
       Password = config.Password,
     });
     case FilterType.NetworkMJPEG:
       return Create(profile, config,
     new MJpegVideoSource(config.OriginalSourceString)
     {
       HttpUserAgent = config.UserAgent,
       Login = config.UserName,
       Password = config.Password,
     });
     default:
       throw new NotSupportedException("Do not support the given filter type " + profile.FilterType.ToString());
       }
 }
Esempio n. 4
0
        public Camera CreateCamera(CameraProfile profile, CameraConfig config)
        {
            lock (_accessLock)
              {
            // 检查给定的源是否存在
            if (profile.FilterType == FilterType.LocalCamera
              || profile.FilterType == FilterType.LocalDesktop)
            {
              if (!Locator.Get<IFilterManager>().IsFilterExist(profile.FilterType, profile.FilterId))
              {
            throw new FilterNotFoundException(string.Format(CultureInfo.InvariantCulture,
              "Cannot find filter by type [{0}] and id [{1}].",
              profile.FilterType, profile.FilterId));
              }
            }
            else if (profile.FilterType == FilterType.LocalAVIFile)
            {
              if (!File.Exists(profile.FilterId))
              {
            throw new FilterNotFoundException(string.Format(CultureInfo.InvariantCulture,
              "Cannot find filter by type [{0}] and id [{1}].",
              profile.FilterType, profile.FilterId));
              }
            }

            // 构造摄像机
            Camera camera = _cameras.Find(c => c.Id == profile.Id);
            if (camera == null)
            {
              camera = CameraBuilder.Create(profile, config);
              _cameras.Add(camera);

              camera.Thumbnail = Locator.Get<IStreamingManager>().GetCameraSnapshot(camera.Id);

              Locator.Get<ICameraRepository>().Save(CameraBuilder.Translate(camera));
            }

            return camera;
              }
        }
Esempio n. 5
0
 internal static DACameraProfile Translate(CameraProfile profile)
 {
     DACameraProfile data = new DACameraProfile()
       {
     Id = profile.Id,
     Name = profile.Name,
     FilterType = (int)profile.FilterType,
     FilterId = profile.FilterId,
     Description = profile.Description,
     Tags = profile.Tags
       };
       return data;
 }
Esempio n. 6
0
 internal static CameraProfile Translate(DACameraProfile data)
 {
     CameraProfile profile = new CameraProfile(data.Id, (FilterType)data.FilterType, data.FilterId)
       {
     Name = data.Name,
     Description = data.Description,
     Tags = data.Tags
       };
       return profile;
 }
Esempio n. 7
0
 internal static Camera Create(CameraProfile profile, CameraConfig config, IVideoSource videoSource)
 {
     return new Camera(profile, config, videoSource);
 }