From cab36c7a1942cafb62b4c650252be9951348a039 Mon Sep 17 00:00:00 2001 From: _ <> Date: Tue, 27 Oct 2020 13:25:21 +0000 Subject: [PATCH] Actually it works okay, I was just off on my estimate of how big videos are. Still needs to support byte range, too. --- src/bin/server.rs | 11 +++++++++-- todo.md | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bin/server.rs b/src/bin/server.rs index ba9b67b..8e2a7e3 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -82,12 +82,14 @@ async fn main () -> Result <(), Box > { //let rx: Receiver > = 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 > { } tx.send (Ok::<_, Infallible> (buffer)).await; + bytes_sent += bytes_read; + + println! ("Sent {} bytes", bytes_sent); + + delay_for (Duration::from_millis (50)).await; } }); diff --git a/todo.md b/todo.md index b3c0cf9..006a766 100644 --- a/todo.md +++ b/todo.md @@ -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