<commit_before>// @flow

import _ from 'lodash';

import Platform from '../react/Platform';
import { equals, ReducerRegistry, set } from '../redux';

import { _UPDATE_CONFIG, CONFIG_WILL_LOAD, LOAD_CONFIG_ERROR, SET_CONFIG } from './actionTypes';
import { _cleanupConfig } from './functions';

/**
 * The initial state of the feature base/config when executing in a
 * non-React Native environment. The mandatory configuration to be passed to
 * JitsiMeetJS#init(). The app will download config.js from the Jitsi Meet
 * deployment and take its values into account but the values bellow will be
 * enforced (because they are essential to the correct execution of the
 * application).
 *
 * @type {Object}
 */
const INITIAL_NON_RN_STATE = {
};

/**
 * When we should enable H.264 on mobile. iOS 10 crashes so we disable it there.
 * See: https://bugs.chromium.org/p/webrtc/issues/detail?id=11002
 * Note that this is only used for P2P calls.
 *
 * @type {boolean}
 */
const RN_ENABLE_H264 = navigator.product === 'ReactNative' && !(Platform.OS === 'ios' && Platform.Version === 10);

/**
 * The initial state of the feature base/config when executing in a React Native
 * environment. The mandatory configuration to be passed to JitsiMeetJS#init().
 * The app will download config.js from the Jitsi Meet deployment and take its
 * values into account but the values bellow will be enforced (because they are
 * essential to the correct execution of the application).
 *
 * @type {Object}
 */
const INITIAL_RN_STATE = {
    analytics: {},

    // FIXME The support for audio levels in lib-jitsi-meet polls the statistics
    // of WebRTC at a short interval multiple times a second. Unfortunately,
    // React Native is slow to fetch these statistics from the native WebRTC
    // API, through the React Native bridge and eventually to JavaScript.
    // Because the audio levels are of no interest to the mobile app, it is
    // fastest to merely disable them.
    disableAudioLevels: true,

    p2p: {
        disableH264: !RN_ENABLE_H264,
        preferH264: RN_ENABLE_H264
    }
};

ReducerRegistry.register('features/base/config', (state = _getInitialState(), action) => {
    switch (action.type) {
    case _UPDATE_CONFIG:
        return _updateConfig(state, action);

    case CONFIG_WILL_LOAD:
        return {
            error: undefined,

            /**
                * The URL of the location associated with/configured by this
                * configuration.
                *
                * @type URL<commit_msg>rn: disable H.264 on select devices even when not in P2P<commit_after>// @flow

import _ from 'lodash';

import Platform from '../react/Platform';
import { equals, ReducerRegistry, set } from '../redux';

import { _UPDATE_CONFIG, CONFIG_WILL_LOAD, LOAD_CONFIG_ERROR, SET_CONFIG } from './actionTypes';
import { _cleanupConfig } from './functions';

/**
 * The initial state of the feature base/config when executing in a
 * non-React Native environment. The mandatory configuration to be passed to
 * JitsiMeetJS#init(). The app will download config.js from the Jitsi Meet
 * deployment and take its values into account but the values bellow will be
 * enforced (because they are essential to the correct execution of the
 * application).
 *
 * @type {Object}
 */
const INITIAL_NON_RN_STATE = {
};

/**
 * When we should enable H.264 on mobile. iOS 10 crashes so we disable it there.
 * See: https://bugs.chromium.org/p/webrtc/issues/detail?id=11002
 * Note that this is only used for P2P calls.
 *
 * @type {boolean}
 */
const RN_ENABLE_H264 = navigator.product === 'ReactNative' && !(Platform.OS === 'ios' && Platform.Version === 10);

/**
 * The initial state of the feature base/config when executing in a React Native
 * environment. The mandatory configuration to be passed to JitsiMeetJS#init().
 * The app will download config.js from the Jitsi Meet deployment and take its
 * values into account but the values bellow will be enforced (because they are
 * essential to the correct execution of the application).
 *
 * @type {Object}
 */
const INITIAL_RN_STATE = {
    analytics: {},

    // FIXME The support for audio levels in lib-jitsi-meet polls the statistics
    // of WebRTC at a short interval multiple times a second. Unfortunately,
    // React Native is slow to fetch these statistics from the native WebRTC
    // API, through the React Native bridge and eventually to JavaScript.
    // Because the audio levels are of no interest to the mobile app, it is
    // fastest to merely disable them.
    disableAudioLevels: true,

    disableH264: !RN_ENABLE_H264,

    p2p: {
        disableH264: !RN_ENABLE_H264,
        preferH264: RN_ENABLE_H264
    }
};

ReducerRegistry.register('features/base/config', (state = _getInitialState(), action) => {
    switch (action.type) {
    case _UPDATE_CONFIG:
        return _updateConfig(state, action);

    case CONFIG_WILL_LOAD:
        return {
            error: undefined,

            /**
                * The URL of the location associated with/configured by this
                * configuration.
                *
                * @type URL
{'fraction_non_alphanumeric': 0.08997279440342013, 'fraction_numerical': 0.013214146910221531, 'mean_word_length': 3.09466984884646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1771078', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1389, 'n_words': 573}