您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.any.js 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // @flow
  2. import { toState } from '../redux';
  3. import JitsiMeetJS from './_';
  4. const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
  5. const JitsiConnectionErrors = JitsiMeetJS.errors.connection;
  6. /**
  7. * Creates a {@link JitsiLocalTrack} model from the given device id.
  8. *
  9. * @param {string} type - The media type of track being created. Expected values
  10. * are "video" or "audio".
  11. * @param {string} deviceId - The id of the target media source.
  12. * @returns {Promise<JitsiLocalTrack>}
  13. */
  14. export function createLocalTrack(type: string, deviceId: string) {
  15. return (
  16. JitsiMeetJS.createLocalTracks({
  17. cameraDeviceId: deviceId,
  18. devices: [ type ],
  19. // eslint-disable-next-line camelcase
  20. firefox_fake_device:
  21. window.config && window.config.firefox_fake_device,
  22. micDeviceId: deviceId
  23. })
  24. .then(([ jitsiLocalTrack ]) => jitsiLocalTrack));
  25. }
  26. /**
  27. * Determines whether analytics is enabled in a specific redux {@code store}.
  28. *
  29. * @param {Function|Object} stateful - The redux store, state, or
  30. * {@code getState} function.
  31. * @returns {boolean} If analytics is enabled, {@code true}; {@code false},
  32. * otherwise.
  33. */
  34. export function isAnalyticsEnabled(stateful: Function | Object) {
  35. const { disableThirdPartyRequests, analytics = {} } = toState(stateful)['features/base/config'];
  36. return !(disableThirdPartyRequests || analytics.disabled);
  37. }
  38. /**
  39. * Determines whether a specific {@link JitsiConferenceErrors} instance
  40. * indicates a fatal {@link JitsiConference} error.
  41. *
  42. * FIXME Figure out the category of errors defined by the function and describe
  43. * that category. I've currently named the category fatal because it appears to
  44. * be used in the cases of unrecoverable errors that necessitate a reload.
  45. *
  46. * @param {Object|string} error - The {@code JitsiConferenceErrors} instance to
  47. * categorize/classify or an {@link Error}-like object.
  48. * @returns {boolean} If the specified {@code JitsiConferenceErrors} instance
  49. * indicates a fatal {@code JitsiConference} error, {@code true}; otherwise,
  50. * {@code false}.
  51. */
  52. export function isFatalJitsiConferenceError(error: Object | string) {
  53. if (typeof error !== 'string') {
  54. error = error.name; // eslint-disable-line no-param-reassign
  55. }
  56. return (
  57. error === JitsiConferenceErrors.FOCUS_DISCONNECTED
  58. || error === JitsiConferenceErrors.FOCUS_LEFT
  59. || error === JitsiConferenceErrors.OFFER_ANSWER_FAILED
  60. || error === JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
  61. }
  62. /**
  63. * Determines whether a specific {@link JitsiConnectionErrors} instance
  64. * indicates a fatal {@link JitsiConnection} error.
  65. *
  66. * FIXME Figure out the category of errors defined by the function and describe
  67. * that category. I've currently named the category fatal because it appears to
  68. * be used in the cases of unrecoverable errors that necessitate a reload.
  69. *
  70. * @param {Object|string} error - The {@code JitsiConnectionErrors} instance to
  71. * categorize/classify or an {@link Error}-like object.
  72. * @returns {boolean} If the specified {@code JitsiConnectionErrors} instance
  73. * indicates a fatal {@code JitsiConnection} error, {@code true}; otherwise,
  74. * {@code false}.
  75. */
  76. export function isFatalJitsiConnectionError(error: Object | string) {
  77. if (typeof error !== 'string') {
  78. error = error.name; // eslint-disable-line no-param-reassign
  79. }
  80. return (
  81. error === JitsiConnectionErrors.CONNECTION_DROPPED_ERROR
  82. || error === JitsiConnectionErrors.OTHER_ERROR
  83. || error === JitsiConnectionErrors.SERVER_ERROR);
  84. }