diff --git a/player/Dockerfile b/player/Dockerfile deleted file mode 100644 index 016e2fe..0000000 --- a/player/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM ubuntu - -# Install dependencies -RUN apt-get update && apt-get install -y nginx certbot python3-certbot-nginx - -# Contains the final certificates created by certbot -VOLUME /etc/letsencrypt - -# Application configuration for our site -COPY nginx/quic.video.conf /etc/nginx/conf.d/quic.video.conf - -# The script to init and run nginx -COPY nginx/run.sh /run/warp-client - -# Copy over the web contents -COPY dist/* /var/www/quic.video - -# Run the shell script -CMD /run/warp-client diff --git a/player/nginx/quic.video.conf b/player/nginx/quic.video.conf deleted file mode 100644 index 01f7b3f..0000000 --- a/player/nginx/quic.video.conf +++ /dev/null @@ -1,6 +0,0 @@ -server { - listen 80; - listen [::]:80; - server_name quic.video; - root /var/www/quic.video; -} diff --git a/player/nginx/run.sh b/player/nginx/run.sh deleted file mode 100755 index d7bdae7..0000000 --- a/player/nginx/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -euxo pipefail - -# Try to generate a certificate that expires in 90 days. -# This will listen on port 80 and serve a challenge file, proving we own the domain. -certbot --nginx --email kixelated@gmail.com -d quic.video --agree-tos - -# The certbot nginx plugin will automatically append the certs to the configuration. -nginx diff --git a/player/package.json b/player/package.json index 2feada3..20861a7 100644 --- a/player/package.json +++ b/player/package.json @@ -3,7 +3,7 @@ "scripts": { "serve": "parcel serve --https --host localhost.warp.demo --port 4444", "prebuild": "rm -rf dist", - "build": "parcel build", + "build": "parcel build --public-url ./", "check": "tsc --noEmit" }, "devDependencies": { diff --git a/player/src/index.html b/player/src/index.html index f4f2aa6..b45fd4f 100644 --- a/player/src/index.html +++ b/player/src/index.html @@ -12,12 +12,11 @@
click to play
- +
-
@@ -35,28 +34,21 @@ // This is so ghetto but I'm too lazy to improve it right now const vidRef = document.getElementById("vid") const liveRef = document.getElementById("live") - const throttleRef = document.getElementById("throttle") const statsRef = document.getElementById("stats") const playRef = document.getElementById("play") const params = new URLSearchParams(window.location.search) const player = new Player({ - url: params.get("url") || "https://localhost.warp.demo:4443", + url: params.get("url") || "https://quic.video/demo", vid: vidRef, stats: statsRef, - throttle: throttleRef, }) liveRef.addEventListener("click", (e) => { e.preventDefault() - player.goLive() - }) - - throttleRef.addEventListener("click", (e) => { - e.preventDefault() - player.throttle() + player.goLive(0.3) // 300ms of buffer }) playRef.addEventListener('click', (e) => { @@ -66,7 +58,7 @@ function playFunc(e) { playRef.style.display = "none" - //player.goLive() + player.goLive(0.3) // 300ms of buffer // Only fire once to restore pause/play functionality vidRef.removeEventListener('play', playFunc) @@ -76,7 +68,7 @@ vidRef.volume = 0.5 // Try to autoplay but ignore errors on mobile; they need to click - //vidRef.play().catch((e) => console.warn(e)) + vidRef.play().catch((e) => console.warn(e)) diff --git a/player/src/player.ts b/player/src/player.ts index c31724a..6141554 100644 --- a/player/src/player.ts +++ b/player/src/player.ts @@ -53,9 +53,6 @@ export class Player { // async functions this.receiveStreams() - - // Limit to 4Mb/s - this.sendThrottle() } async close() { @@ -125,13 +122,24 @@ export class Player { this.updateStats() } - goLive() { + goLive(offset: number) { const ranges = this.vidRef.buffered if (!ranges.length) { return } - this.vidRef.currentTime = ranges.end(ranges.length-1); + // Get the start and the end of the last chunk of the buffer. + const start = ranges.start(ranges.length-1); + const end = ranges.end(ranges.length-1) + + if (start < end - offset) { + // Seek back offset from the end of the buffer. + this.vidRef.currentTime = end - offset; + } else { + // Start at the beginning of the range. + this.vidRef.currentTime = start; + } + this.vidRef.play(); } @@ -272,10 +280,10 @@ export class Player { updateStats() { for (const child of this.statsRef.children) { - if (child.className == "audio buffer") { + if (child.classList.contains("audio")) { const ranges: any = (this.audio) ? this.audio.buffered() : { length: 0 } this.visualizeBuffer(child as HTMLElement, ranges) - } else if (child.className == "video buffer") { + } else if (child.classList.contains("video")) { const ranges: any = (this.video) ? this.video.buffered() : { length: 0 } this.visualizeBuffer(child as HTMLElement, ranges) } diff --git a/server/Dockerfile b/server/Dockerfile deleted file mode 100644 index f56f064..0000000 --- a/server/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -# build image # -FROM golang:1.18 AS build - -WORKDIR /src - -# Don't use the Go proxy because it's blocked on my laptop (lul) -ENV GOPRIVATE=* - -# Copy over the files. -COPY . . - -# Run the unit tests. -RUN go test -race ./... - -# Run go vet -RUN go vet ./... - -# Make sure go fmt was run. -# If this fails, you should configure your editor to run `gofmt` on save. -RUN test -z $(go fmt ./...) - -# Install the binary. -RUN go install -v ./warp-server - -# Final image -FROM ubuntu:22.04 - -# Install root certs for HTTPS -RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates - -# Copy the binary from the build image -COPY --from=build /go/bin /usr/local/bin - -# Copy over our pre-encoded media. -COPY media /media