public void ConnectTo(String address)
        {
            IBMDSwitcherDiscovery discovery = new CBMDSwitcherDiscovery();

            _BMDSwitcherConnectToFailure failReason = 0;

            try
            {
                IBMDSwitcher switcher;
                // 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.
                discovery.ConnectTo(address, out switcher, out failReason);
                Switcher = switcher;
            }
            catch (COMException ex)
            {
                Switcher = null;
                // An exception will be thrown if ConnectTo fails. For more information, see failReason.
                switch (failReason)
                {
                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureNoResponse:
                    throw new Exception("No response from Switcher", ex);

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

                default:
                    throw new Exception("Connection failed for unknown reason", ex);
                }
            }
        }
Esempio n. 2
0
        public static IBMDSwitcherInput GetSource(this IBMDSwitcher switcher, long inputId)
        {
            IBMDSwitcherInputIterator inputIterator = switcher.GetInputIterator();

            if (inputIterator == null)
            {
                return(null);
            }

            IBMDSwitcherInput input;

            inputIterator.Next(out input);
            while (input != null)
            {
                long inputIdFound;
                input.GetInputId(out inputIdFound);
                if (inputIdFound == inputId)
                {
                    return(input);
                }
                inputIterator.Next(out input);
            }

            return(null);
        }
        public static void Build(AtemState state, IBMDSwitcher switcher)
        {
            var auxes = new List <AuxState>();
            var cols  = new List <ColorState>();
            var ssrcs = new List <SuperSourceState>();

            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherInputIterator>(switcher.CreateIterator);

            AtemSDKConverter.Iterate <IBMDSwitcherInput>(iterator.Next, (input, i) =>
            {
                input.GetInputId(out long id);
                var src = (VideoSource)id;

                state.Settings.Inputs[src] = BuildOne(input);

                if (input is IBMDSwitcherInputAux aux)
                {
                    auxes.Add(AuxInput(aux));
                }

                if (input is IBMDSwitcherInputColor col)
                {
                    cols.Add(ColorInput(col));
                }

                if (input is IBMDSwitcherInputSuperSource ssrc)
                {
                    ssrcs.Add(SuperSourceStateBuilder.Build(ssrc));
                }
            });

            state.Auxiliaries     = auxes;
            state.ColorGenerators = cols;
            state.SuperSources    = ssrcs;
        }
Esempio n. 4
0
        public static void IterateMixEffectBlock(this IBMDSwitcher switcher, Func <IBMDSwitcherMixEffectBlock, bool> func)
        {
            // We want to get the first Mix Effect block (ME 1). We create a ME iterator,
            // and then get the first one:
            IBMDSwitcherMixEffectBlock 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);

                while (mixEffectBlock1 != null && func(mixEffectBlock1))
                {
                    meIterator.Next(out mixEffectBlock1);
                }
            }
        }
Esempio n. 5
0
        public static IBMDSwitcherMixEffectBlock GetFirstMixEffectBlock(this IBMDSwitcher switcher)
        {
            IBMDSwitcherMixEffectBlock result = null;

            switcher.IterateMixEffectBlock((b) => { result = b; return(false); });
            return(result);
        }
Esempio n. 6
0
        public static IBMDSwitcherMixEffectBlock GetMixEffectBlock(this IBMDSwitcher switcher, int index)
        {
            IBMDSwitcherMixEffectBlockIterator mixEffectBlockIterator = switcher.GetMixEffectBlockIterator();

            if (mixEffectBlockIterator == null)
            {
                return(null);
            }

            IBMDSwitcherMixEffectBlock mixEffectBlock;

            mixEffectBlockIterator.Next(out mixEffectBlock);
            int i = 0;

            if (mixEffectBlockIterator != null)
            {
                if (i == index)
                {
                    return(mixEffectBlock);
                }
                mixEffectBlockIterator.Next(out mixEffectBlock);
                i++;
            }

            return(null);
        }
        public void TestAutoVideoModeDetected()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <AutoVideoModeCommand, AutoVideoModeCommand>("Detected", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.AutoVideoMode, helper =>
            {
                IBMDSwitcher switcher = helper.SdkClient.SdkSwitcher;

                AutoVideoModeCommand cmd = helper.Server.GetParsedDataDump().OfType <AutoVideoModeCommand>().Single();

                switcher.DoesSupportAutoVideoMode(out int supported);
                Assert.Equal(1, supported);
                tested = true;

                for (int i = 0; i < 5; i++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    stateBefore.Settings.DetectedVideoMode = cmd.Detected = !stateBefore.Settings.DetectedVideoMode;

                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
            Assert.True(tested);
        }
        public static IReadOnlyList <MediaPlayerState> Build(IBMDSwitcher switcher, AtemStateBuilderSettings updateSettings, bool hasClips)
        {
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherMediaPlayerIterator>(switcher.CreateIterator);

            return(AtemSDKConverter.IterateList <IBMDSwitcherMediaPlayer, MediaPlayerState>(iterator.Next,
                                                                                            (media, id) => BuildOne(media, updateSettings, hasClips)));
        }
Esempio n. 9
0
        private void SwitcherDisconnected()
        {
            IsConnected = false;

            // Remove all input monitors, remove callbacks
            foreach (InputMonitor inputMon in m_inputMonitors)
            {
                inputMon.Input.RemoveCallback(inputMon);
                inputMon.LongNameChanged -= new SwitcherEventHandler(OnInputLongNameChanged);
            }
            m_inputMonitors.Clear();

            if (m_mixEffectBlock1 != null)
            {
                // Remove callback
                m_mixEffectBlock1.RemoveCallback(m_mixEffectBlockMonitor);

                // Release reference
                m_mixEffectBlock1 = null;
            }

            if (m_switcher != null)
            {
                // Remove callback:
                m_switcher.RemoveCallback(m_switcherMonitor);

                // release reference:
                m_switcher = null;
            }
        }
        private static void MixMinusOutputs(AtemState state, IBMDSwitcher switcher)
        {
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherMixMinusOutputIterator>(switcher.CreateIterator);

            state.Settings.MixMinusOutputs = AtemSDKConverter.IterateList <IBMDSwitcherMixMinusOutput, SettingsState.MixMinusOutputState>(iterator.Next,
                                                                                                                                          (props, id) =>
            {
                props.GetAvailableAudioModes(out _BMDSwitcherMixMinusOutputAudioMode availableModes);
                props.GetAudioMode(out _BMDSwitcherMixMinusOutputAudioMode mode);
                props.HasMinusAudioInputId(out int hasInputId);

                long inputId = 0;
                if (hasInputId != 0)
                {
                    props.GetMinusAudioInputId(out inputId);
                }

                return(new SettingsState.MixMinusOutputState
                {
                    HasAudioInputId = hasInputId != 0,
                    AudioInputId = (AudioSource)inputId,
                    SupportedModes = AtemEnumMaps.MixMinusModeMap.FindFlagsByValue(availableModes),
                    Mode = AtemEnumMaps.MixMinusModeMap.FindByValue(mode),
                });
            });
        }
Esempio n. 11
0
        public static void IterateInput(this IBMDSwitcher switcher, Action <IBMDSwitcherInput> action)
        {
            // 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:

            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

            switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);

            IBMDSwitcherInputIterator inputIterator = null;

            if (inputIteratorPtr != null)
            {
                inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
            }

            if (inputIterator != null)
            {
                IBMDSwitcherInput input;
                inputIterator.Next(out input);
                while (input != null)
                {
                    action(input);

                    inputIterator.Next(out input);
                }
            }
        }
Esempio n. 12
0
        public static IReadOnlyList <DownstreamKeyerState> Build(IBMDSwitcher switcher)
        {
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherDownstreamKeyIterator>(switcher.CreateIterator);

            return(AtemSDKConverter.IterateList <IBMDSwitcherDownstreamKey, DownstreamKeyerState>(
                       iterator.Next,
                       (key, id) => BuildOne(key)));
        }
Esempio n. 13
0
        public AtemSDKStateMonitor(IBMDSwitcher switcher)
        {
            this.switcher = switcher;
            //switcher.AllowStreamingToResume();

            _root = new SwitcherPropertiesCallback(() => OnStateChange?.Invoke(this));
            switcher.AddCallback(_root);
        }
        public static void Build(MediaPoolState state, IBMDSwitcher switcher)
        {
            var pool = switcher as IBMDSwitcherMediaPool;

            // TODO DoesVideoModeChangeClearMediaPool I don't see anything obvious for this in the protocol

            // Stills
            pool.GetStills(out IBMDSwitcherStills stills);
            stills.GetCount(out uint stillCount);
            state.Stills = Enumerable.Range(0, (int)stillCount).Select(i => BuildStill(stills, (uint)i)).ToList();

            // Clips
            pool.GetFrameTotalForClips(out uint unassignedFrames);
            pool.GetClipCount(out uint clipCount);
            state.Clips = Enumerable.Range(0, (int)clipCount).Select(i =>
            {
                pool.GetClip((uint)i, out IBMDSwitcherClip clip);
                clip.GetMaxFrameCount(out uint maxFrameCount);
                unassignedFrames -= maxFrameCount;
                clip.IsValid(out int valid);
                clip.GetName(out string name);

                clip.GetFrameCount(out uint frameCount);
                var frames = Enumerable.Range(0, (int)maxFrameCount).Select(i =>
                {
                    clip.GetFrameHash((uint)i, out BMDSwitcherHash hash);
                    clip.IsFrameValid((uint)i, out int valid);
                    return(new MediaPoolState.FrameState
                    {
                        IsUsed = valid != 0,
                        Hash = hash.data
                    });
                }).ToList();

                clip.GetAudioName(out string audioName);
                clip.IsAudioValid(out int isAudioValid);
                clip.GetAudioHash(out BMDSwitcherHash audioHash);
                return(new MediaPoolState.ClipState
                {
                    IsUsed = valid != 0,
                    Name = name,
                    FrameCount = frameCount,

                    MaxFrames = maxFrameCount,

                    Frames = frames,

                    Audio =
                    {
                        IsUsed = isAudioValid != 0,
                        Name   = audioName,
                        Hash   = audioHash.data,
                    }
                });
            }).ToList();

            state.UnassignedFrames = unassignedFrames;
        }
Esempio n. 15
0
 public void disconnect()
 {
     if (this.atem_switcher != null)
     {
         atem_switcher.RemoveCallback(atem_callback);
         atem_switcher = null;
         is_connected  = false;
     }
 }
Esempio n. 16
0
 public SwitcherUploadManager(Dispatcher dispatcher, IBMDSwitcher switcher)
 {
     this.dispatcher = dispatcher;
     m_switcher      = switcher;
     m_mediapool     = (IBMDSwitcherMediaPool)switcher;
     m_mediapool.GetStills(out m_stills);
     if (m_stills == null)
     {
         throw new Exception();
     }
 }
        private static void DveInfo(AtemState state, IBMDSwitcher switcher)
        {
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherMixEffectBlockIterator>(switcher.CreateIterator);
            var me       = AtemSDKConverter.ToList <IBMDSwitcherMixEffectBlock>(iterator.Next).FirstOrDefault();

            if (me == null)
            {
                return;
            }

            var keyers = AtemSDKConverter.CastSdk <IBMDSwitcherKeyIterator>(me.CreateIterator);
            var keyer  = AtemSDKConverter.ToList <IBMDSwitcherKey>(keyers.Next).FirstOrDefault();

            if (keyer == null)
            {
                return;
            }

            var flyKey   = keyer as IBMDSwitcherKeyFlyParameters;
            var dveTrans = me as IBMDSwitcherTransitionDVEParameters;

            if (flyKey == null || dveTrans == null)
            {
                return;
            }

            flyKey.GetCanRotate(out int canRotate);
            flyKey.GetCanScaleUp(out int canScaleUp);

            var dveStyles = new List <DVEEffect>();

            foreach (DVEEffect style in Enum.GetValues(typeof(DVEEffect)).OfType <DVEEffect>())
            {
                _BMDSwitcherDVETransitionStyle style2 = AtemEnumMaps.DVEStyleMap[style];
                dveTrans.DoesSupportStyle(style2, out int supported);
                if (supported != 0)
                {
                    dveStyles.Add(style);
                }
            }

            dveTrans.GetNumSupportedStyles(out uint styleCount);
            if (dveStyles.Count != styleCount)
            {
                throw new Exception("Mismatch in number of supported DVE transition styles");
            }

            state.Info.DVE = new InfoState.DveInfoState
            {
                CanScaleUp           = canScaleUp != 0,
                CanRotate            = canRotate != 0,
                SupportedTransitions = dveStyles,
            };
        }
Esempio n. 18
0
 public void Dispose()
 {
     lock (_lock)
     {
         if (_switcher != null)
         {
             _switcher.RemoveCallback(this);
             _switcher = null;
         }
     }
 }
Esempio n. 19
0
        public static T QueryInterface <T>(this IBMDSwitcher switcher)
        {
            IntPtr ptr = Marshal.GetIUnknownForObject(switcher);

            Guid   guid = typeof(T).GUID;
            IntPtr pUnk = IntPtr.Zero;

            Marshal.QueryInterface(ptr, ref guid, out pUnk);

            return((T)Marshal.GetObjectForIUnknown(pUnk));
        }
Esempio n. 20
0
        public static void Build(AtemState state, IBMDSwitcher switcher)
        {
#if !ATEM_v8_1
            var streamingSwitcher = switcher as IBMDSwitcherStreamRTMP;
            if (streamingSwitcher == null)
            {
                return;
            }

            state.Streaming = new StreamingState();

            //streamingSwitcher.IsStreaming(out int isStreaming);
            streamingSwitcher.GetStatus(out _BMDSwitcherStreamRTMPState status, out _BMDSwitcherStreamRTMPError error);
            streamingSwitcher.GetServiceName(out string serviceName);
            streamingSwitcher.GetUrl(out string url);
            streamingSwitcher.GetKey(out string key);
            streamingSwitcher.GetVideoBitrates(out uint lowVideoBitrate, out uint highVideoBitrate);
            streamingSwitcher.GetAudioBitrates(out uint lowAudioBitrate, out uint highAudioBitrate);
            streamingSwitcher.GetTimeCode(out byte hours, out byte minutes, out byte seconds, out byte frames, out int isDropFrame);
            streamingSwitcher.GetEncodingBitrate(out uint encodingBitrate);
            streamingSwitcher.GetCacheUsed(out double cacheUsed);
            streamingSwitcher.GetAuthentication(out string username, out string password);
            streamingSwitcher.GetLowLatency(out int lowLatency);

            //state.Streaming.Status.IsStreaming = isStreaming != 0;
            state.Streaming.Stats.CacheUsed       = (uint)(cacheUsed * 100);
            state.Streaming.Stats.EncodingBitrate = encodingBitrate;
            state.Streaming.Status.Duration       = new Timecode
            {
                Hour      = hours,
                Minute    = minutes,
                Second    = seconds,
                Frame     = frames,
                DropFrame = isDropFrame != 0
            };
            state.Streaming.Status.State = AtemEnumMaps.StreamingStatusMap.FindByValue(status);
            state.Streaming.Status.Error = AtemEnumMaps.StreamingErrorMap.FindByValue(error);

            state.Streaming.Settings.ServiceName      = serviceName;
            state.Streaming.Settings.Url              = url;
            state.Streaming.Settings.Key              = key;
            state.Streaming.Settings.LowVideoBitrate  = lowVideoBitrate;
            state.Streaming.Settings.HighVideoBitrate = highVideoBitrate;
            state.Streaming.Settings.LowAudioBitrate  = lowAudioBitrate;
            state.Streaming.Settings.HighAudioBitrate = highAudioBitrate;

            state.Streaming.Authentication.Username = username;
            state.Streaming.Authentication.Password = password;

            state.Streaming.IsLowLatency = lowLatency != 0;
#endif
        }
Esempio n. 21
0
        public static IBMDSwitcherInputIterator GetInputIterator(this IBMDSwitcher switcher)
        {
            IBMDSwitcherInputIterator inputIterator = null;
            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

            switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);
            if (inputIteratorPtr != IntPtr.Zero)
            {
                inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
            }
            return(inputIterator);
        }
