ep_webrtc 1.1.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,20 +74,6 @@ Supported values for `"disabled"`:
74
74
  * `"soft"`: Initially disabled by default.
75
75
  * `"hard"`: Unavailable (it cannot be enabled).
76
76
 
77
- The camera's record resolution can be configured by setting `videoConstraints`
78
- to any [video
79
- constraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters)
80
- value acceptable to client browsers. It has the following default value:
81
-
82
- ```json
83
- "ep_webrtc": {
84
- "videoConstraints": {
85
- "width": {"ideal": 160},
86
- "height": {"ideal": 120}
87
- }
88
- }
89
- ```
90
-
91
77
  ### Custom Activate Button
92
78
 
93
79
  The misnamed `listenClass` setting allows you to specify a CSS selector for an
@@ -199,10 +185,51 @@ Example:
199
185
  },
200
186
  ```
201
187
 
188
+ ### Microphone Settings
189
+
190
+ The microphone can be configured by setting `audio.constraints` to any [audio
191
+ constraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters)
192
+ value acceptable to client browsers. It has the following default value:
193
+
194
+ ```json
195
+ "ep_webrtc": {
196
+ "audio": {
197
+ "constraints": {
198
+ "autoGainControl": {"ideal": true},
199
+ "echoCancellation": {"ideal": true},
200
+ "noiseSuppression": {"ideal": true}
201
+ }
202
+ }
203
+ },
204
+ ```
205
+
206
+ For a full list of available constraints, see [the
207
+ standard](https://www.w3.org/TR/2022/CRD-mediacapture-streams-20220307/#constrainable-properties).
208
+
202
209
  ### Video Sizes
203
210
 
204
- To set a custom small and/or large size in pixels, for the video displays, set
205
- one or both of the following in your `settings.json`:
211
+ The camera's record resolution can be configured by setting `video.constraints`
212
+ to any [video
213
+ constraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters)
214
+ value acceptable to client browsers. It has the following default value:
215
+
216
+ ```json
217
+ "ep_webrtc": {
218
+ "video": {
219
+ "constraints": {
220
+ "width": {"ideal": 160},
221
+ "height": {"ideal": 120}
222
+ }
223
+ }
224
+ },
225
+ ```
226
+
227
+ For a full list of available constraints, see [the
228
+ standard](https://www.w3.org/TR/2022/CRD-mediacapture-streams-20220307/#constrainable-properties).
229
+
230
+ Changing the record resolution does not change the size of the displayed video
231
+ widgets. To change the video widget size, set `video.sizes.small` and/or
232
+ `video.sizes.large`:
206
233
 
207
234
  ```json
208
235
  "ep_webrtc": {
@@ -212,12 +239,9 @@ one or both of the following in your `settings.json`:
212
239
  "large": 400
213
240
  }
214
241
  }
