Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
PUBLIC_RELAY_SCHEME="http"
PUBLIC_RELAY_HOST="localhost:4443"
PUBLIC_RELAY_REGIONS=""
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
PUBLIC_RELAY_SCHEME="https"
PUBLIC_RELAY_HOST="relay.quic.video"
PUBLIC_RELAY_REGIONS="us-central,europe-west,asia-southeast"
4 changes: 4 additions & 0 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ export default defineConfig({
"@": "/src",
},
},
// Workaround for: https://github.com/vitejs/vite/issues/8427
optimizeDeps: {
exclude: ["@kixelated/moq"],
},
},
});
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/// <reference types="astro/client" />

interface ImportMetaEnv {
readonly PUBLIC_RELAY_SCHEME: string;
readonly PUBLIC_RELAY_HOST: string;
readonly PUBLIC_RELAY_REGIONS: string;
}

interface ImportMeta {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@astrojs/node": "8.3.4",
"@astrojs/solid-js": "4.4.4",
"@astrojs/tailwind": "5.1.2",
"@kixelated/moq": "^0.3.8",
"@kixelated/moq": "^0.3.12",
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
"astro": "4.16.16",
Expand Down
49 changes: 49 additions & 0 deletions src/components/region.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import "@kixelated/moq/video";
import { For, type Setter, createEffect, createSignal } from "solid-js";

// Exposes a region selector to allow overriding the region used by the relay.
export default function Region(props: { path: string; setUrl: Setter<string> }) {
// Use query params to allow overriding environment variables.
const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries());

const [region, setRegion] = createSignal<string | null>(params.region ?? null);
const regions = import.meta.env.PUBLIC_RELAY_REGIONS ? import.meta.env.PUBLIC_RELAY_REGIONS.split(",") : [];
const host = params.server || import.meta.env.PUBLIC_RELAY_HOST;

createEffect(() => {
const scheme = params.scheme || import.meta.env.PUBLIC_RELAY_SCHEME || "https";

const r = region();
const server = r === null ? host : `${r}.${host}`;

props.setUrl(`${scheme}://${server}/${props.path}`);
});

return (
<div class="flex gap-4 items-center mt-8 mb-8">
<span
class="font-bold"
title="Connect to the indicated server. 'Auto' will use Geo-DNS to select the closest server for the best latency and quality. Select a far-away region to test the performance with increased congestion and latency."
>
Relay:
</span>
<button
type="button"
onClick={() => setRegion(null)}
classList={{
"bg-blue-500": region() === null,
}}
>
auto
</button>
<For each={regions}>
{(r) => (
<button type="button" onClick={() => setRegion(r)} classList={{ "bg-blue-500": region() === r }}>
{r}
</button>
)}
</For>
</div>
);
}
20 changes: 10 additions & 10 deletions src/components/watch.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import "@kixelated/moq/video";
import "@kixelated/moq/watch";

export default function Watch(props: { path: string }) {
// Use query params to allow overriding environment variables.
const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries());
const server = params.server ?? import.meta.env.PUBLIC_RELAY_HOST;
import { createSignal } from "solid-js";

import Region from "@/components/region";

const url = `https://${server}/${props.path}`;
export default function Watch(props: { path: string }) {
const [url, setUrl] = createSignal<string>("");

return (
<moq-video prop:src={url} prop:autoplay={true}>
<canvas slot="canvas" class="rounded-lg" />
</moq-video>
<div>
<moq-watch prop:url={url()} class="rounded-lg overflow-hidden" />
<Region setUrl={setUrl} path={props.path} />
</div>
);
}
2 changes: 1 addition & 1 deletion src/layouts/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
button,
.form-button {
@apply rounded-md border-0 bg-slate-700 font-bold shadow-sm hover:bg-slate-800 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2;
@apply px-12 py-4 text-2xl;
@apply px-8 py-3 text-lg;
}

input,
Expand Down
Loading