Esempio n. 1
0
        public bool UpdateMOOFTimeAndOffsetForTrack(int trackID, List <long> MOOFOffsetList)
        {
            bool result = false;

            if (Children != null)
            {
                foreach (var box in Children)
                {
                    if (box.GetBoxType() == "tfra")
                    {
                        Mp4BoxTFRA tfra = box as Mp4BoxTFRA;
                        if (tfra != null)
                        {
                            if (tfra.GetTrackID() == trackID)
                            {
                                if (tfra.GetNumberOfEntry() == MOOFOffsetList.Count)
                                {
                                    return(tfra.UpdateTimeAndOffsetEntries(MOOFOffsetList));
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 2
0
        static public Mp4BoxTFRA CreateTFRABox(Int32 TrackID, List <TimeMoofOffset> list, ulong OffsetWithVideo)
        {
            int  Flag    = 0;
            byte version = 0x01;

            if (list != null)
            {
                int        NumberOfEntry = list.Count;
                Mp4BoxTFRA box           = new Mp4BoxTFRA();
                if (box != null)
                {
                    box.Length = 8 + 4 + 4 + 4 + 4 + (8 + 8 + 3) * NumberOfEntry;
                    box.Type   = "tfra";
                    byte[] Buffer = new byte[box.Length - 8];
                    if (Buffer != null)
                    {
                        WriteMp4BoxByte(Buffer, 0, version);
                        WriteMp4BoxInt24(Buffer, 1, Flag);
                        WriteMp4BoxInt32(Buffer, 4, TrackID);
                        int Reserved = 0;
                        WriteMp4BoxInt32(Buffer, 8, Reserved);
                        WriteMp4BoxInt32(Buffer, 12, NumberOfEntry);
                        ulong offset = 0;
                        for (int i = 0; i < NumberOfEntry; i++)
                        {
                            if (i == 0)
                            {
                                offset = list[i].time;
                            }
                            ulong time = list[i].time - offset + OffsetWithVideo;
                            WriteMp4BoxInt64(Buffer, 16 + i * 19, (long)time);
                            WriteMp4BoxInt64(Buffer, 16 + 8 + i * 19, (long)list[i].offset);
                            WriteMp4BoxInt8(Buffer, 16 + 8 + 8 + i * 19, 1);
                            WriteMp4BoxInt8(Buffer, 16 + 8 + 8 + 1 + i * 19, 1);
                            WriteMp4BoxInt8(Buffer, 16 + 8 + 8 + 1 + 1 + i * 19, 1);
                        }
                        box.Data = Buffer;
                        return(box);
                    }
                }
            }
            return(null);
        }