예제 #1
0
        public void Connect(string address)
        {
            this.AtemIPAddress = address;

            _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 comEx)
            {
                // 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");
                    throw new ConnectFailureNoResponseException(string.Format("Cannot connect to switcher at address: {0}", address));

                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware:
                    // MessageBox.Show("Switcher has incompatible firmware", "Error");
                    throw new ConnectFailureIncompatibleFirmwareException(string.Format("Switcher at address {0} has incompatible firmware.  Either rebuild this library to the switcher version or upgrade the switcher firmware to match.", address));

                default:
                    throw new Exception(string.Format("Cannot connect to switcher at address {0}.  See inner exception for more information", address), comEx);
                }
                throw new Exception(string.Format("Cannot connect to switcher at address {0}.  See inner exception for more information", address), comEx);
            }

            SwitcherConnected();
        }
예제 #2
0
        public void ConnectToIp(string ipAddress)
        {
            _BMDSwitcherConnectToFailure failReason = 0;

            try
            {
                m_switcherDiscovery.ConnectTo(ipAddress, out m_switcher, out failReason);
            }
            catch (COMException)
            {
                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;
            }

            SwitcherConnected();
        }
예제 #3
0
        public AtemSdkClientWrapper(string address, AtemStateBuilderSettings updateSettings, int id)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetExecutingAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
            if (!logRepository.Configured) // Default to all on the console
            {
                BasicConfigurator.Configure(logRepository);
            }

            Id = id;

            _updateSettings = updateSettings;

            _switcherDiscovery = new CBMDSwitcherDiscovery();
            Assert.NotNull(_switcherDiscovery);

            _BMDSwitcherConnectToFailure failReason = 0;

            try
            {
                _switcherDiscovery.ConnectTo(address, out _sdkSwitcher, out failReason);
            }
            catch (COMException)
            {
                throw new Exception($"SDK Connection failure: {failReason}");
            }

            //_sdkSwitcher.AddCallback(new SwitcherConnectionMonitor()); // TODO - make this monitor work better!

            _sdkState = new AtemSDKStateMonitor(_sdkSwitcher);
            _sdkState.OnStateChange += (s) => OnSdkStateChange?.Invoke(s);
        }
예제 #4
0
    private void ConnectAtem(string connectIp)
    {
        m_switcherDiscovery = new CBMDSwitcherDiscovery();
        if (m_switcherDiscovery == null)
        {
            Debug.LogError("Could not create Switcher Discovery Instance.\nATEM Switcher Software may not be installed.");
        }

        _BMDSwitcherConnectToFailure failReason = 0;
        string address = connectIp;

        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:
                Debug.LogError("No response from Switcher");
                break;

            case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware:
                Debug.LogError("Switcher has incompatible firmware");
                break;

            default:
                Debug.LogError("Connection failed for unknown reason");
                break;
            }
            return;
        }
    }
예제 #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");
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            _BMDSwitcherConnectToFailure failReason = 0;

            switcherDiscovery = new CBMDSwitcherDiscovery();
            try
            {
                switcherDiscovery.ConnectTo("10.11.12.21", out 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;
                }
            }

            mixEffectBlock1 = null;

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

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

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

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

            IBMDSwitcherInput         currentInput  = null;
            IBMDSwitcherInputIterator inputIterator = null;
            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

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

            if (inputIterator != null)
            {
                inputIterator.Next(out currentInput);
                while (currentInput != null)
                {
                    MixerInput input = new MixerInput(currentInput);
                    inputList.Add(input);
                    inputIterator.Next(out currentInput);
                }
            }

            mixEffectBlock1.AddCallback(monitor);
            monitor.InTransitionChanged += new MixerMonitorEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => InTransitionChanged(s, a))));

            indev = new Sanford.Multimedia.Midi.InputDevice(3);
            indev.ChannelMessageReceived += Indev_ChannelMessageReceived;
            indev.StartRecording();

            mappingList.ItemsSource = inputList;
        }
