Send video dimensions to the server (#41)

This commit is contained in:
David Zhao
2021-11-30 20:45:09 -08:00
committed by GitHub
parent 2cd3198cdd
commit 004f8c7fdb
3 changed files with 27 additions and 22 deletions
+5 -4
View File
@@ -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
+1 -1
View File
@@ -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
+21 -17
View File
@@ -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,