Пример #1
0
        /// <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);
            }
        }
 public MixEffectBlockConnectedEventArgs(MEBlock connectedMEBlock)
 {
     ConnectedMEBlock = connectedMEBlock;
 }