Ejemplo n.º 1
0
        static EditListBox load32(Mp4Reader reader, int length)
        {
            Entry32[] entries = new Entry32[length];
            var       bytes   = entries.AsSpan().asBytes();

            reader.read(bytes);

            Span <uint> integers = bytes.cast <uint>();

            for (int i = 0; i < integers.Length; i++)
            {
                integers[i] = BinaryPrimitives.ReverseEndianness(integers[i]);
            }

            int rate = reader.readStructure <int>().endian();

            return(new EditListBox(entries, rate));
        }
Ejemplo n.º 2
0
        public static iEditList create(EditListBox box, uint mediaScale, uint trackScale)
        {
            if (null == box || null == box.entries || box.entries.Length <= 0)
            {
                return(new Identity());
            }

            if (box.entries.Length > 1)
            {
                throw new NotSupportedException("The mp4 file has an edit list with more than 1 entry, this is not supported");
            }
            if (box.mediaRate != 0x10000)
            {
                throw new NotSupportedException($"The mp4 file has an edit list with a custom time scale { box.mediaRateDbl }, this is not supported");
            }

            Entry64 entry;

            if (box.entries is Entry32[] list32)
            {
                Entry32 e = list32[0];
                entry.mediaTime       = e.mediaTime;
                entry.segmentDuration = e.segmentDuration;
            }
            else if (box.entries is Entry64[] list64)
            {
                entry = list64[0];
            }
            else
            {
                throw new ApplicationException("Unknown entries type");
            }

            long offsetValue = -entry.mediaTime;

            return(new Offset(offsetValue));
        }