private object getEncoderNode( string aSymbolicLink, uint aStreamIndex, uint aMediaTypeIndex, Guid aCLSIDEncoder, Guid aCLSIDEncoderMode, int aCompressedMediaTypeIndex, object aOutputNode) { object lresult = null; do { if (aCompressedMediaTypeIndex < 0) { break; } object lSourceMediaType = null; if (!mSourceControl.getSourceOutputMediaType( aSymbolicLink, aStreamIndex, aMediaTypeIndex, out lSourceMediaType)) { break; } if (lSourceMediaType == null) { break; } IEncoderNodeFactory lEncoderNodeFactory; if (!mEncoderControl.createEncoderNodeFactory( aCLSIDEncoder, out lEncoderNodeFactory)) { break; } if (lEncoderNodeFactory == null) { break; } object lEncoderNode; if (!lEncoderNodeFactory.createEncoderNode( lSourceMediaType, aCLSIDEncoderMode, 50, (uint)aCompressedMediaTypeIndex, aOutputNode, out lEncoderNode)) { break; } lresult = lEncoderNode; } while (false); return(lresult); }
private object getCompressedMediaType( XmlNode aSourceNode, XmlNode aStreamNode, XmlNode aMediaTypeNode, XmlNode aEncoderNode, XmlNode aEncoderModeNode, int aCompressedMediaTypeIndex) { object lresult = null; do { if (aCompressedMediaTypeIndex < 0) { break; } if (aSourceNode == null) { break; } if (aStreamNode == null) { break; } if (aMediaTypeNode == null) { break; } if (aEncoderNode == null) { break; } if (aEncoderModeNode == null) { break; } var lEncoderGuidAttr = aEncoderNode.Attributes["CLSID"]; if (lEncoderGuidAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lEncoderGuidAttr.Value, out lCLSIDEncoder)) { break; } var lEncoderModeGuidAttr = aEncoderModeNode.Attributes["GUID"]; if (lEncoderModeGuidAttr == null) { break; } Guid lCLSIDEncoderMode; if (!Guid.TryParse(lEncoderModeGuidAttr.Value, out lCLSIDEncoderMode)) { break; } if (aSourceNode == null) { break; } var lNode = aSourceNode.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) { break; } string lSymbolicLink = lNode.Value; if (aStreamNode == null) { break; } lNode = aStreamNode.SelectSingleNode("@Index"); if (lNode == null) { break; } uint lStreamIndex = 0; if (!uint.TryParse(lNode.Value, out lStreamIndex)) { break; } if (aMediaTypeNode == null) { break; } lNode = aMediaTypeNode.SelectSingleNode("@Index"); if (lNode == null) { break; } uint lMediaTypeIndex = 0; if (!uint.TryParse(lNode.Value, out lMediaTypeIndex)) { break; } object lSourceMediaType = null; lSymbolicLink = getScreenCaptureSymbolicLink(lSymbolicLink); if (!mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lSourceMediaType)) { break; } if (lSourceMediaType == null) { break; } IEncoderNodeFactory lEncoderNodeFactory; if (!mEncoderControl.createEncoderNodeFactory( lCLSIDEncoder, out lEncoderNodeFactory)) { break; } if (lEncoderNodeFactory == null) { break; } object lCompressedMediaType; if (!lEncoderNodeFactory.createCompressedMediaType( lSourceMediaType, lCLSIDEncoderMode, 50, (uint)aCompressedMediaTypeIndex, out lCompressedMediaType)) { break; } lresult = lCompressedMediaType; } while (false); return(lresult); }
private void mDo_Click(object sender, EventArgs e) { if (mSession != null) { mSession.closeSession(); mSession = null; mDo.Text = "Stopped"; return; } if (mSink == null) { return; } 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; mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lOutputMediaType); var lSelectedEncoderItem = (ContainerItem)encoderComboBox.SelectedItem; if (lSelectedEncoderItem == null) { return; } var lselectedNode = lSelectedEncoderItem.mXmlNode; if (lselectedNode == null) { return; } var lEncoderNameAttr = lselectedNode.Attributes["Title"]; if (lEncoderNameAttr == null) { return; } var lCLSIDEncoderAttr = lselectedNode.Attributes["CLSID"]; if (lCLSIDEncoderAttr == null) { return; } Guid lCLSIDEncoder; if (!Guid.TryParse(lCLSIDEncoderAttr.Value, out lCLSIDEncoder)) { return; } IEncoderNodeFactory lEncoderNodeFactory; mEncoderControl.createEncoderNodeFactory( lCLSIDEncoder, out lEncoderNodeFactory); var lSelectedEncoderModeItem = (ContainerItem)encoderModeComboBox.SelectedItem; if (lSelectedEncoderModeItem == null) { return; } lselectedNode = lSelectedEncoderModeItem.mXmlNode; if (lselectedNode == null) { return; } var lGUIDEncodingModeAttr = lselectedNode.Attributes["GUID"]; if (lGUIDEncodingModeAttr == null) { return; } Guid lGUIDEncodingMode; if (!Guid.TryParse(lGUIDEncodingModeAttr.Value, out lGUIDEncodingMode)) { return; } if (compressedMediaTypeComboBox.SelectedIndex < 0) { return; } object lCompressedMediaType; lEncoderNodeFactory.createCompressedMediaType( lOutputMediaType, lGUIDEncodingMode, 70, (uint)compressedMediaTypeComboBox.SelectedIndex, out lCompressedMediaType); var lOutputNode = mSink.getOutputNode(lCompressedMediaType); IEncoderNodeFactory lIEncoderNodeFactory; mEncoderControl.createEncoderNodeFactory( lCLSIDEncoder, out lIEncoderNodeFactory); object lEncoderNode; lIEncoderNodeFactory.createEncoderNode( lOutputMediaType, lGUIDEncodingMode, 70, (uint)compressedMediaTypeComboBox.SelectedIndex, lOutputNode, out lEncoderNode); object lSourceMediaNode; mSourceControl.createSourceNode( lSymbolicLink, lStreamIndex, lMediaTypeIndex, lEncoderNode, out lSourceMediaNode); List <object> lSourcesList = new List <object>(); lSourcesList.Add(lSourceMediaNode); mSession = mISessionControl.createSession(lSourcesList.ToArray()); if (mSession != null) { mSession.startSession(0, Guid.Empty); } mDo.Text = "Record is executed!!!"; }
private void init() { string lScreenCaptureSymbolicLink = "CaptureManager///Software///Sources///ScreenCapture///ScreenCapture"; string lAudioLoopBack = "CaptureManager///Software///Sources///AudioEndpointCapture///AudioLoopBack"; // Video Source uint lVideoSourceIndexStream = 0; uint lVideoSourceIndexMediaType = 2; object lVideoSourceOutputMediaType; mSourceControl.getSourceOutputMediaType(lScreenCaptureSymbolicLink, lVideoSourceIndexStream, lVideoSourceIndexMediaType, out lVideoSourceOutputMediaType); Guid lH264Encoder = new Guid("6ca50344-051a-4ded-9779-a43305165e35"); IEncoderNodeFactory lIEncoderNodeFactory; mEncoderControl.createEncoderNodeFactory(lH264Encoder, out lIEncoderNodeFactory); if (lIEncoderNodeFactory == null) { mCtrlBtn.Content = "Error"; mCtrlBtn.IsEnabled = false; mState.Text = "H264 Encoder is not acessable"; return; } object lCompressedMediaType; lIEncoderNodeFactory.createCompressedMediaType( lVideoSourceOutputMediaType, new Guid(0xee8c3745, 0xf45b, 0x42b3, 0xa8, 0xcc, 0xc7, 0xa6, 0x96, 0x44, 0x9, 0x55), 75, 0, out lCompressedMediaType); // Audio Source uint lAudioSourceIndexStream = 0; uint lAudioSourceIndexMediaType = 0; object lAudioSourceOutputMediaType; mSourceControl.getSourceOutputMediaType(lAudioLoopBack, lAudioSourceIndexStream, lAudioSourceIndexMediaType, out lAudioSourceOutputMediaType); Guid lAACEncoder = new Guid("93af0c51-2275-45d2-a35b-f2ba21caed00"); IEncoderNodeFactory lAACIEncoderNodeFactory; mEncoderControl.createEncoderNodeFactory(lAACEncoder, out lAACIEncoderNodeFactory); if (lAACIEncoderNodeFactory == null) { mCtrlBtn.Content = "Error"; mCtrlBtn.IsEnabled = false; mState.Text = "AAC Encoder is not acessable"; return; } object lAACCompressedMediaType; lAACIEncoderNodeFactory.createCompressedMediaType( lAudioSourceOutputMediaType, new Guid(0xca37e2be, 0xbec0, 0x4b17, 0x94, 0x6d, 0x44, 0xfb, 0xc1, 0xb3, 0xdf, 0x55), 0, 0, out lAACCompressedMediaType); IByteStreamSinkFactory lSinkFactory; mSinkControl.createSinkFactory(new Guid("E80A6BFD-D9C2-4A1F-95DC-14685CACEF3E"), out lSinkFactory); if (lSinkFactory == null) { mCtrlBtn.Content = "Error"; mCtrlBtn.IsEnabled = false; mState.Text = "MP4 ByteStream is not acessable"; return; } mNetworkStreamControl = new NetworkStreamControl(lSinkFactory); List <object> lcompressesMediaTypes = new List <object>(); lcompressesMediaTypes.Add(lAACCompressedMediaType); lcompressesMediaTypes.Add(lCompressedMediaType); var lOutputNode = mNetworkStreamControl.getOutputNode( lcompressesMediaTypes, StartSession, StopSession, WriteClientIP); object lVideoEncoderNode; lIEncoderNodeFactory.createEncoderNode(lVideoSourceOutputMediaType, new Guid(0xee8c3745, 0xf45b, 0x42b3, 0xa8, 0xcc, 0xc7, 0xa6, 0x96, 0x44, 0x9, 0x55), 75, 0, lOutputNode[1], out lVideoEncoderNode); object lAudioEncoderNode; lAACIEncoderNodeFactory.createEncoderNode( lAudioSourceOutputMediaType, new Guid(0xca37e2be, 0xbec0, 0x4b17, 0x94, 0x6d, 0x44, 0xfb, 0xc1, 0xb3, 0xdf, 0x55), 75, 0, lOutputNode[0], out lAudioEncoderNode); object lVideoSourceSourceNode; mSourceControl.createSourceNode( lScreenCaptureSymbolicLink, lVideoSourceIndexStream, lVideoSourceIndexMediaType, lVideoEncoderNode, out lVideoSourceSourceNode); object lAudioSourceSourceNode; mSourceControl.createSourceNode( lAudioLoopBack, lAudioSourceIndexStream, lAudioSourceIndexMediaType, lAudioEncoderNode, out lAudioSourceSourceNode); mISessionControl = mCaptureManager.createSessionControl(); object[] lSourceNodes = { lVideoSourceSourceNode, lAudioSourceSourceNode }; mISession = mISessionControl.createSession(lSourceNodes); if (mISession != null) { mState.Text = "Ready for connection"; } }
public object getCompressedMediaType() { object lresult = null; do { var lselectedNode = m_EncodersComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lEncoderGuidAttr = lselectedNode.Attributes["CLSID"]; if (lEncoderGuidAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lEncoderGuidAttr.Value, out lCLSIDEncoder)) { break; } lselectedNode = m_EncodingModeComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { break; } var lEncoderModeGuidAttr = lselectedNode.Attributes["GUID"]; if (lEncoderModeGuidAttr == null) { break; } Guid lCLSIDEncoderMode; if (!Guid.TryParse(lEncoderModeGuidAttr.Value, out lCLSIDEncoderMode)) { break; } string lSymbolicLink = SymbolicLink; if (m_StreamComboBox.SelectedIndex < 0) { break; } uint lStreamIndex = (uint)m_StreamComboBox.SelectedIndex; if (m_MediaTypeComboBox.SelectedIndex < 0) { break; } uint lMediaTypeIndex = (uint)m_MediaTypeComboBox.SelectedIndex; object lSourceMediaType = null; if (!mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lSourceMediaType)) { break; } if (lSourceMediaType == null) { break; } IEncoderNodeFactory lEncoderNodeFactory; if (!mEncoderControl.createEncoderNodeFactory( lCLSIDEncoder, out lEncoderNodeFactory)) { break; } if (lEncoderNodeFactory == null) { break; } object lCompressedMediaType; if (!lEncoderNodeFactory.createCompressedMediaType( lSourceMediaType, lCLSIDEncoderMode, 50, (uint)m_CompressedMediaTypesComboBox.SelectedIndex, out lCompressedMediaType)) { break; } lresult = lCompressedMediaType; } while (false); return(lresult); }
private void mDo_Click(object sender, RoutedEventArgs e) { if (mSession != null) { mSession.closeSession(); mSession = null; mDo.Content = "Stopped"; return; } if (mSink == 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' 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; mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lOutputMediaType); var lselectedNode = mEncodersComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { return; } var lEncoderNameAttr = lselectedNode.Attributes["Title"]; if (lEncoderNameAttr == null) { return; } var lCLSIDEncoderAttr = lselectedNode.Attributes["CLSID"]; if (lCLSIDEncoderAttr == null) { return; } Guid lCLSIDEncoder; if (!Guid.TryParse(lCLSIDEncoderAttr.Value, out lCLSIDEncoder)) { return; } IEncoderNodeFactory lEncoderNodeFactory; mEncoderControl.createEncoderNodeFactory( lCLSIDEncoder, out lEncoderNodeFactory); lselectedNode = mEncodingModeComboBox.SelectedItem as XmlNode; if (lselectedNode == null) { return; } var lGUIDEncodingModeAttr = lselectedNode.Attributes["GUID"]; if (lGUIDEncodingModeAttr == null) { return; } Guid lGUIDEncodingMode; if (!Guid.TryParse(lGUIDEncodingModeAttr.Value, out lGUIDEncodingMode)) { return; } if (mCompressedMediaTypesComboBox.SelectedIndex < 0) { return; } object lCompressedMediaType; lEncoderNodeFactory.createCompressedMediaType( lOutputMediaType, lGUIDEncodingMode, 70, (uint)mCompressedMediaTypesComboBox.SelectedIndex, out lCompressedMediaType); var lOutputNode = mSink.getOutputNode(lCompressedMediaType); IEncoderNodeFactory lIEncoderNodeFactory; mEncoderControl.createEncoderNodeFactory( lCLSIDEncoder, out lIEncoderNodeFactory); object lEncoderNode; lIEncoderNodeFactory.createEncoderNode( lOutputMediaType, lGUIDEncodingMode, 70, (uint)mCompressedMediaTypesComboBox.SelectedIndex, lOutputNode, out lEncoderNode); object lSourceMediaNode; 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='0x7000ff55' />" + "</Option.Extensions>" + "</Option>" + "</Options>"; mSourceControl.createSourceNode( lextendSymbolicLink, lStreamIndex, lMediaTypeIndex, lEncoderNode, out lSourceMediaNode); List <object> lSourcesList = new List <object>(); lSourcesList.Add(lSourceMediaNode); mSession = mISessionControl.createSession(lSourcesList.ToArray()); if (mSession != null) { mSession.startSession(0, Guid.Empty); } mDo.Content = "Record is executed!!!"; }
private object getCompressedMediaType( ICaptureProcessor a_ICaptureProcessor, int a_StreamIndex, int a_MediaTypeIndex, XmlNode aEncoderNode, XmlNode aEncoderModeNode, int aCompressedMediaTypeIndex) { object lresult = null; do { if (aCompressedMediaTypeIndex < 0) { break; } object lMediaSource = null; mSourceControl.createSourceFromCaptureProcessor( a_ICaptureProcessor, out lMediaSource); if (lMediaSource == null) { break; } if (a_StreamIndex < 0) { break; } if (a_MediaTypeIndex < 0) { break; } if (aEncoderNode == null) { break; } if (aEncoderModeNode == null) { break; } var lEncoderGuidAttr = aEncoderNode.Attributes["CLSID"]; if (lEncoderGuidAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lEncoderGuidAttr.Value, out lCLSIDEncoder)) { break; } var lEncoderModeGuidAttr = aEncoderModeNode.Attributes["GUID"]; if (lEncoderModeGuidAttr == null) { break; } Guid lCLSIDEncoderMode; if (!Guid.TryParse(lEncoderModeGuidAttr.Value, out lCLSIDEncoderMode)) { break; } uint lStreamIndex = (uint)a_StreamIndex; uint lMediaTypeIndex = (uint)a_MediaTypeIndex; object lSourceMediaType = null; if (!mSourceControl.getSourceOutputMediaTypeFromMediaSource( lMediaSource, lStreamIndex, lMediaTypeIndex, out lSourceMediaType)) { break; } if (lSourceMediaType == null) { break; } IEncoderNodeFactory lEncoderNodeFactory; if (!mEncoderControl.createEncoderNodeFactory( lCLSIDEncoder, out lEncoderNodeFactory)) { break; } if (lEncoderNodeFactory == null) { break; } object lCompressedMediaType; if (!lEncoderNodeFactory.createCompressedMediaType( lSourceMediaType, lCLSIDEncoderMode, 50, (uint)aCompressedMediaTypeIndex, out lCompressedMediaType)) { break; } lresult = lCompressedMediaType; } while (false); return(lresult); }
private object getCompressedMediaType() { object lresult = null; do { Guid lCLSIDEncoderMode = getEncoderMode(); string lSymbolicLink = getSybolicLink(); uint lStreamIndex = Settings.Default.SourceStream; uint lMediaTypeIndex = Settings.Default.SourceMediaType; object lSourceMediaType = null; lSymbolicLink = getScreenCaptureSymbolicLink(lSymbolicLink); if (!mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lSourceMediaType)) { break; } if (lSourceMediaType == null) { break; } IEncoderNodeFactory lEncoderNodeFactory; if (!mEncoderControl.createEncoderNodeFactory( mCLSIDEncoder, out lEncoderNodeFactory)) { break; } if (lEncoderNodeFactory == null) { break; } object lCompressedMediaType; if (!lEncoderNodeFactory.createCompressedMediaType( lSourceMediaType, lCLSIDEncoderMode, (uint)Settings.Default.CompressionQuality, Settings.Default.EncoderMediaType, out lCompressedMediaType)) { break; } lresult = lCompressedMediaType; } while (false); return(lresult); }
private object getCompressedMediaType( object aSourceMediaType, XmlNode aEncoderNode, XmlNode aEncoderModeNode, int aCompressedMediaTypeIndex) { object lresult = null; do { if (aCompressedMediaTypeIndex < 0) { break; } if (aSourceMediaType == null) { break; } if (aEncoderNode == null) { break; } if (aEncoderModeNode == null) { break; } var lEncoderGuidAttr = aEncoderNode.Attributes["CLSID"]; if (lEncoderGuidAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lEncoderGuidAttr.Value, out lCLSIDEncoder)) { break; } var lEncoderModeGuidAttr = aEncoderModeNode.Attributes["GUID"]; if (lEncoderModeGuidAttr == null) { break; } Guid lCLSIDEncoderMode; if (!Guid.TryParse(lEncoderModeGuidAttr.Value, out lCLSIDEncoderMode)) { break; } string lk = ""; mCaptureManager.parseMediaType(aSourceMediaType, out lk); IEncoderNodeFactory lEncoderNodeFactory; if (!mEncoderControl.createEncoderNodeFactory( lCLSIDEncoder, out lEncoderNodeFactory)) { break; } if (lEncoderNodeFactory == null) { break; } object lCompressedMediaType; if (!lEncoderNodeFactory.createCompressedMediaType( aSourceMediaType, lCLSIDEncoderMode, 50, (uint)aCompressedMediaTypeIndex, out lCompressedMediaType)) { break; } lresult = lCompressedMediaType; } while (false); return(lresult); }