private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (mISession != null)
            {
                mISession.stopSession();

                mISession.closeSession();

                mISession = null;

                mSARSinkOutputNode = null;

                mTitleTxtBlk.Text = "Start playing";

                return;
            }

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

            mSARSinkFactory.createOutputNode(out mSARSinkOutputNode);

            if (mSARSinkOutputNode == null)
            {
                return;
            }


            var l_AudioSourceXmlNode = m_AudioSourceComboBox.SelectedItem as XmlNode;

            if (l_AudioSourceXmlNode == null)
            {
                return;
            }

            var lNode = l_AudioSourceXmlNode.SelectSingleNode(
                "Source.Attributes/Attribute" +
                "[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK']" +
                "/SingleValue/@Value");

            if (lNode == null)
            {
                return;
            }

            string lSymbolicLink = lNode.Value;

            object lSourceNode = null;

            mSourceControl.createSourceNode(
                lSymbolicLink,
                0,
                0,
                mSARSinkOutputNode,
                out lSourceNode);

            if (lSourceNode == null)
            {
                return;
            }

            lSourceNodes.Add(lSourceNode);

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

            if (mISession == null)
            {
                return;
            }

            if (mISession.startSession(0, Guid.Empty))
            {
                mTitleTxtBlk.Text = "Stop playing";

                uint lChannelCount = 0;

                mISARVolumeControl.getChannelCount(mSARSinkOutputNode, out lChannelCount);

                if (lChannelCount > 0)
                {
                    float lLevel = 0;

                    mISARVolumeControl.getChannelVolume(mSARSinkOutputNode, 0, out lLevel);

                    mRVolume.Value = lLevel;

                    if (lChannelCount > 1)
                    {
                        lLevel = 0;

                        mISARVolumeControl.getChannelVolume(mSARSinkOutputNode, 1, out lLevel);

                        mLVolume.Value = lLevel;
                    }
                }
            }
        }
        private Tuple <object, string, int> createVideoStream(ISampleGrabberCallbackSinkFactory aISampleGrabberCallbackSinkFactory, int aIndexCount)
        {
            object result = null;

            int index = 0;

            string lMediaType = "";

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

                ISampleGrabberCallback lH264SampleGrabberCallback;

                aISampleGrabberCallbackSinkFactory.createOutputNode(
                    MFMediaType_Video,
                    MFVideoFormat_H264,
                    out lH264SampleGrabberCallback);

                object lOutputNode = lEVROutputNode;

                if (lH264SampleGrabberCallback != null)
                {
                    lH264SampleGrabberCallback.mUpdateNativeFullEvent += delegate
                                                                         (uint aSampleFlags, long aSampleTime, long aSampleDuration, IntPtr aData, uint aSize)
                    {
                        if (s != null)
                        {
                            lock (s)
                            {
                                Console.WriteLine("aSampleFlags: {0}", aSampleFlags);

                                currentmillisecond += 1;

                                s.sendVideoData(currentmillisecond, aData, (int)aSize, aSampleFlags, aIndexCount);

                                currentmillisecond += 33;
                            }
                        }
                    };

                    var lSampleGrabberCallNode = lH264SampleGrabberCallback.getTopologyNode();

                    if (lSampleGrabberCallNode != null)
                    {
                        IStreamControl       streamControl       = mCaptureManager.createStreamControl();
                        ISpreaderNodeFactory spreaderNodeFactory = null;
                        object        spreaderNode   = null;
                        List <object> outputNodeList = new List <object>();



                        var mEncoderControl = mCaptureManager.createEncoderControl();

                        string lxmldoc = "";

                        XmlDocument doc = new XmlDocument();

                        mCaptureManager.getCollectionOfEncoders(ref lxmldoc);

                        doc.LoadXml(lxmldoc);

                        var l_VideoEncoderNode = doc.SelectSingleNode("EncoderFactories/Group[@GUID='{73646976-0000-0010-8000-00AA00389B71}']/EncoderFactory[@IsStreaming='TRUE'][1]/@CLSID");

                        if (l_VideoEncoderNode == null)
                        {
                            break;
                        }

                        Guid lCLSIDVideoEncoder;

                        if (!Guid.TryParse(l_VideoEncoderNode.Value, out lCLSIDVideoEncoder))
                        {
                            break;
                        }



                        IEncoderNodeFactory lIEncoderNodeFactory;

                        mEncoderControl.createEncoderNodeFactory(lCLSIDVideoEncoder, out lIEncoderNodeFactory);

                        if (lIEncoderNodeFactory != null)
                        {
                            object lVideoSourceOutputMediaType;

                            if (mSourceControl == null)
                            {
                                break;
                            }

                            mSourceControl.getSourceOutputMediaType(
                                lSymbolicLink,
                                lStreamIndex,
                                lMediaTypeIndex,
                                out lVideoSourceOutputMediaType);



                            string lxmlDoc;

                            mEncoderControl.getMediaTypeCollectionOfEncoder(
                                lVideoSourceOutputMediaType,
                                lCLSIDVideoEncoder,
                                out lxmlDoc);

                            doc = new System.Xml.XmlDocument();

                            doc.LoadXml(lxmlDoc);

                            var lGroup = doc.SelectSingleNode("EncoderMediaTypes/Group[@GUID='{8F6FF1B6-534E-49C0-B2A8-16D534EAF135}']");

                            uint lMaxBitRate = 0;

                            if (lGroup != null)
                            {
                                var lAttr = lGroup.SelectSingleNode("@MaxBitRate");

                                if (lAttr != null)
                                {
                                    uint.TryParse(lAttr.Value, out lMaxBitRate);
                                }
                            }



                            object lVideoEncoderNode;

                            lIEncoderNodeFactory.createEncoderNode(
                                lVideoSourceOutputMediaType,
                                StreamingCBR,
                                lMaxBitRate,
                                0,
                                lSampleGrabberCallNode,
                                out lVideoEncoderNode);

                            object lCompressedMediaType;

                            lIEncoderNodeFactory.createCompressedMediaType(
                                lVideoSourceOutputMediaType,
                                StreamingCBR,
                                lMaxBitRate,
                                0,
                                out lCompressedMediaType);


                            streamControl.createStreamControlNodeFactory(ref spreaderNodeFactory);
                            outputNodeList.Add(lEVROutputNode);
                            outputNodeList.Add(lVideoEncoderNode);
                            spreaderNodeFactory.createSpreaderNode(outputNodeList,
                                                                   out spreaderNode);


                            if (spreaderNode != null)
                            {
                                lOutputNode = spreaderNode;
                            }

                            mCaptureManager.parseMediaType(lCompressedMediaType, out lMediaType);
                        }
                    }
                }

                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, string, int>(result, lMediaType, index));
        }
