WebRTC Module

This commit is contained in:
Abdussamed 2023-04-21 18:26:36 +03:00
parent 21c822152b
commit 66df2e7962
1 changed files with 6 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import Peer from "./Peer";
interface TransferStreamInfo
{
senders : RTCRtpSender[];
recaivers : RTCRtpReceiver[];
stream:MediaStream | undefined;
id:string;
name:string;
@ -279,19 +280,18 @@ export default class WebRTC
}
public eventTrack(event: RTCTrackEvent)
{
let rtpRecaiver = event.receiver;
if(event.streams.length)
{
for (const stream of event.streams) {
let streamInfo = this.recaivingStream.get(stream.id) as TransferStreamInfo;
streamInfo.recaivers.push(rtpRecaiver);
if((this.recaivingStream.get(stream.id) as {stream : MediaStream | undefined}).stream == null)
{
(
this.recaivingStream.get(stream.id) as {stream : MediaStream | undefined}
).stream = stream;
streamInfo.stream = stream;
this.emit('stream:added', this.recaivingStream.get(stream.id));
}else{
(
this.recaivingStream.get(stream.id) as {stream : MediaStream | undefined}
).stream = stream;
streamInfo.stream = stream;
}
}
}