Ejemplo n.º 1
0
 public void Start()
 {
     _connection = new CCTVConnection(ServerHost, 60010);
     _connection.ConnectEvent    += onConnected;
     _connection.DisconnectEvent += onDisconnect;
     _connection.MessageEvent    += onMessage;
     _connection.Start();
 }
Ejemplo n.º 2
0
        private void videoRun()
        {
            _videoEvent.Reset();
            _connection = new CCTVConnection(Info.ServerHost, _port);

            _connection.ConnectEvent    += _connection_ConnectEvent;
            _connection.DisconnectEvent += _connection_DisconnectEvent;
            _connection.MessageEvent    += _connection_MessageEvent;
            _connection.Start();

            WaitHandle[] handles = new WaitHandle[] { _event, _videoEvent };
            _lastRecvTime = DateTime.Now;
            while (true)
            {
                int wait = WaitHandle.WaitAny(handles, 1000);
                if (wait == WaitHandle.WaitTimeout)
                {
                    if (DateTime.Now - _lastRecvTime > TimeSpan.FromSeconds(30))
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            _connection.ConnectEvent    -= _connection_ConnectEvent;
            _connection.DisconnectEvent -= _connection_DisconnectEvent;
            _connection.MessageEvent    -= _connection_MessageEvent;
            _connection.Stop();

            _hikm4Decoder.Dispose();
            _ffmpegDecoder.Release();
            _univiewDecoder.Dispose();
        }