215
- }
242
+ },
216
243
  ```
217
244
 
218
- This only controls the size of the video display widget. To set the camera's
219
- record resolution, see the `videoConstraints` setting.
220
-
221
245
  ## Metrics
222
246
 
223
247
  You can see metrics for various errors that users have when attempting to
package/index.js CHANGED
@@ -20,6 +20,7 @@ const crypto = require('crypto');
20
20
  const eejs = require('ep_etherpad-lite/node/eejs/');
21
21
  const sessioninfos = require('ep_etherpad-lite/node/handler/PadMessageHandler').sessioninfos;
22
22
  const stats = require('ep_etherpad-lite/node/stats');
23
+ const util = require('util');
23
24
 
24
25
  let logger = {};
25
26
  for (const level of ['debug', 'info', 'warn', 'error']) {
@@ -30,16 +31,21 @@ const defaultSettings = {
30
31
  // The defaults here are overridden by the values in the `ep_webrtc` object from `settings.json`.
31
32
  enabled: true,
32
33
  audio: {
34
+ constraints: {
35
+ autoGainControl: {ideal: true},
36
+ echoCancellation: {ideal: true},
37
+ noiseSuppression: {ideal: true},
38
+ },
33
39
  disabled: 'none',
34
40
  },
35
41
  video: {
42
+ constraints: {
43
+ width: {ideal: 160},
44
+ height: {ideal: 120},
45
+ },
36
46
  disabled: 'none',
37
47
  sizes: {large: 260, small: 160},
38
48
  },
39
- videoConstraints: {
40
- width: {ideal: 160},
41
- height: {ideal: 120},
42
- },
43
49
  iceServers: [{urls: ['stun:stun.l.google.com:19302']}],
44
50
  listenClass: null,
45
51
  moreInfoUrl: {},
@@ -225,7 +231,7 @@ exports.eejsBlock_styles = (hookName, context) => {
225
231
  exports.loadSettings = async (hookName, {settings: {ep_webrtc: s = {}}}) => {
226
232
  settings = _.mergeWith({}, defaultSettings, s, (objV, srcV, key, obj, src) => {
227
233
  if (Array.isArray(srcV)) return _.cloneDeep(srcV); // Don't merge arrays, replace them.
228
- if (src === s && key === 'videoConstraints') return _.cloneDeep(srcV);
234
+ if (src === s.video && key === 'constraints') return _.cloneDeep(srcV);
229
235
  });
230
236
  settings.configError = (() => {
231
237
  for (const k of ['audio', 'video']) {
@@ -237,8 +243,8 @@ exports.loadSettings = async (hookName, {settings: {ep_webrtc: s = {}}}) => {
237
243
  }
238
244
  return false;
239
245
  })();
240
- logger.info('configured:', {
246
+ logger.info('configured:', util.inspect({
241
247
  ...settings,
242
248
  iceServers: settings.iceServers.map((s) => s.credential ? {...s, credential: '*****'} : s),
243
- });
249
+ }, {depth: Infinity}));
244
250
  };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git@github.com:ether/ep_webrtc.git",
6
6
  "type": "git"
7
7
  },
8
- "version": "1.1.0",
8
+ "version": "2.0.2",
9
9
  "description": "WebRTC based audio/video chat to Etherpad",
10
10
  "author": "John McLear <john@mclear.co.uk>",
11
11
  "contributors": [],
@@ -2405,7 +2405,7 @@ function shimCreateOfferLegacy(window) {
2405
2405
  }
2406
2406
  }
2407
2407
  } else if (offerOptions.offerToReceiveAudio === true && !audioTransceiver) {
2408
- this.addTransceiver('audio');
2408
+ this.addTransceiver('audio', { direction: 'recvonly' });
2409
2409
  }
2410
2410
 
2411
2411
  if (typeof offerOptions.offerToReceiveVideo !== 'undefined') {
@@ -2430,7 +2430,7 @@ function shimCreateOfferLegacy(window) {
2430
2430
  }
2431
2431
  }
2432
2432
  } else if (offerOptions.offerToReceiveVideo === true && !videoTransceiver) {
2433
- this.addTransceiver('video');
2433
+ this.addTransceiver('video', { direction: 'recvonly' });
2434
2434
  }
2435
2435
  }
2436
2436
  return origCreateOffer.apply(this, arguments);
@@ -18,7 +18,7 @@
18
18
  require('./adapter');
19
19
  const padcookie = require('ep_etherpad-lite/static/js/pad_cookie').padcookie;
20
20
 
21
- const enableDebugLogging = false;
21
+ let enableDebugLogging = false;
22
22
  const debug = (...args) => { if (enableDebugLogging) console.debug('ep_webrtc:', ...args); };
23
23
 
24
24
  const EventTargetPolyfill = (() => {
@@ -220,6 +220,7 @@ class PeerState extends EventTargetPolyfill {
220
220
  return;
221
221
  }
222
222
  this._debug('creating RTCPeerConnection with config', this._pcConfig);
223
+ this._debug('peer IDs:', peerIds);
223
224
  this._setRemoteStream(null);
224
225
  this._ids.from.instance = ++nextInstanceId;
225
226
  this._ids.to = peerIds;
@@ -341,7 +342,7 @@ class PeerState extends EventTargetPolyfill {
341
342
  }
342
343
 
343
344
  async receiveMessage(msg) {
344
- if (this._closed) return debug('Ignoring message because PeerState is closed');
345
+ if (this._closed) return this._debug('Ignoring message because PeerState is closed');
345
346
  const {ids, candidate, description, hangup} = msg;
346
347
  if (hangup != null) {
347
348
  this.close(true);
@@ -464,6 +465,9 @@ exports.rtc = new class {
464
465
  this._trackLocks = {audio: new Mutex(), video: new Mutex()};
465
466
  }
466
467
 
468
+ get enableDebugLogging() { return enableDebugLogging; }
469
+ set enableDebugLogging(val) { enableDebugLogging = !!val; }
470
+
467
471
  // API HOOKS
468
472
 
469
473
  async postAceInit(hookName, {pad}) {
@@ -668,8 +672,8 @@ exports.rtc = new class {
668
672
  if (!addAudioTrack && !addVideoTrack) return new MediaStream();
669
673
  debug(`requesting permission to access ${devices.join(' and ')}`);
670
674
  const stream = await window.navigator.mediaDevices.getUserMedia({
671
- audio: addAudioTrack,
672
- video: addVideoTrack && this._settings.videoConstraints,
675
+ audio: addAudioTrack && this._settings.audio.constraints,
676
+ video: addVideoTrack && this._settings.video.constraints,
673
677
  });
674
678
  debug('successfully accessed device(s)');
675
679
  return stream;