Exemplo n.º 1
0
func (editor *FlacTagEditor) makeNewPictureBlock(cover Cover) []byte {
	if cover.Empty() {
		return nil
	}

	pictureData := serializeVorbisTagPictureField(cover)

	typeData := make([]byte, 4)
	typeData[0] = pictureBlockType
	utils.WriteInt24Be(len(pictureData), typeData[1:4])

	return append(typeData, pictureData...)
}
Exemplo n.º 2
0
func (editor *FlacTagEditor) makeNewCommentBlock(tag Tag, existingCommentBlock []byte) []byte {
	var vendorData []byte = nil
	var unsupportedTagData []byte = nil
	var unsupportedFields int = 0

	if len(existingCommentBlock) >= 8 {
		vendorSize := utils.ReadInt32Le(existingCommentBlock[4:8])
		vendorData = existingCommentBlock[4 : 8+vendorSize]
		unsupportedTagData, unsupportedFields = getUnsupportedVorbisTags(existingCommentBlock[8+vendorSize:])
	}

	newCommentData, totalFields := serializeVorbisTag(tag, unsupportedFields)

	newCommentBlock := make([]byte, 4+len(vendorData)+4+len(newCommentData)+len(unsupportedTagData))
	newCommentBlock[0] = commentBlockType
	utils.WriteInt24Be(len(newCommentBlock)-4, newCommentBlock[1:4])
	copy(newCommentBlock[4:], vendorData)
	utils.WriteInt32Le(totalFields, newCommentBlock[4+len(vendorData):8+len(vendorData)])
	copy(newCommentBlock[8+len(vendorData):], newCommentData)
	copy(newCommentBlock[8+len(vendorData)+len(newCommentData):], unsupportedTagData)

	return newCommentBlock
}