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 (deviceProxy.VideoInputs.Count > 0) { success = true; try { m_cameo.SetVideoStream(deviceProxy.VideoInputs[1].Stream); this.m_videoInputVCAEvents = deviceProxy.VideoInputs[(object)1] as Bosch.VideoSDK.GCALib._IVideoInputVCAEvents_Event; m_axCameo.VcaConfig.DisplayMode = Bosch.VideoSDK.Live.VcaDisplayModes.vcmRenderVCD; if (this.m_videoInputVCAEvents != null) { // ISSUE: method pointer m_videoInputVCAEvents.MotionDetectorsStateChanged += new Bosch.VideoSDK.GCALib._IVideoInputVCAEvents_MotionDetectorsStateChangedEventHandler(VideoInputVCAEvents_MotionDetectorsStateChanged); //this.m_videoInputVCAEvents.add_MotionDetectorsStateChanged(new _IVideoInputVCAEvents_MotionDetectorsStateChangedEventHandler((object) this, (UIntPtr) __methodptr(VideoInputVCAEvents_MotionDetectorsStateChanged))); } } 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; } else { if (deviceProxy != null) { deviceProxy.Disconnect(); } m_state = State.Disconnected; MessageBox.Show("Failed to connect to \"" + url + "\"."); } UpdateGUI(); }
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(); }