本文整理汇总了C++中taglib::ByteVector::append方法的典型用法代码示例。如果您正苦于以下问题:C++ ByteVector::append方法的具体用法?C++ ByteVector::append怎么用?C++ ByteVector::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::ByteVector
的用法示例。
在下文中一共展示了ByteVector::append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
SetAPETagFromMetadata(const AudioMetadata& metadata, TagLib::APE::Tag *tag, bool setAlbumArt)
{
if(nullptr == tag)
return false;
// Standard tags
SetAPETag(tag, "ALBUM", metadata.GetAlbumTitle());
SetAPETag(tag, "ARTIST", metadata.GetArtist());
SetAPETag(tag, "ALBUMARTIST", metadata.GetAlbumArtist());
SetAPETag(tag, "COMPOSER", metadata.GetComposer());
SetAPETag(tag, "GENRE", metadata.GetGenre());
SetAPETag(tag, "DATE", metadata.GetReleaseDate());
SetAPETag(tag, "DESCRIPTION", metadata.GetComment());
SetAPETag(tag, "TITLE", metadata.GetTitle());
SetAPETagNumber(tag, "TRACKNUMBER", metadata.GetTrackNumber());
SetAPETagNumber(tag, "TRACKTOTAL", metadata.GetTrackTotal());
SetAPETagBoolean(tag, "COMPILATION", metadata.GetCompilation());
SetAPETagNumber(tag, "DISCNUMBER", metadata.GetDiscNumber());
SetAPETagNumber(tag, "DISCTOTAL", metadata.GetDiscTotal());
SetAPETagNumber(tag, "BPM", metadata.GetBPM());
SetAPETagNumber(tag, "RATING", metadata.GetRating());
SetAPETag(tag, "ISRC", metadata.GetISRC());
SetAPETag(tag, "MCN", metadata.GetMCN());
SetAPETag(tag, "TITLESORT", metadata.GetTitleSortOrder());
SetAPETag(tag, "ALBUMTITLESORT", metadata.GetAlbumTitleSortOrder());
SetAPETag(tag, "ARTISTSORT", metadata.GetArtistSortOrder());
SetAPETag(tag, "ALBUMARTISTSORT", metadata.GetAlbumArtistSortOrder());
SetAPETag(tag, "COMPOSERSORT", metadata.GetComposerSortOrder());
SetAPETag(tag, "GROUPING", metadata.GetGrouping());
// Additional metadata
CFDictionaryRef additionalMetadata = metadata.GetAdditionalMetadata();
if(nullptr != additionalMetadata) {
CFIndex count = CFDictionaryGetCount(additionalMetadata);
const void * keys [count];
const void * values [count];
CFDictionaryGetKeysAndValues(additionalMetadata, reinterpret_cast<const void **>(keys), reinterpret_cast<const void **>(values));
for(CFIndex i = 0; i < count; ++i) {
CFIndex keySize = CFStringGetMaximumSizeForEncoding(CFStringGetLength(reinterpret_cast<CFStringRef>(keys[i])), kCFStringEncodingASCII);
char key [keySize + 1];
if(!CFStringGetCString(reinterpret_cast<CFStringRef>(keys[i]), key, keySize + 1, kCFStringEncodingASCII)) {
LOGGER_ERR("org.sbooth.AudioEngine", "CFStringGetCString failed");
continue;
}
SetAPETag(tag, key, reinterpret_cast<CFStringRef>(values[i]));
}
}
// ReplayGain info
SetAPETagDouble(tag, "REPLAYGAIN_REFERENCE_LOUDNESS", metadata.GetReplayGainReferenceLoudness(), CFSTR("%2.1f dB"));
SetAPETagDouble(tag, "REPLAYGAIN_TRACK_GAIN", metadata.GetReplayGainTrackGain(), CFSTR("%+2.2f dB"));
SetAPETagDouble(tag, "REPLAYGAIN_TRACK_PEAK", metadata.GetReplayGainTrackPeak(), CFSTR("%1.8f"));
SetAPETagDouble(tag, "REPLAYGAIN_ALBUM_GAIN", metadata.GetReplayGainAlbumGain(), CFSTR("%+2.2f dB"));
SetAPETagDouble(tag, "REPLAYGAIN_ALBUM_PEAK", metadata.GetReplayGainAlbumPeak(), CFSTR("%1.8f"));
// Album art
if(setAlbumArt) {
tag->removeItem("Cover Art (Front)");
tag->removeItem("Cover Art (Back)");
#if 0
tag->removeItem("METADATA_BLOCK_PICTURE");
#endif
for(auto attachedPicture : metadata.GetAttachedPictures()) {
// APE can handle front and back covers natively
if(AttachedPicture::Type::FrontCover == attachedPicture->GetType() || AttachedPicture::Type::FrontCover == attachedPicture->GetType()) {
TagLib::ByteVector data;
if(attachedPicture->GetDescription())
data.append(TagLib::StringFromCFString(attachedPicture->GetDescription()).data(TagLib::String::UTF8));
data.append('\0');
data.append(TagLib::ByteVector((const char *)CFDataGetBytePtr(attachedPicture->GetData()), (TagLib::uint)CFDataGetLength(attachedPicture->GetData())));
if(AttachedPicture::Type::FrontCover == attachedPicture->GetType())
tag->setData("Cover Art (Front)", data);
else if(AttachedPicture::Type::BackCover == attachedPicture->GetType())
tag->setData("Cover Art (Back)", data);
}
#if 0
else {
CGImageSourceRef imageSource = CGImageSourceCreateWithData(attachedPicture->GetData(), nullptr);
if(nullptr == imageSource)
return false;
TagLib::FLAC::Picture picture;
picture.setData(TagLib::ByteVector((const char *)CFDataGetBytePtr(attachedPicture->GetData()), (TagLib::uint)CFDataGetLength(attachedPicture->GetData())));
picture.setType(static_cast<TagLib::FLAC::Picture::Type>(attachedPicture->GetType()));
if(attachedPicture->GetDescription())
picture.setDescription(TagLib::StringFromCFString(attachedPicture->GetDescription()));
// Convert the image's UTI into a MIME type
CFStringRef mimeType = UTTypeCopyPreferredTagWithClass(CGImageSourceGetType(imageSource), kUTTagClassMIMEType);
if(mimeType) {
picture.setMimeType(TagLib::StringFromCFString(mimeType));
//.........这里部分代码省略.........