Intel® Collaboration Suite for WebRTC
Community support and discussions on the Intel® Collaboration Suite for WebRTC (Intel® CS for WebRTC).
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646
1136 Discussions

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

Nozhenko__Sergey
Beginner
109 Views

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).

0 Kudos
1 Reply
Jianjun_Z_Intel
Employee
109 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.

Reply