 				"groupId": device.groupId
 			])
 		}
-		
+
 		print("DEVICES => ", json)
 		callback(json as NSDictionary)
 	}
 }
 
 fileprivate func getAllVideoDevices() -> [MediaDeviceInfo] {
-	
+
 	var videoDevicesArr : [MediaDeviceInfo] = []
 	let videoDevices: [AVCaptureDevice] = AVCaptureDevice.DiscoverySession.init(
 		deviceTypes: [AVCaptureDevice.DeviceType.builtInWideAngleCamera, AVCaptureDevice.DeviceType.builtInDualCamera],
 		mediaType: AVMediaType.video,
 		position: AVCaptureDevice.Position.unspecified
 	).devices
-	
+
 	for device: AVCaptureDevice in videoDevices {
 		var facing: String
 		var facingLabel: String;
 		let hasAudio = device.hasMediaType(AVMediaType(rawValue: convertFromAVMediaType(AVMediaType.audio)))
 		let hasVideo = device.hasMediaType(AVMediaType(rawValue: convertFromAVMediaType(AVMediaType.video)))
-		
+
 		switch device.position {
 		case AVCaptureDevice.Position.unspecified:
 			facing = "unknown"

	var audioDevicesArr : [MediaDeviceInfo] = []
	let audioInputDevices: [AVAudioSessionPortDescription] = audioSession.availableInputs!
	var bluetoothDevice: AVAudioSessionPortDescription? = nil
	var isBluetoothConnected : Bool = false
	var wiredDevice: AVAudioSessionPortDescription? = nil
	var isWiredConnected : Bool = false
	var builtMicDevice: AVAudioSessionPortDescription? = nil
	
	for audioInput in audioInputDevices {
		
		let device = MediaDeviceInfo(
			deviceId: audioInput.uid,
			kind: "audioinput",
			label: audioInput.portName
		);
		
		audioDevicesArr.append(device)
		
		// Initialize audioInputSelected. Default Built-In Microphone
		if audioInput.portType == AVAudioSession.Port.builtInMic {
			builtMicDevice = audioInput
		}
		
		if audioInput.portType == .bluetoothHFP || audioInput.portType == .bluetoothA2DP {
			bluetoothDevice = audioInput
			isBluetoothConnected = true
		}
		
		if audioInput.portType == .usbAudio || audioInput.portType == .headsetMic {
			wiredDevice = audioInput
			isWiredConnected = true
		}
	}
	
	// Initialize audioInputSelected. Priority: [Wired - Wireless - Built-In Microphone]
	if isWiredConnected {
		PluginRTCAudioController.saveInputAudioDevice(inputDeviceUID: wiredDevice!.uid)
	} else if isBluetoothConnected {
		PluginRTCAudioController.saveInputAudioDevice(inputDeviceUID: bluetoothDevice!.uid)
	} else {
		PluginRTCAudioController.saveInputAudioDevice(inputDeviceUID: builtMicDevice!.uid)
	}
	return audioDevicesArr

class PluginEnumerateDevices {
	class func call(_ callback: (_ data: NSDictionary) -> Void) {
		NSLog("PluginEnumerateDevices#call()")

		let audioDevices: [MediaDeviceInfo] = getAllAudioDevices()
		let videoDevices: [MediaDeviceInfo] = getAllVideoDevices()
		let allDevices = videoDevices + audioDevices;

		let json: NSMutableDictionary = [
			"devices": NSMutableArray()
		]

		// Casting to NSMutableDictionary
		for device: MediaDeviceInfo in allDevices {
			(json["devices"] as! NSMutableArray).add([
