private void m_VideoEncodersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { do { if (mEncoderControl == null) { break; } var lselectedNode = m_VideoEncodersComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lCLSIDEncoderAttr = lselectedNode.Attributes["CLSID"]; if (lCLSIDEncoderAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lCLSIDEncoderAttr.Value, out lCLSIDEncoder)) { break; } string lSymbolicLink = mCurrentSymbolicLink; uint lStreamIndex = 0; uint lMediaTypeIndex = 0; object lOutputMediaType; mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lOutputMediaType); string lMediaTypeCollection; if (!mEncoderControl.getMediaTypeCollectionOfEncoder( lOutputMediaType, lCLSIDEncoder, out lMediaTypeCollection)) { break; } XmlDataProvider lXmlEncoderModeDataProvider = (XmlDataProvider)this.Resources["XmlEncoderModeProvider"]; if (lXmlEncoderModeDataProvider == null) { return; } XmlDocument lEncoderModedoc = new XmlDocument(); lEncoderModedoc.LoadXml(lMediaTypeCollection); lXmlEncoderModeDataProvider.Document = lEncoderModedoc; } while (false); }
private void m_VideoEncodersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { do { if (mEncoderControl == null) { break; } var lselectedNode = m_VideoEncodersComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lCLSIDEncoderAttr = lselectedNode.Attributes["CLSID"]; if (lCLSIDEncoderAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lCLSIDEncoderAttr.Value, out lCLSIDEncoder)) { break; } var lSourceNode = m_VideoSourceComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { return; } var lNode = lSourceNode.SelectSingleNode( "Source.Attributes/Attribute" + "[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK' or @Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK']" + "/SingleValue/@Value"); if (lNode == null) { return; } string lSymbolicLink = lNode.Value; lSourceNode = m_VideoStreamComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { return; } lNode = lSourceNode.SelectSingleNode("@Index"); if (lNode == null) { return; } uint lStreamIndex = 0; if (!uint.TryParse(lNode.Value, out lStreamIndex)) { return; } lSourceNode = m_VideoSourceMediaTypeComboBox.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; } object lOutputMediaType; if (mSourceControl == null) { return; } lSymbolicLink = getScreenCaptureSymbolicLink(lSymbolicLink); mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lOutputMediaType); string lMediaTypeCollection; if (!mEncoderControl.getMediaTypeCollectionOfEncoder( lOutputMediaType, lCLSIDEncoder, out lMediaTypeCollection)) { break; } XmlDataProvider lXmlEncoderModeDataProvider = (XmlDataProvider)this.Resources["XmlEncoderModeProvider"]; if (lXmlEncoderModeDataProvider == null) { return; } XmlDocument lEncoderModedoc = new XmlDocument(); lEncoderModedoc.LoadXml(lMediaTypeCollection); lXmlEncoderModeDataProvider.Document = lEncoderModedoc; } while (false); }
private void encoderComboBox_SelectedIndexChanged(object sender, EventArgs e) { do { if (mEncoderControl == null) { break; } var lSelectedEncoderItem = (ContainerItem)encoderComboBox.SelectedItem; if (lSelectedEncoderItem == null) { return; } var lselectedNode = lSelectedEncoderItem.mXmlNode; if (lselectedNode == null) { break; } var lEncoderNameAttr = lselectedNode.Attributes["Title"]; if (lEncoderNameAttr == null) { break; } var lCLSIDEncoderAttr = lselectedNode.Attributes["CLSID"]; if (lCLSIDEncoderAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lCLSIDEncoderAttr.Value, out lCLSIDEncoder)) { break; } var lSelectedSourceItem = (ContainerItem)sourceComboBox.SelectedItem; if (lSelectedSourceItem == null) { return; } var lSourceNode = lSelectedSourceItem.mXmlNode; if (lSourceNode == null) { return; } var lNode = lSourceNode.SelectSingleNode( "Source.Attributes/Attribute" + "[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK' or @Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK']" + "/SingleValue/@Value"); if (lNode == null) { return; } string lSymbolicLink = lNode.Value; uint lStreamIndex = 0; var lSelectedMediaTypeItem = (ContainerItem)mediaTypeComboBox.SelectedItem; if (lSelectedMediaTypeItem == null) { return; } lSourceNode = lSelectedMediaTypeItem.mXmlNode; if (lSourceNode == null) { return; } lNode = lSourceNode.SelectSingleNode("@Index"); if (lNode == null) { return; } uint lMediaTypeIndex = 0; if (!uint.TryParse(lNode.Value, out lMediaTypeIndex)) { return; } object lOutputMediaType; if (mSourceControl == null) { return; } mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lOutputMediaType); string lMediaTypeCollection; if (!mEncoderControl.getMediaTypeCollectionOfEncoder( lOutputMediaType, lCLSIDEncoder, out lMediaTypeCollection)) { break; } XmlDocument lEncoderModedoc = new XmlDocument(); lEncoderModedoc.LoadXml(lMediaTypeCollection); var lEncoderNodes = lEncoderModedoc.SelectNodes("EncoderMediaTypes/Group"); encoderModeComboBox.Items.Clear(); foreach (var item in lEncoderNodes) { lNode = (XmlNode)item; if (lNode != null) { var lvalueNode = lNode.SelectSingleNode("@Title"); ContainerItem lSourceItem = new ContainerItem() { mFriendlyName = lvalueNode.Value, mXmlNode = lNode }; encoderModeComboBox.Items.Add(lSourceItem); } } } while (false); }
private void m_VideoEncodersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { do { if (mEncoderControl == null) { break; } var lselectedNode = m_VideoEncodersComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lCLSIDEncoderAttr = lselectedNode.Attributes["CLSID"]; if (lCLSIDEncoderAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lCLSIDEncoderAttr.Value, out lCLSIDEncoder)) { break; } var lSourceNode = m_VideoSourceComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { return; } var lNode = lSourceNode.SelectSingleNode( "Source.Attributes/Attribute" + "[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK' or @Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK']" + "/SingleValue/@Value"); if (lNode == null) { return; } string lSymbolicLink = lNode.Value; lSourceNode = m_VideoStreamComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { return; } lNode = lSourceNode.SelectSingleNode("@Index"); if (lNode == null) { return; } uint lStreamIndex = 0; if (!uint.TryParse(lNode.Value, out lStreamIndex)) { return; } lSourceNode = m_VideoSourceMediaTypeComboBox.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; } object lOutputMediaType; if (mSourceControl == null) { return; } var t = new Thread( delegate() { try { Dispatcher.Invoke( DispatcherPriority.Normal, new Action(() => { m_VideoEncodingModeComboBox.IsEnabled = false; })); mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lOutputMediaType); string lMediaTypeCollection; if (!mEncoderControl.getMediaTypeCollectionOfEncoder( lOutputMediaType, lCLSIDEncoder, out lMediaTypeCollection)) { return; } XmlDataProvider lXmlEncoderModeDataProvider = (XmlDataProvider)this.Resources["XmlEncoderModeProvider"]; if (lXmlEncoderModeDataProvider == null) { return; } XmlDocument lEncoderModedoc = new XmlDocument(); lEncoderModedoc.LoadXml(lMediaTypeCollection); lXmlEncoderModeDataProvider.Document = lEncoderModedoc; Dispatcher.Invoke( DispatcherPriority.Normal, new Action(() => { m_VideoEncodingModeComboBox.IsEnabled = true; })); } catch (Exception ex) { } finally { } }); t.SetApartmentState(ApartmentState.MTA); t.Start(); } while (false); }
public MainWindow() { InitializeComponent(); try { mCaptureManager = new CaptureManager("CaptureManager.dll"); } catch (System.Exception) { try { mCaptureManager = new CaptureManager(); } catch (System.Exception) { } } if (mCaptureManager == null) { return; } XmlDataProvider lXmlDataProvider = (XmlDataProvider)this.Resources["XmlLogProvider"]; if (lXmlDataProvider == null) { return; } System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); string lxmldoc = ""; mCaptureManager.getCollectionOfSources(ref lxmldoc); doc.LoadXml(lxmldoc); lXmlDataProvider.Document = doc; mSourceControl = mCaptureManager.createSourceControl(); mCaptureManager.getCollectionOfSinks(ref lxmldoc); lXmlDataProvider = (XmlDataProvider)this.Resources["XmlSinkFactoryCollectionProvider"]; if (lXmlDataProvider == null) { return; } doc = new System.Xml.XmlDocument(); doc.LoadXml(lxmldoc); lXmlDataProvider.Document = doc; mISessionControl = mCaptureManager.createSessionControl(); mSinkControl = mCaptureManager.createSinkControl(); mEncoderControl = mCaptureManager.createEncoderControl(); mEncodersComboBox.SelectionChanged += delegate { do { if (mEncoderControl == null) { break; } var lselectedNode = mEncodersComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lEncoderNameAttr = lselectedNode.Attributes["Title"]; if (lEncoderNameAttr == null) { break; } var lCLSIDEncoderAttr = lselectedNode.Attributes["CLSID"]; if (lCLSIDEncoderAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lCLSIDEncoderAttr.Value, out lCLSIDEncoder)) { break; } 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' or @Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK']" + "/SingleValue/@Value"); if (lNode == null) { return; } string lSymbolicLink = lNode.Value; lSourceNode = mStreamsComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { return; } lNode = lSourceNode.SelectSingleNode("@Index"); if (lNode == null) { return; } uint lStreamIndex = 0; if (!uint.TryParse(lNode.Value, out lStreamIndex)) { return; } 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; } object lOutputMediaType; if (mSourceControl == null) { return; } mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lOutputMediaType); string lMediaTypeCollection; if (!mEncoderControl.getMediaTypeCollectionOfEncoder( lOutputMediaType, lCLSIDEncoder, out lMediaTypeCollection)) { break; } XmlDataProvider lXmlEncoderModeDataProvider = (XmlDataProvider)this.Resources["XmlEncoderModeProvider"]; if (lXmlEncoderModeDataProvider == null) { return; } XmlDocument lEncoderModedoc = new XmlDocument(); lEncoderModedoc.LoadXml(lMediaTypeCollection); lXmlEncoderModeDataProvider.Document = lEncoderModedoc; } while (false); }; mEncodingModeComboBox.SelectionChanged += delegate { do { if (mEncoderControl == null) { break; } var lselectedNode = mEncodingModeComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lGUIDEncodingModeAttr = lselectedNode.Attributes["GUID"]; if (lGUIDEncodingModeAttr == null) { break; } Guid lGUIDEncodingMode; if (!Guid.TryParse(lGUIDEncodingModeAttr.Value, out lGUIDEncodingMode)) { break; } var lConstantMode = Guid.Parse("{CA37E2BE-BEC0-4B17-946D-44FBC1B3DF55}"); XmlDataProvider lXmlMediaTypeProvider = (XmlDataProvider)this.Resources["XmlMediaTypesCollectionProvider"]; if (lXmlMediaTypeProvider == null) { return; } XmlDocument lMediaTypedoc = new XmlDocument(); var lClonedMediaTypesNode = lMediaTypedoc.ImportNode(lselectedNode, true); lMediaTypedoc.AppendChild(lClonedMediaTypesNode); lXmlMediaTypeProvider.Document = lMediaTypedoc; } while (false); }; mSinkFactoryComboBox.SelectionChanged += delegate { do { if (mEncoderControl == null) { break; } var lselectedNode = mSinkFactoryComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lAttr = lselectedNode.Attributes["GUID"]; if (lAttr == null) { throw new System.Exception("GUID is empty"); } mContainerTypeComboBox.IsEnabled = false; mSinkType = SinkType.Node; if (lAttr.Value == "{D6E342E3-7DDD-4858-AB91-4253643864C2}") { mContainerTypeComboBox.IsEnabled = true; mSinkType = SinkType.File; } else if (lAttr.Value == "{2E891049-964A-4D08-8F36-95CE8CB0DE9B}") { mContainerTypeComboBox.IsEnabled = true; mSinkType = SinkType.BitStream; } else if (lAttr.Value == "{759D24FF-C5D6-4B65-8DDF-8A2B2BECDE39}") { } else if (lAttr.Value == "{3D64C48E-EDA4-4EE1-8436-58B64DD7CF13}") { } else if (lAttr.Value == "{2F34AF87-D349-45AA-A5F1-E4104D5C458E}") { } XmlDataProvider lXmlMediaTypeProvider = (XmlDataProvider)this.Resources["XmlContainerTypeProvider"]; if (lXmlMediaTypeProvider == null) { return; } XmlDocument lMediaTypedoc = new XmlDocument(); var lClonedMediaTypesNode = lMediaTypedoc.ImportNode(lselectedNode, true); lMediaTypedoc.AppendChild(lClonedMediaTypesNode); lXmlMediaTypeProvider.Document = lMediaTypedoc; } while (false); }; }
private void mVideoEncoderComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { do { mBitRateComboBox.Items.Clear(); 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; lSourceNode = mStreamsComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { break; } lNode = lSourceNode.SelectSingleNode("@Index"); if (lNode == null) { break; } uint lStreamIndex = 0; if (!uint.TryParse(lNode.Value, out lStreamIndex)) { break; } 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; } object lVideoSourceOutputMediaType; if (mSourceControl == null) { break; } mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lVideoSourceOutputMediaType); var lVideoEncoderNode = mVideoEncoderComboBox.SelectedItem as XmlNode; if (lVideoEncoderNode == null) { break; } lNode = lVideoEncoderNode.SelectSingleNode("@CLSID"); if (lNode == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lNode.Value, out lCLSIDEncoder)) { break; } string lxmlDoc; mEncoderControl.getMediaTypeCollectionOfEncoder( lVideoSourceOutputMediaType, lCLSIDEncoder, out lxmlDoc); var lXmlDataProvider = (XmlDataProvider)this.Resources["XmlVideoCompressedMediaTypesProvider"]; if (lXmlDataProvider == null) { return; } var doc = new System.Xml.XmlDocument(); doc.LoadXml(lxmlDoc); lXmlDataProvider.Document = doc; var lGroup = doc.SelectSingleNode("EncoderMediaTypes/Group[@GUID='{8F6FF1B6-534E-49C0-B2A8-16D534EAF135}']"); if (lGroup != null) { uint lMaxBitRate = 0; uint lMinBitRate = 0; var lAttr = lGroup.SelectSingleNode("@MaxBitRate"); if (lAttr != null) { if (uint.TryParse(lAttr.Value, out lMaxBitRate)) { } } lAttr = lGroup.SelectSingleNode("@MinBitRate"); if (lAttr != null) { if (uint.TryParse(lAttr.Value, out lMinBitRate)) { } } for (uint i = lMaxBitRate; i >= lMinBitRate; i >>= 1) { mBitRateComboBox.Items.Add(i); } } } while (false); }
private Guid getEncoderMode() { Guid lEncoderMode = Guid.Empty; do { if (mEncoderControl == null) { break; } string lSymbolicLink = getSybolicLink(); uint lStreamIndex = Settings.Default.SourceStream; uint lMediaTypeIndex = Settings.Default.SourceMediaType; object lOutputMediaType; mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lOutputMediaType); string lMediaTypeCollection; if (!mEncoderControl.getMediaTypeCollectionOfEncoder( lOutputMediaType, mCLSIDEncoder, out lMediaTypeCollection)) { break; } XmlDocument lEncoderModedoc = new XmlDocument(); lEncoderModedoc.LoadXml(lMediaTypeCollection); var lNodes = lEncoderModedoc.SelectNodes("EncoderMediaTypes/Group"); var lXmlNode = lNodes.Item((int)Settings.Default.EncoderMode); if (lXmlNode == null) { break; } var lEncoderModeGuidAttr = lXmlNode.Attributes["GUID"]; if (lEncoderModeGuidAttr == null) { break; } Guid lCLSIDEncoderMode; if (!Guid.TryParse(lEncoderModeGuidAttr.Value, out lCLSIDEncoderMode)) { break; } lEncoderMode = lCLSIDEncoderMode; } while (false); return(lEncoderMode); }