rsmp4decrypt 0.2.0

Rust bindings and a CLI for Bento4 mp4decrypt
use rsmp4decrypt::Mp4Decryptor;
use std::thread;

const VIDEO_KID: &str = "eb676abbcb345e96bbcf616630f1a3da";
const VIDEO_KEY: &str = "100b6c20940f779a4589152b57d2dacb";
const AUDIO_KID: &str = "63cb5f7184dd4b689a5c5ff11ee6a328";
const AUDIO_KEY: &str = "3bda3329158a4789880816a70e7e436d";

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let jobs = [
        (
            Mp4Decryptor::builder()
                .kid_key(VIDEO_KID, VIDEO_KEY)?
                .build_isolated()?,
            "tests/fixtures/cenc-multi/video_1.m4s",
            "tests/fixtures/cenc-multi/video_init.mp4",
            "target/example-video.m4s",
        ),
        (
            Mp4Decryptor::builder()
                .kid_key(AUDIO_KID, AUDIO_KEY)?
                .build_isolated()?,
            "tests/fixtures/cenc-multi/audio_1.m4s",
            "tests/fixtures/cenc-multi/audio_init.mp4",
            "target/example-audio.m4s",
        ),
    ];

    let handles = jobs
        .into_iter()
        .map(|(decryptor, input, fragments_info, output)| {
            thread::spawn(move || decryptor.decrypt_file(input, output, Some(fragments_info)))
        })
        .collect::<Vec<_>>();

    for handle in handles {
        handle.join().expect("worker thread panicked")?;
    }

    Ok(())
}