musikr: add id3v1 tag
This commit is contained in:
parent
0cb1b3a309
commit
024cadf530
8 changed files with 121 additions and 12 deletions
|
@ -121,7 +121,8 @@ fn main() {
|
|||
.file("shim/tk_shim.cpp")
|
||||
.file("shim/picture_shim.cpp")
|
||||
.file("shim/xiph_shim.cpp")
|
||||
.file("shim/id3_shim.cpp")
|
||||
.file("shim/id3v1_shim.cpp")
|
||||
.file("shim/id3v2_shim.cpp")
|
||||
.include(format!("taglib/pkg/{}/include", target))
|
||||
.include(".") // Add the current directory to include path
|
||||
.flag_if_supported("-std=c++14");
|
||||
|
|
31
musikr/src/main/jni/shim/id3v1_shim.cpp
Normal file
31
musikr/src/main/jni/shim/id3v1_shim.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "id3v1_shim.hpp"
|
||||
|
||||
namespace taglib_shim {
|
||||
std::unique_ptr<String> ID3v1Tag_title(const ID3v1::Tag& tag) {
|
||||
return std::make_unique<String>(tag.title());
|
||||
}
|
||||
|
||||
std::unique_ptr<String> ID3v1Tag_artist(const ID3v1::Tag& tag) {
|
||||
return std::make_unique<String>(tag.artist());
|
||||
}
|
||||
|
||||
std::unique_ptr<String> ID3v1Tag_album(const ID3v1::Tag& tag) {
|
||||
return std::make_unique<String>(tag.album());
|
||||
}
|
||||
|
||||
std::unique_ptr<String> ID3v1Tag_comment(const ID3v1::Tag& tag) {
|
||||
return std::make_unique<String>(tag.comment());
|
||||
}
|
||||
|
||||
uint ID3v1Tag_genreIndex(const ID3v1::Tag& tag) {
|
||||
return tag.genreIndex();
|
||||
}
|
||||
|
||||
uint ID3v1Tag_year(const ID3v1::Tag& tag) {
|
||||
return tag.year();
|
||||
}
|
||||
|
||||
uint ID3v1Tag_track(const ID3v1::Tag& tag) {
|
||||
return tag.track();
|
||||
}
|
||||
}
|
15
musikr/src/main/jni/shim/id3v1_shim.hpp
Normal file
15
musikr/src/main/jni/shim/id3v1_shim.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <taglib/id3v1tag.h>
|
||||
#include <taglib/tstring.h>
|
||||
|
||||
namespace taglib_shim {
|
||||
std::unique_ptr<TagLib::String> ID3v1Tag_title(const TagLib::ID3v1::Tag& tag);
|
||||
std::unique_ptr<TagLib::String> ID3v1Tag_artist(const TagLib::ID3v1::Tag& tag);
|
||||
std::unique_ptr<TagLib::String> ID3v1Tag_album(const TagLib::ID3v1::Tag& tag);
|
||||
std::unique_ptr<TagLib::String> ID3v1Tag_comment(const TagLib::ID3v1::Tag& tag);
|
||||
uint ID3v1Tag_genreIndex(const TagLib::ID3v1::Tag& tag);
|
||||
uint ID3v1Tag_year(const TagLib::ID3v1::Tag& tag);
|
||||
uint ID3v1Tag_track(const TagLib::ID3v1::Tag& tag);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include "id3_shim.hpp"
|
||||
#include "id3v2_shim.hpp"
|
||||
|
||||
namespace taglib_shim {
|
||||
std::unique_ptr<TagLib::ID3v2::FrameList> Tag_frameList(const TagLib::ID3v2::Tag& tag) {
|
|
@ -32,7 +32,8 @@ mod bridge_impl {
|
|||
include!("shim/tk_shim.hpp");
|
||||
include!("shim/picture_shim.hpp");
|
||||
include!("shim/xiph_shim.hpp");
|
||||
include!("shim/id3_shim.hpp");
|
||||
include!("shim/id3v2_shim.hpp");
|
||||
include!("shim/id3v1_shim.hpp");
|
||||
include!("taglib/mpegfile.h");
|
||||
|
||||
#[namespace = "TagLib"]
|
||||
|
@ -234,6 +235,18 @@ mod bridge_impl {
|
|||
type CPPByteVector;
|
||||
fn size(self: Pin<&CPPByteVector>) -> u32;
|
||||
fn data(self: Pin<&CPPByteVector>) -> *const c_char;
|
||||
|
||||
#[namespace = "TagLib::ID3v1"]
|
||||
#[cxx_name = "Tag"]
|
||||
type CPPID3v1Tag;
|
||||
|
||||
fn ID3v1Tag_title(tag: Pin<&CPPID3v1Tag>) -> UniquePtr<CPPString>;
|
||||
fn ID3v1Tag_artist(tag: Pin<&CPPID3v1Tag>) -> UniquePtr<CPPString>;
|
||||
fn ID3v1Tag_album(tag: Pin<&CPPID3v1Tag>) -> UniquePtr<CPPString>;
|
||||
fn ID3v1Tag_comment(tag: Pin<&CPPID3v1Tag>) -> UniquePtr<CPPString>;
|
||||
fn ID3v1Tag_genreIndex(tag: Pin<&CPPID3v1Tag>) -> u32;
|
||||
fn ID3v1Tag_year(tag: Pin<&CPPID3v1Tag>) -> u32;
|
||||
fn ID3v1Tag_track(tag: Pin<&CPPID3v1Tag>) -> u32;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
49
musikr/src/main/jni/src/taglib/id3v1.rs
Normal file
49
musikr/src/main/jni/src/taglib/id3v1.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
use super::bridge::{self, CPPID3v1Tag};
|
||||
use super::this::{RefThisMut, RefThis, This, OwnedThis};
|
||||
use super::tk::{String, OwnedString};
|
||||
|
||||
pub struct ID3v1Tag<'file_ref> {
|
||||
this: RefThisMut<'file_ref, CPPID3v1Tag>,
|
||||
}
|
||||
|
||||
impl<'file_ref> ID3v1Tag<'file_ref> {
|
||||
pub(super) fn new(this: RefThisMut<'file_ref, CPPID3v1Tag>) -> Self {
|
||||
Self { this }
|
||||
}
|
||||
|
||||
pub fn title(&self) -> Option<OwnedString<'file_ref>> {
|
||||
let title = bridge::ID3v1Tag_title(self.this.pin());
|
||||
let string_this = unsafe { OwnedThis::new(title) };
|
||||
string_this.map(|this| String::new(this))
|
||||
}
|
||||
|
||||
pub fn artist(&self) -> Option<OwnedString<'file_ref>> {
|
||||
let artist = bridge::ID3v1Tag_artist(self.this.pin());
|
||||
let string_this = unsafe { OwnedThis::new(artist) };
|
||||
string_this.map(|this| String::new(this))
|
||||
}
|
||||
|
||||
pub fn album(&self) -> Option<OwnedString<'file_ref>> {
|
||||
let album = bridge::ID3v1Tag_album(self.this.pin());
|
||||
let string_this = unsafe { OwnedThis::new(album) };
|
||||
string_this.map(|this| String::new(this))
|
||||
}
|
||||
|
||||
pub fn comment(&self) -> Option<OwnedString<'file_ref>> {
|
||||
let comment = bridge::ID3v1Tag_comment(self.this.pin());
|
||||
let string_this = unsafe { OwnedThis::new(comment) };
|
||||
string_this.map(|this| String::new(this))
|
||||
}
|
||||
|
||||
pub fn genre_index(&self) -> u32 {
|
||||
bridge::ID3v1Tag_genreIndex(self.this.pin())
|
||||
}
|
||||
|
||||
pub fn year(&self) -> u32 {
|
||||
bridge::ID3v1Tag_year(self.this.pin())
|
||||
}
|
||||
|
||||
pub fn track(&self) -> u32 {
|
||||
bridge::ID3v1Tag_track(self.this.pin())
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
mod bridge;
|
||||
|
||||
pub mod audioproperties;
|
||||
pub mod file;
|
||||
pub mod file_ref;
|
||||
pub mod flac;
|
||||
pub mod id3v2;
|
||||
mod this;
|
||||
pub mod iostream;
|
||||
pub mod mpeg;
|
||||
pub mod file_ref;
|
||||
pub mod file;
|
||||
pub mod audioproperties;
|
||||
pub mod ogg;
|
||||
pub mod tk;
|
||||
pub mod mpeg;
|
||||
pub mod flac;
|
||||
pub mod xiph;
|
||||
pub mod this;
|
||||
pub mod tk;
|
||||
pub mod id3v2;
|
||||
pub mod id3v1;
|
||||
|
|
Loading…
Reference in a new issue