Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

JitsiLocalTrack.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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 {
  263. if(mute) {
  264. this.dontFireRemoveEvent = true;
  265. promise = new Promise((resolve, reject) => {
  266. this._removeStreamFromConferenceAsMute(() => {
  267. // FIXME: Maybe here we should set the SRC for the containers
  268. // to something
  269. this._stopMediaStream();
  270. this._setStream(null);
  271. resolve();
  272. }, err => {
  273. reject(err);
  274. });
  275. });
  276. } else {
  277. // This path is only for camera.
  278. const streamOptions = {
  279. cameraDeviceId: this.getDeviceId(),
  280. devices: [ MediaType.VIDEO ],
  281. facingMode: this.getCameraFacingMode()
  282. };
  283. if (this.resolution) {
  284. streamOptions.resolution = this.resolution;
  285. }
  286. promise = RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
  287. .then(streamsInfo => {
  288. const mediaType = self.getType();
  289. const streamInfo = streamsInfo.find(info => info.mediaType === mediaType);
  290. if(!streamInfo) {
  291. throw new JitsiTrackError(
  292. JitsiTrackErrors.TRACK_NO_STREAM_FOUND);
  293. }else {
  294. self._setStream(streamInfo.stream);
  295. self.track = streamInfo.track;
  296. // This is not good when video type changes after
  297. // unmute, but let's not crash here
  298. if (self.videoType !== streamInfo.videoType) {
  299. logger.warn(
  300. 'Video type has changed after unmute!',
  301. self.videoType, streamInfo.videoType);
  302. self.videoType = streamInfo.videoType;
  303. }
  304. }
  305. self.containers = self.containers.map(cont => RTCUtils.attachMediaStream(cont, self.stream));
  306. return self._addStreamToConferenceAsUnmute();
  307. });
  308. }
  309. }
  310. return promise
  311. .then(() => self._sendMuteStatus(mute))
  312. .then(function() {
  313. self.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED, this);
  314. });
  315. };
  316. /**
  317. * Adds stream to conference and marks it as "unmute" operation.
  318. *
  319. * @private
  320. * @returns {Promise}
  321. */
  322. JitsiLocalTrack.prototype._addStreamToConferenceAsUnmute = function() {
  323. if (!this.conference) {
  324. return Promise.resolve();
  325. }
  326. return new Promise((resolve, reject) => {
  327. this.conference._addLocalStream(
  328. this.stream,
  329. resolve,
  330. error => reject(new Error(error)),
  331. {
  332. mtype: this.type,
  333. type: 'unmute',
  334. ssrcs: this.ssrc && this.ssrc.ssrcs,
  335. groups: this.ssrc && this.ssrc.groups,
  336. msid: this.getMSID()
  337. });
  338. });
  339. };
  340. /**
  341. * Removes stream from conference and marks it as "mute" operation.
  342. * @param {Function} successCallback will be called on success
  343. * @param {Function} errorCallback will be called on error
  344. * @private
  345. */
  346. JitsiLocalTrack.prototype._removeStreamFromConferenceAsMute
  347. = function(successCallback, errorCallback) {
  348. if (!this.conference) {
  349. successCallback();
  350. return;
  351. }
  352. this.conference.removeLocalStream(
  353. this.stream,
  354. successCallback,
  355. error => errorCallback(new Error(error)),
  356. {
  357. mtype: this.type,
  358. type: 'mute',
  359. ssrcs: this.ssrc && this.ssrc.ssrcs,
  360. groups: this.ssrc && this.ssrc.groups
  361. });
  362. };
  363. /**
  364. * Sends mute status for a track to conference if any.
  365. *
  366. * @param {boolean} mute - If track is muted.
  367. * @private
  368. * @returns {Promise}
  369. */
  370. JitsiLocalTrack.prototype._sendMuteStatus = function(mute) {
  371. if (!this.conference || !this.conference.room) {
  372. return Promise.resolve();
  373. }
  374. return new Promise(resolve => {
  375. this.conference.room[
  376. this.isAudioTrack()
  377. ? 'setAudioMute'
  378. : 'setVideoMute'](mute, resolve);
  379. });
  380. };
  381. /**
  382. * @inheritdoc
  383. *
  384. * Stops sending the media track. And removes it from the HTML.
  385. * NOTE: Works for local tracks only.
  386. *
  387. * @extends JitsiTrack#dispose
  388. * @returns {Promise}
  389. */
  390. JitsiLocalTrack.prototype.dispose = function() {
  391. const self = this;
  392. let promise = Promise.resolve();
  393. if (this.conference) {
  394. promise = this.conference.removeTrack(this);
  395. }
  396. if (this.stream) {
  397. this._stopMediaStream();
  398. this.detach();
  399. }
  400. RTCUtils.removeListener(RTCEvents.DEVICE_LIST_CHANGED,
  401. this._onDeviceListChanged);
  402. if (this._onAudioOutputDeviceChanged) {
  403. RTCUtils.removeListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
  404. this._onAudioOutputDeviceChanged);
  405. }
  406. return promise
  407. .then(() => JitsiTrack.prototype.dispose.call(self) // super.dispose();
  408. );
  409. };
  410. /**
  411. * Returns <tt>true</tt> - if the stream is muted
  412. * and <tt>false</tt> otherwise.
  413. * @returns {boolean} <tt>true</tt> - if the stream is muted
  414. * and <tt>false</tt> otherwise.
  415. */
  416. JitsiLocalTrack.prototype.isMuted = function() {
  417. // this.stream will be null when we mute local video on Chrome
  418. if (!this.stream) {
  419. return true;
  420. }
  421. if (this.isVideoTrack() && !this.isActive()) {
  422. return true;
  423. }
  424. return !this.track || !this.track.enabled;
  425. };
  426. /**
  427. * Updates the SSRC associated with the MediaStream in JitsiLocalTrack object.
  428. * @ssrc the new ssrc
  429. */
  430. JitsiLocalTrack.prototype._setSSRC = function(ssrc) {
  431. this.ssrc = ssrc;
  432. };
  433. /**
  434. * Sets the JitsiConference object associated with the track. This is temp
  435. * solution.
  436. * @param conference the JitsiConference object
  437. */
  438. JitsiLocalTrack.prototype._setConference = function(conference) {
  439. this.conference = conference;
  440. // We want to keep up with postponed events which should have been fired
  441. // on "attach" call, but for local track we not always have the conference
  442. // before attaching. However this may result in duplicated events if they
  443. // have been triggered on "attach" already.
  444. for(let i = 0; i < this.containers.length; i++) {
  445. this._maybeFireTrackAttached(this.containers[i]);
  446. }
  447. };
  448. /**
  449. * Gets the SSRC of this local track if it's available already or <tt>null</tt>
  450. * otherwise. That's because we don't know the SSRC until local description is
  451. * created.
  452. * In case of video and simulcast returns the the primarySSRC.
  453. * @returns {string} or {null}
  454. */
  455. JitsiLocalTrack.prototype.getSSRC = function() {
  456. if(this.ssrc && this.ssrc.groups && this.ssrc.groups.length) {
  457. return this.ssrc.groups[0].ssrcs[0];
  458. } else if(this.ssrc && this.ssrc.ssrcs && this.ssrc.ssrcs.length) {
  459. return this.ssrc.ssrcs[0];
  460. }
  461. return null;
  462. };
  463. /**
  464. * Returns <tt>true</tt>.
  465. * @returns {boolean} <tt>true</tt>
  466. */
  467. JitsiLocalTrack.prototype.isLocal = function() {
  468. return true;
  469. };
  470. /**
  471. * Returns device id associated with track.
  472. * @returns {string}
  473. */
  474. JitsiLocalTrack.prototype.getDeviceId = function() {
  475. return this._realDeviceId || this.deviceId;
  476. };
  477. /**
  478. * Sets the value of bytes sent statistic.
  479. * @param bytesSent {integer} the new value (FIXME: what is an integer in js?)
  480. * NOTE: used only for audio tracks to detect audio issues.
  481. */
  482. JitsiLocalTrack.prototype._setByteSent = function(bytesSent) {
  483. this._bytesSent = bytesSent;
  484. // FIXME it's a shame that PeerConnection and ICE status does not belong
  485. // to the RTC module and it has to be accessed through
  486. // the conference(and through the XMPP chat room ???) instead
  487. const iceConnectionState
  488. = this.conference ? this.conference.getConnectionState() : null;
  489. if(this._testByteSent && 'connected' === iceConnectionState) {
  490. setTimeout(() => {
  491. if(this._bytesSent <= 0) {
  492. // we are not receiving anything from the microphone
  493. this._fireNoDataFromSourceEvent();
  494. }
  495. }, 3000);
  496. this._testByteSent = false;
  497. }
  498. };
  499. /**
  500. * Returns facing mode for video track from camera. For other cases (e.g. audio
  501. * track or 'desktop' video track) returns undefined.
  502. *
  503. * @returns {CameraFacingMode|undefined}
  504. */
  505. JitsiLocalTrack.prototype.getCameraFacingMode = function() {
  506. if (this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
  507. // MediaStreamTrack#getSettings() is not implemented in many browsers,
  508. // so we need feature checking here. Progress on the respective
  509. // browser's implementation can be tracked at
  510. // https://bugs.chromium.org/p/webrtc/issues/detail?id=2481 for Chromium
  511. // and https://bugzilla.mozilla.org/show_bug.cgi?id=1213517 for Firefox.
  512. // Even if a browser implements getSettings() already, it might still
  513. // not return anything for 'facingMode'.
  514. let trackSettings;
  515. try {
  516. trackSettings = this.track.getSettings();
  517. } catch (e) {
  518. // XXX React-native-webrtc, for example, defines
  519. // MediaStreamTrack#getSettings() but the implementation throws a
  520. // "Not implemented" Error.
  521. }
  522. if (trackSettings && 'facingMode' in trackSettings) {
  523. return trackSettings.facingMode;
  524. }
  525. if (typeof this._facingMode !== 'undefined') {
  526. return this._facingMode;
  527. }
  528. // In most cases we are showing a webcam. So if we've gotten here, it
  529. // should be relatively safe to assume that we are probably showing
  530. // the user-facing camera.
  531. return CameraFacingMode.USER;
  532. }
  533. return undefined;
  534. };
  535. /**
  536. * Stops the associated MediaStream.
  537. */
  538. JitsiLocalTrack.prototype._stopMediaStream = function() {
  539. this.stopStreamInProgress = true;
  540. RTCUtils.stopMediaStream(this.stream);
  541. this.stopStreamInProgress = false;
  542. };
  543. /**
  544. * Detects camera issues on ended and mute events from MediaStreamTrack.
  545. * @returns {boolean} true if an issue is detected and false otherwise
  546. */
  547. JitsiLocalTrack.prototype._checkForCameraIssues = function() {
  548. if(!this.isVideoTrack() || this.stopStreamInProgress
  549. || this.videoType === VideoType.DESKTOP) {
  550. return false;
  551. }
  552. return !this._isReceivingData();
  553. };
  554. /**
  555. * Checks whether the attached MediaStream is receiving data from source or
  556. * not. If the stream property is null(because of mute or another reason) this
  557. * method will return false.
  558. * NOTE: This method doesn't indicate problem with the streams directly.
  559. * For example in case of video mute the method will return false or if the
  560. * user has disposed the track.
  561. * @returns {boolean} true if the stream is receiving data and false otherwise.
  562. */
  563. JitsiLocalTrack.prototype._isReceivingData = function() {
  564. if(!this.stream) {
  565. return false;
  566. }
  567. // In older version of the spec there is no muted property and
  568. // readyState can have value muted. In the latest versions
  569. // readyState can have values "live" and "ended" and there is
  570. // muted boolean property. If the stream is muted that means that
  571. // we aren't receiving any data from the source. We want to notify
  572. // the users for error if the stream is muted or ended on it's
  573. // creation.
  574. return this.stream.getTracks().some(track =>
  575. (!('readyState' in track) || track.readyState === 'live')
  576. && (!('muted' in track) || track.muted !== true));
  577. };
  578. module.exports = JitsiLocalTrack;