Skip to content

Commit

Permalink
fix track
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed Jan 6, 2025
1 parent 522d262 commit bd44ccd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/webrtc/src/media/rtpReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion packages/webrtc/src/peerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit bd44ccd

Please sign in to comment.