WebRTC Module

This commit is contained in:
Abdussamed 2023-04-21 18:30:27 +03:00
parent 239a5c22fe
commit 23d6d3a55d
1 changed files with 9 additions and 6 deletions

View File

@ -119,12 +119,15 @@ export default class WebRTC
} }
case "streamAccept":{ case "streamAccept":{
let {id} = data; let {id} = data;
let {stream} = this.sendingStream.get(id) as {stream:MediaStream}; let sendingStream = this.sendingStream.get(id) as TransferStreamInfo;
let senders = []; let senders = [];
for (const track of stream.getTracks()) { if(sendingStream && sendingStream.stream)
senders.push(this.rtc.addTrack(track, stream)); {
for (const track of sendingStream.stream.getTracks()) {
senders.push(this.rtc.addTrack(track, sendingStream.stream));
}; };
stream.senders = senders; sendingStream.senders = senders;
}
break; break;
} }
case "message":{ case "message":{
@ -285,7 +288,7 @@ export default class WebRTC
{ {
for (const stream of event.streams) { for (const stream of event.streams) {
let streamInfo = this.recaivingStream.get(stream.id) as TransferStreamInfo; let streamInfo = this.recaivingStream.get(stream.id) as TransferStreamInfo;
streamInfo.recaivers.push(rtpRecaiver); (streamInfo.recaivers || (streamInfo.recaivers = [])).push(rtpRecaiver);
if((this.recaivingStream.get(stream.id) as {stream : MediaStream | undefined}).stream == null) if((this.recaivingStream.get(stream.id) as {stream : MediaStream | undefined}).stream == null)
{ {
streamInfo.stream = stream; streamInfo.stream = stream;