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

Nozhenko__Sergey
Beginner
302 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
302 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
Reply