xaac-rs 0.1.0

High-level Rust AAC/xHE-AAC encoder and decoder bindings built on libxaac
Documentation
use xaac_rs::{Decoder, DecoderConfig, Encoder, EncoderConfig, OutputFormat};

#[test]
fn decoder_initializes_with_default_config() {
    let decoder = Decoder::new(DecoderConfig::default()).expect("decoder should initialize");
    assert!(decoder.input_capacity() > 0);
}

#[test]
fn encodes_aac_lc_adts_frame() {
    let mut encoder = Encoder::new(EncoderConfig {
        output_format: OutputFormat::Adts,
        ..EncoderConfig::default()
    })
    .expect("encoder should initialize");

    let pcm = vec![0i16; encoder.input_frame_bytes() / 2];
    let encoded = encoder
        .encode_i16_interleaved(&pcm)
        .expect("frame should encode");

    assert!(!encoded.data.is_empty());
}

#[test]
fn encodes_partial_frame_with_zero_padding() {
    let mut encoder = Encoder::new(EncoderConfig {
        output_format: OutputFormat::Raw,
        ..EncoderConfig::default()
    })
    .expect("encoder should initialize");

    let partial = vec![0u8; encoder.input_frame_bytes() / 2];
    let encoded = encoder
        .encode_pcm_bytes_with_padding(&partial)
        .expect("partial frame should encode");

    assert_eq!(encoded.padded_input_bytes, partial.len());
    assert!(!encoder.audio_specific_config().is_empty());
    assert!(!encoded.packet.data.is_empty());
}