using System.Collections; using Bmp.Core.FFMpeg.CsCorePorts.FFMpegWrap.Interops; namespace Bmp.Core.FFMpeg.CsCoreExt { public unsafe class FFMpegAttachedPicCollection : IReadOnlyList { private readonly FFMpegAttachedPic[] _items; internal FFMpegAttachedPicCollection(AVFormatContext formatContext) { var pics = new List((int)(formatContext.nb_streams - 1)); for (var i = 0; i < formatContext.nb_streams; i++) { var stream = formatContext.streams[i]; if ((stream->disposition & 0x0400) != 0x0400) continue; // AV_DISPOSITION_ATTACHED_PIC var item = new FFMpegAttachedPic(stream); pics.Add(item); } _items = pics.ToArray(); } public IEnumerator GetEnumerator() { var x = _items.Where(p => true); return x.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public int Count => _items.Length; public FFMpegAttachedPic this[int index] => _items[index]; } }