rtc

minimal webrtc client
git clone https://git.ce9e.org/rtc.git

commit
b496c02d7ef1d9400c518c563eec6a27f799c5c0
parent
4e7b6ab150f8f9b24ec7059120ac302586d9da36
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-03-24 06:13
rtc: use getSender instead of tracking senders manually

Diffstat

M www/rtc/rtc.js 13 +++++--------

1 files changed, 5 insertions, 8 deletions


diff --git a/www/rtc/rtc.js b/www/rtc/rtc.js

@@ -54,7 +54,6 @@
   54    54 		cons[sender] = {
   55    55 			'con': con,
   56    56 			'video': video,
   57    -1 			'tracks': tracks,
   58    57 		};
   59    58 
   60    59 		return con;
@@ -118,16 +117,14 @@
  118   117 		var tracks = localVideo.srcObject.getTracks();
  119   118 
  120   119 		for (sender in cons) {
  121    -1 			var c = cons[sender];
   -1   120 			var con = cons[sender].con;
  122   121 
  123    -1 			while (c.tracks.length) {
  124    -1 				s = c.tracks.pop();
  125    -1 				c.con.removeTrack(s);
  126    -1 			}
   -1   122 			con.getSenders().forEach(s => {
   -1   123 				con.removeTrack(s);
   -1   124 			});
  127   125 
  128   126 			tracks.forEach(track => {
  129    -1 				s = c.con.addTrack(track, localVideo.srcObject);
  130    -1 				c.tracks.push(s);
   -1   127 				con.addTrack(track, localVideo.srcObject);
  131   128 			});
  132   129 		}
  133   130 	}