Ejemplo n.º 3
0
        private object getSourceNode(
            XmlNode aSourceNode,
            XmlNode aStreamNode,
            XmlNode aMediaTypeNode,
            XmlNode aEncoderNode,
            XmlNode aEncoderModeNode,
            int aCompressedMediaTypeIndex,
            object PreviewRenderNode,
            object aSwitcherNode)
        {
            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;

                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 SpreaderNode = aSwitcherNode;

                if (PreviewRenderNode != null)
                {
                    List <object> lOutputNodeList = new List <object>();

                    lOutputNodeList.Add(PreviewRenderNode);

                    lOutputNodeList.Add(aSwitcherNode);

                    mSpreaderNodeFactory.createSpreaderNode(
                        lOutputNodeList,
                        out SpreaderNode);
                }

                object lSourceNode;

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

                if (!mSourceControl.createSourceNode(
                        lextendSymbolicLink,
                        lStreamIndex,
                        lMediaTypeIndex,
                        SpreaderNode,
                        out lSourceNode))
                {
                    break;
                }

                lresult = lSourceNode;
            } while (false);

            return(lresult);
        }
        private object getSourceNode(
            string a_SymbolicLink,
            int a_StreamIndex,
            int a_MediaTypeIndex,
            XmlNode aEncoderNode,
            XmlNode aEncoderModeNode,
            int aCompressedMediaTypeIndex,
            object PreviewRenderNode,
            object aOutputNode)
        {
            object lresult = null;

            do
            {
                if (aCompressedMediaTypeIndex < 0)
                {
                    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.getSourceOutputMediaType(
                        a_SymbolicLink,
                        lStreamIndex,
                        lMediaTypeIndex,
                        out lSourceMediaType))
                {
                    break;
                }

                if (lSourceMediaType == null)
                {
                    break;
                }

                IEncoderNodeFactory lEncoderNodeFactory;

                if (!mEncoderControl.createEncoderNodeFactory(
                        lCLSIDEncoder,
                        out lEncoderNodeFactory))
                {
                    break;
                }

                if (lEncoderNodeFactory == null)
                {
                    break;
                }

                object lEncoderNode;

                if (!lEncoderNodeFactory.createEncoderNode(
                        lSourceMediaType,
                        lCLSIDEncoderMode,
                        50,
                        (uint)aCompressedMediaTypeIndex,
                        aOutputNode,
                        out lEncoderNode))
                {
                    break;
                }


                object SpreaderNode = lEncoderNode;

                if (PreviewRenderNode != null)
                {
                    List <object> lOutputNodeList = new List <object>();

                    lOutputNodeList.Add(PreviewRenderNode);

                    lOutputNodeList.Add(lEncoderNode);

                    mSpreaderNodeFactory.createSpreaderNode(
                        lOutputNodeList,
                        out SpreaderNode);
                }

                object lSourceNode;

                if (!mSourceControl.createSourceNode(
                        a_SymbolicLink,
                        lStreamIndex,
                        lMediaTypeIndex,
                        SpreaderNode,
                        out lSourceNode))
                {
                    break;
                }

                lresult = lSourceNode;
            } while (false);

            return(lresult);
        }
