diff --git a/packages/webrtc/src/media/rtpReceiver.ts b/packages/webrtc/src/media/rtpReceiver.ts index 040d4731..95c49d6e 100644 --- a/packages/webrtc/src/media/rtpReceiver.ts +++ b/packages/webrtc/src/media/rtpReceiver.ts @@ -36,7 +36,7 @@ import { NackHandler } from "./receiver/nack"; import { ReceiverTWCC } from "./receiver/receiverTwcc"; import { StreamStatistics } from "./receiver/statistics"; -import type { MediaStreamTrack } from "./track"; +import { MediaStreamTrack } from "./track"; const log = debug("werift:packages/webrtc/src/media/rtpReceiver.ts"); @@ -91,7 +91,7 @@ export class RTCRtpReceiver { // todo fix get track() { - return this.tracks[0]; + return this.tracks[0] ?? new MediaStreamTrack({ kind: this.kind }); } get nackEnabled() { diff --git a/packages/webrtc/src/peerConnection.ts b/packages/webrtc/src/peerConnection.ts index a54c1fac..7fb827a6 100644 --- a/packages/webrtc/src/peerConnection.ts +++ b/packages/webrtc/src/peerConnection.ts @@ -1300,7 +1300,9 @@ export class RTCPeerConnection extends EventTarget { /**todo impl */ ms?: MediaStream, ) { - if (this.isClosed) throw new Error("is closed"); + if (this.isClosed) { + throw new Error("is closed"); + } if (this.getSenders().find((sender) => sender.track?.uuid === track.uuid)) { throw new Error("track exist"); }