musikr: add id3v1 tags to files

This commit is contained in:
Alexander Capehart 2025-02-17 14:39:47 -07:00
parent 60e5614e63
commit d4890af780
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 27 additions and 6 deletions

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 = "ID3v1Tag"]
fn FLACID3v1Tag(self: Pin<&mut CPPFLACFile>, create: bool) -> *mut CPPID3v1Tag;
#[cxx_name = "ID3v2Tag"]
fn FLACID3v2Tag(self: Pin<&mut CPPFLACFile>, create: bool) -> *mut CPPID3v2Tag;
#[namespace = "taglib_shim"]
@ -113,6 +115,8 @@ mod bridge_impl {
#[namespace = "TagLib::MPEG"]
#[cxx_name = "File"]
type CPPMPEGFile;
#[cxx_name = "ID3v1Tag"]
fn MPEGID3v1Tag(self: Pin<&mut CPPMPEGFile>, create: bool) -> *mut CPPID3v1Tag;
#[cxx_name = "ID3v2Tag"]
fn MPEGID3v2Tag(self: Pin<&mut CPPMPEGFile>, create: bool) -> *mut CPPID3v2Tag;

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::id3v1::ID3v1Tag;
use super::id3v2::ID3v2Tag;
use super::tk::{ByteVector, OwnedByteVector};
pub use super::xiph::XiphComment;
@ -18,12 +19,6 @@ 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);
@ -41,6 +36,20 @@ impl<'file_ref> FLACFile<'file_ref> {
let this = unsafe { OwnedThis::new(pictures) };
this.map(|this| PictureList::new(this))
}
pub fn id3v1_tag(&mut self) -> Option<ID3v1Tag<'file_ref>> {
let tag = self.this.pin_mut().FLACID3v1Tag(false);
let tag_ref = unsafe { tag.as_mut() };
let tag_this = tag_ref.map(|tag| unsafe { RefThisMut::new(tag) });
tag_this.map(|this| ID3v1Tag::new(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 struct PictureList<'file_ref> {

View file

@ -1,4 +1,5 @@
use super::bridge::{self, CPPMPEGFile};
use super::id3v1::ID3v1Tag;
use super::id3v2::ID3v2Tag;
use super::this::{RefThisMut, This, ThisMut};
use std::pin::Pin;
@ -12,6 +13,13 @@ impl<'file_ref> MPEGFile<'file_ref> {
Self { this }
}
pub fn id3v1_tag(&mut self) -> Option<ID3v1Tag<'file_ref>> {
let tag = self.this.pin_mut().MPEGID3v1Tag(false);
let tag_ref = unsafe { tag.as_mut() };
let tag_this = tag_ref.map(|tag| unsafe { RefThisMut::new(tag) });
tag_this.map(|this| ID3v1Tag::new(this))
}
pub fn id3v2_tag(&mut self) -> Option<ID3v2Tag<'file_ref>> {
let tag = self.this.pin_mut().MPEGID3v2Tag(false);
let tag_ref = unsafe { tag.as_mut() };