musikr: reformat
This commit is contained in:
parent
a4d7b54db7
commit
32b152e155
5 changed files with 64 additions and 37 deletions
|
@ -87,30 +87,30 @@ void JVMMetadataBuilder::setMp4(const TagLib::MP4::Tag &tag) {
|
|||
auto type = itemValue.type();
|
||||
std::string serializedValue;
|
||||
switch (type) {
|
||||
// Normal expected MP4 items
|
||||
case TagLib::MP4::Item::Type::StringList:
|
||||
mp4AddImpl(mp4, itemName, itemValue.toStringList());
|
||||
break;
|
||||
// Weird MP4 items I'm 90% sure I'll encounter.
|
||||
case TagLib::MP4::Item::Type::Int:
|
||||
serializedValue = std::to_string(itemValue.toInt());
|
||||
break;
|
||||
case TagLib::MP4::Item::Type::UInt:
|
||||
serializedValue = std::to_string(itemValue.toUInt());
|
||||
break;
|
||||
case TagLib::MP4::Item::Type::LongLong:
|
||||
serializedValue = std::to_string(itemValue.toLongLong());
|
||||
break;
|
||||
case TagLib::MP4::Item::Type::IntPair:
|
||||
// It's inefficient going from the integer representation back into
|
||||
// a string, but I fully expect taggers to just write "NN/TT" strings
|
||||
// anyway, and musikr doesn't have to do as much fiddly variant handling.
|
||||
serializedValue = std::to_string(itemValue.toIntPair().first) + "/"
|
||||
+ std::to_string(itemValue.toIntPair().second);
|
||||
break;
|
||||
default:
|
||||
// Don't care about the other types
|
||||
continue;
|
||||
// Normal expected MP4 items
|
||||
case TagLib::MP4::Item::Type::StringList:
|
||||
mp4AddImpl(mp4, itemName, itemValue.toStringList());
|
||||
break;
|
||||
// Weird MP4 items I'm 90% sure I'll encounter.
|
||||
case TagLib::MP4::Item::Type::Int:
|
||||
serializedValue = std::to_string(itemValue.toInt());
|
||||
break;
|
||||
case TagLib::MP4::Item::Type::UInt:
|
||||
serializedValue = std::to_string(itemValue.toUInt());
|
||||
break;
|
||||
case TagLib::MP4::Item::Type::LongLong:
|
||||
serializedValue = std::to_string(itemValue.toLongLong());
|
||||
break;
|
||||
case TagLib::MP4::Item::Type::IntPair:
|
||||
// It's inefficient going from the integer representation back into
|
||||
// a string, but I fully expect taggers to just write "NN/TT" strings
|
||||
// anyway, and musikr doesn't have to do as much fiddly variant handling.
|
||||
serializedValue = std::to_string(itemValue.toIntPair().first) + "/"
|
||||
+ std::to_string(itemValue.toIntPair().second);
|
||||
break;
|
||||
default:
|
||||
// Don't care about the other types
|
||||
continue;
|
||||
}
|
||||
mp4AddImpl(mp4, itemName, TagLib::String(serializedValue));
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
#include "util.h"
|
||||
|
||||
JVMTagMap::JVMTagMap(JNIEnv *env) : env(env) {
|
||||
jclass tagMapClass = env->FindClass("org/oxycblt/musikr/metadata/NativeTagMap");
|
||||
jclass tagMapClass = env->FindClass(
|
||||
"org/oxycblt/musikr/metadata/NativeTagMap");
|
||||
jmethodID init = env->GetMethodID(tagMapClass, "<init>", "()V");
|
||||
tagMap = env->NewObject(tagMapClass, init);
|
||||
tagMapAddIdSingleMethod = env->GetMethodID(tagMapClass, "addID",
|
||||
|
@ -53,7 +54,8 @@ JVMTagMap::~JVMTagMap() {
|
|||
|
||||
void JVMTagMap::add_id(TagLib::String &id, TagLib::String &value) {
|
||||
env->CallVoidMethod(tagMap, tagMapAddIdSingleMethod,
|
||||
env->NewStringUTF(id.toCString(true)), env->NewStringUTF(value.toCString(true)));
|
||||
env->NewStringUTF(id.toCString(true)),
|
||||
env->NewStringUTF(value.toCString(true)));
|
||||
}
|
||||
|
||||
void JVMTagMap::add_id(TagLib::String &id, TagLib::StringList &value) {
|
||||
|
@ -68,10 +70,12 @@ void JVMTagMap::add_id(TagLib::String &id, TagLib::StringList &value) {
|
|||
|
||||
void JVMTagMap::add_custom(TagLib::String &description, TagLib::String &value) {
|
||||
env->CallVoidMethod(tagMap, tagMapAddCustomSingleMethod,
|
||||
env->NewStringUTF(description.toCString(true)), env->NewStringUTF(value.toCString(true)));
|
||||
env->NewStringUTF(description.toCString(true)),
|
||||
env->NewStringUTF(value.toCString(true)));
|
||||
}
|
||||
|
||||
void JVMTagMap::add_custom(TagLib::String &description, TagLib::StringList &value) {
|
||||
void JVMTagMap::add_custom(TagLib::String &description,
|
||||
TagLib::StringList &value) {
|
||||
jobject arrayList = env->NewObject(arrayListClass, arrayListInitMethod);
|
||||
for (auto &item : value) {
|
||||
env->CallBooleanMethod(arrayList, arrayListAddMethod,
|
||||
|
@ -81,21 +85,24 @@ void JVMTagMap::add_custom(TagLib::String &description, TagLib::StringList &valu
|
|||
env->NewStringUTF(description.toCString(true)), arrayList);
|
||||
}
|
||||
|
||||
void JVMTagMap::add_combined(TagLib::String &id, TagLib::String &description, TagLib::String &value) {
|
||||
void JVMTagMap::add_combined(TagLib::String &id, TagLib::String &description,
|
||||
TagLib::String &value) {
|
||||
env->CallVoidMethod(tagMap, tagMapAddCombinedSingleMethod,
|
||||
env->NewStringUTF(id.toCString(true)), env->NewStringUTF(description.toCString(true)),
|
||||
env->NewStringUTF(id.toCString(true)),
|
||||
env->NewStringUTF(description.toCString(true)),
|
||||
env->NewStringUTF(value.toCString(true)));
|
||||
}
|
||||
|
||||
void JVMTagMap::add_combined(TagLib::String &id, TagLib::String &description, TagLib::StringList &value) {
|
||||
void JVMTagMap::add_combined(TagLib::String &id, TagLib::String &description,
|
||||
TagLib::StringList &value) {
|
||||
jobject arrayList = env->NewObject(arrayListClass, arrayListInitMethod);
|
||||
for (auto &item : value) {
|
||||
env->CallBooleanMethod(arrayList, arrayListAddMethod,
|
||||
env->NewStringUTF(item.toCString(true)));
|
||||
}
|
||||
env->CallVoidMethod(tagMap, tagMapAddCombinedListMethod,
|
||||
env->NewStringUTF(id.toCString(true)), env->NewStringUTF(description.toCString(true)),
|
||||
arrayList);
|
||||
env->NewStringUTF(id.toCString(true)),
|
||||
env->NewStringUTF(description.toCString(true)), arrayList);
|
||||
}
|
||||
|
||||
jobject JVMTagMap::getObject() {
|
||||
|
|
|
@ -38,8 +38,10 @@ public:
|
|||
void add_custom(TagLib::String &description, TagLib::String &value);
|
||||
void add_custom(TagLib::String &description, TagLib::StringList &value);
|
||||
|
||||
void add_combined(TagLib::String &id, TagLib::String &description, TagLib::String &value);
|
||||
void add_combined(TagLib::String &id, TagLib::String &description, TagLib::StringList &value);
|
||||
void add_combined(TagLib::String &id, TagLib::String &description,
|
||||
TagLib::String &value);
|
||||
void add_combined(TagLib::String &id, TagLib::String &description,
|
||||
TagLib::StringList &value);
|
||||
|
||||
jobject getObject();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Auxio Project
|
||||
* log.h is part of Auxio.
|
||||
* util.h is part of Auxio.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Auxio Project
|
||||
* NativeTagMap.kt is part of Auxio.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.musikr.metadata
|
||||
|
||||
import org.oxycblt.musikr.util.correctWhitespace
|
||||
|
|
Loading…
Reference in a new issue