Ejemplo n.º 1
0
        private void StartSession()
        {
            object          lPtrSourceNode = null;
            ISourceControl  sourceControl  = CaptureManager.createSourceControl();
            ISessionControl sessionControl = CaptureManager.createSessionControl();

            _EVROutputAdapter = new EVROutputAdapter(Instance, _HWND);

            if (sessionControl != null && sessionControl != null && _EVROutputAdapter.Node != null)
            {
                Session = null;

                sourceControl.createSourceNode(_SymbolicLink,
                                               _StreamIndex,
                                               _MediaTypeIndex,
                                               _EVROutputAdapter.Node,
                                               out lPtrSourceNode);

                Session = sessionControl.createSession(new object[]
                {
                    lPtrSourceNode
                });

                if (Session != null)
                {
                    Session.registerUpdateStateDelegate(HandleSessionStateChanged);
                    Session.startSession(0, Guid.Empty);
                }
            }
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var lThumbnailOutputNode = m_Thumbnail.init(m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode);

            if (lThumbnailOutputNode == null)
            {
                return;
            }

            object lSwitcherNode = getSwitcher();

            if (lSwitcherNode == null)
            {
                return;
            }

            object SpreaderNode = lSwitcherNode;


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

            lOutputNodeList.Add(lSwitcherNode);

            lOutputNodeList.Add(lThumbnailOutputNode);

            mSpreaderNodeFactory.createSpreaderNode(
                lOutputNodeList,
                out SpreaderNode);

            object lSourceNode = getSourceNode(
                m_VideoSourceComboBox.SelectedItem as XmlNode,
                m_VideoStreamComboBox.SelectedItem as XmlNode,
                m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode,
                SpreaderNode);

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

            lSourceNodes.Add(lSourceNode);

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

            if (mISession == null)
            {
                return;
            }

            mSwitcherControl.pauseSwitchers(mISession);

            mIsPausedDisplay = true;

            if (mISession.startSession(0, Guid.Empty))
            {
                m_Thumbnail.start();
            }
        }
Ejemplo n.º 3
0
        private void m_StartStopBtn_Click(object sender, RoutedEventArgs e)
        {
            if (mState == State.Paused && mISession != null)
            {
                mISession.startSession(0, Guid.Empty);

                mState = State.Started;

                m_PauseBtn.IsEnabled = true;

                m_StopBtn.IsEnabled = true;

                m_StartStopBtn.IsEnabled = false;

                return;
            }


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

            if ((bool)m_VideoStreamChkBtn.IsChecked)
            {
                object lCompressedMediaType = getCompressedMediaType(
                    m_VideoSourceComboBox.SelectedItem as XmlNode,
                    m_VideoStreamComboBox.SelectedItem as XmlNode,
                    m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode,
                    m_VideoEncodersComboBox.SelectedItem as XmlNode,
                    m_VideoEncodingModeComboBox.SelectedItem as XmlNode,
                    m_VideoCompressedMediaTypesComboBox.SelectedIndex);

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

            if ((bool)m_AudioStreamChkBtn.IsChecked)
            {
                object lCompressedMediaType = getCompressedMediaType(
                    m_AudioSourceComboBox.SelectedItem as XmlNode,
                    m_AudioStreamComboBox.SelectedItem as XmlNode,
                    m_AudioSourceMediaTypeComboBox.SelectedItem as XmlNode,
                    m_AudioEncodersComboBox.SelectedItem as XmlNode,
                    m_AudioEncodingModeComboBox.SelectedItem as XmlNode,
                    m_AudioCompressedMediaTypesComboBox.SelectedIndex);

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

            List <object> lOutputNodes = getOutputNodes(lCompressedMediaTypeList);

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

            int lOutputIndex = 0;

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

            if ((bool)m_VideoStreamChkBtn.IsChecked && m_VideoCompressedMediaTypesComboBox.SelectedIndex > -1)
            {
                object RenderNode = 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)
                    {
                        RenderNode = lRenderOutputNodesList[0];
                    }
                }



                object lSourceNode = getSourceNode(
                    m_VideoSourceComboBox.SelectedItem as XmlNode,
                    m_VideoStreamComboBox.SelectedItem as XmlNode,
                    m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode,
                    m_VideoEncodersComboBox.SelectedItem as XmlNode,
                    m_VideoEncodingModeComboBox.SelectedItem as XmlNode,
                    m_VideoCompressedMediaTypesComboBox.SelectedIndex,
                    RenderNode,
                    lOutputNodes[lOutputIndex++]);

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

            if ((bool)m_AudioStreamChkBtn.IsChecked && m_AudioCompressedMediaTypesComboBox.SelectedIndex > -1)
            {
                object lSourceNode = getSourceNode(
                    m_AudioSourceComboBox.SelectedItem as XmlNode,
                    m_AudioStreamComboBox.SelectedItem as XmlNode,
                    m_AudioSourceMediaTypeComboBox.SelectedItem as XmlNode,
                    m_AudioEncodersComboBox.SelectedItem as XmlNode,
                    m_AudioEncodingModeComboBox.SelectedItem as XmlNode,
                    m_AudioCompressedMediaTypesComboBox.SelectedIndex,
                    null,
                    lOutputNodes[lOutputIndex++]);

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

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

            if (mISession == null)
            {
                return;
            }

            if (mISession.startSession(0, Guid.Empty))
            {
                mState = State.Started;

                m_PauseBtn.IsEnabled = true;

                m_StopBtn.IsEnabled = true;

                m_StartStopBtn.IsEnabled = false;
            }
        }
        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;
            }
        }
