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())); }
public virtual void TestShouldPackAndUnpackHeaderToGiveEquivalentObject() { byte[] bytes = new byte[26]; for (int i = 0; i < bytes.Length; i++) { bytes[i] = unchecked((byte)((byte)('A') + i)); } ID3v2Frame frame = new ID3v2Frame("TEST", bytes); byte[] newBytes = frame.ToBytes(); ID3v2Frame frameCopy = new ID3v2Frame(newBytes, 0); Assert.AreEqual("TEST", frameCopy.GetId()); Assert.AreEqual(frame, frameCopy); }
/// <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); } }
public virtual void AddFrame(ID3v2Frame frame) { frames.AddItem(frame); }
private void AddFrame(ID3v2Frame frame, bool replace) { ID3v2FrameSet frameSet = frameSets.Get(frame.GetId()); if (frameSet == null) { frameSet = new ID3v2FrameSet(frame.GetId()); frameSet.AddFrame(frame); frameSets.Put(frame.GetId(), frameSet); } else { if (replace) { frameSet.Clear(); frameSet.AddFrame(frame); } else { frameSet.AddFrame(frame); } } }