public void Parse(byte[] bytes, ref int startIndex, int length, int count) { Chunks = new SourceDescriptionPacketChunk[count]; for (int i = 0; i < Chunks.Length; i++) { UInt32 ssrc = bytes.BigendianToUInt32(ref startIndex); if (Enum.IsDefined(typeof(SourceDescriptionPacketChunk.ItemType), (int)bytes[startIndex]) == false) { throw new ParseException(@"Invalid SourceDescriptionPacketChunk.ItemType value"); } var itemType = (SourceDescriptionPacketChunk.ItemType)bytes[startIndex++]; string value = null; int prefixLength = 0; if (itemType == SourceDescriptionPacketChunk.ItemType.Priv) { value = RtcpString.Decode(bytes, ref startIndex, length, out prefixLength); } else { value = RtcpString.Decode(bytes, ref startIndex, length); } Chunks[i] = new SourceDescriptionPacketChunk() { Ssrc = ssrc, Type = itemType, Value = value, PrefixLength = prefixLength, }; // Each chunk starts on a 32-bit boundary. startIndex += (startIndex % 4 > 0) ? 4 - startIndex % 4 : 0; } }
public void Parse(byte[] bytes, ref int startIndex, int length, int count) { Chunks = new SourceDescriptionPacketChunk[count]; for (int i = 0; i < Chunks.Length; i++) { UInt32 ssrc = bytes.BigendianToUInt32(ref startIndex); if (Enum.IsDefined(typeof(SourceDescriptionPacketChunk.ItemType), (int)bytes[startIndex]) == false) throw new ParseException(@"Invalid SourceDescriptionPacketChunk.ItemType value"); var itemType = (SourceDescriptionPacketChunk.ItemType)bytes[startIndex++]; string value = null; int prefixLength = 0; if (itemType == SourceDescriptionPacketChunk.ItemType.Priv) value = RtcpString.Decode(bytes, ref startIndex, length, out prefixLength); else value = RtcpString.Decode(bytes, ref startIndex, length); Chunks[i] = new SourceDescriptionPacketChunk() { Ssrc = ssrc, Type = itemType, Value = value, PrefixLength = prefixLength, }; // Each chunk starts on a 32-bit boundary. startIndex += (startIndex % 4 > 0) ? 4 - startIndex % 4 : 0; } }