private async void m_StopBtn_Click(object sender, RoutedEventArgs e)
        {
            if (mState != State.Stopped)
            {
                m_StopBtn.IsEnabled = false;

                m_PauseBtn.IsEnabled = false;

                mSourceGrid.IsEnabled = true;

                mState = State.Stopped;

                if (mISession == null)
                {
                    return;
                }

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

                await mISession.stopSessionAsync();

                await mISession.closeSessionAsync();

                mISession = null;

                m_StartStopBtn.IsEnabled = true;

                m_PauseBtn.Content = "Start recording";
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (mISession != null)
            {
                mStartStopTxtBlk.Text = "Start";

                await mISession.stopSessionAsync();

                await mISession.closeSessionAsync();

                mISession = null;

                return;
            }

            await init();
        }
        private async void m_StopBtn_Click(object sender, RoutedEventArgs e)
        {
            m_PauseBtn.IsEnabled = false;

            m_StopBtn.IsEnabled = false;

            if (mState != State.Stopped)
            {
                mState = State.Stopped;

                if (mISession == null)
                {
                    return;
                }

                await mISession.stopSessionAsync();

                await mISession.closeSessionAsync();

                mISession = null;

                m_StartStopBtn.IsEnabled = true;
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            mStartStopBtn.IsEnabled = false;

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

                    await mISession.stopSessionAsync();

                    await mISession.closeSessionAsync();

                    mISession = null;

                    mSourcesPanel.IsEnabled = false;

                    if (mAddCameraSession != null)
                    {
                        await mAddCameraSession.stopSessionAsync();

                        await mAddCameraSession.closeSessionAsync();

                        mAddCameraSession = null;

                        mAddCameraTxtBlk.Text = "Add Camera";

                        mVideoTopologyInputMixerNodes.Add(mCameraVideoTopologyInputMixerNode);

                        mCameraVideoTopologyInputMixerNode = null;
                    }

                    if (mAddImageSession != null)
                    {
                        await mAddImageSession.stopSessionAsync();

                        await mAddImageSession.closeSessionAsync();

                        mAddImageSession = null;

                        mAddImageTxtBlk.Text = "Add Image";

                        mVideoTopologyInputMixerNodes.Add(mImageVideoTopologyInputMixerNode);

                        mImageVideoTopologyInputMixerNode = null;
                    }

                    if (mAddMicSession != null)
                    {
                        await mAddMicSession.stopSessionAsync();

                        await mAddMicSession.closeSessionAsync();

                        mAddMicSession = null;
                    }

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(mAudioTopologyInputMixerNode);

                    mAudioTopologyInputMixerNode = null;

                    foreach (var item in mVideoTopologyInputMixerNodes)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(item);
                    }

                    mVideoTopologyInputMixerNodes.Clear();

                    break;
                }

                await init();
            } while (false);

            mStartStopBtn.IsEnabled = true;
        }
        private async void mLaunchButton_Click(object sender, RoutedEventArgs e)
        {
            mLaunchButton.IsEnabled = false;

            do
            {
                if (mLaunchButton.Content.ToString() == "Stop")
                {
                    if (mISession != null)
                    {
                        await mISession.stopSessionAsync();

                        await mISession.closeSessionAsync();

                        mLaunchButton.Content = "Launch";
                    }

                    mISession = null;

                    break;
                }

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


                string lxmldoc = await mCaptureManager.getCollectionOfSinksAsync();

                XmlDocument doc = new XmlDocument();

                doc.LoadXml(lxmldoc);

                var lSinkNode = doc.SelectSingleNode("SinkFactories/SinkFactory[@GUID='{2F34AF87-D349-45AA-A5F1-E4104D5C458E}']");

                if (lSinkNode == null)
                {
                    break;
                }

                var lContainerNode = lSinkNode.SelectSingleNode("Value.ValueParts/ValuePart[1]");

                if (lContainerNode == null)
                {
                    break;
                }

                var lSinkControl = await mCaptureManager.createSinkControlAsync();

                var lSinkFactory = await lSinkControl.createEVRSinkFactoryAsync(
                    Guid.Empty);

                if (mEVROutputNode == null)
                {
                    mEVROutputNode = await lSinkFactory.createOutputNodeAsync(
                        mVideoPanel.Handle);
                }

                if (mEVROutputNode == null)
                {
                    break;
                }

                var lSourceControl = await mCaptureManager.createSourceControlAsync();

                if (lSourceControl == null)
                {
                    break;
                }

                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' Shape='Ellipse'/>" +
                                             "</Option.Extensions>" +
                                             "</Option>" +
                                             "</Options>";

                if ((bool)mNormalizeChkBtn.IsChecked)
                {
                    lextendSymbolicLink += " --normalize=Landscape";
                }

                object lPtrSourceNode = await lSourceControl.createSourceNodeWithDownStreamConnectionAsync(
                    lextendSymbolicLink,
                    lStreamIndex,
                    lMediaTypeIndex,
                    mEVROutputNode);


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

                lSourceMediaNodeList.Add(lPtrSourceNode);

                var lSessionControl = await mCaptureManager.createSessionControlAsync();

                if (lSessionControl == null)
                {
                    break;
                }

                mISession = await lSessionControl.createSessionAsync(
                    lSourceMediaNodeList.ToArray());

                if (mISession == null)
                {
                    break;
                }

                foreach (var item in lSourceMediaNodeList)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(item);
                }

                await mISession.registerUpdateStateDelegateAsync(UpdateStateDelegate);

                await mISession.startSessionAsync(0, Guid.Empty);

                mLaunchButton.Content = "Stop";


                if (_ThumbnailTimer == null)
                {
                    ThumbnailTimer.Start();
                }
            } while (false);

            mLaunchButton.IsEnabled = true;
        }
