You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JitsiLocalTrack.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /* global __filename, Promise */
  2. import CameraFacingMode from '../../service/RTC/CameraFacingMode';
  3. import { getLogger } from 'jitsi-meet-logger';
  4. import JitsiTrack from './JitsiTrack';
  5. import JitsiTrackError from '../../JitsiTrackError';
  6. import * as JitsiTrackErrors from '../../JitsiTrackErrors';
  7. import * as JitsiTrackEvents from '../../JitsiTrackEvents';
  8. import * as MediaType from '../../service/RTC/MediaType';
  9. import RTCBrowserType from './RTCBrowserType';
  10. import RTCEvents from '../../service/RTC/RTCEvents';
  11. import RTCUtils from './RTCUtils';
  12. import Statistics from '../statistics/statistics';
  13. import VideoType from '../../service/RTC/VideoType';
  14. const logger = getLogger(__filename);
  15. /**
  16. * Represents a single media track(either audio or video).
  17. * One <tt>JitsiLocalTrack</tt> corresponds to one WebRTC MediaStreamTrack.
  18. * @param stream WebRTC MediaStream, parent of the track
  19. * @param track underlying WebRTC MediaStreamTrack for new JitsiRemoteTrack
  20. * @param mediaType the MediaType of the JitsiRemoteTrack
  21. * @param videoType the VideoType of the JitsiRemoteTrack
  22. * @param resolution the video resolution if it's a video track
  23. * @param deviceId the ID of the local device for this track
  24. * @param facingMode the camera facing mode used in getUserMedia call
  25. * @constructor
  26. */
  27. function JitsiLocalTrack(stream, track, mediaType, videoType, resolution,
  28. deviceId, facingMode) {
  29. const self = this;
  30. JitsiTrack.call(this,
  31. null /* RTC */, stream, track,
  32. () => {
  33. if (!this.dontFireRemoveEvent) {
  34. this.eventEmitter.emit(
  35. JitsiTrackEvents.LOCAL_TRACK_STOPPED);
  36. }
  37. this.dontFireRemoveEvent = false;
  38. } /* inactiveHandler */,
  39. mediaType, videoType, null /* ssrc */);
  40. this.dontFireRemoveEvent = false;
  41. this.resolution = resolution;
  42. // FIXME: currently firefox is ignoring our constraints about resolutions
  43. // so we do not store it, to avoid wrong reporting of local track resolution
  44. if (RTCBrowserType.isFirefox()) {
  45. this.resolution = null;
  46. }
  47. this.deviceId = deviceId;
  48. this.startMuted = false;
  49. this.initialMSID = this.getMSID();
  50. this.inMuteOrUnmuteProgress = false;
  51. /**
  52. * The facing mode of the camera from which this JitsiLocalTrack instance
  53. * was obtained.
  54. */
  55. this._facingMode = facingMode;
  56. // Currently there is no way to know the MediaStreamTrack ended due to to
  57. // device disconnect in Firefox through e.g. "readyState" property. Instead
  58. // we will compare current track's label with device labels from
  59. // enumerateDevices() list.
  60. this._trackEnded = false;
  61. /**
  62. * The value of bytes sent received from the statistics module.
  63. */
  64. this._bytesSent = null;
  65. /**
  66. * Used only for detection of audio problems. We want to check only once
  67. * whether the track is sending bytes ot not. This flag is set to false
  68. * after the check.
  69. */
  70. this._testByteSent = true;
  71. // Currently there is no way to determine with what device track was
  72. // created (until getConstraints() support), however we can associate tracks
  73. // with real devices obtained from enumerateDevices() call as soon as it's
  74. // called.
  75. this._realDeviceId = this.deviceId === '' ? undefined : this.deviceId;
  76. /**
  77. * Indicates that we have called RTCUtils.stopMediaStream for the
  78. * MediaStream related to this JitsiTrack object.
  79. */
  80. this.stopStreamInProgress = false;
  81. /**
  82. * On mute event we are waiting for 3s to check if the stream is going to
  83. * be still muted before firing the event for camera issue detected
  84. * (NO_DATA_FROM_SOURCE).
  85. */
  86. this._noDataFromSourceTimeout = null;
  87. this._onDeviceListChanged = function(devices) {
  88. self._setRealDeviceIdFromDeviceList(devices);
  89. // Mark track as ended for those browsers that do not support
  90. // "readyState" property. We do not touch tracks created with default
  91. // device ID "".
  92. if (typeof self.getTrack().readyState === 'undefined'
  93. && typeof self._realDeviceId !== 'undefined'
  94. && !devices.find(d => d.deviceId === self._realDeviceId)) {
  95. self._trackEnded = true;
  96. }
  97. };
  98. // Subscribe each created local audio track to
  99. // RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED event. This is different from
  100. // handling this event for remote tracks (which are handled in RTC.js),
  101. // because there might be local tracks not attached to a conference.
  102. if (this.isAudioTrack() && RTCUtils.isDeviceChangeAvailable('output')) {
  103. this._onAudioOutputDeviceChanged = this.setAudioOutput.bind(this);
  104. RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
  105. this._onAudioOutputDeviceChanged);
  106. }
  107. RTCUtils.addListener(RTCEvents.DEVICE_LIST_CHANGED,
  108. this._onDeviceListChanged);
  109. this._initNoDataFromSourceHandlers();
  110. }
  111. JitsiLocalTrack.prototype = Object.create(JitsiTrack.prototype);
  112. JitsiLocalTrack.prototype.constructor = JitsiLocalTrack;
  113. /**
  114. * Returns if associated MediaStreamTrack is in the 'ended' state
  115. * @returns {boolean}
  116. */
  117. JitsiLocalTrack.prototype.isEnded = function() {
  118. return this.getTrack().readyState === 'ended' || this._trackEnded;
  119. };
  120. /**
  121. * Sets handlers to the MediaStreamTrack object that will detect camera issues.
  122. */
  123. JitsiLocalTrack.prototype._initNoDataFromSourceHandlers = function() {
  124. if (this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
  125. const _onNoDataFromSourceError
  126. = this._onNoDataFromSourceError.bind(this);
  127. this._setHandler('track_mute', () => {
  128. if (this._checkForCameraIssues()) {
  129. const now = window.performance.now();
  130. this._noDataFromSourceTimeout
  131. = setTimeout(_onNoDataFromSourceError, 3000);
  132. this._setHandler('track_unmute', () => {
  133. this._clearNoDataFromSourceMuteResources();
  134. Statistics.sendEventToAll(
  135. `${this.getType()}.track_unmute`,
  136. { value: window.performance.now() - now });
  137. });
  138. }
  139. });
  140. this._setHandler('track_ended', _onNoDataFromSourceError);
  141. }
  142. };
  143. /**
  144. * Clears all timeouts and handlers set on MediaStreamTrack mute event.
  145. * FIXME: Change the name of the method with better one.
  146. */
  147. JitsiLocalTrack.prototype._clearNoDataFromSourceMuteResources = function() {
  148. if (this._noDataFromSourceTimeout) {
  149. clearTimeout(this._noDataFromSourceTimeout);
  150. this._noDataFromSourceTimeout = null;
  151. }
  152. this._setHandler('track_unmute', undefined);
  153. };
  154. /**
  155. * Called when potential camera issue is detected. Clears the handlers and
  156. * timeouts set on MediaStreamTrack muted event. Verifies that the camera
  157. * issue persists and fires NO_DATA_FROM_SOURCE event.
  158. */
  159. JitsiLocalTrack.prototype._onNoDataFromSourceError = function() {
  160. this._clearNoDataFromSourceMuteResources();
  161. if (this._checkForCameraIssues()) {
  162. this._fireNoDataFromSourceEvent();
  163. }
  164. };
  165. /**
  166. * Fires JitsiTrackEvents.NO_DATA_FROM_SOURCE and logs it to analytics and
  167. * callstats.
  168. */
  169. JitsiLocalTrack.prototype._fireNoDataFromSourceEvent = function() {
  170. this.eventEmitter.emit(JitsiTrackEvents.NO_DATA_FROM_SOURCE);
  171. const eventName = `${this.getType()}.no_data_from_source`;
  172. Statistics.analytics.sendEvent(eventName);
  173. const log = { name: eventName };
  174. if (this.isAudioTrack()) {
  175. log.isReceivingData = this._isReceivingData();
  176. }
  177. Statistics.sendLog(JSON.stringify(log));
  178. };
  179. /**
  180. * Sets real device ID by comparing track information with device information.
  181. * This is temporary solution until getConstraints() method will be implemented
  182. * in browsers.
  183. * @param {MediaDeviceInfo[]} devices - list of devices obtained from
  184. * enumerateDevices() call
  185. */
  186. JitsiLocalTrack.prototype._setRealDeviceIdFromDeviceList = function(devices) {
  187. const track = this.getTrack();
  188. const device
  189. = devices.find(
  190. d => d.kind === `${track.kind}input` && d.label === track.label);
  191. if (device) {
  192. this._realDeviceId = device.deviceId;
  193. }
  194. };
  195. /**
  196. * Mutes the track. Will reject the Promise if there is mute/unmute operation
  197. * in progress.
  198. * @returns {Promise}
  199. */
  200. JitsiLocalTrack.prototype.mute = function() {
  201. return createMuteUnmutePromise(this, true);
  202. };
  203. /**
  204. * Unmutes the track. Will reject the Promise if there is mute/unmute operation
  205. * in progress.
  206. * @returns {Promise}
  207. */
  208. JitsiLocalTrack.prototype.unmute = function() {
  209. return createMuteUnmutePromise(this, false);
  210. };
  211. /**
  212. * Creates Promise for mute/unmute operation.
  213. *
  214. * @param {JitsiLocalTrack} track - The track that will be muted/unmuted.
  215. * @param {boolean} mute - Whether to mute or unmute the track.
  216. * @returns {Promise}
  217. */
  218. function createMuteUnmutePromise(track, mute) {
  219. if (track.inMuteOrUnmuteProgress) {
  220. return Promise.reject(
  221. new JitsiTrackError(JitsiTrackErrors.TRACK_MUTE_UNMUTE_IN_PROGRESS)
  222. );
  223. }
  224. track.inMuteOrUnmuteProgress = true;
  225. return track._setMute(mute)
  226. .then(() => {
  227. track.inMuteOrUnmuteProgress = false;
  228. })
  229. .catch(status => {
  230. track.inMuteOrUnmuteProgress = false;
  231. throw status;
  232. });
  233. }
  234. /**
  235. * Mutes / unmutes the track.
  236. *
  237. * @param {boolean} mute - If true the track will be muted. Otherwise the track
  238. * will be unmuted.
  239. * @private
  240. * @returns {Promise}
  241. */
  242. JitsiLocalTrack.prototype._setMute = function(mute) {
  243. if (this.isMuted() === mute) {
  244. return Promise.resolve();
  245. }
  246. let promise = Promise.resolve();
  247. const self = this;
  248. // Local track can be used out of conference, so we need to handle that
  249. // case and mark that track should start muted or not when added to
  250. // conference.
  251. if (!this.conference || !this.conference.room) {
  252. this.startMuted = mute;
  253. }
  254. this.dontFireRemoveEvent = false;
  255. // FIXME FF does not support 'removeStream' method used to mute
  256. if (this.isAudioTrack()
  257. || this.videoType === VideoType.DESKTOP
  258. || RTCBrowserType.isFirefox()) {
  259. if (this.track) {
  260. this.track.enabled = !mute;
  261. }
  262. } else if (mute) {
  263. this.dontFireRemoveEvent = true;
  264. promise = new Promise((resolve, reject) => {
  265. this._removeStreamFromConferenceAsMute(() => {
  266. // FIXME: Maybe here we should set the SRC for the containers
  267. // to something
  268. this._stopMediaStream();
  269. this._setStream(null);
  270. resolve();
  271. }, err => {
  272. reject(err);
  273. });
  274. });
  275. } else {
  276. // This path is only for camera.
  277. const streamOptions = {
  278. cameraDeviceId: this.getDeviceId(),
  279. devices: [ MediaType.VIDEO ],
  280. facingMode: this.getCameraFacingMode()
  281. };
  282. if (this.resolution) {
  283. streamOptions.resolution = this.resolution;
  284. }
  285. promise = RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
  286. .then(streamsInfo => {
  287. const mediaType = self.getType();
  288. const streamInfo
  289. = streamsInfo.find(info => info.mediaType === mediaType);
  290. if (streamInfo) {
  291. self._setStream(streamInfo.stream);
  292. self.track = streamInfo.track;
  293. // This is not good when video type changes after
  294. // unmute, but let's not crash here
  295. if (self.videoType !== streamInfo.videoType) {
  296. logger.warn(
  297. 'Video type has changed after unmute!',
  298. self.videoType, streamInfo.videoType);
  299. self.videoType = streamInfo.videoType;
  300. }
  301. } else {
  302. throw new JitsiTrackError(
  303. JitsiTrackErrors.TRACK_NO_STREAM_FOUND);
  304. }
  305. self.containers
  306. = self.containers.map(
  307. cont => RTCUtils.attachMediaStream(cont, self.stream));
  308. return self._addStreamToConferenceAsUnmute();
  309. });
  310. }
  311. return promise
  312. .then(() => self._sendMuteStatus(mute))
  313. .then(function() {
  314. self.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED, this);
  315. });
  316. };
  317. /**
  318. * Adds stream to conference and marks it as "unmute" operation.
  319. *
  320. * @private
  321. * @returns {Promise}
  322. */
  323. JitsiLocalTrack.prototype._addStreamToConferenceAsUnmute = function() {
  324. if (!this.conference) {
  325. return Promise.resolve();
  326. }
  327. return new Promise((resolve, reject) => {
  328. this.conference._addLocalStream(
  329. this.stream,
  330. resolve,
  331. error => reject(new Error(error)),
  332. {
  333. mtype: this.type,
  334. type: 'unmute',
  335. ssrcs: this.ssrc && this.ssrc.ssrcs,
  336. groups: this.ssrc && this.ssrc.groups,
  337. msid: this.getMSID()
  338. });
  339. });
  340. };
  341. /**
  342. * Removes stream from conference and marks it as "mute" operation.
  343. * @param {Function} successCallback will be called on success
  344. * @param {Function} errorCallback will be called on error
  345. * @private
  346. */
  347. JitsiLocalTrack.prototype._removeStreamFromConferenceAsMute
  348. = function(successCallback, errorCallback) {
  349. if (!this.conference) {
  350. successCallback();
  351. return;
  352. }
  353. this.conference.removeLocalStream(
  354. this.stream,
  355. successCallback,
  356. error => errorCallback(new Error(error)),
  357. {
  358. mtype: this.type,
  359. type: 'mute',
  360. ssrcs: this.ssrc && this.ssrc.ssrcs,
  361. groups: this.ssrc && this.ssrc.groups
  362. });
  363. };
  364. /**
  365. * Sends mute status for a track to conference if any.
  366. *
  367. * @param {boolean} mute - If track is muted.
  368. * @private
  369. * @returns {Promise}
  370. */
  371. JitsiLocalTrack.prototype._sendMuteStatus = function(mute) {
  372. if (!this.conference || !this.conference.room) {
  373. return Promise.resolve();
  374. }
  375. return new Promise(resolve => {
  376. this.conference.room[
  377. this.isAudioTrack()
  378. ? 'setAudioMute'
  379. : 'setVideoMute'](mute, resolve);
  380. });
  381. };
  382. /**
  383. * @inheritdoc
  384. *
  385. * Stops sending the media track. And removes it from the HTML.
  386. * NOTE: Works for local tracks only.
  387. *
  388. * @extends JitsiTrack#dispose
  389. * @returns {Promise}
  390. */
  391. JitsiLocalTrack.prototype.dispose = function() {
  392. const self = this;
  393. let promise = Promise.resolve();
  394. if (this.conference) {
  395. promise = this.conference.removeTrack(this);
  396. }
  397. if (this.stream) {
  398. this._stopMediaStream();
  399. this.detach();
  400. }
  401. RTCUtils.removeListener(RTCEvents.DEVICE_LIST_CHANGED,
  402. this._onDeviceListChanged);
  403. if (this._onAudioOutputDeviceChanged) {
  404. RTCUtils.removeListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
  405. this._onAudioOutputDeviceChanged);
  406. }
  407. return promise
  408. .then(() => JitsiTrack.prototype.dispose.call(self) // super.dispose();
  409. );
  410. };
  411. /**
  412. * Returns <tt>true</tt> - if the stream is muted
  413. * and <tt>false</tt> otherwise.
  414. * @returns {boolean} <tt>true</tt> - if the stream is muted
  415. * and <tt>false</tt> otherwise.
  416. */
  417. JitsiLocalTrack.prototype.isMuted = function() {
  418. // this.stream will be null when we mute local video on Chrome
  419. if (!this.stream) {
  420. return true;
  421. }
  422. if (this.isVideoTrack() && !this.isActive()) {
  423. return true;
  424. }
  425. return !this.track || !this.track.enabled;
  426. };
  427. /**
  428. * Updates the SSRC associated with the MediaStream in JitsiLocalTrack object.
  429. * @ssrc the new ssrc
  430. */
  431. JitsiLocalTrack.prototype._setSSRC = function(ssrc) {
  432. this.ssrc = ssrc;
  433. };
  434. /**
  435. * Sets the JitsiConference object associated with the track. This is temp
  436. * solution.
  437. * @param conference the JitsiConference object
  438. */
  439. JitsiLocalTrack.prototype._setConference = function(conference) {
  440. this.conference = conference;
  441. // We want to keep up with postponed events which should have been fired
  442. // on "attach" call, but for local track we not always have the conference
  443. // before attaching. However this may result in duplicated events if they
  444. // have been triggered on "attach" already.
  445. for (let i = 0; i < this.containers.length; i++) {
  446. this._maybeFireTrackAttached(this.containers[i]);
  447. }
  448. };
  449. /**
  450. * Gets the SSRC of this local track if it's available already or <tt>null</tt>
  451. * otherwise. That's because we don't know the SSRC until local description is
  452. * created.
  453. * In case of video and simulcast returns the the primarySSRC.
  454. * @returns {string} or {null}
  455. */
  456. JitsiLocalTrack.prototype.getSSRC = function() {
  457. if (this.ssrc && this.ssrc.groups && this.ssrc.groups.length) {
  458. return this.ssrc.groups[0].ssrcs[0];
  459. } else if (this.ssrc && this.ssrc.ssrcs && this.ssrc.ssrcs.length) {
  460. return this.ssrc.ssrcs[0];
  461. }
  462. return null;
  463. };
  464. /**
  465. * Returns <tt>true</tt>.
  466. * @returns {boolean} <tt>true</tt>
  467. */
  468. JitsiLocalTrack.prototype.isLocal = function() {
  469. return true;
  470. };
  471. /**
  472. * Returns device id associated with track.
  473. * @returns {string}
  474. */
  475. JitsiLocalTrack.prototype.getDeviceId = function() {
  476. return this._realDeviceId || this.deviceId;
  477. };
  478. /**
  479. * Sets the value of bytes sent statistic.
  480. * @param bytesSent {integer} the new value (FIXME: what is an integer in js?)
  481. * NOTE: used only for audio tracks to detect audio issues.
  482. */
  483. JitsiLocalTrack.prototype._setByteSent = function(bytesSent) {
  484. this._bytesSent = bytesSent;
  485. // FIXME it's a shame that PeerConnection and ICE status does not belong
  486. // to the RTC module and it has to be accessed through
  487. // the conference(and through the XMPP chat room ???) instead
  488. const iceConnectionState
  489. = this.conference ? this.conference.getConnectionState() : null;
  490. if (this._testByteSent && iceConnectionState === 'connected') {
  491. setTimeout(() => {
  492. if (this._bytesSent <= 0) {
  493. // we are not receiving anything from the microphone
  494. this._fireNoDataFromSourceEvent();
  495. }
  496. }, 3000);
  497. this._testByteSent = false;
  498. }
  499. };
  500. /**
  501. * Returns facing mode for video track from camera. For other cases (e.g. audio
  502. * track or 'desktop' video track) returns undefined.
  503. *
  504. * @returns {CameraFacingMode|undefined}
  505. */
  506. JitsiLocalTrack.prototype.getCameraFacingMode = function() {
  507. if (this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
  508. // MediaStreamTrack#getSettings() is not implemented in many browsers,
  509. // so we need feature checking here. Progress on the respective
  510. // browser's implementation can be tracked at
  511. // https://bugs.chromium.org/p/webrtc/issues/detail?id=2481 for Chromium
  512. // and https://bugzilla.mozilla.org/show_bug.cgi?id=1213517 for Firefox.
  513. // Even if a browser implements getSettings() already, it might still
  514. // not return anything for 'facingMode'.
  515. let trackSettings;
  516. try {
  517. trackSettings = this.track.getSettings();
  518. } catch (e) {
  519. // XXX React-native-webrtc, for example, defines
  520. // MediaStreamTrack#getSettings() but the implementation throws a
  521. // "Not implemented" Error.
  522. }
  523. if (trackSettings && 'facingMode' in trackSettings) {
  524. return trackSettings.facingMode;
  525. }
  526. if (typeof this._facingMode !== 'undefined') {
  527. return this._facingMode;
  528. }
  529. // In most cases we are showing a webcam. So if we've gotten here, it
  530. // should be relatively safe to assume that we are probably showing
  531. // the user-facing camera.
  532. return CameraFacingMode.USER;
  533. }
  534. return undefined;
  535. };
  536. /**
  537. * Stops the associated MediaStream.
  538. */
  539. JitsiLocalTrack.prototype._stopMediaStream = function() {
  540. this.stopStreamInProgress = true;
  541. RTCUtils.stopMediaStream(this.stream);
  542. this.stopStreamInProgress = false;
  543. };
  544. /**
  545. * Detects camera issues on ended and mute events from MediaStreamTrack.
  546. * @returns {boolean} true if an issue is detected and false otherwise
  547. */
  548. JitsiLocalTrack.prototype._checkForCameraIssues = function() {
  549. if (!this.isVideoTrack() || this.stopStreamInProgress
  550. || this.videoType === VideoType.DESKTOP) {
  551. return false;
  552. }
  553. return !this._isReceivingData();
  554. };
  555. /**
  556. * Checks whether the attached MediaStream is receiving data from source or
  557. * not. If the stream property is null(because of mute or another reason) this
  558. * method will return false.
  559. * NOTE: This method doesn't indicate problem with the streams directly.
  560. * For example in case of video mute the method will return false or if the
  561. * user has disposed the track.
  562. * @returns {boolean} true if the stream is receiving data and false otherwise.
  563. */
  564. JitsiLocalTrack.prototype._isReceivingData = function() {
  565. if (!this.stream) {
  566. return false;
  567. }
  568. // In older version of the spec there is no muted property and
  569. // readyState can have value muted. In the latest versions
  570. // readyState can have values "live" and "ended" and there is
  571. // muted boolean property. If the stream is muted that means that
  572. // we aren't receiving any data from the source. We want to notify
  573. // the users for error if the stream is muted or ended on it's
  574. // creation.
  575. return this.stream.getTracks().some(track =>
  576. (!('readyState' in track) || track.readyState === 'live')
  577. && (!('muted' in track) || track.muted !== true));
  578. };
  579. module.exports = JitsiLocalTrack;