Exemplo n.º 1
0
SjByteVector APE_Footer::renderHeader() const
{
	if (!m_headerPresent)
		return SjByteVector();

	return render(true);
}
Exemplo n.º 2
0
SjByteVector ID3v2_Tag::render()
{
	// We need to render the "tag data" first so that we have to correct size to
	// render in the tag's 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's header or footer.

	SjByteVector tagData;

	// TODO: Render the extended header.

	// Loop through the frames rendering them and adding them to the tagData.

	//for(FrameList::Iterator it = d->frameList.begin(); it != d->frameList.end(); it++)
	for ( ID3v2_FrameList::Node *node = m_frameList.GetFirst(); node; node = node->GetNext() )
	{
		ID3v2_Frame* it = node->GetData();
		if(!it->header()->tagAlterPreservation())
			tagData.append(it->render());
	}

	// Compute the amount of padding, and append that to tagData.

	SjUint paddingSize = 0;
	SjUint originalSize = m_header.tagSize();

	if(tagData.size() < originalSize)
		paddingSize = originalSize - tagData.size();
	else
		paddingSize = 1024;

	tagData.append(SjByteVector(paddingSize, char(0)));

	// Set the tag size.
	m_header.setTagSize(tagData.size());

	// TODO: This should eventually include d->footer->render().
	return m_header.render() + tagData;
}
Exemplo n.º 3
0
SjByteVector APE_Item::render() const
{
	SjByteVector data;
	SjUint flags = ((m_readOnly) ? 1 : 0) | (m_type << 1);
	SjByteVector value;

	if(isEmpty())
		return data;

	if(m_type != APE_ItemBinary)
	{
		int i, iCount = m_stringList.GetCount();
		if( iCount>0 )
		{
			value.appendString(m_stringList.Item(0), SJ_UTF8);
			for( i = 1; i < iCount; i++ )
			{
				value.append((unsigned char)'\0');
				value.appendString(m_stringList.Item(i), SJ_UTF8);
			}
		}

		// there should be no need to set back m_binary
	}
	else
	{
		value.append(m_binary);
	}

	data.append(SjByteVector::fromUint(value.size(), false));
	data.append(SjByteVector::fromUint(flags, false));
	data.appendString(m_key, SJ_UTF8);
	data.append(SjByteVector((unsigned char)'\0'));
	data.append(value);

	return data;
}