Esempio n. 22
0
        public static IBMDSwitcherMixEffectBlockIterator GetMixEffectBlockIterator(this IBMDSwitcher switcher)
        {
            IBMDSwitcherMixEffectBlockIterator meIterator = null;
            IntPtr meIteratorPtr;
            Guid   meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID;

            switcher.CreateIterator(ref meIteratorIID, out meIteratorPtr);
            if (meIteratorPtr != IntPtr.Zero)
            {
                meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr);
            }
            return(meIterator);
        }
Esempio n. 23
0
        private void SwitcherDisconnected()
        {
            if (m_switcher != null)
            {
                // Remove callback:
                m_switcher.RemoveCallback(this);

                // release reference:
                m_switcher = null;
            }

            nullifyMixEffectsBlocks();
            DisconnectedEvent?.Invoke(this, new EventArgs());
        }
        public static void Build(AtemState state, IBMDSwitcher switcher)
        {
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherTalkbackIterator>(switcher.CreateIterator);
            var talkback = AtemSDKConverter.IterateList <IBMDSwitcherTalkback, SettingsState.TalkbackState>(iterator.Next,
                                                                                                            (props, id0) =>
            {
                props.GetId(out _BMDSwitcherTalkbackId channelId);
                var id = AtemEnumMaps.TalkbackChannelMap.FindByValue(channelId);
                Assert.Equal((uint)id, id0);

                props.GetMuteSDI(out int muteSDI);

                var audioInputIds = state.Settings.Inputs
                                    .Where(i => i.Value.Properties.InternalPortType == InternalPortType.External &&
                                           i.Value.Properties.AvailableExternalPortTypes.Contains(VideoPortType.SDI))
                                    .Select(i => (long)i.Key).ToList();

                var res = new SettingsState.TalkbackState
                {
                    MuteSDI = muteSDI != 0,
                };

                foreach (long inputId in audioInputIds)
                {
                    props.CurrentInputSupportsMuteSDI(inputId, out int supportsMuteInputSdi);
                    int muteInputSdi    = 0;
                    int canMuteinputSdi = 0;
                    if (supportsMuteInputSdi != 0)
                    {
                        props.InputCanMuteSDI(inputId, out canMuteinputSdi);
                        if (canMuteinputSdi != 0)
                        {
                            props.GetInputMuteSDI(inputId, out muteInputSdi);
                        }
                    }

                    res.Inputs[(VideoSource)inputId] = new SettingsState.TalkbackInputState
                    {
                        MuteSDI                     = muteInputSdi != 0,
                        InputCanMuteSDI             = canMuteinputSdi != 0,
                        CurrentInputSupportsMuteSDI = supportsMuteInputSdi != 0,
                    };
                }


                return(res);
            });

            state.Settings.Talkback = talkback;
        }
