SjByteVector ID3v2_TextIdentificationFrame::renderFields() const
{
	SjByteVector v;

	if(m_fieldList.GetCount() > 0) {

		v.append((unsigned char)(m_textEncoding));

		/*for(StringList::Iterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) {

		  // Since the field list is null delimited, if this is not the first
		  // element in the list, append the appropriate delimiter for this
		  // encoding.

		  if(it != d->fieldList.begin())
		    v.append(textDelimiter(d->textEncoding));

		  v.append((*it).data(d->textEncoding));
		}*/
		int i, iCount = m_fieldList.GetCount();
		for( i = 0; i < iCount; i++ )
		{
			if( i )
				v.append(textDelimiter(m_textEncoding));

			v.appendString(m_fieldList.Item(i), m_textEncoding);
		}
	}

	return v;
}
SjByteVector ID3v2_UniqueFileIdentifierFrame::renderFields() const
{
	SjByteVector data;

	data.appendString(m_owner, SJ_LATIN1);
	data.append((unsigned char)(0));
	data.append(m_identifier);

	return data;
}
SjByteVector ID3v2_PopularimeterFrame::renderFields() const
{
	SjByteVector data;

	data.appendString(m_email, SJ_LATIN1);
	data.append(textDelimiter(SJ_LATIN1));
	data.append((unsigned char)m_rating255);
	data.append(SjByteVector::fromUint((SjUint)m_counter));

	return data;
}
SjByteVector ID3v2_AttachedPictureFrame::renderFields() const
{
	SjByteVector data;

	data.append((unsigned char)(m_textEncoding));
	data.appendString(m_mimeType, SJ_LATIN1);
	data.append(textDelimiter(SJ_LATIN1));
	data.append((unsigned char)(m_type));
	data.appendString(m_description, m_textEncoding);
	data.append(textDelimiter(m_textEncoding));
	data.append(m_data);

	return data;
}
Esempio n. 5
0
SjByteVector ID3v2_Frame::textDelimiter(SjStringType t)
{
	SjByteVector d = (unsigned char)(0);
	if(t == SJ_UTF16 || t == SJ_UTF16BE)
		d.append((unsigned char)(0));
	return d;
}
Esempio n. 6
0
SjByteVector APE_Footer::render(bool isHeader) const
{
	SjByteVector v;

	// add the file identifier -- "APETAGEX"
	v.append(fileIdentifier());

	// add the version number -- we always render a 2.000 tag regardless of what
	// the tag originally was.
	v.append(SjByteVector::fromUint(2000, false));

	// add the tag size
	v.append(SjByteVector::fromUint(m_tagSize, false));

	// add the item count
	v.append(SjByteVector::fromUint(m_itemCount, false));

	// render and add the flags (footer is always present)
	unsigned long flags = 0;
	flags |= m_headerPresent? 0x80000000UL : 0UL;
	flags |= isHeader? 0x20000000UL : 0UL;

	v.append(SjByteVector::fromUint(flags, false));

	// add the reserved 64bit
	v.append(SjByteVector::fromLongLong(0));

	// done
	return v;
}
Esempio n. 7
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;
}
SjByteVector ID3v2_CommentsFrame::renderFields() const
{
	SjByteVector v;

	v.append((unsigned char)(m_textEncoding));

	//v.append(d->language.size() == 3 ? d->language : "   ");
	if( m_language.size() == 3 )
	{
		v.append(m_language);
	}
	else
	{
		v.append((unsigned char*)"   ");
	}

	v.appendString(m_description, m_textEncoding);
	v.append(textDelimiter(m_textEncoding));
	v.appendString(m_text, m_textEncoding);

	return v;
}
Esempio n. 9
0
static void get_str16_nolen(WMA_File *f, int len, wxString& s)
{
	SjByteVector bv = f->ReadBlock(len); // len here is apparently in bytes (see code below)
	bv.append( SjByteVector::fromShort(0) ); // NULL terminator
	s = bv.toString(SJ_UTF16LE);
	//s = String(bv, String::UTF16LE);

//   int c;
//   char *q;

//   q = buf;
//   while (len > 0) {
//     c = get_le16(f);
//     if ((q - buf) < buf_size - 1)
//             *q++ = c;
//     len-=2;
//   }
//   *q = '\0';
}
Esempio n. 10
0
SjByteVector APE_Tag::render() const
{
	SjByteVector data;
	SjUint itemCount = 0;

	{
		SjHashIterator iterator;
		APE_Item* item;
		wxString key;
		while( (item=(APE_Item*)m_itemListMap.Iterate(iterator, key)) )
		{
			data.append(item->render());
			itemCount++;
		}
	}

	m_footer.setItemCount(itemCount);
	m_footer.setTagSize(data.size()+APE_FOOTER_SIZE);
	m_footer.setHeaderPresent(true);

	return m_footer.renderHeader() + data + m_footer.renderFooter();
}
Esempio n. 11
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;
}