Compare commits
2 Commits
f3b9075a82
...
2809f9e495
Author | SHA1 | Date | |
---|---|---|---|
2809f9e495 | |||
9c12d2384c |
BIN
um_audio/src/__fixtures__/mp3_with_id3v2.bin
Normal file
BIN
um_audio/src/__fixtures__/mp3_with_id3v2.bin
Normal file
Binary file not shown.
@ -129,3 +129,15 @@ pub fn detect_audio_type(buffer: &[u8]) -> Result<AudioType, AudioError> {
|
|||||||
|
|
||||||
Ok(AudioType::Unknown)
|
Ok(AudioType::Unknown)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{detect_audio_type, AudioType};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mp3() {
|
||||||
|
let mp3_data = include_bytes!("__fixtures__/mp3_with_id3v2.bin");
|
||||||
|
let result = detect_audio_type(mp3_data).expect("failed to parse mp3");
|
||||||
|
assert_eq!(result, AudioType::MP3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -67,7 +67,7 @@ fn get_ape_v2_size(buffer: &[u8], offset: usize) -> Result<usize, AudioError> {
|
|||||||
|
|
||||||
pub fn get_header_metadata_size(buffer: &[u8], offset: usize) -> Result<usize, AudioError> {
|
pub fn get_header_metadata_size(buffer: &[u8], offset: usize) -> Result<usize, AudioError> {
|
||||||
let len = get_id3_header_size(buffer, offset)?;
|
let len = get_id3_header_size(buffer, offset)?;
|
||||||
if len == 0 {
|
if len != 0 {
|
||||||
Ok(len)
|
Ok(len)
|
||||||
} else {
|
} else {
|
||||||
get_ape_v2_size(buffer, offset)
|
get_ape_v2_size(buffer, offset)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@unlock-music/crypto",
|
"name": "@unlock-music/crypto",
|
||||||
"version": "0.0.0-alpha.7",
|
"version": "0.0.0-alpha.8",
|
||||||
"description": "Project Unlock Music: 加解密支持库",
|
"description": "Project Unlock Music: 加解密支持库",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node build.js",
|
"build": "node build.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user