public ByteVector Render() { // We need to render the "tag data" first so that we have to correct size to // render in the tag'field header. The "tag data" -- everything that is included // in ID3v2::Header::tagSize() -- includes the extended header, frames and // padding, but does not include the tag'field header or footer. ByteVector tagData = new ByteVector(); // TODO: Render the extended header. header.ExtendedHeader = false; // Loop through the frames rendering them and adding them to the tagData. foreach (Id3v2Frame frame in frameList) { if (!frame.Header.TagAlterPreservation) { tagData.Add(frame.Render()); } } // Compute the amount of padding, and append that to tagData. uint padding_size = 0; uint original_size = header.TagSize; if (!header.FooterPresent) { if (tagData.Count < original_size) { padding_size = (uint)(original_size - tagData.Count); } else { padding_size = 1024; } tagData.Add(new ByteVector((int)padding_size)); } // Set the tag size. header.TagSize = (uint)tagData.Count; if (header.FooterPresent) { footer = new Id3v2Footer(header); return(header.Render() + tagData + footer.Render()); } return(header.Render() + tagData); }
public ByteVector Render() { // We need to render the "tag data" first so that we have to correct size to // render in the tag'field header. The "tag data" -- everything that is included // in ID3v2::Header::tagSize() -- includes the extended header, frames and // padding, but does not include the tag'field header or footer. ByteVector tagData = new ByteVector(); // TODO: Render the extended header. header.ExtendedHeader = false; // Loop through the frames rendering them and adding them to the tagData. foreach (Id3v2Frame frame in frameList) if (!frame.Header.TagAlterPreservation) tagData.Add(frame.Render()); // Compute the amount of padding, and append that to tagData. uint padding_size = 0; uint original_size = header.TagSize; if (!header.FooterPresent) { if (tagData.Count < original_size) padding_size = (uint)(original_size - tagData.Count); else padding_size = 1024; tagData.Add(new ByteVector((int)padding_size)); } // Set the tag size. header.TagSize = (uint)tagData.Count; if (header.FooterPresent) { footer = new Id3v2Footer(header); return header.Render() + tagData + footer.Render(); } return header.Render() + tagData; }