Ejemplo n.º 5
0
        private object getSourceNode(
            object PreviewRenderNode,
            object aOutputNode)
        {
            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 lEncoderNode;

                if (!lEncoderNodeFactory.createEncoderNode(
                        lSourceMediaType,
                        lCLSIDEncoderMode,
                        (uint)Settings.Default.CompressionQuality,
                        Settings.Default.EncoderMediaType,
                        aOutputNode,
                        out lEncoderNode))
                {
                    break;
                }


                object SpreaderNode = lEncoderNode;

                if (PreviewRenderNode != null)
                {
                    List <object> lOutputNodeList = new List <object>();

                    lOutputNodeList.Add(PreviewRenderNode);

                    lOutputNodeList.Add(lEncoderNode);

                    mSpreaderNodeFactory.createSpreaderNode(
                        lOutputNodeList,
                        out SpreaderNode);
                }

                object lSourceNode;

                if (!mSourceControl.createSourceNode(
                        lSymbolicLink,
                        lStreamIndex,
                        lMediaTypeIndex,
                        SpreaderNode,
                        out lSourceNode))
                {
                    break;
                }

                lresult = lSourceNode;
            } while (false);

            return(lresult);
        }
        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;

                uint lStreamIndex = 0;

                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));
        }
Ejemplo n.º 7
0
        private object getSourceNode(
            XmlNode aSourceNode,
            XmlNode aStreamNode,
            XmlNode aMediaTypeNode,
            object MixerNode)
        {
            object lresult = null;

            do
            {
                if (aSourceNode == null)
                {
                    break;
                }


                if (aStreamNode == null)
                {
                    break;
                }


                if (aMediaTypeNode == 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 lSourceNode;

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

                if (!mSourceControl.createSourceNode(
                        lextendSymbolicLink,
                        lStreamIndex,
                        lMediaTypeIndex,
                        MixerNode,
                        out lSourceNode))
                {
                    break;
                }

                lresult = lSourceNode;
            } 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;

            var lSelectedStreamItem = (ContainerItem)streamComboBox.SelectedItem;

            if (lSelectedStreamItem == null)
            {
                return;
            }

            lSourceNode = lSelectedStreamItem.mXmlNode;

            if (lSourceNode == null)
            {
                return;
            }

            lNode = lSourceNode.SelectSingleNode("@Index");

            if (lNode == null)
            {
                return;
            }

            uint lStreamIndex = 0;

            if (!uint.TryParse(lNode.Value, out lStreamIndex))
            {
                return;
            }

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

            uint lStreamIndex = 0;

            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!!!";
        }
        public object getSourceNode(object aOutputNode)
        {
            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 lEncoderNode;

                if (!lEncoderNodeFactory.createEncoderNode(
                        lSourceMediaType,
                        lCLSIDEncoderMode,
                        50,
                        (uint)m_CompressedMediaTypesComboBox.SelectedIndex,
                        aOutputNode,
                        out lEncoderNode))
                {
                    break;
                }


                object SpreaderNode = lEncoderNode;

                if (TypeSource == "Video")
                {
                    object PreviewRenderNode = null;

                    // if ((bool)m_VideoStreamPreviewChkBtn.IsChecked)
                    {
                        List <object> lRenderOutputNodesList = new List <object>();

                        if (mEVRMultiSinkFactory != null)
                        {
                            mEVRMultiSinkFactory.createOutputNodes(
                                IntPtr.Zero,
                                m_EVRDisplay.Surface.texture,
                                1,
                                out lRenderOutputNodesList);
                        }

                        if (lRenderOutputNodesList.Count == 1)
                        {
                            PreviewRenderNode = lRenderOutputNodesList[0];
                        }
                    }


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

                    lOutputNodeList.Add(PreviewRenderNode);

                    lOutputNodeList.Add(lEncoderNode);

                    mSpreaderNodeFactory.createSpreaderNode(
                        lOutputNodeList,
                        out SpreaderNode);
                }

                object lSourceNode;

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

                if (!mSourceControl.createSourceNode(
                        lextendSymbolicLink,
                        lStreamIndex,
                        lMediaTypeIndex,
                        SpreaderNode,
                        out lSourceNode))
                {
                    break;
                }

                lresult = lSourceNode;
            } while (false);

            return(lresult);
        }