| 
				
			 | 
			
			
				
				@@ -9,6 +9,8 @@ import { groupDevicesByKind } from './functions'; 
			 | 
		
		
	
		
			
			| 
				9
			 | 
			
				9
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				10
			 | 
			
				10
			 | 
			
			
				
				 import { ReducerRegistry } from '../redux'; 
			 | 
		
		
	
		
			
			| 
				11
			 | 
			
				11
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				
				+import logger from './logger'; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				13
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				12
			 | 
			
				14
			 | 
			
			
				
				 const DEFAULT_STATE = { 
			 | 
		
		
	
		
			
			| 
				13
			 | 
			
				15
			 | 
			
			
				
				     availableDevices: { 
			 | 
		
		
	
		
			
			| 
				14
			 | 
			
				16
			 | 
			
			
				
				         audioInput: [], 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -18,6 +20,24 @@ const DEFAULT_STATE = { 
			 | 
		
		
	
		
			
			| 
				18
			 | 
			
				20
			 | 
			
			
				
				     pendingRequests: [] 
			 | 
		
		
	
		
			
			| 
				19
			 | 
			
				21
			 | 
			
			
				
				 }; 
			 | 
		
		
	
		
			
			| 
				20
			 | 
			
				22
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				
				+/** 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				24
			 | 
			
			
				
				+ * Logs the current device list. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				25
			 | 
			
			
				
				+ * 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				
				+ * @param {Object} deviceList - Whatever is returned by {@link groupDevicesByKind}. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				27
			 | 
			
			
				
				+ * @returns {string} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				28
			 | 
			
			
				
				+ */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				29
			 | 
			
			
				
				+function logDeviceList(deviceList) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				30
			 | 
			
			
				
				+    const devicesToStr = list => list.map(device => `\t\t${device.label}[${device.deviceId}]`).join('\n'); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				31
			 | 
			
			
				
				+    const audioInputs = devicesToStr(deviceList.audioInput); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				32
			 | 
			
			
				
				+    const audioOutputs = devicesToStr(deviceList.audioOutput); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				33
			 | 
			
			
				
				+    const videoInputs = devicesToStr(deviceList.videoInput); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				34
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				
				+    logger.debug('Device list updated:\n' 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				
				+        + `audioInput:\n${audioInputs}\n` 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				
				+        + `audioOutput:\n${audioOutputs}\n` 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				
				+        + `videoInput:\n${videoInputs}`); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				
				+} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				21
			 | 
			
				41
			 | 
			
			
				
				 /** 
			 | 
		
		
	
		
			
			| 
				22
			 | 
			
				42
			 | 
			
			
				
				  * Listen for actions which changes the state of known and used devices. 
			 | 
		
		
	
		
			
			| 
				23
			 | 
			
				43
			 | 
			
			
				
				  * 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -35,6 +55,8 @@ ReducerRegistry.register( 
			 | 
		
		
	
		
			
			| 
				35
			 | 
			
				55
			 | 
			
			
				
				         case UPDATE_DEVICE_LIST: { 
			 | 
		
		
	
		
			
			| 
				36
			 | 
			
				56
			 | 
			
			
				
				             const deviceList = groupDevicesByKind(action.devices); 
			 | 
		
		
	
		
			
			| 
				37
			 | 
			
				57
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				
				+            logDeviceList(deviceList); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				38
			 | 
			
				60
			 | 
			
			
				
				             return { 
			 | 
		
		
	
		
			
			| 
				39
			 | 
			
				61
			 | 
			
			
				
				                 ...state, 
			 | 
		
		
	
		
			
			| 
				40
			 | 
			
				62
			 | 
			
			
				
				                 availableDevices: deviceList 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -56,11 +78,17 @@ ReducerRegistry.register( 
			 | 
		
		
	
		
			
			| 
				56
			 | 
			
				78
			 | 
			
			
				
				                 pendingRequests: [ ] 
			 | 
		
		
	
		
			
			| 
				57
			 | 
			
				79
			 | 
			
			
				
				             }; 
			 | 
		
		
	
		
			
			| 
				58
			 | 
			
				80
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				
				-        // TODO: Changing of current audio and video device id is currently 
			 | 
		
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				
				-        // handled outside of react/redux. Fall through to default logic for 
			 | 
		
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				
				-        // now. 
			 | 
		
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				
				-        case SET_AUDIO_INPUT_DEVICE: 
			 | 
		
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				
				-        case SET_VIDEO_INPUT_DEVICE: 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				
				+        // TODO: Changing of current audio and video device id is currently handled outside of react/redux. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				
				+        case SET_AUDIO_INPUT_DEVICE: { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				
				+            logger.debug(`set audio input device: ${action.deviceId}`); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				
				+            return state; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				
				+        } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				
				+        case SET_VIDEO_INPUT_DEVICE: { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				
				+            logger.debug(`set video input device: ${action.deviceId}`); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				
				+            return state; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				
				+        } 
			 | 
		
		
	
		
			
			| 
				64
			 | 
			
				92
			 | 
			
			
				
				         default: 
			 | 
		
		
	
		
			
			| 
				65
			 | 
			
				93
			 | 
			
			
				
				             return state; 
			 | 
		
		
	
		
			
			| 
				66
			 | 
			
				94
			 | 
			
			
				
				         } 
			 |