From 004f8c7fdbffd00f634ecd6f5d5363fcccaca5e4 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 30 Nov 2021 20:45:09 -0800 Subject: [PATCH] Send video dimensions to the server (#41) --- README.md | 9 ++--- example/macos/Podfile.lock | 2 +- lib/src/participant/local_participant.dart | 38 ++++++++++++---------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 12fd9be..5a6d840 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ More Docs and guides are available at [https://docs.livekit.io](https://docs.liv 🔴 = Not currently available (Possibly in the future) + +## Example app + +We built a multi-user conferencing app as an example in the [example/](example/) folder. You can join the same room from any supported LiveKit clients. + ## Installation Include this package to your `pubspec.yaml` @@ -87,10 +92,6 @@ On M1 Macs, you will also need to install x86_64 version of FFI: sudo arch -x86_64 gem install ffi ``` -## Example app - -We built a multi-user conferencing app as an example in the [example/](example/) folder. You can join the same room from any supported LiveKit clients. - ## Usage ### Connecting to a room, publish video & audio diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index 4fc86a1..660b4fd 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -36,7 +36,7 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos SPEC CHECKSUMS: - flutter_webrtc: eb68063546a533bb98f0fbcc7b54daf62edea4ed + flutter_webrtc: e5036305102877d6a3dc18b8754aaae71851cb27 FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 livekit_client: b137f094e90d910cfa846b282ad41e0e4a6a029b path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f diff --git a/lib/src/participant/local_participant.dart b/lib/src/participant/local_participant.dart index 5dab951..75bcec8 100644 --- a/lib/src/participant/local_participant.dart +++ b/lib/src/participant/local_participant.dart @@ -99,38 +99,42 @@ class LocalParticipant extends Participant { // Use defaultPublishOptions if options is null options = options ?? defaultVideoPublishOptions; - final trackInfo = await engine.addTrack( - cid: track.getCid(), - name: track.name, - kind: track.kind, - source: track.source.toPBType(), - ); - - logger.fine('publishVideoTrack addTrack response: ${trackInfo}'); - - await track.start(); - - // Video encodings and simulcasts - // use constraints passed to getUserMedia by default - int? width = track.currentOptions.params.width; - int? height = track.currentOptions.params.height; + int width = track.currentOptions.params.width; + int height = track.currentOptions.params.height; if (kIsWeb) { // getSettings() is only implemented for Web try { // try to use getSettings for more accurate resolution final settings = track.mediaStreamTrack.getSettings(); - width = settings['width'] as int?; - height = settings['height'] as int?; + if (settings['width'] is int) { + width = settings['width'] as int; + } + if (settings['height'] is int) { + height = settings['height'] as int; + } } catch (_) { logger.warning('Failed to call `mediaStreamTrack.getSettings()`'); } } + final trackInfo = await engine.addTrack( + cid: track.getCid(), + name: track.name, + kind: track.kind, + source: track.source.toPBType(), + dimension: TrackDimension(width, height), + ); + + logger.fine('publishVideoTrack addTrack response: ${trackInfo}'); + + await track.start(); + logger.fine( 'Compute encodings with resolution: ${width}x${height}, options: ${options}'); + // Video encodings and simulcasts final encodings = Utils.computeVideoEncodings( width: width, height: height,