Files
jitsi-meet/react/features/app/functions.native.js
Saúl Ibarra Corretgé 9bca0e3b3d [RN] Create tracks right when they are required
When do we need tracks?

- Welcome page (only the video track)
- Conference (depends if starting with audio / video muted is requested)

When do we need to destroy the tracks?

- When we are not in a conference and there is no welcome page

In order to accommodate all the above use cases, a new component is introduced:
BlankWelcomePage. Its purpose is to take the place of the welcome page when it
is disabled. When this component is mounted local tracks are destroyed.

Analogously, a video track is created when the (real) welcome page is created,
and all the desired tracks are created then the Conference component is created.
What are desired tracks? These are the tracks we'd like to use for the
conference that is about to happen. By default both audio and video are desired.
It's possible, however, the user requested to start the call with no
video/audio, in which case it's muted in base/media and a track is not created.

The first time the app starts (with the welcome page) it will request permission
for video only, since there is no need for audio in the welcome page. Later,
when a conference is joined permission for audio will be requested when an audio
track is to be created. The audio track is not destroyed when the conference
ends. Yours truly thinks this is not needed since it's a stopped track which is
not using system resources.
2017-08-22 07:28:19 -05:00

39 lines
1.3 KiB
JavaScript

import { isRoomValid } from '../base/conference';
import { RouteRegistry } from '../base/react';
import { Conference } from '../conference';
import { BlankWelcomePage, WelcomePage } from '../welcome';
/**
* Determines which route is to be rendered in order to depict a specific Redux
* store.
*
* @param {(Object|Function)} stateOrGetState - Redux state or Regux getState()
* method.
* @returns {Route}
*/
export function _getRouteToRender(stateOrGetState) {
const state
= typeof stateOrGetState === 'function'
? stateOrGetState()
: stateOrGetState;
const { room } = state['features/base/conference'];
let component;
if (isRoomValid(room)) {
component = Conference;
} else {
// The value of the App prop welcomePageEnabled was stored in redux in
// saghul's PR. But I removed the redux state, action, action type, etc.
// because I didn't like the name. We are not using the prop is a
// React-ive way anyway so it's all the same difference.
const { app } = state['features/app'];
component
= app && app.props.welcomePageEnabled
? WelcomePage
: BlankWelcomePage;
}
return RouteRegistry.getRouteByComponent(component);
}