private void 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;
            }

            mSinkControl.createSinkFactory(
                Guid.Parse(lSelectedAttr.Value),
                out mFileSinkFactory);



            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 = "";

            mEncoderControl.getCollectionOfEncoders(out l_EncodersXMLstring);


            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 = getCompressedMediaType(
                    lScreenCaptureSymbolicLink,
                    lVideoSourceIndexStream,
                    lVideoSourceIndexMediaType,
                    l_VideoEncoder,
                    m_VideoEncoderMode,
                    l_VideoCompressedMediaTypeSelectedIndex);

                if (lCompressedMediaType != null)
                {
                    lCompressedMediaTypeList.Add(lCompressedMediaType);
                }
            }


            if (true)
            {
                object lCompressedMediaType = getCompressedMediaType(
                    lAudioLoopBack,
                    lAudioSourceIndexStream,
                    lAudioSourceIndexMediaType,
                    l_AudioEncoder,
                    m_AudioEncoderMode,
                    l_AudioCompressedMediaTypeSelectedIndex);

                if (lCompressedMediaType != null)
                {
                    lCompressedMediaTypeList.Add(lCompressedMediaType);
                }
            }


            List <object> lOutputNodes = getOutputNodes(lCompressedMediaTypeList, lFilename);

            if (lOutputNodes == null || lOutputNodes.Count == 0)
            {
                return;
            }

            IEVRSinkFactory lSinkFactory;

            mSinkControl.createSinkFactory(
                Guid.Empty,
                out lSinkFactory);

            object lEVROutputNode = null;

            lSinkFactory.createOutputNode(
                mVideoPanel.Handle,
                out lEVROutputNode);

            if (lEVROutputNode == null)
            {
                return;
            }


            object SpreaderNode = lEVROutputNode;

            if (true)
            {
                var lEncoderNode = getEncoderNode(
                    lScreenCaptureSymbolicLink,
                    lVideoSourceIndexStream,
                    lVideoSourceIndexMediaType,
                    l_VideoEncoder,
                    m_VideoEncoderMode,
                    l_VideoCompressedMediaTypeSelectedIndex,
                    lOutputNodes[0]);

                List <object> lOutputNodeList = new List <object>();

                lOutputNodeList.Add(lEncoderNode);

                lOutputNodeList.Add(lEVROutputNode);

                mSpreaderNodeFactory.createSpreaderNode(
                    lOutputNodeList,
                    out SpreaderNode);

                //SpreaderNode = lEncoderNode;
            }



            IMixerNodeFactory lMixerNodeFactory = null;

            mStreamControl.createStreamControlNodeFactory(ref lMixerNodeFactory);

            List <object> lVideoTopologyInputMixerNodes;

            lMixerNodeFactory.createMixerNodes(
                SpreaderNode,
                2,
                out lVideoTopologyInputMixerNodes);

            if (lVideoTopologyInputMixerNodes.Count == 0)
            {
                return;
            }

            for (int i = 1; i < lVideoTopologyInputMixerNodes.Count; i++)
            {
                mVideoTopologyInputMixerNodes.Add(lVideoTopologyInputMixerNodes[i]);
            }



            object lAudioEncoderNode = null;

            if (true)
            {
                lAudioEncoderNode = getEncoderNode(
                    lAudioLoopBack,
                    lAudioSourceIndexStream,
                    lAudioSourceIndexMediaType,
                    l_AudioEncoder,
                    m_AudioEncoderMode,
                    l_AudioCompressedMediaTypeSelectedIndex,
                    lOutputNodes[1]);
            }


            List <object> lAudioTopologyInputMixerNodes;

            lMixerNodeFactory.createMixerNodes(
                lAudioEncoderNode,
                2,
                out lAudioTopologyInputMixerNodes);

            if (lAudioTopologyInputMixerNodes.Count == 0)
            {
                return;
            }

            mAudioTopologyInputMixerNode = lAudioTopologyInputMixerNodes[1];



            List <object> lSourceNodes = new List <object>();

            if (true)
            {
                object lSourceNode = getSourceNode(
                    lScreenCaptureSymbolicLink,
                    lVideoSourceIndexStream,
                    lVideoSourceIndexMediaType,
                    lVideoTopologyInputMixerNodes[0]);

                if (lSourceNodes != null)
                {
                    lSourceNodes.Add(lSourceNode);
                }
            }



            if (true)
            {
                object lSourceNode = getSourceNode(
                    lAudioLoopBack,
                    lAudioSourceIndexStream,
                    lAudioSourceIndexMediaType,
                    lAudioTopologyInputMixerNodes[0]);

                if (lSourceNodes != null)
                {
                    lSourceNodes.Add(lSourceNode);
                }
            }


            mISession = mISessionControl.createSession(lSourceNodes.ToArray());

            if (mISession != null)
            {
                mStartStopTxtBlk.Text = "Stop";

                mISession.startSession(0, Guid.Empty);

                mSourcesPanel.IsEnabled = true;
            }
        }
Exemplo n.º 2
0
        private void init()
        {
            var l_image_source = 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;
            }

            mSinkControl.createSinkFactory(
                Guid.Parse(lSelectedAttr.Value),
                out mFileSinkFactory);



            // Video Source
            uint lVideoSourceIndexStream = 0;

            uint lVideoSourceIndexMediaType = 0;

            int l_VideoCompressedMediaTypeSelectedIndex = 0;



            string l_EncodersXMLstring = "";

            mEncoderControl.getCollectionOfEncoders(out l_EncodersXMLstring);


            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 = getCompressedMediaType(
                    l_image_source,
                    lVideoSourceIndexStream,
                    lVideoSourceIndexMediaType,
                    l_VideoEncoder,
                    m_VideoEncoderMode,
                    l_VideoCompressedMediaTypeSelectedIndex);

                if (lCompressedMediaType != null)
                {
                    lCompressedMediaTypeList.Add(lCompressedMediaType);
                }
            }

            List <object> lOutputNodes = getOutputNodes(lCompressedMediaTypeList, lFilename);

            if (lOutputNodes == null || lOutputNodes.Count == 0)
            {
                return;
            }

            IEVRSinkFactory lSinkFactory;

            mSinkControl.createSinkFactory(
                Guid.Empty,
                out lSinkFactory);

            object lEVROutputNode = null;

            lSinkFactory.createOutputNode(
                mVideoPanel.Handle,
                out lEVROutputNode);

            if (lEVROutputNode == null)
            {
                return;
            }


            object SpreaderNode = lEVROutputNode;

            if (true)
            {
                var lEncoderNode = 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);

                mSpreaderNodeFactory.createSpreaderNode(
                    lOutputNodeList,
                    out SpreaderNode);
            }

            List <object> lSourceNodes = new List <object>();

            object lSourceNode = null;

            mSourceControl.createSourceNodeFromExternalSourceWithDownStreamConnection(
                l_image_source,
                lVideoSourceIndexStream,
                lVideoSourceIndexMediaType,
                SpreaderNode,
                out lSourceNode);

            if (lSourceNode == null)
            {
                return;
            }

            lSourceNodes.Add(lSourceNode);

            mISession = mISessionControl.createSession(lSourceNodes.ToArray());

            if (mISession != null)
            {
                mStartStopTxtBlk.Text = "Stop";

                mISession.startSession(0, Guid.Empty);
            }
        }