using JT1078.FMp4.Interfaces; using JT1078.FMp4.MessagePack; using System; using System.Collections.Generic; using System.Text; namespace JT1078.FMp4 { /// /// tfhd /// public class TrackFragmentHeaderBox : FullBox, IFMp4MessagePackFormatter { /// /// tfhd /// /// /// public TrackFragmentHeaderBox(byte version, uint flags) : base("tfhd", version, flags) { } /// /// tfhd /// /// public TrackFragmentHeaderBox(uint flags = 0) : this(0, flags) { } public uint TrackID { get; set; } #region all the following are optional fields /// /// TFHD_FLAG_BASE_DATA_OFFSET /// public ulong BaseDataOffset { get; set; } /// /// TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX /// public uint SampleDescriptionIndex { get; set; } /// /// TFHD_FLAG_DEFAULT_DURATION /// public uint DefaultSampleDuration { get; set; } /// /// TFHD_FLAG_DEFAULT_SIZE /// H.264 NALU SIZE /// public uint DefaultSampleSize { get; set; } /// /// TFHD_FLAG_DEFAULT_FLAGS /// public uint DefaultSampleFlags { get; set; } #endregion public void ToBuffer(ref FMp4MessagePackWriter writer) { Start(ref writer); WriterFullBoxToBuffer(ref writer); writer.WriteUInt32(TrackID); if ((FMp4Constants.TFHD_FLAG_BASE_DATA_OFFSET & Flags) > 0) { writer.WriteUInt64(BaseDataOffset); } if ((FMp4Constants.TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX & Flags) > 0) { writer.WriteUInt32(SampleDescriptionIndex); } if ((FMp4Constants.TFHD_FLAG_DEFAULT_DURATION & Flags) > 0) { writer.WriteUInt32(DefaultSampleDuration); } if ((FMp4Constants.TFHD_FLAG_DEFAULT_SIZE & Flags) > 0) { writer.WriteUInt32(DefaultSampleSize); } if ((FMp4Constants.TFHD_FLAG_DEFAULT_FLAGS & Flags) > 0) { writer.WriteUInt32(DefaultSampleFlags); } End(ref writer); } } }