private Tuple <object, RtspServer.StreamType, int> createAudioStream(ISampleGrabberCallbackSinkFactory aISampleGrabberCallbackSinkFactory, int aIndexCount) { object result = null; RtspServer.StreamType type = RtspServer.StreamType.Audio; int index = 0; do { Guid lAudioFormat = Guid.Empty; var lAudioCompressedNode = mAudioMediaTypeComboBox.SelectedItem as XmlNode; if (lAudioCompressedNode != null) { var lGUID = lAudioCompressedNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_SUBTYPE']/SingleValue/@GUID"); if (lGUID != null) { Guid.TryParse(lGUID.Value, out lAudioFormat); } } ISampleGrabberCallback lSampleGrabberCallback; aISampleGrabberCallbackSinkFactory.createOutputNode( MFMediaType_Audio, lAudioFormat, out lSampleGrabberCallback); if (lSampleGrabberCallback != null) { lSampleGrabberCallback.mUpdateFullEvent += delegate (uint aSampleFlags, long aSampleTime, long aSampleDuration, byte[] aData, uint aLength) { if (s != null) { lock (s) { currentmillisecond = (uint)aSampleTime / 10000; s.sendData(aIndexCount, (int)type, currentmillisecond * 90, aData); } } }; var lSampleGrabberCallNode = lSampleGrabberCallback.getTopologyNode(); if (lSampleGrabberCallNode != null) { var mEncoderControl = mCaptureManager.createEncoderControl(); var lEncoderNode = mAudioEncoderComboBox.SelectedItem as XmlNode; if (lEncoderNode == null) { break; } var lNode = lEncoderNode.SelectSingleNode("@CLSID"); if (lNode == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lNode.Value, out lCLSIDEncoder)) { break; } IEncoderNodeFactory lIEncoderNodeFactory; mEncoderControl.createEncoderNodeFactory(lCLSIDEncoder, out lIEncoderNodeFactory); if (lIEncoderNodeFactory != null) { var lSourceNode = mAudioSourcesComboBox.SelectedItem as XmlNode; if (lSourceNode == null) { break; } lNode = lSourceNode.SelectSingleNode("Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK']/SingleValue/@Value"); if (lNode == null) { break; } string lSymbolicLink = lNode.Value; lSourceNode = mAudioStreamsComboBox.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 = mAudioMediaTypesComboBox.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 lAudioSourceOutputMediaType; mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lAudioSourceOutputMediaType); object lAudioEncoder; lIEncoderNodeFactory.createEncoderNode(lAudioSourceOutputMediaType, //new Guid(0xee8c3745, 0xf45b, 0x42b3, 0xa8, 0xcc, 0xc7, 0xa6, 0x96, 0x44, 0x9, 0x55), //new Guid(0xca37e2be, 0xbec0, 0x4b17, 0x94, 0x6d, 0x44, 0xfb, 0xc1, 0xb3, 0xdf, 0x55), StreamingCBR, 75, 0, lSampleGrabberCallNode, out lAudioEncoder); mSourceControl.createSourceNode( lSymbolicLink, lStreamIndex, lMediaTypeIndex, lAudioEncoder, out result); if (result != null) { index = aIndexCount; } } } } }while (false); return(Tuple.Create <object, RtspServer.StreamType, int>(result, type, index)); }
private Tuple <object, RtspServer.StreamType, int, string> createVideoStream(ISampleGrabberCallbackSinkFactory aISampleGrabberCallbackSinkFactory, int aIndexCount) { object result = null; RtspServer.StreamType type = RtspServer.StreamType.Video; int index = 0; string format = ""; do { 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; } IEVRSinkFactory lSinkFactory; var lSinkControl = mCaptureManager.createSinkControl(); lSinkControl.createSinkFactory( Guid.Empty, out lSinkFactory); object lEVROutputNode = null; lSinkFactory.createOutputNode( mVideoPanel.Handle, out lEVROutputNode); if (lEVROutputNode == null) { break; } Guid lVideoFormat = Guid.Empty; var lVideoCompressedNode = mVideoMediaTypeComboBox.SelectedItem as XmlNode; if (lVideoCompressedNode != null) { var lGUID = lVideoCompressedNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_SUBTYPE']/SingleValue/@GUID"); if (lGUID != null) { Guid.TryParse(lGUID.Value, out lVideoFormat); } var lvalue = lVideoCompressedNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_SUBTYPE']/SingleValue/@Value"); if (lvalue != null && lvalue.Value != null) { var lsplit = lvalue.Value.Split(new char[] { '_' }); if (lsplit != null && lsplit.Length == 2) { format = lsplit[1]; } if (format == "HEVC") { format = "H265"; } } } ISampleGrabberCallback lSampleGrabberCallback = null; aISampleGrabberCallbackSinkFactory.createOutputNode( MFMediaType_Video, lVideoFormat, out lSampleGrabberCallback); object lOutputNode = lEVROutputNode; if (lSampleGrabberCallback != null) { lSampleGrabberCallback.mUpdateFullEvent += delegate (uint aSampleFlags, long aSampleTime, long aSampleDuration, byte[] aData, uint aLength) { if (s != null) { lock (s) { currentmillisecond += 1; s.sendData(aIndexCount, (int)type, currentmillisecond * 90, aData); currentmillisecond += 20; } } }; var lSampleGrabberCallNode = lSampleGrabberCallback.getTopologyNode(); if (lSampleGrabberCallNode != null) { IStreamControl streamControl = mCaptureManager.createStreamControl(); ISpreaderNodeFactory spreaderNodeFactory = null; object spreaderNode = null; List <object> outputNodeList = new List <object>(); var mEncoderControl = mCaptureManager.createEncoderControl(); var lEncoderNode = mVideoEncoderComboBox.SelectedItem as XmlNode; if (lEncoderNode == null) { break; } lNode = lEncoderNode.SelectSingleNode("@CLSID"); if (lNode == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lNode.Value, out lCLSIDEncoder)) { break; } var lBitRate = (uint)mBitRateComboBox.SelectedItem; IEncoderNodeFactory lIEncoderNodeFactory; mEncoderControl.createEncoderNodeFactory(lCLSIDEncoder, out lIEncoderNodeFactory); if (lIEncoderNodeFactory != null) { object lVideoSourceOutputMediaType; if (mSourceControl == null) { break; } mSourceControl.getSourceOutputMediaType( lSymbolicLink, lStreamIndex, lMediaTypeIndex, out lVideoSourceOutputMediaType); object lVideoEncoderNode; lIEncoderNodeFactory.createEncoderNode(lVideoSourceOutputMediaType, StreamingCBR, lBitRate, 0, lSampleGrabberCallNode, out lVideoEncoderNode); streamControl.createStreamControlNodeFactory(ref spreaderNodeFactory); outputNodeList.Add(lEVROutputNode); outputNodeList.Add(lVideoEncoderNode); spreaderNodeFactory.createSpreaderNode(outputNodeList, out spreaderNode); if (spreaderNode != null) { lOutputNode = spreaderNode; } } } } 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"; mSourceControl.createSourceNode( lextendSymbolicLink, lStreamIndex, lMediaTypeIndex, lOutputNode, out result); if (result != null) { index = aIndexCount; } }while (false); return(Tuple.Create <object, RtspServer.StreamType, int, string>(result, type, index, format)); }