"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7561/react/features/base/lib-jitsi-meet/functions.any.ts" (29 Sep 2023, 4152 Bytes) of package /linux/misc/jitsi-meet-7561.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "functions.any.ts": jitsi-meet_8922_vs_jitsi-meet_8960.

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