Skip to content

Commit 1b71810

Browse files
authored
add video input selection dogfooding menu (#973)
1 parent 0d3d299 commit 1b71810

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

dogfooding/lib/widgets/settings_menu/settings_menu.dart

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SettingsMenu extends StatefulWidget {
4646
this.onStatsPressed,
4747
this.onAudioOutputChange,
4848
this.onAudioInputChange,
49+
this.onVideoInputChange,
4950
super.key,
5051
});
5152

@@ -55,6 +56,7 @@ class SettingsMenu extends StatefulWidget {
5556
final void Function()? onStatsPressed;
5657
final void Function(RtcMediaDevice, {bool closeMenu})? onAudioOutputChange;
5758
final void Function(RtcMediaDevice)? onAudioInputChange;
59+
final void Function(RtcMediaDevice)? onVideoInputChange;
5860

5961
@override
6062
State<SettingsMenu> createState() => _SettingsMenuState();
@@ -71,16 +73,19 @@ class _SettingsMenuState extends State<SettingsMenu> {
7173
RtcMediaDevice? get _audioOutputDevice =>
7274
widget.call.state.value.audioOutputDevice;
7375
var _audioInputs = <RtcMediaDevice>[];
76+
var _videoInputs = <RtcMediaDevice>[];
7477

7578
bool _backgroundEffectsSupported = false;
7679
bool showAudioOutputs = false;
7780
bool showAudioInputs = false;
81+
bool showVideoInputs = false;
7882
bool showIncomingQuality = false;
7983
bool showBackgroundEffects = false;
8084

8185
bool get showMainSettings =>
8286
!showAudioOutputs &&
8387
!showAudioInputs &&
88+
!showVideoInputs &&
8489
!showIncomingQuality &&
8590
!showBackgroundEffects;
8691

@@ -101,6 +106,12 @@ class _SettingsMenuState extends State<SettingsMenu> {
101106
)
102107
.toList();
103108

109+
_videoInputs = devices
110+
.where(
111+
(it) => it.kind == RtcMediaDeviceKind.videoInput,
112+
)
113+
.toList();
114+
104115
if (context.mounted) setState(() {}); // intentionally empty
105116
},
106117
);
@@ -130,6 +141,7 @@ class _SettingsMenuState extends State<SettingsMenu> {
130141
if (showMainSettings) ..._buildMenuItems(),
131142
if (showAudioOutputs) ..._buildAudioOutputsMenu(),
132143
if (showAudioInputs) ..._buildAudioInputsMenu(),
144+
if (showVideoInputs) ..._buildVideoInputsMenu(),
133145
if (showIncomingQuality) ..._buildIncomingQualityMenu(),
134146
if (showBackgroundEffects) ..._buildBackgroundFiltersMenu(),
135147
]),
@@ -219,6 +231,16 @@ class _SettingsMenuState extends State<SettingsMenu> {
219231
},
220232
),
221233
const SizedBox(height: 16),
234+
StandardActionMenuItem(
235+
icon: Icons.camera_alt,
236+
label: 'Choose video input',
237+
onPressed: () {
238+
setState(() {
239+
showVideoInputs = true;
240+
});
241+
},
242+
),
243+
const SizedBox(height: 16),
222244
StandardActionMenuItem(
223245
icon: Icons.auto_awesome,
224246
label: 'Set Background Effect',
@@ -332,6 +354,41 @@ class _SettingsMenuState extends State<SettingsMenu> {
332354
];
333355
}
334356

357+
List<Widget> _buildVideoInputsMenu() {
358+
return [
359+
GestureDetector(
360+
onTap: () {
361+
setState(() {
362+
showVideoInputs = false;
363+
});
364+
},
365+
child: const Align(
366+
alignment: Alignment.centerLeft,
367+
child: Icon(Icons.arrow_back, size: 24),
368+
),
369+
),
370+
const SizedBox(height: 16),
371+
..._videoInputs
372+
.map(
373+
(device) {
374+
return StandardActionMenuItem(
375+
icon: Icons.camera_alt,
376+
label: device.label,
377+
color: widget.call.state.value.videoInputDevice?.id == device.id
378+
? AppColorPalette.appGreen
379+
: null,
380+
onPressed: () {
381+
widget.call.setVideoInputDevice(device);
382+
widget.onVideoInputChange?.call(device);
383+
},
384+
);
385+
},
386+
)
387+
.cast()
388+
.insertBetween(const SizedBox(height: 16)),
389+
];
390+
}
391+
335392
List<Widget> _buildBackgroundFiltersMenu() {
336393
return [
337394
Row(

0 commit comments

Comments
 (0)