public void Parse(HDSBinaryReader br, bool longIdFields, bool longOffsetFields)
        {
            time = br.ReadUInt64();

            if (longIdFields)
            {
                segment  = br.ReadUInt32();
                fragment = br.ReadUInt32();
            }
            else
            {
                segment  = br.ReadUInt16();
                fragment = br.ReadUInt16();
            }

            if (longOffsetFields)
            {
                afraOffset     = br.ReadUInt64();
                offsetFromAfra = br.ReadUInt64();
            }
            else
            {
                afraOffset     = br.ReadUInt32();
                offsetFromAfra = br.ReadUInt32();
            }
        }
Beispiel #2
0
        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);
                }
            }
        }
Beispiel #3
0
        public void Parse(HDSBinaryReader br)
        {
            firstFragment   = br.ReadUInt32();
            durationAccrued = br.ReadUInt64();
            duration        = br.ReadUInt32();

            if (duration == 0)
            {
                discontinuityIndicator = br.ReadByte();
            }
        }
Beispiel #4
0
        public static BoxInfo getNextBoxInfo(HDSBinaryReader br)
        {
            if (!br.BaseStream.CanRead || (br.BytesAvailable < F4FConstants.FIELD_SIZE_LENGTH + F4FConstants.FIELD_TYPE_LENGTH))
            {
                return(null);
            }
            uint   size   = br.ReadUInt32();
            string type   = br.ReadUtfBytes(F4FConstants.FIELD_TYPE_LENGTH);
            uint   length = F4FConstants.FIELD_SIZE_LENGTH + F4FConstants.FIELD_TYPE_LENGTH;

            if (size == F4FConstants.FLAG_USE_LARGE_SIZE)
            {
                size    = (uint)br.ReadUInt64();
                length += F4FConstants.FIELD_LARGE_SIZE_LENGTH;
            }

            if (type == F4FConstants.EXTENDED_TYPE)
            {
                // Read past the extended type.
                br.Position += F4FConstants.FIELD_EXTENDED_TYPE_LENGTH;
                length      += F4FConstants.FIELD_EXTENDED_TYPE_LENGTH;
            }

            return(new BoxInfo(size, type, length));
        }
Beispiel #5
0
        public static FLVTag Parse(HDSBinaryReader br)
        {
            if (!br.BaseStream.CanRead || (br.BytesAvailable <= TAG_HEADER_BYTE_COUNT))
            {
                return(null);
            }
            FLVTag tag;

            byte    b    = br.ReadByte();
            TagType type = (TagType)(b & 0x1f);

            switch (type)
            {
            case TagType.AUDIO:
            case TagType.AKAMAI_ENC_AUDIO: tag = new FLVTagAudio(type); break;

            case TagType.VIDEO:
            case TagType.AKAMAI_ENC_VIDEO: tag = new FLVTagVideo(type); break;

            default:                       tag = new FLVTag(type);      break;
            }
            tag.Filter = (b & 0x20) > 0;
            uint dataSize = br.ReadUInt24();

            tag.Timestamp = br.ReadUInt24() + (uint)(br.ReadByte() << 24);
            uint StreamID = br.ReadUInt24();

            tag.Data = br.ReadBytes((int)dataSize);
            if (br.BytesAvailable > 3)
            {
                tag.SizeOfPreviousPacket = br.ReadUInt32();
            }
            return(tag);
        }
        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 void Parse(HDSBinaryReader br, bool longOffsetFields)
 {
     time = br.ReadUInt64();
     if (longOffsetFields)
     {
         offset = br.ReadUInt64();
     }
     else
     {
         offset = 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 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();
            }
        }