public virtual void TestShouldReadValid32WFrame() { byte[] bytes = BufferTools.StringToByteBuffer(W_FRAME + "xxxxx", 0, W_FRAME.Length); TestHelper.ReplaceNumbersWithBytes(bytes, 0); ID3v2Frame frame = new ID3v2Frame(bytes, 0); Assert.AreEqual(43, frame.GetLength()); Assert.AreEqual("WXXX", frame.GetId()); string s = "00ABCDEFGHIJKLMNOPQRSTUVWXYZABCDE"; byte[] expectedBytes = BufferTools.StringToByteBuffer(s, 0, s.Length); TestHelper.ReplaceNumbersWithBytes(expectedBytes, 0); Assert.IsTrue(Arrays.Equals(expectedBytes, frame.GetData())); }
/// <exception cref="Mp3net.InvalidDataException"></exception> protected internal override void UnpackFrameData(byte[] bytes) { ByteBuffer bb = ByteBuffer.Wrap(bytes); id = ByteBufferUtils.ExtractNullTerminatedString(bb); byte flags = bb.Get(); if ((flags & unchecked((int)(0x01))) == unchecked((int)(0x01))) { isRoot = true; } if ((flags & unchecked((int)(0x02))) == unchecked((int)(0x02))) { isOrdered = true; } int childCount = bb.Get(); // TODO: 0xFF -> int = 255; byte = -128; childs = new string[childCount]; for (int i = 0; i < childCount; i++) { childs[i] = ByteBufferUtils.ExtractNullTerminatedString(bb); } for (int offset = bb.Position(); offset < bytes.Length; ) { ID3v2Frame frame = new ID3v2Frame(bytes, offset); offset += frame.GetLength(); subframes.AddItem(frame); } }
/// <exception cref="Mp3net.InvalidDataException"></exception> protected internal override void UnpackFrameData(byte[] bytes) { ByteBuffer bb = ByteBuffer.Wrap(bytes); id = ByteBufferUtils.ExtractNullTerminatedString(bb); bb.Position(id.Length + 1); startTime = bb.GetInt(); endTime = bb.GetInt(); startOffset = bb.GetInt(); endOffset = bb.GetInt(); for (int offset = bb.Position(); offset < bytes.Length; ) { ID3v2Frame frame = new ID3v2Frame(bytes, offset); offset += frame.GetLength(); subframes.AddItem(frame); } }