Actually it works okay, I was just off on my estimate of how big videos are.

Still needs to support byte range, too.
main
_ 2020-10-27 13:25:21 +00:00
parent b9db10b76a
commit cab36c7a19
2 changed files with 12 additions and 3 deletions

View File

@ -82,12 +82,14 @@ async fn main () -> Result <(), Box <dyn Error>> {
//let rx: Receiver <Vec <u8>> = rx;
tokio::spawn (async move {
let path = "/home/user/videos/Hidden_-_A_Gender_-_by_Kate_Bornstein-fFD8NpA3hec.mp4";
let path = "/home/user/pictures/bzqcChY.jpg";
let path = "/home/user/videos/Decearing Egg.webm";
let mut f = File::open (path).await.unwrap ();
let mut tx = tx;
let mut bytes_sent = 0;
loop {
let mut buffer = vec! [0u8; 256];
let mut buffer = vec! [0u8; 4096];
let bytes_read = f.read (&mut buffer).await.unwrap ();
buffer.truncate (bytes_read);
@ -97,6 +99,11 @@ async fn main () -> Result <(), Box <dyn Error>> {
}
tx.send (Ok::<_, Infallible> (buffer)).await;
bytes_sent += bytes_read;
println! ("Sent {} bytes", bytes_sent);
delay_for (Duration::from_millis (50)).await;
}
});

View File

@ -1 +1,3 @@
- Streaming in Step 6/7 on the relay
- Byte range request header
- Actually pass request URL through relay
- Content-Length response header