private async void StartSession() { object lPtrSourceNode = null; var sourceControl = await CaptureManager.createSourceControlAsync(); var sessionControl = await CaptureManager.createSessionControlAsync(); _EVROutputAdapter = new EVROutputAdapter(Instance, _HWND); if (sessionControl != null && sessionControl != null && _EVROutputAdapter.Node != null) { Session = null; lPtrSourceNode = await sourceControl.createSourceNodeWithDownStreamConnectionAsync(_SymbolicLink, _StreamIndex, _MediaTypeIndex, _EVROutputAdapter.Node); Session = await sessionControl.createSessionAsync(new object[] { lPtrSourceNode }); if (Session != null) { await Session.registerUpdateStateDelegateAsync(HandleSessionStateChanged); await Session.startSessionAsync(0, Guid.Empty); } } }
private async void mLaunchButton_Click(object sender, RoutedEventArgs e) { mLaunchButton.IsEnabled = false; do { if (mLaunchButton.Content.ToString() == "Stop") { if (mISession != null) { await mISession.stopSessionAsync(); await mISession.closeSessionAsync(); mLaunchButton.Content = "Launch"; } mISession = null; break; } var lSourceNode = mSourcesComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { break; } var lNode = lSourceNode.SelectSingleNode("Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK']/SingleValue/@Value"); if (lNode == null) { break; } string lSymbolicLink = lNode.Value; uint lStreamIndex = 0; lSourceNode = mMediaTypesComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { break; } lNode = lSourceNode.SelectSingleNode("@Index"); if (lNode == null) { break; } uint lMediaTypeIndex = 0; if (!uint.TryParse(lNode.Value, out lMediaTypeIndex)) { break; } string lxmldoc = await mCaptureManager.getCollectionOfSinksAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(lxmldoc); var lSinkNode = doc.SelectSingleNode("SinkFactories/SinkFactory[@GUID='{2F34AF87-D349-45AA-A5F1-E4104D5C458E}']"); if (lSinkNode == null) { break; } var lContainerNode = lSinkNode.SelectSingleNode("Value.ValueParts/ValuePart[1]"); if (lContainerNode == null) { break; } var lSinkControl = await mCaptureManager.createSinkControlAsync(); var lSinkFactory = await lSinkControl.createEVRSinkFactoryAsync( Guid.Empty); if (mEVROutputNode == null) { mEVROutputNode = await lSinkFactory.createOutputNodeAsync( mVideoPanel.Handle); } if (mEVROutputNode == null) { break; } var lSourceControl = await mCaptureManager.createSourceControlAsync(); if (lSourceControl == null) { break; } string lextendSymbolicLink = lSymbolicLink + " --options=" + "<?xml version='1.0' encoding='UTF-8'?>" + "<Options>" + "<Option Type='Cursor' Visiblity='True'>" + "<Option.Extensions>" + "<Extension Type='BackImage' Height='100' Width='100' Fill='0x7055ff55' Shape='Ellipse'/>" + "</Option.Extensions>" + "</Option>" + "</Options>"; if ((bool)mNormalizeChkBtn.IsChecked) { lextendSymbolicLink += " --normalize=Landscape"; } object lPtrSourceNode = await lSourceControl.createSourceNodeWithDownStreamConnectionAsync( lextendSymbolicLink, lStreamIndex, lMediaTypeIndex, mEVROutputNode); List <object> lSourceMediaNodeList = new List <object>(); lSourceMediaNodeList.Add(lPtrSourceNode); var lSessionControl = await mCaptureManager.createSessionControlAsync(); if (lSessionControl == null) { break; } mISession = await lSessionControl.createSessionAsync( lSourceMediaNodeList.ToArray()); if (mISession == null) { break; } foreach (var item in lSourceMediaNodeList) { System.Runtime.InteropServices.Marshal.ReleaseComObject(item); } await mISession.registerUpdateStateDelegateAsync(UpdateStateDelegate); await mISession.startSessionAsync(0, Guid.Empty); mLaunchButton.Content = "Stop"; if (_ThumbnailTimer == null) { ThumbnailTimer.Start(); } } while (false); mLaunchButton.IsEnabled = true; }
private async void mLaunchButton_Click(object sender, RoutedEventArgs e) { if (!m_socketAccessable) { return; } mLaunchButton.IsEnabled = false; do { if (mLaunchButton.Content == "Stop") { if (mISession != null) { await mISession.closeSessionAsync(); mLaunchButton.Content = "Launch"; } mISession = null; if (s != null) { s.disconnect(); } s = null; mLaunchButton.IsEnabled = true; break; } string lxmldoc = await mCaptureManager.getCollectionOfSinksAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(lxmldoc); var lSinkNode = doc.SelectSingleNode("SinkFactories/SinkFactory[@GUID='{3D64C48E-EDA4-4EE1-8436-58B64DD7CF13}']"); if (lSinkNode == null) { break; } var lContainerNode = lSinkNode.SelectSingleNode("Value.ValueParts/ValuePart[1]"); if (lContainerNode == null) { break; } var lReadMode = setContainerFormat(lContainerNode); var lSinkControl = await mCaptureManager.createSinkControlAsync(); ISampleGrabberCallbackSinkFactoryAsync lSampleGrabberCallbackSinkFactory = await lSinkControl.createSampleGrabberCallbackSinkFactoryAsync( lReadMode); int lIndexCount = 0; var lVideoStreamSourceNode = await createVideoStream(lSampleGrabberCallbackSinkFactory, lIndexCount); var lAudioStreamSourceNode = await createAudioStream(lSampleGrabberCallbackSinkFactory, lIndexCount); XmlDocument l_streamMediaTypesXml = new XmlDocument(); XmlNode ldocNode = l_streamMediaTypesXml.CreateXmlDeclaration("1.0", "UTF-8", null); l_streamMediaTypesXml.AppendChild(ldocNode); XmlElement rootNode = l_streamMediaTypesXml.CreateElement("MediaTypes"); l_streamMediaTypesXml.AppendChild(rootNode); var lAttr = l_streamMediaTypesXml.CreateAttribute("StreamName"); lAttr.Value = mStreamNameTxtBx.Text; rootNode.Attributes.Append(lAttr); List <object> lSourceMediaNodeList = new List <object>(); if (lVideoStreamSourceNode.Item1 != null) { doc = new XmlDocument(); doc.LoadXml(lVideoStreamSourceNode.Item2); var lMediaType = doc.SelectSingleNode("MediaType"); if (lMediaType != null) { rootNode.AppendChild(l_streamMediaTypesXml.ImportNode(lMediaType, true)); } lSourceMediaNodeList.Add(lVideoStreamSourceNode.Item1); } if (lAudioStreamSourceNode.Item1 != null) { doc = new XmlDocument(); doc.LoadXml(lAudioStreamSourceNode.Item2); var lMediaType = doc.SelectSingleNode("MediaType"); if (lMediaType != null) { rootNode.AppendChild(l_streamMediaTypesXml.ImportNode(lMediaType, true)); } lSourceMediaNodeList.Add(lAudioStreamSourceNode.Item1); } var lSessionControl = await mCaptureManager.createSessionControlAsync(); if (lSessionControl == null) { break; } mISession = await lSessionControl.createSessionAsync( lSourceMediaNodeList.ToArray()); if (mISession == null) { break; } startServer(l_streamMediaTypesXml.InnerXml); await mISession.registerUpdateStateDelegateAsync(UpdateStateDelegate); await mISession.startSessionAsync(0, Guid.Empty); mLaunchButton.Content = "Stop"; } while (false); mLaunchButton.IsEnabled = true; }
private async void mLaunchButton_Click(object sender, RoutedEventArgs e) { if (mLaunchButton.Content.ToString() == "Stop") { if (mISession != null) { await mISession.closeSessionAsync(); mLaunchButton.Content = "Launch"; } mISession = null; return; } if (mISourceControl == null) { return; } var lICaptureProcessor = ImageCaptureProcessor.createCaptureProcessor(); if (lICaptureProcessor == null) { return; } object lMediaSource = await mISourceControl.createSourceFromCaptureProcessorAsync( lICaptureProcessor); if (lMediaSource == null) { return; } string lxmldoc = await mCaptureManager.getCollectionOfSinksAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(lxmldoc); var lSinkNode = doc.SelectSingleNode("SinkFactories/SinkFactory[@GUID='{2F34AF87-D349-45AA-A5F1-E4104D5C458E}']"); if (lSinkNode == null) { return; } var lContainerNode = lSinkNode.SelectSingleNode("Value.ValueParts/ValuePart[1]"); if (lContainerNode == null) { return; } var lSinkControl = await mCaptureManager.createSinkControlAsync(); var lSinkFactory = await lSinkControl.createEVRSinkFactoryAsync( Guid.Empty); object lEVROutputNode = await lSinkFactory.createOutputNodeAsync( mVideoPanel.Handle); if (lEVROutputNode == null) { return; } var lSourceControl = await mCaptureManager.createSourceControlAsync(); if (lSourceControl == null) { return; } object lPtrSourceNode = await lSourceControl.createSourceNodeFromExternalSourceWithDownStreamConnectionAsync( lMediaSource, 0, 0, lEVROutputNode); List <object> lSourceMediaNodeList = new List <object>(); lSourceMediaNodeList.Add(lPtrSourceNode); var lSessionControl = await mCaptureManager.createSessionControlAsync(); if (lSessionControl == null) { return; } mISession = await lSessionControl.createSessionAsync( lSourceMediaNodeList.ToArray()); if (mISession == null) { return; } await mISession.registerUpdateStateDelegateAsync(UpdateStateDelegate); await mISession.startSessionAsync(0, Guid.Empty); mLaunchButton.Content = "Stop"; }
private async void mLaunchButton_Click(object sender, RoutedEventArgs e) { if (mLaunchButton.Content == "Stop") { if (s != null) { s.StopListen(); } s = null; if (mISession != null) { await mISession.closeSessionAsync(); mLaunchButton.Content = "Launch"; } mISession = null; return; } string lxmldoc = await mCaptureManager.getCollectionOfSinksAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(lxmldoc); var lSinkNode = doc.SelectSingleNode("SinkFactories/SinkFactory[@GUID='{3D64C48E-EDA4-4EE1-8436-58B64DD7CF13}']"); if (lSinkNode == null) { return; } var lContainerNode = lSinkNode.SelectSingleNode("Value.ValueParts/ValuePart[1]"); if (lContainerNode == null) { return; } var lReadMode = setContainerFormat(lContainerNode); var lSinkControl = await mCaptureManager.createSinkControlAsync(); var lSampleGrabberCallbackSinkFactory = await lSinkControl.createSampleGrabberCallbackSinkFactoryAsync( lReadMode); int lIndexCount = 120; var lVideoStreamSourceNode = await createVideoStream(lSampleGrabberCallbackSinkFactory, lIndexCount ++); var lAudioStreamSourceNode = await createAudioStream(lSampleGrabberCallbackSinkFactory, lIndexCount ++); List <object> lSourceMediaNodeList = new List <object>(); List <Tuple <RtspServer.StreamType, int, string> > streams = new List <Tuple <RtspServer.StreamType, int, string> >(); if (lVideoStreamSourceNode.Item1 != null) { lSourceMediaNodeList.Add(lVideoStreamSourceNode.Item1); streams.Add(Tuple.Create <RtspServer.StreamType, int, string>(lVideoStreamSourceNode.Item2, lVideoStreamSourceNode.Item3, lVideoStreamSourceNode.Item4)); } if (lAudioStreamSourceNode.Item1 != null) { lSourceMediaNodeList.Add(lAudioStreamSourceNode.Item1); streams.Add(Tuple.Create <RtspServer.StreamType, int, string>(lAudioStreamSourceNode.Item2, lAudioStreamSourceNode.Item3, "")); } var lSessionControl = await mCaptureManager.createSessionControlAsync(); if (lSessionControl == null) { return; } mISession = await lSessionControl.createSessionAsync( lSourceMediaNodeList.ToArray()); if (mISession == null) { return; } await mISession.registerUpdateStateDelegateAsync(UpdateStateDelegate); await mISession.startSessionAsync(0, Guid.Empty); mLaunchButton.Content = "Stop"; startServer(streams); }
private async void mLaunchButton_Click(object sender, RoutedEventArgs e) { if (mLaunchButton.Content == "Stop") { if (mISession != null) { await mISession.closeSessionAsync(); mLaunchButton.Content = "Launch"; } mISession = null; //mEVROutputNode = null; return; } var lSourceNode = mSourcesComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { return; } var lNode = lSourceNode.SelectSingleNode("Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK']/SingleValue/@Value"); if (lNode == null) { return; } string lSymbolicLink = lNode.Value; uint lStreamIndex = 0; lSourceNode = mMediaTypesComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { return; } lNode = lSourceNode.SelectSingleNode("@Index"); if (lNode == null) { return; } uint lMediaTypeIndex = 0; if (!uint.TryParse(lNode.Value, out lMediaTypeIndex)) { return; } string lxmldoc = await mCaptureManager.getCollectionOfSinksAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(lxmldoc); var lSinkNode = doc.SelectSingleNode("SinkFactories/SinkFactory[@GUID='{2F34AF87-D349-45AA-A5F1-E4104D5C458E}']"); if (lSinkNode == null) { return; } var lContainerNode = lSinkNode.SelectSingleNode("Value.ValueParts/ValuePart[1]"); if (lContainerNode == null) { return; } var lSinkControl = await mCaptureManager.createSinkControlAsync(); var lSinkFactory = await lSinkControl.createEVRMultiSinkFactoryAsync( Guid.Empty); if (mEVROutputNode == null) { List <object> ltemp = await lSinkFactory.createOutputNodesAsync( //IntPtr.Zero, //mVideoPanel.SharedResource.texture, mVideoPanel.Handle, 1); mEVROutputNode = ltemp[0]; } if (mEVROutputNode == null) { return; } var lSourceControl = await mCaptureManager.createSourceControlAsync(); if (lSourceControl == null) { return; } string lextendSymbolicLink = lSymbolicLink + " --options=" + "<?xml version='1.0' encoding='UTF-8'?>" + "<Options>" + "<Option Type='Cursor' Visiblity='True'>" + "<Option.Extensions>" + "<Extension Type='BackImage' Height='100' Width='100' Fill='0x7055ff55' />" + "</Option.Extensions>" + "</Option>" + "</Options>"; lextendSymbolicLink += " --normalize=Landscape"; object lPtrSourceNode = await lSourceControl.createSourceNodeWithDownStreamConnectionAsync( lextendSymbolicLink, lStreamIndex, lMediaTypeIndex, mEVROutputNode); List <object> lSourceMediaNodeList = new List <object>(); lSourceMediaNodeList.Add(lPtrSourceNode); var lSessionControl = await mCaptureManager.createSessionControlAsync(); if (lSessionControl == null) { return; } mISession = await lSessionControl.createSessionAsync( lSourceMediaNodeList.ToArray()); if (mISession == null) { return; } await mISession.registerUpdateStateDelegateAsync(UpdateStateDelegate); await mISession.startSessionAsync(0, Guid.Empty); mLaunchButton.Content = "Stop"; }