screen sharing for desktop. (#135)
* screen sharing for desktop (WIP). * use git repo for testing. * update. * Add sourceId/frameRate to ScreenShareCaptureOptions. * Compatible with flutter web. * Rendering of camera and screenshare video tracks at same time. * Remote screen sharing is shown first, and fixed sub/unsub button for screenshare widget. * resolved conflict. * modify flutter-webrtc to pub version. * remove unused import. * chore: Common params for Camera and ScreenShare.
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_background/flutter_background.dart';
|
||||
import 'package:livekit_client/livekit_client.dart';
|
||||
import 'package:flutter_webrtc/flutter_webrtc.dart';
|
||||
|
||||
import '../exts.dart';
|
||||
|
||||
@@ -86,9 +87,30 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
}
|
||||
|
||||
void _enableScreenShare() async {
|
||||
await participant.setScreenShareEnabled(true);
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
if (WebRTC.platformIsDesktop) {
|
||||
try {
|
||||
final source = await showDialog<DesktopCapturerSource>(
|
||||
context: context,
|
||||
builder: (context) => ScreenSelectDialog(),
|
||||
);
|
||||
if (source == null) {
|
||||
print('cancelled screenshare');
|
||||
return;
|
||||
}
|
||||
print('DesktopCapturerSource: ${source.id}');
|
||||
var track = await LocalVideoTrack.createScreenShareTrack(
|
||||
ScreenShareCaptureOptions(
|
||||
sourceId: source.id,
|
||||
maxFrameRate: 15.0,
|
||||
),
|
||||
);
|
||||
await participant.publishVideoTrack(track);
|
||||
} catch (e) {
|
||||
print('could not publish video: $e');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (WebRTC.platformIsAndroid) {
|
||||
// Android specific
|
||||
try {
|
||||
// Required for android screenshare.
|
||||
@@ -105,6 +127,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
print('could not publish video: $e');
|
||||
}
|
||||
}
|
||||
await participant.setScreenShareEnabled(true);
|
||||
}
|
||||
|
||||
void _disableScreenShare() async {
|
||||
|
||||
Reference in New Issue
Block a user