예제 #7
0
        private void Run()
        {
            m_switcherDiscovery = new CBMDSwitcherDiscovery();
            if (m_switcherDiscovery == null)
            {
                WaitForExit("Could not create Switcher Discovery Instance.\nATEM Switcher Software may not be installed.");
                return;
            }

            _BMDSwitcherConnectToFailure failReason = 0;
            string address = "10.42.13.99";

            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:
                    WaitForExit("No response from Switcher");
                    break;

                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware:
                    WaitForExit("Switcher has incompatible firmware");
                    break;

                default:
                    WaitForExit("Connection failed for unknown reason");
                    break;
                }
                return;
            }

            Console.WriteLine("Connected");


            m_mediaPool = m_switcher as IBMDSwitcherMediaPool;
            if (m_mediaPool == null)
            {
                WaitForExit("Failed to cast to media pool");
                return;
            }


            m_mediaPool.CreateFrame(_BMDSwitcherPixelFormat.bmdSwitcherPixelFormat10BitYUVA, 1920, 1080, out IBMDSwitcherFrame frame);
            if (frame == null)
            {
                WaitForExit("Failed to create frame");
                return;
            }

            frame.GetBytes(out IntPtr buffer);
            byte[] frameData = RandomFrame();
            Marshal.Copy(frameData, 0, buffer, 1920 * 1080 * 4);

            Stopwatch sw = new Stopwatch();

            uint max_index = 32;
            uint index     = 0;

            while (true)
            {
                sw.Restart();
                UploadStillSdk(index % max_index, "frame " + index, frame);
                sw.Stop();

                Console.WriteLine("Upload outer #{0} took {1}ms", index, sw.ElapsedMilliseconds);

                Thread.Sleep(100);

                index++;
            }


            // End
            WaitForExit();
        }
예제 #8
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); });
        }
예제 #9
0
        public MainWindow()
        {
            InitializeComponent();

            m_switcherMonitor = new SwitcherMonitor();

            m_audioInputMonitor     = new AudioInputMonitor();
            m_mixEffectBlockMonitor = new MixEffectBlockMonitor();
            m_transitionMonitor     = new TransitionMonitor();
            m_dkeyMonitor           = new DownStreamKeyMonitor();

            m_switcherDiscovery = new CBMDSwitcherDiscovery();
            if (m_switcherDiscovery == null)
            {
                MessageBox.Show("Could not create Switcher Discovery Instance.\nATEM Switcher Software may not be installed.", "Error");
                Environment.Exit(1);
            }

            SwitcherDisconnected();             // start with switcher disconnected

            _BMDSwitcherConnectToFailure failReason = 0;
            string address = "192.168.30.8";

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

            m_mixEffectBlockMonitor.ProgramInputChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => UpdateProgramButtonSelection())));
            m_mixEffectBlockMonitor.PreviewInputChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => UpdatePreviewButtonSelection())));
            m_mixEffectBlockMonitor.TransitionFramesRemainingChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => UpdateTransitionFramesRemaining())));
            m_mixEffectBlockMonitor.TransitionPositionChanged        += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => UpdateSliderPosition())));
            m_mixEffectBlockMonitor.InTransitionChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => OnInTransitionChanged())));

            m_audioMixerMonitor = new AudioMixerMonitor();
            //m_audioMixerMonitor.ProgramOutBalanceChanged += new SwitcherEventHandler((s, a) => this.Invoke((Action)(() => AudioProgramOutBalanceChanged())));
            //m_audioMixerMonitor.ProgramOutGainChanged += new SwitcherEventHandler((s, a) => this.Invoke((Action)(() => AudioProgramOutGainChanged())));
            //m_audioMixerMonitor.ProgramOutLevelNotificationChanged += new SwitcherEventHandler((s, a) => this.Invoke((Action)(() => AudioProgramOutLevelNotificationChanged())));

            m_audioOutputMonitor = new AudioMixerMonitorOutputMonitor();
            //m_audioOutputMonitor.DimChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioOutputMonitor.DimLevelChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioOutputMonitor.GainChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioOutputMonitor.LevelNotificationChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioOutputMonitor.MonitorEnableChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioOutputMonitor.MuteChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioOutputMonitor.SoloInputChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloInputChanged())));

            m_audioInputMonitor = new AudioInputMonitor();
            //m_audioInputMonitor.IsMixedInChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloInputChanged())));
            //m_audioInputMonitor.MixOptionChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioInputMonitor.BalanceChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloInputChanged())));
            //m_audioInputMonitor.GainChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioInputMonitor.IsMixedInChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioInputMonitor.LevelNotificationChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));
            //m_audioInputMonitor.MixOptionChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => AudioOutputSoloChanged())));


            //m_transitionMonitor.TransitionStyleChanged += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => OnNextTransitionStyleChanged())));
            //m_dkeyMonitor. += new SwitcherEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => OnNextTransitionStyleChanged())));

            SwitcherConnected();
        }