Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
37 Views

A mistake in the ConferencePeerConnectionChannel.publish method of the JS SDK 4.1

Here is an excerpt from the ics.js 4.1 (beautified a little to make it readable):

key: "publish",
value: function (e, t) {
  var n = this;
  if (void 0 === t && (t = { audio: !!e.mediaStream.getAudioTracks(), video: !!e.mediaStream.getVideoTracks() }), "object" !== (void 0 === t ? "undefined" : r(t))) return Promise.reject(new TypeError("Options should be an object."));
  if (void 0 === t.audio && (t.audio = !!e.mediaStream.getAudioTracks()),
      void 0 === t.video && (t.video = !!e.mediaStream.getVideoTracks()),
      !!t.audio == !e.mediaStream.getAudioTracks().length || !!t.video == !e.mediaStream.getVideoTracks().length)
    return Promise.reject(new f.ConferenceError("options.audio/video is inconsistent with tracks presented in the MediaStream."));

If the second argument (options) is missing, { audio: !!e.mediaStream.getAudioTracks(), video: !!e.mediaStream.getVideoTracks() } is assigned instead. The problem is, getAudioTracks() and getVideoTracks() are always arrays, and never nulls. At least it is so in Mozilla. Thus, the result is always { audio: true, video: true }. Now as soon as any of these arrays is empty (i.e. the stream is either audio-, or video-only), !!t.audio == !e.mediaStream.getAudioTracks().length || !!t.video == !e.mediaStream.getVideoTracks().length gives 'true' and voilà, the stream won't be published.

The workaround is to explicitly specify 'option' argument in ConferenceClient.publish(stream, options).

Tags (2)
0 Kudos
1 Reply
Highlighted
37 Views

Hi Nozhenko,

Thanks for debugging and reporting this issue. This is a bug in the JavaScript SDK. Returning an empty array for getAudioTracks()/getVideoTracks() when there is no audio/video track complies with the getUserMedia spec.

You may find the source code of the JavaScript SDK here. Hope it saves your time on debugging issues. Thanks.

0 Kudos