Esempio n. 25
0
 public void Disconnect()
 {
     if (switcher == null)
     {
         return;
     }
     switcher.RemoveCallback(switcherMonitor);
     switcher = null;
     foreach (var item in inputs)
     {
         item.Dispose();
     }
     inputs.Clear();
 }
        private static void SerialPorts(AtemState state, IBMDSwitcher switcher)
        {
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherSerialPortIterator>(switcher.CreateIterator);

            AtemSDKConverter.Iterate <IBMDSwitcherSerialPort>(iterator.Next, (port, id) =>
            {
                if (id != 0)
                {
                    throw new Exception("Too many serial ports");
                }

                port.GetFunction(out _BMDSwitcherSerialPortFunction function);
                state.Settings.SerialMode = AtemEnumMaps.SerialModeMap.FindByValue(function);
            });
        }
        private static void Macros(MacroState state, IBMDSwitcher switcher)
        {
            var pool = switcher as IBMDSwitcherMacroPool;

            pool.GetMaxCount(out uint count);
            state.Pool = Enumerable.Range(0, (int)count).Select(i =>
            {
                pool.IsValid((uint)i, out int valid);
                pool.HasUnsupportedOps((uint)i, out int unsupported);
                pool.GetName((uint)i, out string name);
                pool.GetDescription((uint)i, out string description);
                return(new MacroState.ItemState
                {
                    IsUsed = valid != 0,
                    HasUnsupportedOps = unsupported != 0,
                    Name = name,
                    Description = description
                });
            }).ToList();

            var control = switcher as IBMDSwitcherMacroControl;

            control.GetRunStatus(out _BMDSwitcherMacroRunStatus status, out int loop, out uint index);

            switch (status)
            {
            case _BMDSwitcherMacroRunStatus.bmdSwitcherMacroRunStatusIdle:
                state.RunStatus.RunStatus = MacroState.MacroRunStatus.Idle;
                break;

            case _BMDSwitcherMacroRunStatus.bmdSwitcherMacroRunStatusRunning:
                state.RunStatus.RunStatus = MacroState.MacroRunStatus.Running;
                break;

            case _BMDSwitcherMacroRunStatus.bmdSwitcherMacroRunStatusWaitingForUser:
                state.RunStatus.RunStatus = MacroState.MacroRunStatus.UserWait;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(status), status, null);
            }

            state.RunStatus.Loop     = loop != 0;
            state.RunStatus.RunIndex = index;
            control.GetRecordStatus(out _BMDSwitcherMacroRecordStatus recStatus, out uint recIndex);
            state.RecordStatus.IsRecording = recStatus == _BMDSwitcherMacroRecordStatus.bmdSwitcherMacroRecordStatusRecording;
            state.RecordStatus.RecordIndex = recIndex;
        }
