-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt_files_concurrently_async.rs
More file actions
43 lines (38 loc) · 1.33 KB
/
Copy pathdecrypt_files_concurrently_async.rs
File metadata and controls
43 lines (38 loc) · 1.33 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
42
43
use rsmp4decrypt::Mp4Decryptor;
const VIDEO_KID: &str = "eb676abbcb345e96bbcf616630f1a3da";
const VIDEO_KEY: &str = "100b6c20940f779a4589152b57d2dacb";
const AUDIO_KID: &str = "63cb5f7184dd4b689a5c5ff11ee6a328";
const AUDIO_KEY: &str = "3bda3329158a4789880816a70e7e436d";
#[tokio::main(flavor = "multi_thread")]
async 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-async-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-async-audio.m4s",
),
];
let mut tasks = tokio::task::JoinSet::new();
for (decryptor, input, fragments_info, output) in jobs {
tasks.spawn(async move {
decryptor
.decrypt_file_async(input, output, Some(fragments_info))
.await
});
}
while let Some(result) = tasks.join_next().await {
result??;
}
Ok(())
}