Intel® Collaboration Suite for WebRTC
Community support and discussions on the Intel® Collaboration Suite for WebRTC (Intel® CS for WebRTC).
1146 Discussions

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 === && ( = !!e.mediaStream.getAudioTracks()),
      void 0 === && ( = !!e.mediaStream.getVideoTracks()),
      !! == !e.mediaStream.getAudioTracks().length || !! == !e.mediaStream.getVideoTracks().length)
    return Promise.reject(new f.ConferenceError(" 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), !! == !e.mediaStream.getAudioTracks().length || !! == !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).

0 Kudos
1 Reply

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