musikr: add wav files

This commit is contained in:
Alexander Capehart 2025-02-17 16:28:19 -07:00
parent a3f01f152b
commit da43ebda96
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 24 additions and 0 deletions

View file

@ -132,6 +132,8 @@ mod bridge_impl {
#[namespace = "TagLib::RIFF::WAV"]
#[cxx_name = "File"]
type CPPWAVFile;
#[cxx_name = "ID3v2Tag"]
fn WAVID3v2Tag(self: &CPPWAVFile) -> *mut CPPID3v2Tag;
#[namespace = "TagLib::FLAC"]
#[cxx_name = "Picture"]

View file

@ -12,3 +12,4 @@ pub mod tk;
pub mod id3v2;
pub mod id3v1;
pub mod mp4;
pub mod riff;

View file

@ -0,0 +1,21 @@
use super::bridge::{self, CPPWAVFile};
use super::id3v2::ID3v2Tag;
use super::this::{RefThisMut, This, ThisMut};
use std::pin::Pin;
pub struct WAVFile<'file_ref> {
this: RefThisMut<'file_ref, CPPWAVFile>,
}
impl<'file_ref> WAVFile<'file_ref> {
pub(super) fn new(this: RefThisMut<'file_ref, CPPWAVFile>) -> Self {
Self { this }
}
pub fn id3v2_tag(&mut self) -> Option<ID3v2Tag<'file_ref>> {
let tag = self.this.as_ref().WAVID3v2Tag();
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))
}
}