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();
|
auto type = itemValue.type();
|
||||||
std::string serializedValue;
|
std::string serializedValue;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
// Normal expected MP4 items
|
// Normal expected MP4 items
|
||||||
case TagLib::MP4::Item::Type::StringList:
|
case TagLib::MP4::Item::Type::StringList:
|
||||||
mp4AddImpl(mp4, itemName, itemValue.toStringList());
|
mp4AddImpl(mp4, itemName, itemValue.toStringList());
|
||||||
break;
|
break;
|
||||||
// Weird MP4 items I'm 90% sure I'll encounter.
|
// Weird MP4 items I'm 90% sure I'll encounter.
|
||||||
case TagLib::MP4::Item::Type::Int:
|
case TagLib::MP4::Item::Type::Int:
|
||||||
serializedValue = std::to_string(itemValue.toInt());
|
serializedValue = std::to_string(itemValue.toInt());
|
||||||
break;
|
break;
|
||||||
case TagLib::MP4::Item::Type::UInt:
|
case TagLib::MP4::Item::Type::UInt:
|
||||||
serializedValue = std::to_string(itemValue.toUInt());
|
serializedValue = std::to_string(itemValue.toUInt());
|
||||||
break;
|
break;
|
||||||
case TagLib::MP4::Item::Type::LongLong:
|
case TagLib::MP4::Item::Type::LongLong:
|
||||||
serializedValue = std::to_string(itemValue.toLongLong());
|
serializedValue = std::to_string(itemValue.toLongLong());
|
||||||
break;
|
break;
|
||||||
case TagLib::MP4::Item::Type::IntPair:
|
case TagLib::MP4::Item::Type::IntPair:
|
||||||
// It's inefficient going from the integer representation back into
|
// It's inefficient going from the integer representation back into
|
||||||
// a string, but I fully expect taggers to just write "NN/TT" strings
|
// 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.
|
// anyway, and musikr doesn't have to do as much fiddly variant handling.
|
||||||
serializedValue = std::to_string(itemValue.toIntPair().first) + "/"
|
serializedValue = std::to_string(itemValue.toIntPair().first) + "/"
|
||||||
+ std::to_string(itemValue.toIntPair().second);
|
+ std::to_string(itemValue.toIntPair().second);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Don't care about the other types
|
// Don't care about the other types
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mp4AddImpl(mp4, itemName, TagLib::String(serializedValue));
|
mp4AddImpl(mp4, itemName, TagLib::String(serializedValue));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
JVMTagMap::JVMTagMap(JNIEnv *env) : env(env) {
|
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");
|
jmethodID init = env->GetMethodID(tagMapClass, "<init>", "()V");
|
||||||
tagMap = env->NewObject(tagMapClass, init);
|
tagMap = env->NewObject(tagMapClass, init);
|
||||||
tagMapAddIdSingleMethod = env->GetMethodID(tagMapClass, "addID",
|
tagMapAddIdSingleMethod = env->GetMethodID(tagMapClass, "addID",
|
||||||
|
@ -53,7 +54,8 @@ JVMTagMap::~JVMTagMap() {
|
||||||
|
|
||||||
void JVMTagMap::add_id(TagLib::String &id, TagLib::String &value) {
|
void JVMTagMap::add_id(TagLib::String &id, TagLib::String &value) {
|
||||||
env->CallVoidMethod(tagMap, tagMapAddIdSingleMethod,
|
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) {
|
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) {
|
void JVMTagMap::add_custom(TagLib::String &description, TagLib::String &value) {
|
||||||
env->CallVoidMethod(tagMap, tagMapAddCustomSingleMethod,
|
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);
|
jobject arrayList = env->NewObject(arrayListClass, arrayListInitMethod);
|
||||||
for (auto &item : value) {
|
for (auto &item : value) {
|
||||||
env->CallBooleanMethod(arrayList, arrayListAddMethod,
|
env->CallBooleanMethod(arrayList, arrayListAddMethod,
|
||||||
|
@ -81,21 +85,24 @@ void JVMTagMap::add_custom(TagLib::String &description, TagLib::StringList &valu
|
||||||
env->NewStringUTF(description.toCString(true)), arrayList);
|
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->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)));
|
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);
|
jobject arrayList = env->NewObject(arrayListClass, arrayListInitMethod);
|
||||||
for (auto &item : value) {
|
for (auto &item : value) {
|
||||||
env->CallBooleanMethod(arrayList, arrayListAddMethod,
|
env->CallBooleanMethod(arrayList, arrayListAddMethod,
|
||||||
env->NewStringUTF(item.toCString(true)));
|
env->NewStringUTF(item.toCString(true)));
|
||||||
}
|
}
|
||||||
env->CallVoidMethod(tagMap, tagMapAddCombinedListMethod,
|
env->CallVoidMethod(tagMap, tagMapAddCombinedListMethod,
|
||||||
env->NewStringUTF(id.toCString(true)), env->NewStringUTF(description.toCString(true)),
|
env->NewStringUTF(id.toCString(true)),
|
||||||
arrayList);
|
env->NewStringUTF(description.toCString(true)), arrayList);
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject JVMTagMap::getObject() {
|
jobject JVMTagMap::getObject() {
|
||||||
|
|
|
@ -38,8 +38,10 @@ public:
|
||||||
void add_custom(TagLib::String &description, TagLib::String &value);
|
void add_custom(TagLib::String &description, TagLib::String &value);
|
||||||
void add_custom(TagLib::String &description, TagLib::StringList &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,
|
||||||
void add_combined(TagLib::String &id, TagLib::String &description, TagLib::StringList &value);
|
TagLib::String &value);
|
||||||
|
void add_combined(TagLib::String &id, TagLib::String &description,
|
||||||
|
TagLib::StringList &value);
|
||||||
|
|
||||||
jobject getObject();
|
jobject getObject();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024 Auxio Project
|
* 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
|
* 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
|
* 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
|
package org.oxycblt.musikr.metadata
|
||||||
|
|
||||||
import org.oxycblt.musikr.util.correctWhitespace
|
import org.oxycblt.musikr.util.correctWhitespace
|
||||||
|
@ -32,4 +50,4 @@ class NativeTagMap {
|
||||||
fun getObject(): Map<String, List<String>> {
|
fun getObject(): Map<String, List<String>> {
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue