musikr: add flac id3v2 tags

This commit is contained in:
Alexander Capehart 2025-02-17 14:37:38 -07:00
parent 6385928150
commit 60e5614e63
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
4 changed files with 14 additions and 2 deletions

View file

@ -25,6 +25,7 @@ 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);
// Return the title
let output = shared_env

View file

@ -92,6 +92,8 @@ mod bridge_impl {
#[cxx_name = "File"]
type CPPFLACFile;
fn xiphComment(self: Pin<&mut CPPFLACFile>, create: bool) -> *mut CPPXiphComment;
#[cxx_name = "ID3v2Tag"]
fn FLACID3v2Tag(self: Pin<&mut CPPFLACFile>, create: bool) -> *mut CPPID3v2Tag;
#[namespace = "taglib_shim"]
fn FLACFile_pictureList(file: Pin<&mut CPPFLACFile>) -> UniquePtr<CPPPictureList>;
@ -111,7 +113,8 @@ mod bridge_impl {
#[namespace = "TagLib::MPEG"]
#[cxx_name = "File"]
type CPPMPEGFile;
fn ID3v2Tag(self: Pin<&mut CPPMPEGFile>, create: bool) -> *mut CPPID3v2Tag;
#[cxx_name = "ID3v2Tag"]
fn MPEGID3v2Tag(self: Pin<&mut CPPMPEGFile>, create: bool) -> *mut CPPID3v2Tag;
#[namespace = "TagLib::MP4"]
#[cxx_name = "File"]

View file

@ -1,6 +1,7 @@
pub use super::bridge::CPPFLACFile;
pub use super::bridge::CPPFLACPicture;
use super::bridge::{CPPPictureList, FLACFile_pictureList, PictureList_to_vector, Picture_data, CPPByteVector};
use super::id3v2::ID3v2Tag;
use super::tk::{ByteVector, OwnedByteVector};
pub use super::xiph::XiphComment;
use super::this::{OwnedThis, RefThisMut, RefThis, This, ThisMut};
@ -17,6 +18,13 @@ impl<'file_ref> FLACFile<'file_ref> {
Self { this }
}
pub fn id3v2_tag(&mut self) -> Option<ID3v2Tag<'file_ref>> {
let tag = self.this.pin_mut().FLACID3v2Tag(false);
let tag_ref = unsafe { tag.as_mut() };
let tag_this = tag_ref.map(|tag| unsafe { RefThisMut::new(tag) });
tag_this.map(|this| ID3v2Tag::new(this))
}
pub fn xiph_comments(&mut self) -> Option<XiphComment<'file_ref>> {
let tag = self.this.pin_mut().xiphComment(false);
let tag_ref = unsafe {

View file

@ -13,7 +13,7 @@ impl<'file_ref> MPEGFile<'file_ref> {
}
pub fn id3v2_tag(&mut self) -> Option<ID3v2Tag<'file_ref>> {
let tag = self.this.pin_mut().ID3v2Tag(false);
let tag = self.this.pin_mut().MPEGID3v2Tag(false);
let tag_ref = unsafe { tag.as_mut() };
let tag_this = tag_ref.map(|tag| unsafe { RefThisMut::new(tag) });
tag_this.map(|this| ID3v2Tag::new(this))