|
|
@@ -18,9 +18,11 @@ import {
|
|
18
|
18
|
createLocalTracks,
|
|
19
|
19
|
destroyLocalTracks
|
|
20
|
20
|
} from './actions';
|
|
21
|
|
-import { TRACK_UPDATED } from './actionTypes';
|
|
|
21
|
+import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from './actionTypes';
|
|
22
|
22
|
import { getLocalTrack, setTrackMuted } from './functions';
|
|
23
|
23
|
|
|
|
24
|
+declare var APP: Object;
|
|
|
25
|
+
|
|
24
|
26
|
/**
|
|
25
|
27
|
* Middleware that captures LIB_DID_DISPOSE and LIB_DID_INIT actions and,
|
|
26
|
28
|
* respectively, creates/destroys local media tracks. Also listens to
|
|
|
@@ -92,7 +94,40 @@ MiddlewareRegistry.register(store => next => action => {
|
|
92
|
94
|
break;
|
|
93
|
95
|
}
|
|
94
|
96
|
|
|
|
97
|
+ case TRACK_ADDED:
|
|
|
98
|
+ // TODO Remove this middleware case once all UI interested in new tracks
|
|
|
99
|
+ // being added are converted to react and listening for store changes.
|
|
|
100
|
+ if (typeof APP !== 'undefined' && !action.track.local) {
|
|
|
101
|
+ APP.UI.addRemoteStream(action.track.jitsiTrack);
|
|
|
102
|
+ }
|
|
|
103
|
+ break;
|
|
|
104
|
+
|
|
|
105
|
+ case TRACK_REMOVED:
|
|
|
106
|
+ // TODO Remove this middleware case once all UI interested in tracks
|
|
|
107
|
+ // being removed are converted to react and listening for store changes.
|
|
|
108
|
+ if (typeof APP !== 'undefined' && !action.track.local) {
|
|
|
109
|
+ APP.UI.removeRemoteStream(action.track.jitsiTrack);
|
|
|
110
|
+ }
|
|
|
111
|
+ break;
|
|
|
112
|
+
|
|
95
|
113
|
case TRACK_UPDATED:
|
|
|
114
|
+ // TODO Remove the below calls to APP.UI once components interested in
|
|
|
115
|
+ // track mute changes are moved into react.
|
|
|
116
|
+ if (typeof APP !== 'undefined' && !action.track.local) {
|
|
|
117
|
+ const { jitsiTrack } = action.track;
|
|
|
118
|
+ const isMuted = jitsiTrack.isMuted();
|
|
|
119
|
+ const participantID = jitsiTrack.getParticipantId();
|
|
|
120
|
+ const { videoType } = jitsiTrack;
|
|
|
121
|
+
|
|
|
122
|
+ if (videoType) {
|
|
|
123
|
+ APP.UI.setVideoMuted(participantID, isMuted);
|
|
|
124
|
+ APP.UI.onPeerVideoTypeChanged(
|
|
|
125
|
+ participantID, jitsiTrack.videoType);
|
|
|
126
|
+ } else {
|
|
|
127
|
+ APP.UI.setAudioMuted(participantID, isMuted);
|
|
|
128
|
+ }
|
|
|
129
|
+ }
|
|
|
130
|
+
|
|
96
|
131
|
return _trackUpdated(store, next, action);
|
|
97
|
132
|
}
|
|
98
|
133
|
|