public Mp4ObjectDescriptor(Mp4Stream stream, Mp4DescriptorTag tag, uint headerSize, uint payloadSize) : base(tag, headerSize, payloadSize) { Mp4Descriptor descriptor; long position = stream.Position; ushort num2 = stream.ReadUInt16(); this.ObjectDescriptorId = (ushort)(num2 >> 6); this.UrlFlag = (num2 & 0x20) != 0; if (this.UrlFlag) { byte count = stream.ReadUInt08(); byte[] buffer = new byte[0x100]; stream.Read(buffer, count); buffer[count] = 0; this.Url = Encoding.ASCII.GetString(buffer, 0, count); } long offset = stream.Position; this.SubDescriptors = new List <Mp4Descriptor>(); Mp4DescriptorFactory factory = new Mp4DescriptorFactory(); Mp4SubStream stream2 = new Mp4SubStream(stream, offset, (long)(payloadSize - ((uint)(offset - position)))); while ((descriptor = factory.Read(stream2)) != null) { this.SubDescriptors.Add(descriptor); } }
public Mp4Descriptor(Mp4DescriptorTag tag, uint headerSize, uint payloadSize) { this.Tag = tag; this.HeaderSize = headerSize; this.PayloadSize = payloadSize; if ((headerSize < 2) || (headerSize > 5)) { throw new Exception(); } }
public Mp4Descriptor Read(Mp4Stream stream) { if ((stream.Length - stream.Position) == 0L) { return(null); } Mp4Descriptor descriptor = null; long position = stream.Position; Mp4DescriptorTag tag = (Mp4DescriptorTag)stream.ReadUInt08(); uint payloadSize = 0; uint headerSize = 1; uint num4 = 4; byte num5 = 0; do { headerSize++; num5 = stream.ReadUInt08(); payloadSize = (payloadSize << 7) + ((uint)(num5 & 0x7f)); }while ((--num4 != 0) && ((num5 & 0x80) != 0)); switch (tag) { case Mp4DescriptorTag.OD: case Mp4DescriptorTag.MP4_OD: descriptor = new Mp4ObjectDescriptor(stream, tag, headerSize, payloadSize); break; case Mp4DescriptorTag.ES: descriptor = new Mp4EsDescriptor(stream, headerSize, payloadSize); break; case Mp4DescriptorTag.DECODER_CONFIG: descriptor = new Mp4DecoderConfigDescriptor(stream, headerSize, payloadSize); break; case Mp4DescriptorTag.DECODER_SPECIFIC_INFO: descriptor = new Mp4DecoderSpecificInfoDescriptor(stream, headerSize, payloadSize); break; case Mp4DescriptorTag.SL_CONFIG: if (payloadSize != 1) { throw new Exception("INVALID_FORMAT"); } descriptor = new Mp4SLConfigDescriptor(stream, headerSize, payloadSize); break; default: descriptor = new Mp4UnknownDescriptor(stream, tag, headerSize, payloadSize); break; } stream.Seek((position + headerSize) + payloadSize); return(descriptor); }
public Mp4UnknownDescriptor(Mp4Stream stream, Mp4DescriptorTag tag, uint headerSize, uint payloadSize) : base(tag, headerSize, payloadSize) { this.Data = new byte[payloadSize]; stream.Read(this.Data, (int)payloadSize); }