bool CTagLoaderTagLib::ParseMP4Tag(MP4::Tag *mp4, EmbeddedArt *art, CMusicInfoTag& tag) { if (!mp4) return false; MP4::ItemListMap& itemListMap = mp4->itemListMap(); for (MP4::ItemListMap::ConstIterator it = itemListMap.begin(); it != itemListMap.end(); ++it) { if (it->first == "\251nam") tag.SetTitle(it->second.toStringList().front().to8Bit(true)); else if (it->first == "\251ART") SetArtist(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "\251alb") tag.SetAlbum(it->second.toStringList().front().to8Bit(true)); else if (it->first == "aART") SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "\251gen") SetGenre(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "\251cmt") tag.SetComment(it->second.toStringList().front().to8Bit(true)); else if (it->first == "cpil") tag.SetCompilation(it->second.toBool()); else if (it->first == "trkn") tag.SetTrackNumber(it->second.toIntPair().first); else if (it->first == "disk") tag.SetPartOfSet(it->second.toIntPair().first); else if (it->first == "\251day") tag.SetYear(it->second.toStringList().front().toInt()); else if (it->first == "----:com.apple.iTunes:MusicBrainz Artist Id") tag.SetMusicBrainzArtistID(it->second.toStringList().front().to8Bit(true)); else if (it->first == "----:com.apple.iTunes:MusicBrainz Album Artist Id") tag.SetMusicBrainzAlbumArtistID(it->second.toStringList().front().to8Bit(true)); else if (it->first == "----:com.apple.iTunes:MusicBrainz Album Id") tag.SetMusicBrainzAlbumID(it->second.toStringList().front().to8Bit(true)); else if (it->first == "----:com.apple.iTunes:MusicBrainz Track Id") tag.SetMusicBrainzTrackID(it->second.toStringList().front().to8Bit(true)); else if (it->first == "covr") { MP4::CoverArtList coverArtList = it->second.toCoverArtList(); for (MP4::CoverArtList::ConstIterator pt = coverArtList.begin(); pt != coverArtList.end(); ++pt) { string mime; switch (pt->format()) { case MP4::CoverArt::PNG: mime = "image/png"; break; case MP4::CoverArt::JPEG: mime = "image/jpeg"; break; default: break; } if (mime.empty()) continue; tag.SetCoverArtInfo(pt->data().size(), mime); if (art) art->set((const uint8_t *)pt->data().data(), pt->data().size(), mime); break; // one is enough } } } return true; }
ByteVector MP4::Tag::renderCovr(const ByteVector &name, const MP4::Item &item) const { ByteVector data; MP4::CoverArtList value = item.toCoverArtList(); for(MP4::CoverArtList::ConstIterator it = value.begin(); it != value.end(); ++it) { data.append(renderAtom("data", ByteVector::fromUInt(it->format()) + ByteVector(4, '\0') + it->data())); } return renderAtom(name, data); }
bool CTagLoaderTagLib::ParseTag(MP4::Tag *mp4, EmbeddedArt *art, CMusicInfoTag& tag) { if (!mp4) return false; ReplayGain replayGainInfo; MP4::ItemListMap& itemListMap = mp4->itemListMap(); for (MP4::ItemListMap::ConstIterator it = itemListMap.begin(); it != itemListMap.end(); ++it) { if (it->first == "\251nam") tag.SetTitle(it->second.toStringList().front().to8Bit(true)); else if (it->first == "\251ART") SetArtist(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:ARTISTS") SetArtistHints(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "\251alb") tag.SetAlbum(it->second.toStringList().front().to8Bit(true)); else if (it->first == "aART") SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:ALBUMARTISTS") SetAlbumArtistHints(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "\251gen") SetGenre(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:MOOD") tag.SetMood(it->second.toStringList().front().to8Bit(true)); else if (it->first == "\251cmt") tag.SetComment(it->second.toStringList().front().to8Bit(true)); else if (it->first == "\251wrt") AddArtistRole(tag, "Composer", StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:CONDUCTOR") AddArtistRole(tag, "Conductor", StringListToVectorString(it->second.toStringList())); //No MP4 standard tag for "ensemble" else if (it->first == "----:com.apple.iTunes:LYRICIST") AddArtistRole(tag, "Lyricist", StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:REMIXER") AddArtistRole(tag, "Remixer", StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:ENGINEER") AddArtistRole(tag, "Engineer", StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:PRODUCER") AddArtistRole(tag, "Producer", StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:DJMIXER") AddArtistRole(tag, "DJMixer", StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:MIXER") AddArtistRole(tag, "Mixer", StringListToVectorString(it->second.toStringList())); //No MP4 standard tag for musician credits else if (it->first == "----:com.apple.iTunes:LABEL") {} // Publisher. Known unsupported, supress warnings else if (it->first == "cpil") tag.SetCompilation(it->second.toBool()); else if (it->first == "trkn") tag.SetTrackNumber(it->second.toIntPair().first); else if (it->first == "disk") tag.SetDiscNumber(it->second.toIntPair().first); else if (it->first == "\251day") tag.SetYear(it->second.toStringList().front().toInt()); else if (it->first == "----:com.apple.iTunes:replaygain_track_gain") replayGainInfo.ParseGain(ReplayGain::TRACK, it->second.toStringList().front().toCString()); else if (it->first == "----:com.apple.iTunes:replaygain_album_gain") replayGainInfo.ParseGain(ReplayGain::ALBUM, it->second.toStringList().front().toCString()); else if (it->first == "----:com.apple.iTunes:replaygain_track_peak") replayGainInfo.ParsePeak(ReplayGain::TRACK, it->second.toStringList().front().toCString()); else if (it->first == "----:com.apple.iTunes:replaygain_album_peak") replayGainInfo.ParsePeak(ReplayGain::ALBUM, it->second.toStringList().front().toCString()); else if (it->first == "----:com.apple.iTunes:MusicBrainz Artist Id") tag.SetMusicBrainzArtistID(SplitMBID(StringListToVectorString(it->second.toStringList()))); else if (it->first == "----:com.apple.iTunes:MusicBrainz Album Artist Id") tag.SetMusicBrainzAlbumArtistID(SplitMBID(StringListToVectorString(it->second.toStringList()))); else if (it->first == "----:com.apple.iTunes:MusicBrainz Album Artist") SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList())); else if (it->first == "----:com.apple.iTunes:MusicBrainz Album Id") tag.SetMusicBrainzAlbumID(it->second.toStringList().front().to8Bit(true)); else if (it->first == "----:com.apple.iTunes:MusicBrainz Track Id") tag.SetMusicBrainzTrackID(it->second.toStringList().front().to8Bit(true)); else if (it->first == "covr") { MP4::CoverArtList coverArtList = it->second.toCoverArtList(); for (MP4::CoverArtList::ConstIterator pt = coverArtList.begin(); pt != coverArtList.end(); ++pt) { std::string mime; switch (pt->format()) { case MP4::CoverArt::PNG: mime = "image/png"; break; case MP4::CoverArt::JPEG: mime = "image/jpeg"; break; default: break; } if (mime.empty()) continue; tag.SetCoverArtInfo(pt->data().size(), mime); if (art) art->set(reinterpret_cast<const uint8_t *>(pt->data().data()), pt->data().size(), mime); break; // one is enough } } } if (mp4->comment() != String::null) tag.SetComment(mp4->comment().toCString(true)); tag.SetReplayGain(replayGainInfo); return true; }