public override void Parse(BoxInfo bi, HDSBinaryReader br) { base.Parse(bi, br); uint sizes = br.ReadByte(); bool longIdFields = ((sizes & AFRA_MASK_LONG_ID) > 0); bool longOffsetFields = ((sizes & AFRA_MASK_LONG_OFFSET) > 0); bool globalEntries = ((sizes & AFRA_MASK_GLOBAL_ENTRIES) > 0); timeScale = br.ReadUInt32(); localRandomAccessEntries.Clear(); uint entryCount = br.ReadUInt32(); for (uint i = 0; i < entryCount; i++) { LocalRandomAccessEntry lrae = new LocalRandomAccessEntry(); lrae.Parse(br, longOffsetFields); localRandomAccessEntries.Add(lrae); } globalRandomAccessEntries.Clear(); if (globalEntries) { entryCount = br.ReadUInt32(); for (int i = 0; i < entryCount; i++) { GlobalRandomAccessEntry grae = new GlobalRandomAccessEntry(); grae.Parse(br, longIdFields, longOffsetFields); globalRandomAccessEntries.Add(grae); } } }
public static List <Box> GetBoxes(byte[] data, string boxType = "") { List <Box> boxes = new List <Box>(); System.IO.MemoryStream stream = null; try { stream = new System.IO.MemoryStream(data); using (HDSBinaryReader br = new HDSBinaryReader(stream)) { stream = null; BoxInfo bi = BoxInfo.getNextBoxInfo(br); while (bi != null) { if (!string.IsNullOrEmpty(boxType) && bi.Type != boxType) { bi.Type = ""; // for skip other boxes } switch (bi.Type) { case F4FConstants.BOX_TYPE_ABST: AdobeBootstrapBox abst = new AdobeBootstrapBox(); abst.Parse(bi, br); boxes.Add(abst); break; case F4FConstants.BOX_TYPE_AFRA: AdobeFragmentRandomAccessBox arfa = new AdobeFragmentRandomAccessBox(); arfa.Parse(bi, br); boxes.Add(arfa); break; case F4FConstants.BOX_TYPE_MDAT: MediaDataBox mdat = new MediaDataBox(); mdat.Parse(bi, br); boxes.Add(mdat); break; default: br.Position += bi.Size - bi.Length; break; } bi = BoxInfo.getNextBoxInfo(br); if (bi != null && bi.Size <= 0) { break; } } } } finally { if (stream != null) { stream.Dispose(); } } return(boxes); }
public override void Parse(BoxInfo bi, HDSBinaryReader br) { base.Parse(bi, br); qualitySegmentURLModifiers.Clear(); uint qualityEntryCount = br.ReadByte(); for (uint i = 0; i < qualityEntryCount; i++) { qualitySegmentURLModifiers.Add(br.ReadString()); } uint entryCount = br.ReadUInt32(); for (uint i = 0; i < entryCount; i++) { addSegmentFragmentPair(new SegmentFragmentPair(br.ReadUInt32(), br.ReadUInt32())); } }
public override void Parse(BoxInfo bi, HDSBinaryReader br) { base.Parse(bi, br); timeScale = br.ReadUInt32(); qualitySegmentURLModifiers.Clear(); uint qualityEntryCount = br.ReadByte(); for (uint i = 0; i < qualityEntryCount; i++) { qualitySegmentURLModifiers.Add(br.ReadString()); } uint entryCount = br.ReadUInt32(); for (uint i = 0; i < entryCount; i++) { FragmentDurationPair fdp = new FragmentDurationPair(); fdp.Parse(br); fragmentDurationPairs.Add(fdp); } }
public virtual void Parse(BoxInfo bi, HDSBinaryReader br) { Size = bi.Size; Type = bi.Type; Length = bi.Length; }
public override void Parse(BoxInfo bi, HDSBinaryReader br) { base.Parse(bi, br); bootstrapVersion = br.ReadUInt32(); byte temp = br.ReadByte(); profile = (uint)(temp >> 6); live = ((temp & 0x20) > 0); update = ((temp & 0x01) > 0); timeScale = br.ReadUInt32(); currentMediaTime = br.ReadUInt64(); smpteTimeCodeOffset = br.ReadUInt64(); movieIdentifier = br.ReadString(); serverBaseURLs.Clear(); int serverEntryCount = br.ReadByte(); for (int i = 0; i < serverEntryCount; i++) { serverBaseURLs.Add(br.ReadString()); } qualitySegmentURLModifiers.Clear(); int qualityEntryCount = br.ReadByte(); for (int i = 0; i < qualityEntryCount; i++) { qualitySegmentURLModifiers.Add(br.ReadString()); } drmData = br.ReadString(); metadata = br.ReadString(); segmentRunTables.Clear(); uint segmentRunTableCount = br.ReadByte(); for (uint i = 0; i < segmentRunTableCount; i++) { BoxInfo boxInfo = BoxInfo.getNextBoxInfo(br); if (boxInfo == null) { break; } if (boxInfo.Type == F4FConstants.BOX_TYPE_ASRT) { AdobeSegmentRunTable asrt = new AdobeSegmentRunTable(); asrt.Parse(boxInfo, br); segmentRunTables.Add(asrt); } } fragmentRunTables.Clear(); uint fragmentRunTableCount = br.ReadByte(); for (uint i = 0; i < fragmentRunTableCount; i++) { BoxInfo boxInfo = BoxInfo.getNextBoxInfo(br); if (boxInfo == null) { break; } if (boxInfo.Type == F4FConstants.BOX_TYPE_AFRT) { AdobeFragmentRunTable afrt = new AdobeFragmentRunTable(); afrt.Parse(boxInfo, br); fragmentRunTables.Add(afrt); } } // Check if live stream is still live if (live && (fragmentRunTables.Count > 0) && ContentComplete()) { live = false; RemoveLastFragment(); } }