-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt_files_concurrently.rs
More file actions
41 lines (36 loc) · 1.27 KB
/
Copy pathdecrypt_files_concurrently.rs
File metadata and controls
41 lines (36 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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(())
}