private async Task <List <object> > getOutputNodes(List <object> aCompressedMediaTypeList) { List <object> lresult = new List <object>(); do { if (aCompressedMediaTypeList == null) { break; } if (aCompressedMediaTypeList.Count == 0) { break; } var lselectedNode = getFileFormat(); var lSelectedAttr = lselectedNode.Attributes["GUID"]; if (lSelectedAttr == null) { break; } var mFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync(Guid.Parse(lSelectedAttr.Value)); if (mFileSinkFactory == null) { break; } lSelectedAttr = lselectedNode.Attributes["Value"]; if (lSelectedAttr == null) { break; } string s = String.Format("Video_{0:yyyy_MM_dd_HH_mm_ss}.", DateTime.Now); string mFilename = s + lSelectedAttr.Value.ToLower(); mStatus.Text = "File: " + mFilename; mFilename = Settings.Default.StoringDir + @"\" + mFilename; if (string.IsNullOrEmpty(mFilename)) { break; } lresult = await mFileSinkFactory.createOutputNodesAsync( aCompressedMediaTypeList, mFilename); } while (false); return(lresult); }
private async void m_SelectFileBtn_Click(object sender, RoutedEventArgs e) { do { var lselectedNode = m_FileFormatComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lSelectedAttr = lselectedNode.Attributes["Value"]; if (lSelectedAttr == null) { break; } String limageSourceDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); SaveFileDialog lsaveFileDialog = new SaveFileDialog(); lsaveFileDialog.InitialDirectory = limageSourceDir; lsaveFileDialog.DefaultExt = "." + lSelectedAttr.Value.ToLower(); lsaveFileDialog.AddExtension = true; lsaveFileDialog.CheckFileExists = false; lsaveFileDialog.Filter = "Media file (*." + lSelectedAttr.Value.ToLower() + ")|*." + lSelectedAttr.Value.ToLower(); var lresult = lsaveFileDialog.ShowDialog(); if (lresult != true) { break; } mFilename = lsaveFileDialog.FileName; lSelectedAttr = lselectedNode.Attributes["GUID"]; if (lSelectedAttr == null) { break; } mFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync( Guid.Parse(lSelectedAttr.Value)); m_StartStopBtn.IsEnabled = true; } while (false); }
private async void button1_Click(object sender, EventArgs e) { do { var lSelectedFormatItem = (ContainerItem)formatComboBox.SelectedItem; if (lSelectedFormatItem == null) { return; } var lselectedNode = lSelectedFormatItem.mXmlNode; if (lselectedNode == null) { break; } var lSelectedAttr = lselectedNode.Attributes["Value"]; if (lSelectedAttr == null) { break; } String limageSourceDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); SaveFileDialog lsaveFileDialog = new SaveFileDialog(); lsaveFileDialog.InitialDirectory = limageSourceDir; lsaveFileDialog.DefaultExt = "." + lSelectedAttr.Value.ToLower(); lsaveFileDialog.AddExtension = true; lsaveFileDialog.CheckFileExists = false; lsaveFileDialog.Filter = "Media file (*." + lSelectedAttr.Value.ToLower() + ")|*." + lSelectedAttr.Value.ToLower(); var lresult = lsaveFileDialog.ShowDialog(); if (lresult != DialogResult.OK) { break; } mDo.Enabled = true; lSelectedAttr = lselectedNode.Attributes["GUID"]; if (lSelectedAttr == null) { break; } var lFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync( Guid.Parse(lSelectedAttr.Value)); mSink = new FileSink(lFileSinkFactory); mSink.setOptions(lsaveFileDialog.FileName); }while (false); }
private async Task init() { var l_image_source = await createImageSource(); if (l_image_source == null) { return; } var lselectedNode = m_FileFormatComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { return; } var lSelectedAttr = lselectedNode.Attributes["Value"]; if (lSelectedAttr == null) { return; } String limageSourceDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); SaveFileDialog lsaveFileDialog = new SaveFileDialog(); lsaveFileDialog.InitialDirectory = limageSourceDir; lsaveFileDialog.DefaultExt = "." + lSelectedAttr.Value.ToLower(); lsaveFileDialog.AddExtension = true; lsaveFileDialog.CheckFileExists = false; lsaveFileDialog.Filter = "Media file (*." + lSelectedAttr.Value.ToLower() + ")|*." + lSelectedAttr.Value.ToLower(); var lresult = lsaveFileDialog.ShowDialog(); if (lresult != true) { return; } var lFilename = lsaveFileDialog.FileName; lSelectedAttr = lselectedNode.Attributes["GUID"]; if (lSelectedAttr == null) { return; } mFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync( Guid.Parse(lSelectedAttr.Value)); // Video Source uint lVideoSourceIndexStream = 0; uint lVideoSourceIndexMediaType = 0; int l_VideoCompressedMediaTypeSelectedIndex = 0; string l_EncodersXMLstring = await mEncoderControl.getCollectionOfEncodersAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(l_EncodersXMLstring); var lAttrNode = doc.SelectSingleNode("EncoderFactories/Group[@GUID='{73646976-0000-0010-8000-00AA00389B71}']/EncoderFactory[1]/@CLSID"); if (lAttrNode == null) { return; } Guid l_VideoEncoder = Guid.Empty; Guid.TryParse(lAttrNode.Value, out l_VideoEncoder); List <object> lCompressedMediaTypeList = new List <object>(); if (true) { object lCompressedMediaType = await getCompressedMediaType( l_image_source, lVideoSourceIndexStream, lVideoSourceIndexMediaType, l_VideoEncoder, m_VideoEncoderMode, l_VideoCompressedMediaTypeSelectedIndex); if (lCompressedMediaType != null) { lCompressedMediaTypeList.Add(lCompressedMediaType); } } List <object> lOutputNodes = await getOutputNodes(lCompressedMediaTypeList, lFilename); if (lOutputNodes == null || lOutputNodes.Count == 0) { return; } var lSinkFactory = await mSinkControl.createEVRSinkFactoryAsync( Guid.Empty); object lEVROutputNode = await lSinkFactory.createOutputNodeAsync( mVideoPanel.Handle); if (lEVROutputNode == null) { return; } object SpreaderNode = lEVROutputNode; if (true) { var lEncoderNode = await getEncoderNode( l_image_source, lVideoSourceIndexStream, lVideoSourceIndexMediaType, l_VideoEncoder, m_VideoEncoderMode, l_VideoCompressedMediaTypeSelectedIndex, lOutputNodes[0]); List <object> lOutputNodeList = new List <object>(); lOutputNodeList.Add(lEncoderNode); lOutputNodeList.Add(lEVROutputNode); SpreaderNode = await mSpreaderNodeFactory.createSpreaderNodeAsync( lOutputNodeList); } List <object> lSourceNodes = new List <object>(); object lSourceNode = await mSourceControl.createSourceNodeFromExternalSourceWithDownStreamConnectionAsync( l_image_source, lVideoSourceIndexStream, lVideoSourceIndexMediaType, SpreaderNode); if (lSourceNode == null) { return; } lSourceNodes.Add(lSourceNode); mISession = await mISessionControl.createSessionAsync(lSourceNodes.ToArray()); if (mISession != null && await mISession.startSessionAsync(0, Guid.Empty)) { mStartStopTxtBlk.Text = "Stop"; } }
private async Task init() { var lselectedNode = m_FileFormatComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { return; } var lSelectedAttr = lselectedNode.Attributes["Value"]; if (lSelectedAttr == null) { return; } String limageSourceDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); SaveFileDialog lsaveFileDialog = new SaveFileDialog(); lsaveFileDialog.InitialDirectory = limageSourceDir; lsaveFileDialog.DefaultExt = "." + lSelectedAttr.Value.ToLower(); lsaveFileDialog.AddExtension = true; lsaveFileDialog.CheckFileExists = false; lsaveFileDialog.Filter = "Media file (*." + lSelectedAttr.Value.ToLower() + ")|*." + lSelectedAttr.Value.ToLower(); var lresult = lsaveFileDialog.ShowDialog(); if (lresult != true) { return; } var lFilename = lsaveFileDialog.FileName; lSelectedAttr = lselectedNode.Attributes["GUID"]; if (lSelectedAttr == null) { return; } mFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync(Guid.Parse(lSelectedAttr.Value)); string lScreenCaptureSymbolicLink = "CaptureManager///Software///Sources///ScreenCapture///ScreenCapture"; string lAudioLoopBack = "CaptureManager///Software///Sources///AudioEndpointCapture///AudioLoopBack"; // Video Source uint lVideoSourceIndexStream = 0; uint lVideoSourceIndexMediaType = 2; int l_VideoCompressedMediaTypeSelectedIndex = 0; // Audio Source uint lAudioSourceIndexStream = 0; uint lAudioSourceIndexMediaType = 0; int l_AudioCompressedMediaTypeSelectedIndex = 0; string l_EncodersXMLstring = await mEncoderControl.getCollectionOfEncodersAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(l_EncodersXMLstring); var lAttrNode = doc.SelectSingleNode("EncoderFactories/Group[@GUID='{73646976-0000-0010-8000-00AA00389B71}']/EncoderFactory[1]/@CLSID"); if (lAttrNode == null) { return; } Guid l_VideoEncoder = Guid.Empty; Guid.TryParse(lAttrNode.Value, out l_VideoEncoder); lAttrNode = doc.SelectSingleNode("EncoderFactories/Group[@GUID='{73647561-0000-0010-8000-00AA00389B71}']/EncoderFactory[1]/@CLSID"); if (lAttrNode == null) { return; } Guid l_AudioEncoder = Guid.Empty; Guid.TryParse(lAttrNode.Value, out l_AudioEncoder); List <object> lCompressedMediaTypeList = new List <object>(); if (true) { object lCompressedMediaType = await getCompressedMediaType( lScreenCaptureSymbolicLink, lVideoSourceIndexStream, lVideoSourceIndexMediaType, l_VideoEncoder, m_VideoEncoderMode, l_VideoCompressedMediaTypeSelectedIndex); if (lCompressedMediaType != null) { lCompressedMediaTypeList.Add(lCompressedMediaType); } } if (true) { object lCompressedMediaType = await getCompressedMediaType( lAudioLoopBack, lAudioSourceIndexStream, lAudioSourceIndexMediaType, l_AudioEncoder, m_AudioEncoderMode, l_AudioCompressedMediaTypeSelectedIndex); if (lCompressedMediaType != null) { lCompressedMediaTypeList.Add(lCompressedMediaType); } } List <object> lOutputNodes = await getOutputNodes(lCompressedMediaTypeList, lFilename); if (lOutputNodes == null || lOutputNodes.Count == 0) { return; } var lSinkFactory = await mSinkControl.createEVRSinkFactoryAsync( Guid.Empty); object lEVROutputNode = await lSinkFactory.createOutputNodeAsync( mVideoPanel.Handle); if (lEVROutputNode == null) { return; } object SpreaderNode = lEVROutputNode; if (true) { var lEncoderNode = await getEncoderNode( lScreenCaptureSymbolicLink, lVideoSourceIndexStream, lVideoSourceIndexMediaType, l_VideoEncoder, m_VideoEncoderMode, l_VideoCompressedMediaTypeSelectedIndex, lOutputNodes[0]); List <object> lOutputNodeList = new List <object>(); lOutputNodeList.Add(lEncoderNode); lOutputNodeList.Add(lEVROutputNode); SpreaderNode = await mSpreaderNodeFactory.createSpreaderNodeAsync( lOutputNodeList); //SpreaderNode = lEncoderNode; } var lMixerNodeFactory = await mStreamControl.createMixerNodeFactoryAsync(); List <object> lVideoTopologyInputMixerNodes = await lMixerNodeFactory.createMixerNodesAsync( SpreaderNode, 2); if (lVideoTopologyInputMixerNodes.Count == 0) { return; } for (int i = 1; i < lVideoTopologyInputMixerNodes.Count; i++) { mVideoTopologyInputMixerNodes.Add(lVideoTopologyInputMixerNodes[i]); } object lAudioEncoderNode = null; if (true) { lAudioEncoderNode = await getEncoderNode( lAudioLoopBack, lAudioSourceIndexStream, lAudioSourceIndexMediaType, l_AudioEncoder, m_AudioEncoderMode, l_AudioCompressedMediaTypeSelectedIndex, lOutputNodes[1]); } List <object> lAudioTopologyInputMixerNodes = await lMixerNodeFactory.createMixerNodesAsync( lAudioEncoderNode, 2); if (lAudioTopologyInputMixerNodes.Count == 0) { return; } mAudioTopologyInputMixerNode = lAudioTopologyInputMixerNodes[1]; List <object> lSourceNodes = new List <object>(); if (true) { object lSourceNode = await getSourceNode( lScreenCaptureSymbolicLink, lVideoSourceIndexStream, lVideoSourceIndexMediaType, lVideoTopologyInputMixerNodes[0]); if (lSourceNodes != null) { lSourceNodes.Add(lSourceNode); } } if (true) { object lSourceNode = await getSourceNode( lAudioLoopBack, lAudioSourceIndexStream, lAudioSourceIndexMediaType, lAudioTopologyInputMixerNodes[0]); if (lSourceNodes != null) { lSourceNodes.Add(lSourceNode); } } mISession = await mISessionControl.createSessionAsync(lSourceNodes.ToArray()); if (mISession != null) { mStartStopTxtBlk.Text = "Stop"; await mISession.startSessionAsync(0, Guid.Empty); mSourcesPanel.IsEnabled = true; } }
private async Task <List <object> > getOutputNodes(List <object> aCompressedMediaTypeList, string aFileName) { List <object> lresult = new List <object>(); do { if (aCompressedMediaTypeList == null) { break; } if (aCompressedMediaTypeList.Count == 0) { break; } var lselectedNode = m_FileFormatComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lSelectedAttr = lselectedNode.Attributes["Value"]; if (lSelectedAttr == null) { break; } aFileName += "." + lSelectedAttr.Value.ToLower(); lSelectedAttr = lselectedNode.Attributes["GUID"]; if (lSelectedAttr == null) { break; } mFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync( Guid.Parse(lSelectedAttr.Value)); if (string.IsNullOrEmpty(aFileName)) { break; } foreach (var item in mFileList.Items) { var lFileItemControl = item as FileItemControl; if (lFileItemControl != null) { lFileItemControl.stopAnimation(); } } mFileList.Items.Add(new FileItemControl(aFileName)); String limageSourceDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); lresult = await mFileSinkFactory.createOutputNodesAsync( aCompressedMediaTypeList, limageSourceDir + @"\" + aFileName); } while (false); return(lresult); }
private async void mOptionsButton_Click(object sender, RoutedEventArgs e) { switch (mSinkType) { case SinkType.Node: break; case SinkType.File: { do { var lselectedNode = mContainerTypeComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lSelectedAttr = lselectedNode.Attributes["Value"]; if (lSelectedAttr == null) { break; } String limageSourceDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); SaveFileDialog lsaveFileDialog = new SaveFileDialog(); lsaveFileDialog.InitialDirectory = limageSourceDir; lsaveFileDialog.DefaultExt = "." + lSelectedAttr.Value.ToLower(); lsaveFileDialog.AddExtension = true; lsaveFileDialog.CheckFileExists = false; lsaveFileDialog.Filter = "Media file (*." + lSelectedAttr.Value.ToLower() + ")|*." + lSelectedAttr.Value.ToLower(); var lresult = lsaveFileDialog.ShowDialog(); if (lresult != true) { break; } mDo.IsEnabled = true; lSelectedAttr = lselectedNode.Attributes["GUID"]; if (lSelectedAttr == null) { break; } var lFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync( Guid.Parse(lSelectedAttr.Value)); mSink = new FileSink(lFileSinkFactory); mSink.setOptions(lsaveFileDialog.FileName); }while (false); } break; case SinkType.BitStream: { var lselectedNode = mContainerTypeComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lSelectedAttr = lselectedNode.Attributes["GUID"]; if (lSelectedAttr == null) { break; } var lByteStreamSinkFactory = await mSinkControl.createByteStreamSinkFactoryAsync( Guid.Parse(lSelectedAttr.Value)); lSelectedAttr = lselectedNode.Attributes["MIME"]; if (lSelectedAttr == null) { break; } mSink = new NetworkStreamSink( lByteStreamSinkFactory, lSelectedAttr.Value); mSink.setOptions("8080"); mDo.IsEnabled = true; } break; default: break; } }
private async void mControlBtn_Click(object sender, RoutedEventArgs e) { if (mIsStarted) { mIsStarted = false; if (mISession == null) { return; } await mISession.stopSessionAsync(); await mISession.closeSessionAsync(); mISession = null; m_StartStopBtn.Content = "Start"; foreach (var item in mISourceItems) { var lsourceitem = (ISource)item; if (lsourceitem != null) { lsourceitem.access(true); } } return; } else { var lFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync( Guid.Parse("A2A56DA1-EB84-460E-9F05-FEE51D8C81E3")); if (lFileSinkFactory == null) { return; } List <object> lCompressedMediaTypeList = new List <object>(); foreach (var item in mISources) { var lCompressedMediaType = await item.getCompressedMediaType(); if (lCompressedMediaType != null) { lCompressedMediaTypeList.Add(lCompressedMediaType); } } List <object> lOutputNodes = await getOutputNodes(lCompressedMediaTypeList, lFileSinkFactory); if (lOutputNodes == null || lOutputNodes.Count == 0) { return; } List <object> lSourceNodes = new List <object>(); for (int i = 0; i < lOutputNodes.Count; i++) { var lSourceNode = await mISources[i].getSourceNode(lOutputNodes[i]); if (lSourceNode != null) { lSourceNodes.Add(lSourceNode); } } mISession = await mISessionControl.createSessionAsync(lSourceNodes.ToArray()); if (mISession == null) { return; } if (await mISession.startSessionAsync(0, Guid.Empty)) { m_StartStopBtn.Content = "Stop"; } mIsStarted = true; foreach (var item in mISourceItems) { var lsourceitem = (ISource)item; if (lsourceitem != null) { lsourceitem.access(false); } } } }