Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

JitsiLocalTrack.js 22KB

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