Ejemplo n.º 5
0
        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";
            }
        }
Ejemplo n.º 6
0
        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!!!";
        }
Ejemplo n.º 7
0
        private void m_StartStopBtn_Click(object sender, RoutedEventArgs e)
        {
            m_StartStopBtn.IsEnabled = false;

            if (mIsStarted)
            {
                mIsStarted = false;

                var tl = new Thread(

                    delegate()
                {
                    try
                    {
                        if (mISession == null)
                        {
                            return;
                        }

                        mISession.stopSession();

                        mISession.closeSession();

                        mISession = null;

                        Dispatcher.Invoke(
                            DispatcherPriority.Normal,
                            new Action(() => {
                            m_BtnTxtBlk.Text = "Start";

                            m_StartStopBtn.IsEnabled = true;
                        }));
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                    }
                });
                tl.SetApartmentState(ApartmentState.MTA);

                tl.Start();

                return;
            }

            var l_videoStreamEnabled = (bool)m_VideoStreamChkBtn.IsChecked && m_VideoCompressedMediaTypesComboBox.SelectedIndex > -1;

            var l_previewEnabled = (bool)m_VideoStreamPreviewChkBtn.IsChecked;



            var l_VideoSourceXmlNode                    = m_VideoSourceComboBox.SelectedItem as XmlNode;
            var l_VideoStreamXmlNode                    = m_VideoStreamComboBox.SelectedItem as XmlNode;
            var l_VideoSourceMediaTypeXmlNode           = m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode;
            var l_VideoEncodersXmlNode                  = m_VideoEncodersComboBox.SelectedItem as XmlNode;
            var l_VideoEncodingModeXmlNode              = m_VideoEncodingModeComboBox.SelectedItem as XmlNode;
            var l_VideoCompressedMediaTypeSelectedIndex = m_VideoCompressedMediaTypesComboBox.SelectedIndex;


            var l_audioStreamEnabled = (bool)m_AudioStreamChkBtn.IsChecked && m_AudioCompressedMediaTypesComboBox.SelectedIndex > -1;


            var l_AudioSourceXmlNode          = m_AudioSourceComboBox.SelectedItem as XmlNode;
            var l_AudioStreamXmlNode          = m_AudioStreamComboBox.SelectedItem as XmlNode;
            var l_AudioSourceMediaTypeXmlNode = m_AudioSourceMediaTypeComboBox.SelectedItem as XmlNode;
            var l_AudioEncodersXmlNode        = m_AudioEncodersComboBox.SelectedItem as XmlNode;
            var l_AudioEncodingModeXmlNode    = m_AudioEncodingModeComboBox.SelectedItem as XmlNode;
            var l_AudioCompressedMediaTypeSelectedIndexXmlNode = m_AudioCompressedMediaTypesComboBox.SelectedIndex;

            var lHandle = m_EVRDisplay.Handle;


            object RenderNode = null;

            if (l_previewEnabled)
            {
                //List<object> lRenderOutputNodesList = new List<object>();

                //if (mEVRMultiSinkFactory != null)
                //    mEVRMultiSinkFactory.createOutputNodes(
                //        lHandle,
                //        1,
                //        out lRenderOutputNodesList);

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


                if (mEVRSinkFactory != null)
                {
                    mEVRSinkFactory.createOutputNode(
                        lHandle,
                        out RenderNode);
                }
            }

            var t = new Thread(

                delegate()
            {
                try
                {
                    List <object> lCompressedMediaTypeList = new List <object>();

                    if (l_videoStreamEnabled)
                    {
                        object lCompressedMediaType = getCompressedMediaType(
                            l_VideoSourceXmlNode,
                            l_VideoStreamXmlNode,
                            l_VideoSourceMediaTypeXmlNode,
                            l_VideoEncodersXmlNode,
                            l_VideoEncodingModeXmlNode,
                            l_VideoCompressedMediaTypeSelectedIndex);

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

                    if (l_audioStreamEnabled)
                    {
                        object lCompressedMediaType = getCompressedMediaType(
                            l_AudioSourceXmlNode,
                            l_AudioStreamXmlNode,
                            l_AudioSourceMediaTypeXmlNode,
                            l_AudioEncodersXmlNode,
                            l_AudioEncodingModeXmlNode,
                            l_AudioCompressedMediaTypeSelectedIndexXmlNode);

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

                    List <object> lOutputNodes = getOutputNodes(lCompressedMediaTypeList);

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


                    int lOutputIndex = 0;

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

                    if (l_videoStreamEnabled)
                    {
                        object lSourceNode = getSourceNode(
                            l_VideoSourceXmlNode,
                            l_VideoStreamXmlNode,
                            l_VideoSourceMediaTypeXmlNode,
                            l_VideoEncodersXmlNode,
                            l_VideoEncodingModeXmlNode,
                            l_VideoCompressedMediaTypeSelectedIndex,
                            RenderNode,
                            lOutputNodes[lOutputIndex++]);

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

                    if (l_audioStreamEnabled)
                    {
                        object lSourceNode = getSourceNode(
                            l_AudioSourceXmlNode,
                            l_AudioStreamXmlNode,
                            l_AudioSourceMediaTypeXmlNode,
                            l_AudioEncodersXmlNode,
                            l_AudioEncodingModeXmlNode,
                            l_AudioCompressedMediaTypeSelectedIndexXmlNode,
                            null,
                            lOutputNodes[lOutputIndex++]);

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

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

                    if (mISession == null)
                    {
                        return;
                    }

                    if (mISession.startSession(0, Guid.Empty))
                    {
                        Dispatcher.Invoke(
                            DispatcherPriority.Normal,
                            new Action(() => {
                            m_BtnTxtBlk.Text = "Stop";

                            m_StartStopBtn.IsEnabled = true;
                        }));
                    }

                    mIsStarted = true;
                }
                catch (Exception ex)
                {
                }
                finally
                {
                }
            });

            t.SetApartmentState(ApartmentState.MTA);

            t.Start();
        }
Ejemplo n.º 8
0
        private void m_StartBtn_Click(object sender, RoutedEventArgs e)
        {
            if (mState == State.Paused && mISession != null)
            {
                mSwitcherControl.resumeSwitchers(mISession);

                mState = State.Started;

                m_PauseBtn.IsEnabled = true;

                m_StopBtn.IsEnabled = true;

                m_StartStopBtn.IsEnabled = false;

                return;
            }


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


            object lCompressedMediaType = getCompressedMediaType(
                m_VideoSourceComboBox.SelectedItem as XmlNode,
                m_VideoStreamComboBox.SelectedItem as XmlNode,
                m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode,
                m_VideoEncodersComboBox.SelectedItem as XmlNode,
                m_VideoEncodingModeComboBox.SelectedItem as XmlNode,
                m_VideoCompressedMediaTypesComboBox.SelectedIndex);

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

            List <object> lOutputNodes = getOutputNodes(lCompressedMediaTypeList);

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

            int lOutputIndex = 0;

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


            object RenderNode = null;


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

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

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

            object lEncoderNode = getEncoder(
                m_VideoSourceComboBox.SelectedItem as XmlNode,
                m_VideoStreamComboBox.SelectedItem as XmlNode,
                m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode,
                m_VideoEncodersComboBox.SelectedItem as XmlNode,
                m_VideoEncodingModeComboBox.SelectedItem as XmlNode,
                m_VideoCompressedMediaTypesComboBox.SelectedIndex,
                lOutputNodes[lOutputIndex++]);

            if (lEncoderNode == null)
            {
                return;
            }

            object lSwitcherNode = getSwitcher(lEncoderNode);

            if (lSwitcherNode == null)
            {
                return;
            }

            object lSourceNode = getSourceNode(
                m_VideoSourceComboBox.SelectedItem as XmlNode,
                m_VideoStreamComboBox.SelectedItem as XmlNode,
                m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode,
                m_VideoEncodersComboBox.SelectedItem as XmlNode,
                m_VideoEncodingModeComboBox.SelectedItem as XmlNode,
                m_VideoCompressedMediaTypesComboBox.SelectedIndex,
                RenderNode,
                lSwitcherNode);

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

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

            if (mISession == null)
            {
                return;
            }

            mSwitcherControl.pauseSwitchers(mISession);

            if (mISession.startSession(0, Guid.Empty))
            {
                mState = State.Started;

                mRecordingState = State.Paused;

                mStateLabel.Visibility = System.Windows.Visibility.Collapsed;

                m_PauseBtn.IsEnabled = true;

                m_StopBtn.IsEnabled = true;

                m_StartStopBtn.IsEnabled = false;
            }
        }
Ejemplo n.º 9
0
        private void m_StartBtn_Click(object sender, RoutedEventArgs e)
        {
            if (mState == State.Paused && mISession != null)
            {
                mSwitcherControl.resumeSwitchers(mISession);

                mState = State.Started;

                m_PauseBtn.IsEnabled = true;

                m_StopBtn.IsEnabled = true;

                m_StartStopBtn.IsEnabled = false;

                return;
            }

            mVideoSwitcherNode = null;

            mAudioSwitcherNode = null;

            object RenderNode = null;


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

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

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

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

            if ((bool)m_VideoStreamChkBtn.IsChecked)
            {
                mVideoSwitcherNode = createSwitcher(null);

                if (mVideoSwitcherNode == null)
                {
                    return;
                }

                object lSourceNode = getSourceNode(
                    m_VideoSourceComboBox.SelectedItem as XmlNode,
                    m_VideoStreamComboBox.SelectedItem as XmlNode,
                    m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode,
                    m_VideoEncodersComboBox.SelectedItem as XmlNode,
                    m_VideoEncodingModeComboBox.SelectedItem as XmlNode,
                    m_VideoCompressedMediaTypesComboBox.SelectedIndex,
                    RenderNode,
                    mVideoSwitcherNode);

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

            if ((bool)m_AudioStreamChkBtn.IsChecked)
            {
                mAudioSwitcherNode = createSwitcher(null);

                if (mAudioSwitcherNode == null)
                {
                    return;
                }

                object lSourceNode = getSourceNode(
                    m_AudioSourceComboBox.SelectedItem as XmlNode,
                    m_AudioStreamComboBox.SelectedItem as XmlNode,
                    m_AudioSourceMediaTypeComboBox.SelectedItem as XmlNode,
                    m_AudioEncodersComboBox.SelectedItem as XmlNode,
                    m_AudioEncodingModeComboBox.SelectedItem as XmlNode,
                    m_AudioCompressedMediaTypesComboBox.SelectedIndex,
                    null,
                    mAudioSwitcherNode);

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

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

            if (mISession == null)
            {
                return;
            }

            if (mISession.startSession(0, Guid.Empty))
            {
                mState = State.Started;

                mRecordingState = State.Paused;

                mStateLabel.Visibility = System.Windows.Visibility.Collapsed;

                m_PauseBtn.IsEnabled = true;

                m_StopBtn.IsEnabled = true;

                m_StartStopBtn.IsEnabled = false;

                mSourceGrid.IsEnabled = false;
            }
        }
Ejemplo n.º 10
0
        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!!!";
        }
Ejemplo n.º 11
0
        private void mControlBtn_Click(object sender, RoutedEventArgs e)
        {
            if (mIsStarted)
            {
                mIsStarted = false;

                if (mISession == null)
                {
                    return;
                }

                mISession.stopSession();

                mISession.closeSession();

                mISession = null;

                m_StartStopBtn.Content = "Start";

                foreach (var item in mISourceItems)
                {
                    var lsourceitem = (ISource)item;

                    if (lsourceitem != null)
                    {
                        lsourceitem.access(true);
                    }
                }

                return;
            }
            else
            {
                IFileSinkFactory lFileSinkFactory = null;

                mSinkControl.createSinkFactory(
                    Guid.Parse("A2A56DA1-EB84-460E-9F05-FEE51D8C81E3"),
                    out lFileSinkFactory);

                if (lFileSinkFactory == null)
                {
                    return;
                }

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

                foreach (var item in mISources)
                {
                    var lCompressedMediaType = item.getCompressedMediaType();

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

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

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

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

                for (int i = 0; i < lOutputNodes.Count; i++)
                {
                    var lSourceNode = mISources[i].getSourceNode(lOutputNodes[i]);

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

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

                if (mISession == null)
                {
                    return;
                }

                if (mISession.startSession(0, Guid.Empty))
                {
                    m_StartStopBtn.Content = "Stop";
                }

                mIsStarted = true;

                foreach (var item in mISourceItems)
                {
                    var lsourceitem = (ISource)item;

                    if (lsourceitem != null)
                    {
                        lsourceitem.access(false);
                    }
                }
            }
        }
        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;
                    }
                }
            }
        }
Ejemplo n.º 13
0
        private void mStartStop_Click(object sender, RoutedEventArgs e)
        {
            if (mState == State.Started)
            {
                mISession.stopSession();

                mISession.closeSession();

                mISession = null;

                mState = State.Stopped;

                mStartStop.Content = "Start";

                return;
            }

            getEncoderInfo();

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

            object lCompressedMediaType = getCompressedMediaType();

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

            List <object> lOutputNodes = getOutputNodes(lCompressedMediaTypeList);

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

            int lOutputIndex = 0;

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


            object RenderNode = 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)
                {
                    RenderNode = lRenderOutputNodesList[0];
                }
            }



            object lSourceNode = getSourceNode(
                RenderNode,
                lOutputNodes[lOutputIndex++]);

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

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

            if (mISession == null)
            {
                return;
            }

            if (mISession.startSession(0, Guid.Empty))
            {
                mState = State.Started;

                mStartStop.Content = "Stop";
            }
        }
Ejemplo n.º 14
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);
            }
        }
