musikr: make ogg field list map consistent
This commit is contained in:
parent
2c03cf8fed
commit
98bf82ea15
3 changed files with 4 additions and 32 deletions
|
@ -22,34 +22,6 @@ pub extern "C" fn Java_org_oxycblt_musikr_metadata_MetadataJNI_openFile<'local>(
|
|||
let shared_env = Rc::new(RefCell::new(env));
|
||||
let mut stream = JInputStream::new(shared_env.clone(), input);
|
||||
let file_ref = FileRef::new(stream);
|
||||
let title = file_ref.file().and_then(|mut file| {
|
||||
let audio_properties = file.audio_properties();
|
||||
|
||||
if let Some(vorbis_file) = file.as_vorbis() {
|
||||
vorbis_file
|
||||
.xiph_comments()
|
||||
.map(|comments| comments.field_list_map().to_hashmap())
|
||||
.and_then(|comments| comments.get("TITLE").cloned())
|
||||
.and_then(|title| title.first().cloned())
|
||||
.map(|s| s.to_string())
|
||||
} else if let Some(opus_file) = file.as_opus() {
|
||||
opus_file
|
||||
.xiph_comments()
|
||||
.map(|comments| comments.field_list_map().to_hashmap())
|
||||
.and_then(|comments| comments.get("TITLE").cloned())
|
||||
.and_then(|title| title.first().cloned())
|
||||
.map(|s| s.to_string())
|
||||
} else if let Some(mut flac_file) = file.as_flac() {
|
||||
flac_file
|
||||
.xiph_comments()
|
||||
.map(|comments| comments.field_list_map().to_hashmap())
|
||||
.and_then(|comments| comments.get("TITLE").cloned())
|
||||
.and_then(|title| title.first().cloned())
|
||||
.map(|s| s.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
// Return the title
|
||||
let output = shared_env
|
||||
|
|
|
@ -145,8 +145,8 @@ mod bridge_impl {
|
|||
#[namespace = "taglib_shim"]
|
||||
#[cxx_name = "FieldListEntry"]
|
||||
type CPPFieldListEntry;
|
||||
fn key(self: Pin<&CPPFieldListEntry>) -> &CPPString;
|
||||
fn value(self: Pin<&CPPFieldListEntry>) -> &CPPStringList;
|
||||
fn key<'slf, 'file_ref>(self: Pin<&'slf CPPFieldListEntry>) -> &'file_ref CPPString;
|
||||
fn value<'slf, 'file_ref>(self: Pin<&'slf CPPFieldListEntry>) -> &'file_ref CPPStringList;
|
||||
|
||||
#[namespace = "TagLib::ID3v2"]
|
||||
#[cxx_name = "Tag"]
|
||||
|
|
|
@ -39,7 +39,7 @@ impl<'file_ref> FieldListMap<'file_ref> {
|
|||
}
|
||||
|
||||
impl<'file_ref> FieldListMap<'file_ref> {
|
||||
pub fn to_hashmap(&self) -> HashMap<String, Vec<String>> {
|
||||
pub fn to_hashmap(&self) -> HashMap<String, tk::RefStringList<'file_ref>> {
|
||||
let cxx_vec = FieldListMap_to_entries(self.this.pin());
|
||||
cxx_vec
|
||||
.iter()
|
||||
|
@ -56,7 +56,7 @@ impl<'file_ref> FieldListMap<'file_ref> {
|
|||
let key = tk::String::new(key_this).to_string();
|
||||
let value_ref = property_pin.value();
|
||||
let value_this = unsafe { RefThis::new(value_ref) };
|
||||
let value = tk::StringList::new(value_this).to_vec();
|
||||
let value = tk::StringList::new(value_this);
|
||||
(key, value)
|
||||
})
|
||||
.collect()
|
||||
|
|
Loading…
Reference in a new issue