コード例 #1
0
ファイル: SwitcherControl.cs プロジェクト: Gustice/SimpleCut
        private void SwitcherConnected()
        {
            string switcherName;

            m_switcher.GetProductName(out switcherName);
            SwitcherName = switcherName;

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

            GetInputs();

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

            m_switcherKey       = GetSwitcherKey1(m_mixEffectBlock1);
            m_switcherKeyPreset = GetKeyParam(m_mixEffectBlock1);
            m_transitionParam   = GetKeyTransition(m_mixEffectBlock1);

            UpdatePopupItems();
            UpdateSliderPosition();
            IsConnected = true;

            m_switcherKey.SetOnAir(0);
        }
コード例 #2
0
        public AtemSDKStateMonitor(IBMDSwitcher switcher)
        {
            this.switcher = switcher;
            //switcher.AllowStreamingToResume();

            _root = new SwitcherPropertiesCallback(() => OnStateChange?.Invoke(this));
            switcher.AddCallback(_root);
        }
コード例 #3
0
        private void SwitcherConnected()
        {
            // TODO: Make this an event

            // Get the switcher name:
            m_switcher.GetProductName(out string switcherName);

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

            // mix effects blocks
            getMEBlocks();

            if (this.Connected != null)
            {
                Connected(this, new EventArgs());
            }
        }
コード例 #4
0
        IBMDSwitcher ConnectImpl()
        {
            if (string.IsNullOrEmpty(_ipaddress))
            {
                Console.WriteLine("Warning: IP address has not been initialized. I do not like your chances.");
            }

            if (_switcher == null || !_isConnected)
            {
                var discovery = new CBMDSwitcherDiscovery();
                _BMDSwitcherConnectToFailure failure = 0;
                try
                {
                    discovery.ConnectTo(_ipaddress, out _switcher, out failure);
                }
                catch (System.Runtime.InteropServices.COMException e)
                {
                    _logger.LogWarning(e, $"Could not connect: {failure}");
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Could not connect");
                }
                if (failure == 0)
                {
                    _isConnected = true;
                    _switcher.AddCallback(this);
                    _switcher.GetProductName(out string productName);
                    _logger.LogInformation($"Happy Days... connected to {productName}@{_ipaddress}!");
                }
                else
                {
                    _logger.LogWarning(failure.ToString());
                }
            }

            return(_switcher);
        }
コード例 #5
0
        public void Connect()
        {
            if (IsConnected)
            {
                throw new InvalidOperationException("Already connected");
            }

            _BMDSwitcherConnectToFailure failed = 0;

            try
            {
                switcherDiscovery.ConnectTo(ipAddress.ToString(), out switcher, out failed);
                switcher.GetProductName(out name);
                switcher.AddCallback(switcherMonitor);

                inputs.Clear();
                foreach (var item in GetInputs())
                {
                    inputs.Add(new Input(this, item));
                }
            }
            catch (COMException)
            {
                switch (failed)
                {
                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureNoResponse:
                    throw new Exception("No response from Switcher");

                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware:
                    throw new Exception("Switcher has incompatible firmware");

                default:
                    throw new Exception("Connection failed for unknown reason");
                }
            }
        }
コード例 #6
0
 public SwitcherMonitor(IBMDSwitcher switcher)
 {
     Switcher = switcher;
     switcher.AddCallback(this);
 }
コード例 #7
0
        public BMDSwitcherManagement(string address)
        {
            //_synchContext = System.Threading.SynchronizationContext.Current;

            m_switcherMonitor = new SwitcherMonitor();
            m_switcherMonitor.SwitcherDisconnected += OnSwitcherDisconnected;


            m_mixEffectBlockMonitor = new MixEffectBlockMonitor();
            m_mixEffectBlockMonitor.ProgramInputChanged += OnProgramInputChanged;

            m_switcherDiscovery = new CBMDSwitcherDiscovery();

            if (m_switcherDiscovery == null)
            {
                return;
            }

            _BMDSwitcherConnectToFailure failReason = 0;

            try
            {
                // Note that ConnectTo() can take several seconds to return, both for success or failure,
                // depending upon hostname resolution and network response times, so it may be best to
                // do this in a separate thread to prevent the main GUI thread blocking.
                m_switcherDiscovery.ConnectTo(address, out m_switcher, out failReason);
            }
            catch (COMException)
            {
                // An exception will be thrown if ConnectTo fails. For more information, see failReason.
                switch (failReason)
                {
                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureNoResponse:
                    //MessageBox.Show("No response from Switcher", "Error");
                    break;

                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware:
                    //MessageBox.Show("Switcher has incompatible firmware", "Error");
                    break;

                default:
                    //MessageBox.Show("Connection failed for unknown reason", "Error");
                    break;
                }
                return;
            }

            // Get the switcher name:
            string switcherName;

            m_switcher.GetProductName(out switcherName);
            _switcherName = switcherName;


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

            m_switcher.IterateInput((i) =>
            {
                InputMonitor newInputMonitor = new InputMonitor(i);

                i.AddCallback(newInputMonitor);
                newInputMonitor.LongNameChanged += new SwitcherEventHandler(OnInputLongNameChanged);
                m_inputMonitors.Add(newInputMonitor);
            });

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

            if (m_mixEffectBlock1 != null)
            {
                m_mixEffectBlock1.AddCallback(m_mixEffectBlockMonitor);
                UpdatePrograms();
                this.Connected = true;
            }

            m_audioMixer = m_switcher.GetBMDSwitcherAudioMixer();

            m_audioMixer.IterateAudioInput(i => { _audioInputs.Add(i); });
        }
コード例 #8
0
        private void SwitcherConnected()
        {
            //buttonConnect.Enabled = false;

            // Get the switcher name:
            string switcherName;

            m_switcher.GetProductName(out switcherName);
            //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)
            {
                MessageBox.Show("Unexpected: Could not get first mix effect block", "Error");
                return;
            }

            // Install MixEffectBlockMonitor callbacks:
            m_mixEffectBlock1.AddCallback(m_mixEffectBlockMonitor);
            //MixEffectBlockSetEnable(true);
            getInputNames();
            addAUXCallback();



            //setCurrent preview ID
            m_mixEffectBlock1.GetInt(_BMDSwitcherMixEffectBlockPropertyId.bmdSwitcherMixEffectBlockPropertyIdPreviewInput, out currentPreview);
            currentKey = -1;
            //setCurrent Program ID
            m_mixEffectBlock1.GetInt(_BMDSwitcherMixEffectBlockPropertyId.bmdSwitcherMixEffectBlockPropertyIdProgramInput, out currentProgram);
            updateProgPrevUI(currentPreview, false);
            updateProgPrevUI(currentProgram, true);
            UpdateAuxSourceCombos();

            MidiListener midi = new MidiListener();

            midi.StartListening(this);
        }