Esempio n. 28
0
        public VisionService(String IP)
        {
            if (!MainForm.IGNORE_VISION)
            {
                _BMDSwitcherConnectToFailure failReason = 0;

                CBMDSwitcherDiscovery switcher_discovery = new CBMDSwitcherDiscovery();
                if (switcher_discovery == null)
                {
                    throw new Exception("ATEM Switcher Software not installed");
                }

                try
                {
                    switcher_discovery.ConnectTo(IP, out this.Switcher, out failReason);
                }
                catch (COMException)
                {
                    switch (failReason)
                    {
                    case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureNoResponse:
                        throw new Exception("No response from Switcher at " + IP);

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

                    default:
                        throw new Exception("Connection to " + IP + " failed for unknown reason");
                    }
                }

                if (this.Switcher != null)
                {
                    IntPtr input_iterator_ptr;
                    this.Switcher.CreateIterator(typeof(IBMDSwitcherInputIterator).GUID, out input_iterator_ptr);
                    if (input_iterator_ptr != null)
                    {
                        this.InputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(input_iterator_ptr);
                    }
                    else
                    {
                        this.Switcher = null;
                    }
                }
            }
        }
Esempio n. 29
0
        public Upload(Dispatcher d, IBMDSwitcher switcher, string filename, int uploadSlot)
        {
            this.switcher   = switcher;
            this.filename   = filename;
            this.uploadSlot = uploadSlot;
            this.d          = d;

            if (!File.Exists(filename))
            {
                throw new FileNotFoundException(String.Format("{0} does not exist", filename));
            }

            d.Invoke(() =>
            {
                this.stills = this.GetStills();
            });
        }
        public void TestRequestTimecode()
        {
            var handler = CommandGenerator.MatchCommand(new TimeCodeRequestCommand());

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper =>
            {
                IBMDSwitcher switcher = helper.SdkClient.SdkSwitcher;

                AtemState stateBefore = helper.Helper.BuildLibState();

                uint timeBefore = helper.Server.CurrentTime;

                helper.SendAndWaitForChange(stateBefore, () => { switcher.RequestTimeCode(); });

                // It should have sent a response, but we dont expect any comparable data
                Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
            });
        }
Esempio n. 31
0
        public VisionService(String IP)
        {
            if (!MainForm.IGNORE_VISION)
            {
                _BMDSwitcherConnectToFailure failReason = 0;

                CBMDSwitcherDiscovery switcher_discovery = new CBMDSwitcherDiscovery();
                if (switcher_discovery == null)
                {
                    throw new Exception("ATEM Switcher Software not installed");
                }

                try
                {
                    switcher_discovery.ConnectTo(IP, out this.Switcher, out failReason);
                }
                catch (COMException)
                {
                    switch (failReason)
                    {
                        case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureNoResponse:
                            throw new Exception("No response from Switcher at " + IP);
                        case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware:
                            throw new Exception("Switcher at " + IP + " has incompatible firmware");
                        default:
                            throw new Exception("Connection to " + IP + " failed for unknown reason");
                    }
                }

                if (this.Switcher != null)
                {
                    IntPtr input_iterator_ptr;
                    this.Switcher.CreateIterator(typeof(IBMDSwitcherInputIterator).GUID, out input_iterator_ptr);
                    if (input_iterator_ptr != null)
                    {
                        this.InputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(input_iterator_ptr);
                    }
                    else
                    {
                        this.Switcher = null;
                    }
                }
            }
        }
Esempio n. 32
0
        private void SwitcherDisconnected()
        {
            try
            {
                this.Text = "";
                deactivatebuttons();
                btn_reconnect.Enabled = true;
                btnKey1Air.Enabled = false;
                if (m_audioInput != null)
                {
                    m_audioInput.RemoveCallback(m_audioInputMonitor);
                    m_audioInput = null;
                }

                if (m_audioMonitorOutput != null)
                {
                    m_audioMonitorOutput.RemoveCallback(m_audioOutputMonitor);
                    m_audioMonitorOutput = null;
                }

                if (m_audiomixer != null)
                {
                    m_audiomixer.RemoveCallback(m_audioMixerMonitor);
                    m_audiomixer = null;
                }

                if (me1_dkey1 != null)
                {
                    // Remove callback
                    me1_dkey1.RemoveCallback(m_dkeyMonitor);

                    // Release reference
                    me1_dkey1 = null;
                }

                if (me1_dkey2 != null)
                {
                    // Remove callback
                    me1_dkey2.RemoveCallback(m_dkeyMonitor);

                    // Release reference
                    me1_dkey2 = null;
                }

                if (m_AUX1 != null)
                {
                    // Remove callback
                    m_AUX1.RemoveCallback(m_auxMonitor);

                    // Release reference
                    m_AUX1 = null;
                }

                if (m_AUX2 != null)
                {
                    // Remove callback
                    m_AUX2.RemoveCallback(m_auxMonitor);

                    // Release reference
                    m_AUX2 = null;
                }

                if (m_AUX3 != null)
                {
                    // Remove callback
                    m_AUX3.RemoveCallback(m_auxMonitor);

                    // Release reference
                    m_AUX3 = null;
                }

                if (me1_key1 != null)
                {
                    // Remove callback
                    me1_key1.RemoveCallback(m_keyMonitor);

                    // Release reference
                    me1_key1 = null;
                }
                if (me1_key2 != null)
                {
                    // Remove callback
                    me1_key2.RemoveCallback(m_keyMonitor);

                    // Release reference
                    me1_key2 = null;
                }
                if (me1_key3 != null)
                {
                    // Remove callback
                    me1_key3.RemoveCallback(m_keyMonitor);

                    // Release reference
                    me1_key3 = null;
                }
                if (me1_key4 != null)
                {
                    // Remove callback
                    me1_key4.RemoveCallback(m_keyMonitor);

                    // Release reference
                    me1_key4 = null;
                }

                if (m_transition != null)
                {
                    // Remove callback
                    m_transition.RemoveCallback(m_transitionMonitor);

                    // Release reference
                    m_transition = null;
                }

                // Remove all input monitors, remove callbacks
                foreach (InputMonitor inputMon in m_inputMonitors)
                {
                    inputMon.Input.RemoveCallback(inputMon);
                }
                m_inputMonitors.Clear();

                if (m_mixEffectBlock1 != null)
                {
                    // Remove callback
                    m_mixEffectBlock1.RemoveCallback(m_mixEffectBlockMonitor);

                    // Release reference
                    m_mixEffectBlock1 = null;
                }

                if (m_switcher != null)
                {
                    // Remove callback:
                    m_switcher.RemoveCallback(m_switcherMonitor);

                    // release reference:
                    m_switcher = null;
                }
            }
            catch (ArgumentException)
            {
                SwitcherDisconnected();
            }
        }
Esempio n. 33
0
		public virtual extern void ConnectTo([In] string deviceAddress, out IBMDSwitcher switcherDevice, out _BMDSwitcherConnectToFailure failReason);
Esempio n. 34
0
        private void SwitcherDisconnected()
        {
            buttonConnect.Enabled = true;
            textBoxSwitcherName.Text = "";

            if (m_audioInput != null)
            {
                m_audioInput.RemoveCallback(m_audioInputMonitor);
                m_audioInput = null;
            }

            if (m_audioMonitorOutput != null)
            {
                m_audioMonitorOutput.RemoveCallback(m_audioOutputMonitor);
                m_audioMonitorOutput = null;
            }

            if (m_audiomixer != null)
            {
                 m_audiomixer.RemoveCallback(m_audioMixerMonitor);
                 m_audiomixer = null;
            }

            if (me1_dkey1 != null)
            {
                // Remove callback
                me1_dkey1.RemoveCallback(m_dkeyMonitor);

                // Release reference
                me1_dkey1 = null;
            }

            if (me1_dkey2 != null)
            {
                // Remove callback
                me1_dkey2.RemoveCallback(m_dkeyMonitor);

                // Release reference
                me1_dkey2 = null;
            }

            if (m_AUX1 != null)
            {
                // Remove callback
                m_AUX1.RemoveCallback(m_auxMonitor);

                // Release reference
                m_AUX1 = null;
            }

            if (m_AUX2 != null)
            {
                // Remove callback
                m_AUX2.RemoveCallback(m_auxMonitor);

                // Release reference
                m_AUX2 = null;
            }

            if (m_AUX3 != null)
            {
                // Remove callback
                m_AUX3.RemoveCallback(m_auxMonitor);

                // Release reference
                m_AUX3 = null;
            }

            if (m_inputAux != null)
            {
                // Remove callback
                m_inputAux.RemoveCallback(m_auxMonitor);

                // Release reference
                m_inputAux = null;
            }

            if (me1_key1 != null)
            {
                // Remove callback
                me1_key1.RemoveCallback(m_keyMonitor);

                // Release reference
                me1_key1 = null;
            }
            if (me1_key2 != null)
            {
                // Remove callback
                me1_key2.RemoveCallback(m_keyMonitor);

                // Release reference
                me1_key2 = null;
            }
            if (me1_key3 != null)
            {
                // Remove callback
                me1_key3.RemoveCallback(m_keyMonitor);

                // Release reference
                me1_key3 = null;
            }
            if (me1_key4 != null)
            {
                // Remove callback
                me1_key4.RemoveCallback(m_keyMonitor);

                // Release reference
                me1_key4 = null;
            }

            if (m_transition != null)
            {
                // Remove callback
                m_transition.RemoveCallback(m_transitionMonitor);

                // Release reference
                m_transition = null;
            }
            
            // Remove all input monitors, remove callbacks
            foreach (InputMonitor inputMon in m_inputMonitors)
            {
                inputMon.Input.RemoveCallback(inputMon);
            }
            m_inputMonitors.Clear();

            if (m_mixEffectBlock1 != null)
            {
                // Remove callback
                m_mixEffectBlock1.RemoveCallback(m_mixEffectBlockMonitor);

                // Release reference
                m_mixEffectBlock1 = null;
            }

            if (m_switcher != null)
            {
                // Remove callback:
                m_switcher.RemoveCallback(m_switcherMonitor);

                // release reference:
                m_switcher = null;
            }
        }