public PublishedCamera PublishCamera(string cameraId, PublishDestination destination)
        {
            lock (_accessLock)
            {
                if (destination == null)
                {
                    throw new ArgumentNullException("destination");
                }

                PublishedCamera camera = GetPublishedCamera(cameraId);

                if (camera != null)
                {
                    camera.AddDestination(destination);
                }
                else
                {
                    camera        = new PublishedCamera(Locator.Get <ICameraManager>().GetCamera(cameraId)).AddDestination(destination);
                    camera.Sender = StreamSenderFactory.GetSender().Start();
                    camera.CameraErrorOccurred += new EventHandler <CameraErrorOccurredEventArgs>(OnCameraErrorOccurred);
                    camera.Start();
                    _cameras.Add(camera);

                    _timeToAlive.AddOrUpdate(new CameraPublishDestination(cameraId, destination),
                                             DateTime.Now, (k, v) => { return(DateTime.Now); });
                }

                return(camera);
            }
        }
        public void UnpublishCamera(string cameraId, PublishDestination destination)
        {
            lock (_accessLock)
            {
                if (destination == null)
                {
                    throw new ArgumentNullException("destination");
                }

                PublishedCamera camera = GetPublishedCamera(cameraId);
                if (camera != null)
                {
                    camera.RemoveDestination(destination);

                    DateTime aliveTime;
                    _timeToAlive.TryRemove(
                        new CameraPublishDestination(cameraId, destination), out aliveTime);

                    if (camera.Destinations.Count <= 0)
                    {
                        camera.CameraErrorOccurred -= new EventHandler <CameraErrorOccurredEventArgs>(OnCameraErrorOccurred);
                        camera.Stop();
                        _cameras.Remove(camera);
                        camera.Dispose();
                    }
                }
            }
        }
Beispiel #3
0
 public StreamPacket(Bitmap frame, int sequenceNumber, DateTime timestamp, PublishDestination destination)
 {
     Frame          = frame;
     SequenceNumber = sequenceNumber;
     Timestamp      = timestamp;
     Destination    = destination;
 }
Beispiel #4
0
        public void PublishPackage(string pathToNupkg, string apiKey)
        {
            var fi        = new FileInfo(pathToNupkg);
            var localRepo = PackageRepositoryFactory.Default.CreateRepository(fi.Directory.FullName);
            var package   = localRepo.FindPackagesById(fi.Name.Replace(fi.Extension, string.Empty)).First();
            var size      = fi.Length;
            var ps        = new PackageServer(PublishDestination.ToString(), "userAgent");

            ps.PushPackage(apiKey, package, size, 1800, false);
        }
Beispiel #5
0
 public PublishedCamera RemoveDestination(PublishDestination destination)
 {
     lock (_destLock)
     {
         if (destination == null)
         {
             throw new ArgumentNullException("destination");
         }
         _destinations.RemoveAll(p => p == destination);
         return(this);
     }
 }
        public void KeepAlive(string cameraId, PublishDestination destination)
        {
            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }

            CameraPublishDestination dest = new CameraPublishDestination(cameraId, destination);

            if (_timeToAlive.ContainsKey(dest))
            {
                _timeToAlive[dest] = DateTime.Now;
            }
        }
Beispiel #7
0
 public PublishedCamera AddDestination(PublishDestination destination)
 {
     lock (_destLock)
     {
         if (destination == null)
         {
             throw new ArgumentNullException("destination");
         }
         if (_destinations.Find(p => p == destination) == null)
         {
             _destinations.Add(destination);
         }
         return(this);
     }
 }
        internal static PublishDestination Translate(PublishDestinationData data)
        {
            PublishDestination dest = new PublishDestination(data.Address, data.Port);

            return(dest);
        }