Beispiel #1
0
        private void DeviceProxy_ConnectionStateChanged(object eventSource, Bosch.VideoSDK.Device.ConnectResultEnum state)
        {
            if (state == Bosch.VideoSDK.Device.ConnectResultEnum.creConnectionTerminated)
            {
                m_cameo.SetVideoStream(null);
                m_deviceProxy.ConnectionStateChanged -= new Bosch.VideoSDK.GCALib._IDeviceProxyEvents_ConnectionStateChangedEventHandler(DeviceProxy_ConnectionStateChanged);
                m_deviceProxy = null;
                m_state       = State.Disconnected;

                UpdateGUI();
            }
        }
Beispiel #2
0
        private void DeviceConnector_ConnectResult(Bosch.VideoSDK.Device.ConnectResultEnum connectResult, string url, Bosch.VideoSDK.Device.DeviceProxy deviceProxy)
        {
            bool success = false;

            if (connectResult == Bosch.VideoSDK.Device.ConnectResultEnum.creInitialized)
            {
                if (url.ToLower().IndexOf("file") == 0)
                {
                    Bosch.VideoSDK.MediaDatabase.PlaybackController pc = new Bosch.VideoSDK.MediaDatabase.PlaybackController();
                    Bosch.VideoSDK.MediaSession session = deviceProxy.MediaDatabase.GetMediaSession(-1, pc);

                    success = true;

                    try
                    {
                        m_cameo.SetVideoStream(session.GetVideoStream());
                        pc.Play(100);
                    }
                    catch (Exception ex)
                    {
                        CheckException(ex, "Failed to render file video stream of {0}", url);
                        success = false;
                    }
                }
                else
                {
                    if (deviceProxy.VideoInputs.Count > 0)
                    {
                        success = true;

                        try
                        {
                            m_cameo.SetVideoStream(deviceProxy.VideoInputs[1].Stream);
                        }
                        catch (Exception ex)
                        {
                            CheckException(ex, "Failed to render first video stream of {0}", url);
                            success = false;
                        }
                    }
                }
            }

            if (success)
            {
                m_deviceProxy = deviceProxy;
                m_deviceProxy.ConnectionStateChanged += new Bosch.VideoSDK.GCALib._IDeviceProxyEvents_ConnectionStateChangedEventHandler(DeviceProxy_ConnectionStateChanged);
                //m_state = State.Connected;

                try
                {
                    m_videoInputVCAEvents = (Bosch.VideoSDK.GCALib._IVideoInputVCAEvents_Event)m_deviceProxy.VideoInputs[1];
                    m_videoInputVCAEvents.MotionDetectorsStateChanged += new Bosch.VideoSDK.GCALib._IVideoInputVCAEvents_MotionDetectorsStateChangedEventHandler(m_videoInputVCAEvents_MotionDetectorsStateChanged);

                    if (deviceProxy.Relays != null)
                    {
                        foreach (Bosch.VideoSDK.Live.Relay relay in deviceProxy.Relays)
                        {
                            relayNode.SetRelay(relay);

                            // relaysNode.Nodes.Add(relayNode);
                        }
                    }
                }
                catch (System.InvalidCastException)
                {
                    m_videoInputVCAEvents = null;
                }
                m_state = State.Connected;
            }



            else
            {
                if (deviceProxy != null)
                {
                    deviceProxy.Disconnect();
                }
                m_state = State.Disconnected;
                MessageBox.Show("Failed to connect to \"" + url + "\".");
            }

            UpdateGUI();
        }