Exemple #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;
              }
        }
Exemple #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;
        }
Exemple #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());
       }
 }
Exemple #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;
              }
        }
Exemple #5
0
 internal static Camera Create(CameraProfile profile, CameraConfig config, IVideoSource videoSource)
 {
     return new Camera(profile, config, videoSource);
 }
Exemple #6
0
        internal static DACameraConfig Translate(CameraConfig config)
        {
            DACameraConfig data = new DACameraConfig()
              {
            FriendlyName = config.FriendlyName,
            OriginalSourceString = config.OriginalSourceString,
            SourceString = config.SourceString,
            FrameInterval = config.FrameInterval,
            FrameRate = config.FrameRate,
            UserName = config.UserName,
            Password = config.Password,
            UserAgent = config.UserAgent,
              };

              if (config.Resolution != null)
              {
            data.Resolution = new DAResolution() { Width = config.Resolution.Width, Height = config.Resolution.Height };
              }

              return data;
        }
Exemple #7
0
        internal static CameraConfig Translate(DACameraConfig data)
        {
            CameraConfig config = new CameraConfig()
              {
            FriendlyName = data.FriendlyName,
            OriginalSourceString = data.OriginalSourceString,
            SourceString = data.SourceString,
            FrameInterval = data.FrameInterval,
            FrameRate = data.FrameRate,
            UserName = data.UserName,
            Password = data.Password,
            UserAgent = data.UserAgent,
              };

              if (data.Resolution != null)
              {
            config.Resolution = new Resolution() { Width = data.Resolution.Width, Height = data.Resolution.Height };
              }

              return config;
        }