Esempio n. 1
0
        private void SwitcherConnected()
        {
            btn_reconnect.Enabled = false;
            reactivatebuttons();
            // Get the switcher name:
            string switcherName;
            m_switcher.GetString(_BMDSwitcherPropertyId.bmdSwitcherPropertyIdProductName, out switcherName);
            this.Text = switcherName;

            // Install SwitcherMonitor callbacks:
            m_switcher.AddCallback(m_switcherMonitor);

            // We create input monitors for each input. To do this we iterator over all inputs:
            // This will allow us to update the combo boxes when input names change:
            IBMDSwitcherInputIterator inputIterator;
            if (SwitcherAPIHelper.CreateIterator(m_switcher, out inputIterator))
            {
                IBMDSwitcherInput input;
                inputIterator.Next(out input);
                while (input != null)
                {
                    InputMonitor newInputMonitor = new InputMonitor(input);
                    input.AddCallback(newInputMonitor);

                    m_inputMonitors.Add(newInputMonitor);

                    inputIterator.Next(out input);
                }
            }

            // We want to get the first Mix Effect block (ME 1). We create a ME iterator,
            // and then get the first one:
            m_mixEffectBlock1 = null;
            IBMDSwitcherMixEffectBlockIterator meIterator;
            SwitcherAPIHelper.CreateIterator(m_switcher, out meIterator);

            if (meIterator != null)
            {
                meIterator.Next(out m_mixEffectBlock1);
            }

            if (m_mixEffectBlock1 == null)
            {
                MessageBox.Show("Unexpected: Could not get first mix effect block", "Error");
                return;
            }

            // Install MixEffectBlockMonitor callbacks:
            m_mixEffectBlock1.AddCallback(m_mixEffectBlockMonitor);

            m_transition = (BMDSwitcherAPI.IBMDSwitcherTransitionParameters)m_mixEffectBlock1;
            m_transition.AddCallback(m_transitionMonitor);

            IBMDSwitcherKeyIterator keyIterator;
            SwitcherAPIHelper.CreateIterator(m_mixEffectBlock1, out keyIterator);

            if (keyIterator != null)
            {
                keyIterator.Next(out me1_key1);
                keyIterator.Next(out me1_key2);
                keyIterator.Next(out me1_key3);
                keyIterator.Next(out me1_key4);   
            }

            me1_key1.AddCallback(m_keyMonitor);
            me1_key2.AddCallback(m_keyMonitor);
            me1_key3.AddCallback(m_keyMonitor);
            me1_key4.AddCallback(m_keyMonitor);


            if (SwitcherAPIHelper.CreateIterator(m_switcher, out inputIterator))
            {
                IBMDSwitcherInput input;
                inputIterator.Next(out input);
                while (input != null)
                {
                    InputMonitor newInputMonitor = new InputMonitor(input);
                    input.AddCallback(newInputMonitor);
                    m_inputMonitors.Add(newInputMonitor);
                    inputIterator.Next(out input);
                    IntPtr lvPointer;
                    IBMDSwitcherInputIterator lvInputIterator;
                    IBMDSwitcherInput lvInput;
                    string lvPortName;
                    long lvPortType;
                    int lvAUXCount;
                    lvAUXCount = 0;
                    m_switcher.CreateIterator(typeof(IBMDSwitcherInputIterator).GUID, out lvPointer);
                    lvInputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(lvPointer);
                    lvInputIterator.Next(out lvInput);
                    while (lvInput != null)
                    {
                        lvInput.GetString(BMDSwitcherAPI._BMDSwitcherInputPropertyId.bmdSwitcherInputPropertyIdLongName, out lvPortName); // bmdSwitcherInputPropertyIdLongName

                        lvInput.GetInt(BMDSwitcherAPI._BMDSwitcherInputPropertyId.bmdSwitcherInputPropertyIdPortType, out lvPortType);

                        if ((_BMDSwitcherPortType)lvPortType == BMDSwitcherAPI._BMDSwitcherPortType.bmdSwitcherPortTypeColorGenerator)
                        {

                        }

                        if ((_BMDSwitcherPortType)lvPortType == BMDSwitcherAPI._BMDSwitcherPortType.bmdSwitcherPortTypeAuxOutput)
                        {
                            lvAUXCount = lvAUXCount + 1;

                            m_inputAux = (IBMDSwitcherInputAux)lvInput;

                            if (lvAUXCount == 1)
                            {
                                m_AUX1 = m_inputAux;
                            }
                            if (lvAUXCount == 2)
                            {
                                m_AUX2 = m_inputAux;
                            }
                            if (lvAUXCount == 3)
                            {
                                m_AUX3 = m_inputAux;
                            }
                        }
                        lvInputIterator.Next(out lvInput);
                    }
                }
            }
            m_AUX1.AddCallback(m_auxMonitor);
            m_AUX2.AddCallback(m_auxMonitor);
            m_AUX3.AddCallback(m_auxMonitor);
            
            IBMDSwitcherDownstreamKeyIterator dkeyiterator;
            dkeyiterator = null;
            SwitcherAPIHelper.CreateIterator(m_switcher, out dkeyiterator);
            if (dkeyiterator != null)
            {
                dkeyiterator.Next(out me1_dkey1);
                dkeyiterator.Next(out me1_dkey2);
            }

            me1_dkey1.AddCallback(m_dkeyMonitor);
            me1_dkey2.AddCallback(m_dkeyMonitor);

            m_audiomixer = (BMDSwitcherAPI.IBMDSwitcherAudioMixer)m_switcher;
            m_audiomixer.AddCallback(m_audioMixerMonitor);

            IBMDSwitcherAudioInputIterator m_audioInputiterator;
            SwitcherAPIHelper.CreateIterator(m_audiomixer, out m_audioInputiterator);

            if (m_audioInputiterator != null)
            {
                m_audioInputiterator.Next(out m_audioInput);
            }

            m_audioInput.AddCallback(m_audioInputMonitor);

            IBMDSwitcherAudioMonitorOutputIterator m_audioOutputIterator;
            SwitcherAPIHelper.CreateIterator(m_audiomixer, out m_audioOutputIterator);

            if (m_audioOutputIterator != null)
            {
                m_audioOutputIterator.Next(out m_audioMonitorOutput);
            }

            m_audioMonitorOutput.AddCallback(m_audioOutputMonitor);
            btnKey1Air.Enabled = true;
            ProgramInputChanged();
            KeyerOnAirChanged();
            InputAuxChanged();
        }
        private void SwitcherConnected()
        {
            if (SwitcherPanel.IsMainThread)
            {
                new Thread(SwitcherConnected).Start();
                return;
            }
            this.Invoke((Action)(() => { buttonConnect.Enabled = false; }));

            // Get the switcher name:
            string switcherName;

            m_switcher.GetProductName(out switcherName);
            this.Invoke((Action)(() => { textBoxSwitcherName.Text = switcherName; }));

            // Install SwitcherMonitor callbacks:
            m_switcher.AddCallback(m_switcherMonitor);

            // We create input monitors for each input. To do this we iterate over all inputs:
            // This will allow us to update the combo boxes when input names change:
            IBMDSwitcherInputIterator inputIterator = null;
            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

            m_switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);
            if (inputIteratorPtr != null)
            {
                inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
            }

            if (inputIterator != null)
            {
                IBMDSwitcherInput input;
                inputIterator.Next(out input);
                while (input != null)
                {
                    InputMonitor newInputMonitor = new InputMonitor(input);
                    input.AddCallback(newInputMonitor);
                    newInputMonitor.LongNameChanged += new SwitcherEventHandler(OnInputLongNameChanged);

                    m_inputMonitors.Add(newInputMonitor);

                    inputIterator.Next(out input);
                }
            }

            // We want to get the first Mix Effect block (ME 1). We create a ME iterator,
            // and then get the first one:
            m_mixEffectBlock1 = null;

            IBMDSwitcherMixEffectBlockIterator meIterator = null;
            IntPtr meIteratorPtr;
            Guid   meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID;

            m_switcher.CreateIterator(ref meIteratorIID, out meIteratorPtr);
            if (meIteratorPtr != null)
            {
                meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr);
            }

            if (meIterator == null)
            {
                return;
            }

            if (meIterator != null)
            {
                meIterator.Next(out m_mixEffectBlock1);
            }

            if (m_mixEffectBlock1 == null)
            {
                this.Invoke((Action)(() => { MessageBox.Show("Unexpected: Could not get first mix effect block", "Error"); }));
                return;
            }

            // Install MixEffectBlockMonitor callbacks:
            m_mixEffectBlock1.AddCallback(m_mixEffectBlockMonitor);

            this.Invoke((Action)(() =>
            {
                MixEffectBlockSetEnable(true);
            }));
            UpdatePopupItems();
            UpdateTransitionFramesRemaining();
            UpdateSliderPosition();
        }