Skip to content

Commit

Permalink
[example][screen_sharing] Allow input the screen capture frame rate b…
Browse files Browse the repository at this point in the history
…y user
  • Loading branch information
littleGnAl committed May 23, 2024
1 parent 7e6613e commit f94472b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions example/lib/examples/advanced/screen_sharing/screen_sharing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ class _ScreenShareDesktopState extends State<ScreenShareDesktop>
List<ScreenCaptureSourceInfo> _screenCaptureSourceInfos = [];
late ScreenCaptureSourceInfo _selectedScreenCaptureSourceInfo;

late final TextEditingController _screenShareFrameRateController;

@override
bool get isScreenShared => widget.isScreenShared;

Expand Down Expand Up @@ -586,6 +588,8 @@ class _ScreenShareDesktopState extends State<ScreenShareDesktop>
void initState() {
super.initState();

_screenShareFrameRateController = TextEditingController(text: '30');

_initScreenCaptureSourceInfos();
}

Expand All @@ -596,6 +600,14 @@ class _ScreenShareDesktopState extends State<ScreenShareDesktop>
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
controller: _screenShareFrameRateController,
decoration:
const InputDecoration(hintText: 'Screen Sharing frame rate'),
),
const SizedBox(
height: 20,
),
_createDropdownButton(),
if (_screenCaptureSourceInfos.isNotEmpty)
Row(
Expand Down Expand Up @@ -626,18 +638,18 @@ class _ScreenShareDesktopState extends State<ScreenShareDesktop>
await rtcEngine.startScreenCaptureByDisplayId(
displayId: sourceId!,
regionRect: const Rectangle(x: 0, y: 0, width: 0, height: 0),
captureParams: const ScreenCaptureParameters(
captureParams: ScreenCaptureParameters(
captureMouseCursor: true,
frameRate: 30,
frameRate: int.parse(_screenShareFrameRateController.text),
));
} else if (_selectedScreenCaptureSourceInfo.type ==
ScreenCaptureSourceType.screencapturesourcetypeWindow) {
await rtcEngine.startScreenCaptureByWindowId(
windowId: sourceId!,
regionRect: const Rectangle(x: 0, y: 0, width: 0, height: 0),
captureParams: const ScreenCaptureParameters(
captureParams: ScreenCaptureParameters(
captureMouseCursor: true,
frameRate: 30,
frameRate: int.parse(_screenShareFrameRateController.text),
),
);
}
Expand Down

0 comments on commit f94472b

Please sign in to comment.