-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import Moq from @kixelated/moq/video (#271)
- Loading branch information
Showing
11 changed files
with
54 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "moq-web" | ||
authors = ["Luke Curley <[email protected]>"] | ||
edition = "2021" | ||
version = "0.3.7" | ||
version = "0.3.8" | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/kixelated/moq-web" | ||
description = "Web implementation for MoQ utilizing WebAssembly+Typescript" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as Comlink from "comlink"; | ||
import type { Api } from "./worker"; | ||
|
||
// Create a new worker instance | ||
// We wait until the worker is fully initialized before we return the proxy. | ||
function init(): Promise<Comlink.Remote<Api>> { | ||
return new Promise((resolve) => { | ||
const worker = new Worker(new URL("./worker", import.meta.url), { type: "module" }); | ||
worker.addEventListener( | ||
"message", | ||
(event) => { | ||
const proxy: Comlink.Remote<Api> = Comlink.wrap(worker); | ||
resolve(proxy); | ||
}, | ||
{ once: true }, | ||
); | ||
}); | ||
} | ||
|
||
export { init }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { MoqVideoElement } from "../element/video"; | ||
export { MoqVideoElement } from ".."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { MoqVideoElement } from "./video"; | ||
import MoqVideoElement from "./video"; | ||
export { MoqVideoElement }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import * as Comlink from "comlink"; | ||
import { init } from "./main"; | ||
import { init } from "./bridge"; | ||
import type * as Api from "./worker"; | ||
|
||
export class Watch { | ||
#inner: Promise<Comlink.Remote<Api.Watch>>; | ||
#bridge: Promise<Comlink.Remote<Api.Watch>>; | ||
|
||
constructor(src: string) { | ||
this.#inner = init.then((api) => api.watch(src)); | ||
this.#bridge = init().then((api) => api.watch(src)); | ||
} | ||
|
||
async pause(value: boolean) { | ||
await (await this.#inner).pause(value); | ||
await (await this.#bridge).pause(value); | ||
} | ||
|
||
async volume(value: number) { | ||
await (await this.#inner).volume(value); | ||
await (await this.#bridge).volume(value); | ||
} | ||
|
||
async render(value: HTMLCanvasElement | OffscreenCanvas) { | ||
const canvas = value instanceof HTMLCanvasElement ? value.transferControlToOffscreen() : value; | ||
|
||
await (await this.#inner).render(Comlink.transfer(canvas, [canvas])); | ||
await (await this.#bridge).render(Comlink.transfer(canvas, [canvas])); | ||
} | ||
|
||
async close() { | ||
await (await this.#inner).close(); | ||
await (await this.#bridge).close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters