Skip to content

Commit

Permalink
fix: Fixed confusing room options causing settings to overwrite.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Aug 8, 2024
1 parent c0c4140 commit 5387d76
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
40 changes: 21 additions & 19 deletions example/lib/pages/prejoin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ class _PreJoinPageState extends State<PreJoinPage> {

try {
//create new room
final room = Room();

// Create a Listener before connecting
final listener = room.createListener();
var encoding = VideoEncoding(
maxBitrate: 5 * 1000 * 1000,
maxFramerate: 30,
);

E2EEOptions? e2eeOptions;
if (args.e2ee && args.e2eeKey != null) {
Expand All @@ -177,36 +177,38 @@ class _PreJoinPageState extends State<PreJoinPage> {
await keyProvider.setKey(args.e2eeKey!);
}

// Try to connect to the room
// This will throw an Exception if it fails for any reason.
await room.connect(
args.url,
args.token,
final room = Room(
roomOptions: RoomOptions(
adaptiveStream: args.adaptiveStream,
dynacast: args.dynacast,
defaultAudioPublishOptions: const AudioPublishOptions(
name: 'custom_audio_track_name',
),
defaultCameraCaptureOptions: CameraCaptureOptions(
maxFrameRate: 30,
params: VideoParameters(
dimensions: const VideoDimensions(1280, 720),
encoding: encoding,
)),
defaultVideoPublishOptions: VideoPublishOptions(
simulcast: args.simulcast,
videoCodec: args.preferredCodec,
backupVideoCodec: BackupVideoCodec(
enabled: args.enableBackupVideoCodec,
),
videoEncoding: encoding,
),
defaultScreenShareCaptureOptions: const ScreenShareCaptureOptions(
useiOSBroadcastExtension: true,
params: VideoParameters(
dimensions: VideoDimensionsPresets.h1080_169,
encoding: VideoEncoding(
maxBitrate: 3 * 1000 * 1000,
maxFramerate: 15,
))),
defaultCameraCaptureOptions: CameraCaptureOptions(
maxFrameRate: 30, params: _selectedVideoParameters),
e2eeOptions: e2eeOptions,
),
);
// Create a Listener before connecting
final listener = room.createListener();

// Try to connect to the room
// This will throw an Exception if it fails for any reason.
await room.connect(
args.url,
args.token,
fastConnectOptions: FastConnectOptions(
microphone: TrackOption(track: _audioTrack),
camera: TrackOption(track: _videoTrack),
Expand Down
3 changes: 1 addition & 2 deletions lib/src/core/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
String? url;
String? token;

ConnectOptions connectOptions;
late ConnectOptions connectOptions;
RoomOptions roomOptions;
FastConnectOptions? fastConnectOptions;

Expand Down Expand Up @@ -143,7 +143,6 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
}

Engine({
required this.connectOptions,
required this.roomOptions,
SignalClient? signalClient,
PeerConnectionCreate? peerConnectionCreate,
Expand Down
6 changes: 2 additions & 4 deletions lib/src/core/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
late EventsListener<SignalEvent> _signalListener;

Room({
ConnectOptions connectOptions = const ConnectOptions(),
RoomOptions roomOptions = const RoomOptions(),
Engine? engine,
}) : engine = engine ??
Engine(
connectOptions: connectOptions,
roomOptions: roomOptions,
) {
//
Expand Down Expand Up @@ -152,10 +150,10 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
String url,
String token, {
ConnectOptions? connectOptions,
RoomOptions? roomOptions,
FastConnectOptions? fastConnectOptions,
}) async {
roomOptions ??= this.roomOptions;
var roomOptions = this.roomOptions;
connectOptions ??= ConnectOptions();
if (roomOptions.e2eeOptions != null) {
if (!lkPlatformSupportsE2EE()) {
throw LiveKitE2EEException('E2EE is not supported on this platform');
Expand Down

0 comments on commit 5387d76

Please sign in to comment.