|
9 | 9 | import android.graphics.SurfaceTexture;
|
10 | 10 | import android.hardware.Camera;
|
11 | 11 | import android.hardware.Camera.CameraInfo;
|
| 12 | +import android.media.AudioDeviceInfo; |
12 | 13 | import android.os.Build;
|
13 | 14 | import android.util.Log;
|
14 | 15 | import android.util.LongSparseArray;
|
@@ -673,6 +674,16 @@ public void onMethodCall(MethodCall call, @NonNull Result notSafeResult) {
|
673 | 674 | getTransceivers(peerConnectionId, result);
|
674 | 675 | break;
|
675 | 676 | }
|
| 677 | + case "setPreferredInputDevice": { |
| 678 | + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { |
| 679 | + String deviceId = call.argument("deviceId"); |
| 680 | + getUserMediaImpl.setPreferredInputDevice(Integer.parseInt(deviceId)); |
| 681 | + result.success(null); |
| 682 | + } else { |
| 683 | + result.notImplemented(); |
| 684 | + } |
| 685 | + break; |
| 686 | + } |
676 | 687 | default:
|
677 | 688 | result.notImplemented();
|
678 | 689 | break;
|
@@ -1124,12 +1135,30 @@ public void getSources(Result result) {
|
1124 | 1135 | }
|
1125 | 1136 | }
|
1126 | 1137 |
|
1127 |
| - ConstraintsMap audio = new ConstraintsMap(); |
1128 |
| - audio.putString("label", "Audio"); |
1129 |
| - audio.putString("deviceId", "audio-1"); |
1130 |
| - audio.putString("facing", ""); |
1131 |
| - audio.putString("kind", "audioinput"); |
1132 |
| - array.pushMap(audio); |
| 1138 | + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { |
| 1139 | + ConstraintsMap audio = new ConstraintsMap(); |
| 1140 | + audio.putString("label", "Audio"); |
| 1141 | + audio.putString("deviceId", "audio-1"); |
| 1142 | + audio.putString("facing", ""); |
| 1143 | + audio.putString("kind", "audioinput"); |
| 1144 | + array.pushMap(audio); |
| 1145 | + } else { |
| 1146 | + android.media.AudioManager audioManager = ((android.media.AudioManager) context.getSystemService(Context.AUDIO_SERVICE)); |
| 1147 | + final AudioDeviceInfo[] devices = audioManager.getDevices(android.media.AudioManager.GET_DEVICES_INPUTS); |
| 1148 | + for (int i=0;i<devices.length;i++) { |
| 1149 | + AudioDeviceInfo device=devices[i]; |
| 1150 | + int type = (device.getType() & 0xFF); |
| 1151 | + String label=Build.VERSION.SDK_INT < Build.VERSION_CODES.P ? String.valueOf(i) : device.getAddress(); |
| 1152 | + ConstraintsMap audio = new ConstraintsMap(); |
| 1153 | + audio.putString("label", label); |
| 1154 | + audio.putString("deviceId", String.valueOf(i)); |
| 1155 | + audio.putString("groupId", ""+type); |
| 1156 | + audio.putString("facing", ""); |
| 1157 | + audio.putString("kind", "audioinput"); |
| 1158 | + array.pushMap(audio); |
| 1159 | + } |
| 1160 | + } |
| 1161 | + |
1133 | 1162 |
|
1134 | 1163 | ConstraintsMap map = new ConstraintsMap();
|
1135 | 1164 | map.putArray("sources", array.toArrayList());
|
|
0 commit comments