Yolo host on EC2.
This commit is contained in:
parent
f6163e7a70
commit
1509d799cc
|
@ -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
|
|
@ -1,6 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name quic.video;
|
||||
root /var/www/quic.video;
|
||||
}
|
|
@ -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
|
|
@ -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": {
|
||||
|
|
|
@ -12,12 +12,11 @@
|
|||
<div id="player">
|
||||
<div id="screen">
|
||||
<div id="play"><span>click to play</span></div>
|
||||
<video id="vid" controls></video>
|
||||
<video id="vid" autoplay controls></video>
|
||||
</div>
|
||||
|
||||
<div id="controls">
|
||||
<button type="button" id="live">Go Live</button>
|
||||
<button type="button" id="throttle">Throttle: None</button>
|
||||
</div>
|
||||
|
||||
<div id="stats">
|
||||
|
@ -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))
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue