Пример #1
0
        public override IEnumerator <IReportBlock> GetEnumerator()
        {
            //CheckDisposed();

            //The first entry is in the header
            using (ReportBlock rb = new ReportBlock(Header.GetSendersSynchronizationSourceIdentifierSegment()))
            {
                yield return(rb);
            }//size becomes -.... add shouldDispose = false....

            //If there are no more entries then we can return
            if (Header.BlockCount == 1)
            {
                yield break;
            }

            //The next entries are in the payload.
            using (RFC3550.SourceList sl = GetSourceList())
            {
                foreach (uint ssrc in sl)
                {
                    //Give a ReportBlock of 4 bytes to represent the source list entry
                    using (ReportBlock rb = new ReportBlock(new MemorySegment(Payload.Array, Payload.Offset + sl.ItemIndex * RFC3550.SourceList.ItemSize, RFC3550.SourceList.ItemSize)))
                    {
                        yield return(rb);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new ReportBlock instance from the given existing reference.
        /// Throws a ArgumentNullException if <paramref name="reference"/> is null.
        /// </summary>
        /// <param name="reference">A reference to a ReportBlock instance.</param>
        public ReportBlock(ReportBlock reference, bool shouldDispose = true)
            : base(shouldDispose)
        {
            if (reference == null)
            {
                throw new ArgumentNullException();
            }

            Memory = reference.Memory;
        }
Пример #3
0
        internal protected virtual IEnumerator <IReportBlock> GetEnumeratorInternal(int offset = 0)//, int blockSize = ReportBlock.ReportBlockSize)
        {
            //CheckDisposed();

            //Loop for the BlockCount, bounded by BlockCount and count of bytes in the ReportData
            for (int currentSize = 0, count = ReportBlockOctets, blockCounter = BlockCount, localOffset = Payload.Offset + offset;
                 count > 0 && --blockCounter >= 0 && localOffset + count <= Payload.Count && false.Equals(IsDisposed);
                 count -= currentSize) //Subtract the currentSize each iteration
            {
                //Create the report block using the payload data available, should probably Clamp(count, 0, ReportBlock.ReportBlockSize at report block size since the sdes has its own enumerator.
                using (ReportBlock current = new ReportBlock(new MemorySegment(Payload.Array, localOffset, count)))
                {
                    //Yield the current block
                    yield return(current);

                    //Read the current size
                    currentSize = current.Size;

                    //Move the local offset
                    localOffset += currentSize;
                }
            }
        }