Пример #6
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            mTitleTxtBlk.IsEnabled = false;

            do
            {
                if (mISession != null)
                {
                    await mISession.stopSessionAsync();

                    await mISession.closeSessionAsync();

                    mISession = null;

                    mTitleTxtBlk.Text = "Start playing";

                    break;
                }

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

                object lSARSinkOutputNode = await mSARSinkFactory.createOutputNodeAsync();

                if (lSARSinkOutputNode == null)
                {
                    break;
                }


                var l_AudioSourceXmlNode = m_AudioSourceComboBox.SelectedItem as XmlNode;

                if (l_AudioSourceXmlNode == null)
                {
                    break;
                }

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

                if (lNode == null)
                {
                    break;
                }

                string lSymbolicLink = lNode.Value;

                object lSourceNode = await mSourceControl.createSourceNodeWithDownStreamConnectionAsync(
                    lSymbolicLink,
                    0,
                    0,
                    lSARSinkOutputNode);

                if (lSourceNode == null)
                {
                    break;
                }

                lSourceNodes.Add(lSourceNode);

                mISession = await mISessionControl.createSessionAsync(lSourceNodes.ToArray());

                if (mISession == null)
                {
                    break;
                }

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

                    uint lChannelCount = 0;

                    lChannelCount = await mISARVolumeControl.getChannelCountAsync(lSARSinkOutputNode);

                    if (lChannelCount > 0)
                    {
                        float lLevel = await mISARVolumeControl.getChannelVolumeAsync(lSARSinkOutputNode, 0);

                        mRVolume.ValueChanged += async(s, ev) => {
                            await mISARVolumeControl.setChannelVolumeAsync(lSARSinkOutputNode, 0, (float)ev.NewValue);
                        };

                        mRVolume.Value = lLevel;

                        if (lChannelCount > 1)
                        {
                            lLevel = await mISARVolumeControl.getChannelVolumeAsync(lSARSinkOutputNode, 1);

                            mLVolume.ValueChanged += async(s, ev) => {
                                await mISARVolumeControl.setChannelVolumeAsync(lSARSinkOutputNode, 1, (float)ev.NewValue);
                            };

                            mLVolume.Value = lLevel;
                        }
                    }
                }
            } while (false);

            mTitleTxtBlk.IsEnabled = true;
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            m_Thumbnail.stop();

            if (mISession != null)
            {
                await mISession.stopSessionAsync();

                await mISession.closeSessionAsync();

                mISession = null;

                return;
            }

            var lThumbnailOutputNode = await m_Thumbnail.init(m_VideoSourceMediaTypeComboBox.SelectedItem as XmlNode);

            if (lThumbnailOutputNode == null)
            {
                return;
            }

            object lSwitcherNode = await getSwitcher();

            if (lSwitcherNode == null)
            {
                return;
            }

            object SpreaderNode = lSwitcherNode;


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

            lOutputNodeList.Add(lSwitcherNode);

            lOutputNodeList.Add(lThumbnailOutputNode);

            SpreaderNode = await mSpreaderNodeFactory.createSpreaderNodeAsync(
                lOutputNodeList);

            object lSourceNode = await 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 = await mISessionControl.createSessionAsync(lSourceNodes.ToArray());

            if (mISession == null)
            {
                return;
            }

            await mSwitcherControl.pauseSwitchersAsync(mISession);

            mIsPausedDisplay = true;

            if (await mISession.startSessionAsync(0, Guid.Empty))
            {
                m_Thumbnail.start();
            }
        }
        private async void mStartStop_Click(object sender, RoutedEventArgs e)
        {
            m_VideoSymbolicLink = getVideoSybolicLink();

            bool l_is_VideoStreamPreview = (bool)m_VideoStreamPreviewChkBtn.IsChecked;

            mStartStop.IsEnabled = false;


            if (mState == State.Started)
            {
                await mISession.stopSessionAsync();

                await mISession.closeSessionAsync();

                mISession = null;

                mState = State.Stopped;

                mStartStop.Content = "Start";

                mStartStop.IsEnabled = true;

                return;
            }

            getEncoderInfo();

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

            object lCompressedMediaType = await getVideoCompressedMediaType();

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

            lCompressedMediaType = await getAudioCompressedMediaType();

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

            List <object> lOutputNodes = await 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)
                {
                    lRenderOutputNodesList = await mEVRMultiSinkFactory.createOutputNodesAsync(
                        m_EVRDisplay.Handle,
                        null,
                        1);
                }

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



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

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


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

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

            mISession = await mISessionControl.createSessionAsync(lSourceNodes.ToArray());

            if (mISession == null)
            {
                return;
            }

            var lisStarted = await mISession.startSessionAsync(0, Guid.Empty);

            if (lisStarted)
            {
                mState = State.Started;

                mStartStop.Content = "Stop";

                mStartStop.IsEnabled = true;
            }
        }
Пример #9
0
        private async void mControlBtn_Click(object sender, RoutedEventArgs e)
        {
            if (mIsStarted)
            {
                mIsStarted = false;

                if (mISession == null)
                {
                    return;
                }

                await mISession.stopSessionAsync();

                await mISession.closeSessionAsync();

                mISession = null;

                m_StartStopBtn.Content = "Start";

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

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

                return;
            }
            else
            {
                var lFileSinkFactory = await mSinkControl.createFileSinkFactoryAsync(
                    Guid.Parse("A2A56DA1-EB84-460E-9F05-FEE51D8C81E3"));

                if (lFileSinkFactory == null)
                {
                    return;
                }

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

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

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

                List <object> lOutputNodes = await 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 = await mISources[i].getSourceNode(lOutputNodes[i]);

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

                mISession = await mISessionControl.createSessionAsync(lSourceNodes.ToArray());

                if (mISession == null)
                {
                    return;
                }

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

                mIsStarted = true;

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

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