Ejemplo n.º 15
0
        private void m_StartBtn_Click(object sender, RoutedEventArgs e)
        {
            if (mState == State.Paused && mISession != null)
            {
                mSwitcherControl.resumeSwitchers(mISession);

                mState = State.Started;

                m_PauseBtn.IsEnabled = true;

                m_StopBtn.IsEnabled = true;

                m_StartStopBtn.IsEnabled = false;

                return;
            }


            mVideoSwitcherNode = null;

            mAudioSwitcherNode = null;

            object RenderNode = null;


            var l_videoStreamEnabled = (bool)m_VideoStreamChkBtn.IsChecked;


            XmlNode l_VideoSourceXmlNode          = m_VideoSourceComboBox.SelectedItem as XmlNode;
            XmlNode l_VideoStreamXmlNode          = m_VideoStreamComboBox.SelectedItem as XmlNode;
            XmlNode l_VideoSourceMediaTypeXmlNode = m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode;
            XmlNode l_VideoEncoderXmlNode         = m_VideoEncodersComboBox.SelectedItem as XmlNode;
            XmlNode l_VideoEncodingModeXmlNode    = m_VideoEncodingModeComboBox.SelectedItem as XmlNode;
            var     l_VideoCompressedMediaType    = m_VideoCompressedMediaTypesComboBox.SelectedIndex;



            var l_AudioStreamEnabled = (bool)m_AudioStreamChkBtn.IsChecked;


            XmlNode l_AudioSourceXmlNode          = m_AudioSourceComboBox.SelectedItem as XmlNode;
            XmlNode l_AudioStreamXmlNode          = m_AudioStreamComboBox.SelectedItem as XmlNode;
            XmlNode l_AudioSourceMediaTypeXmlNode = m_AudioSourceMediaTypeComboBox.SelectedItem as XmlNode;
            XmlNode l_AudioEncoderXmlNode         = m_AudioEncodersComboBox.SelectedItem as XmlNode;
            XmlNode l_AudioEncodingModeXmlNode    = m_AudioEncodingModeComboBox.SelectedItem as XmlNode;
            var     l_AudioCompressedMediaType    = m_AudioCompressedMediaTypesComboBox.SelectedIndex;


            var t = new Thread(

                delegate()
            {
                try
                {
                    List <object> lRenderOutputNodesList = new List <object>();

                    if (mEVRMultiSinkFactory != null)
                    {
                        mEVRMultiSinkFactory.createOutputNodes(
                            m_EVRDisplay.SharedResource.SharedHandle,
                            null,
                            1,
                            out lRenderOutputNodesList);
                    }

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

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

                    if (l_videoStreamEnabled)
                    {
                        mVideoSwitcherNode = createSwitcher(null);

                        if (mVideoSwitcherNode == null)
                        {
                            return;
                        }

                        var lSourceNode = getSourceNode(
                            l_VideoSourceXmlNode,
                            l_VideoStreamXmlNode,
                            l_VideoSourceMediaTypeXmlNode,
                            l_VideoEncoderXmlNode,
                            l_VideoEncodingModeXmlNode,
                            l_VideoCompressedMediaType,
                            RenderNode,
                            mVideoSwitcherNode);

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

                            mVideoSourceMediaType = lSourceNode.Item2;
                        }
                        else
                        {
                            mVideoSwitcherNode = null;
                        }
                    }

                    if (l_AudioStreamEnabled)
                    {
                        mAudioSwitcherNode = createSwitcher(null);

                        if (mAudioSwitcherNode == null)
                        {
                            return;
                        }

                        var lSourceNode = getSourceNode(
                            l_AudioSourceXmlNode,
                            l_AudioStreamXmlNode,
                            l_AudioSourceMediaTypeXmlNode,
                            l_AudioEncoderXmlNode,
                            l_AudioEncodingModeXmlNode,
                            l_AudioCompressedMediaType,
                            null,
                            mAudioSwitcherNode);

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

                            mAudioSourceMediaType = lSourceNode.Item2;
                        }
                        else
                        {
                            mAudioSwitcherNode = null;
                        }
                    }


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

                    //mISession = mISessionControl.createUnblockedSession(lSourceNodes.ToArray());

                    if (mISession == null)
                    {
                        return;
                    }

                    mISession.registerUpdateStateDelegate(UpdateStateDelegate);

                    if (mISession.startSession(0, Guid.Empty))
                    {
                        mState = State.Started;


                        Dispatcher.Invoke(
                            DispatcherPriority.Normal,
                            new Action(() =>
                        {
                            mStateLabel.Visibility = System.Windows.Visibility.Collapsed;

                            m_PauseBtn.IsEnabled = true;

                            m_StopBtn.IsEnabled = true;

                            m_StartStopBtn.IsEnabled = false;

                            mSourceGrid.IsEnabled = false;
                        }));
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                }
            });

            t.SetApartmentState(ApartmentState.MTA);

            t.Start();
        }
        private void mStartStop_Click(object sender, RoutedEventArgs e)
        {
            m_VideoSymbolicLink = getVideoSybolicLink();

            bool l_is_VideoStreamPreview = (bool)m_VideoStreamPreviewChkBtn.IsChecked;

            mStartStop.IsEnabled = false;

            var t = new Thread(

                delegate()
            {
                if (mState == State.Started)
                {
                    mISession.stopSession();

                    mISession.closeSession();

                    mISession = null;

                    mState = State.Stopped;

                    App.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (ThreadStart) delegate()
                    {
                        mStartStop.Content = "Start";

                        mStartStop.IsEnabled = true;
                    });

                    return;
                }

                getEncoderInfo();

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

                object lCompressedMediaType = getVideoCompressedMediaType();

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

                lCompressedMediaType = getAudioCompressedMediaType();

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

                List <object> lOutputNodes = getOutputNodes(lCompressedMediaTypeList);

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

                int lOutputIndex = 0;

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


                object RenderNode = null;

                if (l_is_VideoStreamPreview)
                {
                    List <object> lRenderOutputNodesList = new List <object>();

                    if (mEVRMultiSinkFactory != null)
                    {
                        mEVRMultiSinkFactory.createOutputNodes(
                            m_EVRDisplay.Handle,
                            null,
                            1,
                            out lRenderOutputNodesList);
                    }

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



                object lSourceNode = getVideoSourceNode(
                    RenderNode,
                    lOutputNodes[lOutputIndex++]);

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


                lSourceNode = getAudioSourceNode(
                    lOutputNodes[lOutputIndex++]);

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

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

                if (mISession == null)
                {
                    return;
                }

                if (mISession.startSession(0, Guid.Empty))
                {
                    mState = State.Started;

                    App.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (ThreadStart) delegate()
                    {
                        mStartStop.Content = "Stop";

                        mStartStop.IsEnabled = true;
                    });
                }
            });

            t.SetApartmentState(ApartmentState.MTA);

            t.Start();
        }