|
1 | 1 | import { put, fork, takeLatest, call, select } from 'redux-saga/effects' |
2 | 2 | import { |
3 | | - INITIALIZE_SOUNDCHECK, |
4 | | - INITIALIZE_SOUNDCHECK_SUCCESS, |
| 3 | + INITIALIZE_SOUNDCHECK, |
| 4 | + INITIALIZE_SOUNDCHECK_SUCCESS, |
5 | 5 | INITIALIZE_SOUNDCHECK_FAILED, |
6 | 6 | UPDATE_SOUNDCHECK, |
7 | 7 | UPDATE_SOUNDCHECK_FAILED, |
8 | 8 | UPDATE_SOUNDCHECK_SUCCESS |
9 | 9 | } from '../ducks/soundcheck' |
10 | 10 | import { INITIALIZE_SUCCESS } from '../ducks/room' |
11 | 11 | import { getDevices, getUserMedia } from '../../utils/navigator' |
| 12 | +import { setLocalStorage, getLocalStorage } from '../../utils/window' |
| 13 | +import config from '../../config' |
12 | 14 |
|
13 | 15 | function* soundcheckInitialize () { |
14 | 16 | try { |
15 | 17 | const devices = yield getDevices() |
| 18 | + const constraints = getLocalStorage(config.localStorage.gumConstraints) |
| 19 | + let audioEnabled = true |
| 20 | + let videoEnabled = true |
| 21 | + if (constraints) { |
| 22 | + audioEnabled = constraints.audio && constraints.audio !== false |
| 23 | + videoEnabled = constraints.video && constraints.video !== false |
| 24 | + } |
16 | 25 | yield put({ |
17 | 26 | type: INITIALIZE_SOUNDCHECK_SUCCESS, |
18 | | - devices |
| 27 | + devices, |
| 28 | + audioEnabled, |
| 29 | + videoEnabled |
19 | 30 | }) |
20 | 31 | } catch (err) { |
21 | 32 | console.log('Error initializing soundcheck') |
@@ -71,11 +82,13 @@ function* soundcheckUpdate ({ audioInput, audioOutput, videoInput, audioEnabled, |
71 | 82 | console.log('scheck-updatesaga: constraints', constraints) |
72 | 83 | const stream = yield call(getUserMedia, constraints) |
73 | 84 | console.log('scheck-updatasaga: stream', stream, roomId, stream.getVideoTracks()) |
| 85 | + setLocalStorage(config.localStorage.gumConstraints, constraints) |
74 | 86 | yield put({ |
75 | 87 | type: INITIALIZE_SUCCESS, |
76 | 88 | roomId, |
77 | 89 | stream |
78 | 90 | }) |
| 91 | + // @todo: TODO: Pass stream updates to all users |
79 | 92 | } catch (err) { |
80 | 93 | console.log('Error initializing soundcheck') |
81 | 94 | console.error(err) |
|
0 commit comments