public override bool Parse(QtParser parser) { if (!base.Parse(parser)) { return(false); } parser.GetUInt(Attribute.Version, "{0:X8}"); // TODO: the sequence of descriptors is taken (mostly) from ffmpeg // TODO: verify that this is the actual sequence seen in (all) 3GPP files BaseDescriptor descriptor = ReadDescriptor(parser); if (descriptor.Tag == DescriptorClassTag.ES_DescrTag) { parser.GetUShort(); // ID parser.GetByte(); // priority } else { parser.GetUShort(); // ID } descriptor = ReadDescriptor(parser); if (descriptor.Tag == DescriptorClassTag.DecoderConfigDescrTag) { parser.GetByte(Attribute.ObjectTypeIndication); // 0x20 Visual ISO/IEC 14496-2 parser.GetByte(Attribute.StreamType); parser.GetThreeBytes(Attribute.BufferSizeDB); // 3 bytes parser.GetUInt(Attribute.MaxBitrate); parser.GetUInt(Attribute.AvgBitrate); descriptor = ReadDescriptor(parser); if ((parser.Position + descriptor.Length) > parser.Length) { return(false); } if (descriptor.Tag == DescriptorClassTag.DecSpecificInfoTag) { // Extra data can be empty (0 bytes) if (descriptor.Length > 0) { ExtraData = parser.GetDataPacket(parser.Position, descriptor.Length); } Attributes.Add(new FormattedAttribute <Attribute, long>(Attribute.DecSpecificInfoSize, descriptor.Length)); } parser.Position += Math.Min(descriptor.Length, parser.Length - parser.Position); } return(this.Valid); }
public override bool Parse(QtParser parser) { if (!base.Parse(parser)) { return(false); } if (parser.BytesRemaining > 255) { Valid = false; string value = string.Format("{0} descriptor bytes found", parser.BytesRemaining); parser.AddAttribute(new FormattedAttribute <Attribute, string>(Attribute.Descriptor, value)); parser.GetDataPacket(parser.Position, (long)parser.BytesRemaining); parser.Position += (long)parser.BytesRemaining; } return(Valid); }
// for (i=0; i< numOfSequenceParameterSets; i++) { // unsigned int(16) sequenceParameterSetLength ; // bit(8*sequenceParameterSetLength) sequenceParameterSetNALUnit; // } // // for (i=0; i< numOfPictureParameterSets; i++) { // unsigned int(16) pictureParameterSetLength; // bit(8*pictureParameterSetLength) pictureParameterSetNALUnit; // } private static IDataPacket CreateNalUnit(QtParser parser, byte setCount, Attribute attribute) { long beginOffset = parser.Position; int totalSetLength = 0; for (int i = 0; i < setCount; i++) { ushort setLength = parser.GetUShort(); parser.Position += setLength; totalSetLength += setLength + sizeof(ushort); } if (totalSetLength > 0) { parser.Position = beginOffset; parser.GetHexDump <Attribute>(attribute, totalSetLength); return(parser.GetDataPacket(beginOffset, totalSetLength)); } return(null); }