diff options
author | metamuffin <metamuffin@disroot.org> | 2022-09-16 20:46:58 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-09-16 20:46:58 +0200 |
commit | a3cc9f8fb1bf45741b08ce6d383c4d7cc8ea8b1f (patch) | |
tree | ddd353400f3d75b26a4158059038d8e583cd81f4 /client-web/source/user | |
parent | 969444b32101a45d5917a3947b94bb09c3fc01a1 (diff) | |
download | keks-meet-a3cc9f8fb1bf45741b08ce6d383c4d7cc8ea8b1f.tar keks-meet-a3cc9f8fb1bf45741b08ce6d383c4d7cc8ea8b1f.tar.bz2 keks-meet-a3cc9f8fb1bf45741b08ce6d383c4d7cc8ea8b1f.tar.zst |
optional streams (2, basic functionality)
Diffstat (limited to 'client-web/source/user')
-rw-r--r-- | client-web/source/user/local.ts | 4 | ||||
-rw-r--r-- | client-web/source/user/mod.ts | 2 | ||||
-rw-r--r-- | client-web/source/user/remote.ts | 13 |
3 files changed, 14 insertions, 5 deletions
diff --git a/client-web/source/user/local.ts b/client-web/source/user/local.ts index 4b057ee..e5d22e5 100644 --- a/client-web/source/user/local.ts +++ b/client-web/source/user/local.ts @@ -72,6 +72,10 @@ export class LocalUser extends User { this.el.append(r.el) const provide: ProvideInfo = r.info this.room.signaling.send_relay({ provide }) + r.on_destroy = () => { + this.el.removeChild(r.el); + this.room.signaling.send_relay({ provide_stop: { id: r.info.id } }) + } } send_track(t: TrackHandle) { diff --git a/client-web/source/user/mod.ts b/client-web/source/user/mod.ts index 59c58b7..85c6960 100644 --- a/client-web/source/user/mod.ts +++ b/client-web/source/user/mod.ts @@ -6,7 +6,7 @@ import { Resource } from "../resource/mod.ts"; import { Room } from "../room.ts" export abstract class User { - protected el: HTMLElement + public el: HTMLElement public local = false public resources: Map<string, Resource> = new Map() diff --git a/client-web/source/user/remote.ts b/client-web/source/user/remote.ts index 110fd40..59d811a 100644 --- a/client-web/source/user/remote.ts +++ b/client-web/source/user/remote.ts @@ -31,11 +31,15 @@ export class RemoteUser extends User { this.update_stats() } this.peer.ontrack = ev => { + console.log(ev) const t = ev.track - log("media", `remote track: ${this.display_name}`, t) - const r = this.resources.get(t.label) - if (r instanceof TrackResource) { r.track = new TrackHandle(t); r.state = "running" } + const id = ev.streams[0].id + if (!id) return log({ scope: "media", warn: true }, "got a track without stream") + const r = this.resources.get(id) + if (!r) return log({ scope: "media", warn: true }, "got an unassociated track") + if (r instanceof TrackResource) r.track = new TrackHandle(t); else log({ scope: "media", warn: true }, "got a track for a resource that should use data channel") + log("media", `remote track: ${this.display_name}`, t) this.update_stats() } this.peer.onnegotiationneeded = () => { @@ -73,6 +77,7 @@ export class RemoteUser extends User { if (PREFS.notify_join) notify(`${this.display_name} joined`) } if (message.provide) { + console.log(message.provide.id); const d = Resource.create(this, message.provide) if (!d) return this.el.append(d.el) @@ -87,7 +92,7 @@ export class RemoteUser extends User { if (!r) return log({ scope: "*", warn: true }, "somebody requested an unknown resource") if (r instanceof TrackResource) { if (!r.track) throw new Error("local resources not avail"); - const sender = this.peer.addTrack(r.track.track) + const sender = this.peer.addTrack(r.track.track, r.track.stream) this.senders.set(r.track.id, sender) r.track.addEventListener("end", () => { this.senders.delete(r.track?.id ?? "") }) } |