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); } } }
IBMDSwitcherMixEffectBlock GetMixBox1() { 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(null); } IBMDSwitcherMixEffectBlock temp = null; if (meIterator != null) { meIterator.Next(out temp); } return(temp); }
private void GetMixEffectBlock() { bSwitcherMixEffectBlock = null; IBMDSwitcherMixEffectBlockIterator mixEffectBlockIterator = null; IntPtr mixEffectBlockIteratorPointer; Guid mixEffectBlockIteratorInterfaceID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID; bSwitcher.CreateIterator(ref mixEffectBlockIteratorInterfaceID, out mixEffectBlockIteratorPointer); if (mixEffectBlockIteratorPointer == null) { return; } mixEffectBlockIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(mixEffectBlockIteratorPointer); if (mixEffectBlockIterator == null) { return; } mixEffectBlockIterator.Next(out bSwitcherMixEffectBlock); if (bSwitcherMixEffectBlock == null) { return; } bSwitcherMixEffectBlock.AddCallback(bMixEffectBlockCallback); }
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); }
/// <summary> /// Creates the BMD iterator and retrives the Mix Effect(s) banks from the ATEM /// </summary> private void getMEBlocks() { // ensure m_mixEffectBlocks is empty nullifyMixEffectsBlocks(); // init the mix effects count, this is a zero-based count so we start at -1 int meCount = -1; // meIteratorIID holds the COM class GUID of the iterator Guid meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID; // meIteratorPtr holds the pointer to the mix effects iterator object // create the iterator and out to the meIteratorPtr pointer m_switcher.CreateIterator(ref meIteratorIID, out IntPtr meIteratorPtr); // create the iterator IBMDSwitcherMixEffectBlockIterator meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr); // bail if that returned null if (meIterator == null) { return; } // now we can start to iterate over the ME blocks this ATEM has. Usually the basic ATEM's have only one Mix Effect Block. The 2M/E ATEM's have two. Some have more. // try and get the Mix Effect Block from the iterator meIterator.Next(out IBMDSwitcherMixEffectBlock meBlock); // if that wasn't null then add to our array of ME Blocks while (meBlock != null) { // We're not null, we increment our Mix Effect count! meCount++; // is this the first ME Block? if (meCount == 0) { // Yes, so we init our ME Block array with just one item m_mixEffectBlocks = new MEBlock[1]; m_mixEffectBlocks[0] = new MEBlock(meBlock, meCount); } else // otherwise we re-create our ME Block array and increase size by one! { MEBlock[] oldMEArray = m_mixEffectBlocks; m_mixEffectBlocks = new MEBlock[meCount]; oldMEArray.CopyTo(m_mixEffectBlocks, 0); m_mixEffectBlocks[meCount] = new MEBlock(meBlock, meCount); } // raise an event // the consumer of this event should hook into the mbBlock events MixEffectBlockConnectedEvent?.Invoke(this, new MixEffectBlockConnectedEventArgs(m_mixEffectBlocks[meCount])); // Try and get the next block. A ref of null means there are no more Mix Effects Blocks on this ATEM meIterator.Next(out meBlock); } }
private IBMDSwitcherMixEffectBlock GetMixEffectBlock() { IntPtr mixEffectBlockPtr; Guid mixEffectBlockIID = typeof(IBMDSwitcherMixEffectBlock).GUID; switcher.GetSwitcher().CreateIterator(ref mixEffectBlockIID, out mixEffectBlockPtr); IBMDSwitcherMixEffectBlockIterator mixEffectBlockIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(mixEffectBlockPtr); IBMDSwitcherMixEffectBlock mixEffectBlock; mixEffectBlockIterator.Next(out mixEffectBlock); return(mixEffectBlock); }
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); }
public static List <IBMDSwitcherMixEffectBlock> GetAllMixEffectBlocks(this IBMDSwitcher switcher) { IBMDSwitcherMixEffectBlockIterator mixEffectBlockIterator = switcher.GetMixEffectBlockIterator(); if (mixEffectBlockIterator == null) { return(null); } List <IBMDSwitcherMixEffectBlock> mixEffectBlocks = new List <IBMDSwitcherMixEffectBlock>(); IBMDSwitcherMixEffectBlock mixEffectBlock; mixEffectBlockIterator.Next(out mixEffectBlock); while (mixEffectBlock != null) { mixEffectBlocks.Add(mixEffectBlock); mixEffectBlockIterator.Next(out mixEffectBlock); } return(mixEffectBlocks); }
private void GetSwitcherMixEffectBlock() { // We want to get the first Mix Effect block (ME 1). We create a ME iterator, // and then get the first one: m_mixEffectBlock = 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); } Marshal.Release(meIteratorPtr); // Release必須? if (meIterator != null) { meIterator.Next(out m_mixEffectBlock); } }
internal IEnumerable <IBMDSwitcherMixEffectBlock> GetMixEffectBlocks() { // Create a mix effect block iterator IntPtr meIteratorPtr; switcher.CreateIterator(typeof(IBMDSwitcherMixEffectBlockIterator).GUID, out meIteratorPtr); IBMDSwitcherMixEffectBlockIterator meIterator = Marshal.GetObjectForIUnknown(meIteratorPtr) as IBMDSwitcherMixEffectBlockIterator; if (meIterator == null) { yield break; } try { // Iterate through all mix effect blocks while (true) { IBMDSwitcherMixEffectBlock me; meIterator.Next(out me); if (me != null) { yield return(me); } else { break; } } } finally { Marshal.ReleaseComObject(meIterator); } }
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(); }
public Switcher(string ipAddress) { var options = new PusherOptions { Cluster = "us2", Encrypted = true }; pusher = new Pusher( "1137245", "f9cabd4c01730143d579", "3b87a4daf5b3f26ee1be", options); IBMDSwitcherDiscovery discovery = new CBMDSwitcherDiscovery(); _BMDSwitcherConnectToFailure failureReason; discovery.ConnectTo(ipAddress, out m_switcher, out failureReason); m_switcherMonitor = new SwitcherMonitor(); m_switcherMonitor.SwitcherDisconnected += OnSwitcherDisconnected; m_mixEffectBlockMonitor = new MixEffectBlockMonitor(); m_mixEffectBlockMonitor.ProgramInputChanged += OnSwitcherProgramChange; m_mixEffectBlockMonitor.PreviewInputChanged += OnSwitcherPreviewChange; m_switcher.AddCallback(m_switcherMonitor); IBMDSwitcherInput input = null; // 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) { input = null; inputIterator.Next(out input); while (input != null) { InputMonitor newInputMonitor = new InputMonitor(input); input.AddCallback(newInputMonitor); m_inputMonitors.Add(newInputMonitor); inputIterator.Next(out input); } } //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; //} // 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); } // Install MixEffectBlockMonitor callbacks: m_mixEffectBlock1.AddCallback(m_mixEffectBlockMonitor); // Get an input iterator. inputIterator = null; inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID; m_switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr); if (inputIteratorPtr != null) { inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr); } if (inputIterator == null) { return; } input = null; inputIterator.Next(out input); while (input != null) { string inputName; long inputId; input.GetInputId(out inputId); input.GetLongName(out inputName); // Add items to list: m_output_list.Add(new StringObjectPair <long>(inputName, inputId)); //m_output_list.Add(new StringObjectPair<long>(inputName, inputId)); inputIterator.Next(out input); } //while (true) //{ //} }
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; }
public void Connect() { if (this.connected) { return; } IBMDSwitcherDiscovery switcherDiscovery = new CBMDSwitcherDiscovery(); _BMDSwitcherConnectToFailure failReason = 0; try { switcherDiscovery.ConnectTo(this.deviceAddress, out this.switcher, out failReason); this.connected = true; // Get the first Mix Effect block (ME 1). m_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) { return; } if (meIterator != null) { meIterator.Next(out m_mixEffectBlock1); } if (m_mixEffectBlock1 == null) { throw new SwitcherLibException("Unexpected: Could not get first mix effect block"); } // Get the second Mix Effect block (ME 2). m_mixEffectBlock2 = null; if (meIterator != null) { meIterator.Next(out m_mixEffectBlock2); } } catch (COMException ex) { switch (failReason) { case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware: throw new SwitcherLibException("Incompatible firmware"); case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureNoResponse: throw new SwitcherLibException(String.Format("No response from {0}", this.deviceAddress)); default: throw new SwitcherLibException(String.Format("Unknown Error: {0}", ex.Message)); } } catch (Exception ex) { throw new SwitcherLibException(String.Format("Unable to connect to switcher: {0}", ex.Message)); } }
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); }