rtc

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

commit
5ac433419cb145a3ca75dab24ada2fba4c551c41
parent
b496c02d7ef1d9400c518c563eec6a27f799c5c0
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-03-24 07:56
rtc: mirror own video

Diffstat

M www/rtc/rtc.css 3 +++
M www/rtc/rtc.js 12 +++++++-----

2 files changed, 10 insertions, 5 deletions


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

@@ -21,3 +21,6 @@ video {
   21    21 	width: 100%;
   22    22 	max-height: 80vh;
   23    23 }
   -1    24 video.mirrored {
   -1    25 	transform: scale(-1, 1);
   -1    26 }

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

@@ -131,7 +131,7 @@
  131   131 
  132   132 	var updateStreams = async function(event) {
  133   133 		var newStream = new MediaStream();
  134    -1 		var kind, getStream, other;
   -1   134 		var kind, getStream;
  135   135 
  136   136 		if (event.target.name === 'audio') {
  137   137 			kind = 'audio';
@@ -139,11 +139,9 @@
  139   139 		} else if (event.target.name === 'video') {
  140   140 			kind = 'video';
  141   141 			getStream = () => navigator.mediaDevices.getUserMedia({video: true});
  142    -1 			other = document.querySelector('[name="screen"]');
  143   142 		} else {
  144   143 			kind = 'video';
  145   144 			getStream = () => navigator.mediaDevices.getDisplayMedia();
  146    -1 			other = document.querySelector('[name="video"]');
  147   145 		}
  148   146 
  149   147 		localVideo.srcObject.getTracks().forEach(track => {
@@ -166,8 +164,12 @@
  166   164 			});
  167   165 		}
  168   166 
  169    -1 		if (other) {
  170    -1 			other.checked = false;
   -1   167 		if (event.target.name === 'video') {
   -1   168 			localVideo.classList.add('mirrored');
   -1   169 			document.querySelector('[name="screen"]').checked = false;
   -1   170 		} else if (event.target.name === 'screen') {
   -1   171 			localVideo.classList.remove('mirrored');
   -1   172 			document.querySelector('[name="video"]').checked = false;
  171   173 		}
  172   174 
  173   175 		localVideo.srcObject = newStream;