Dynacast (#62)
* signal * engine * dynacast option * implement * update for non simulcast * use low when rid is null * firefox comment
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../extensions.dart';
|
||||
import '../logger.dart';
|
||||
import '../participant/local.dart';
|
||||
import '../proto/livekit_models.pb.dart' as lk_models;
|
||||
import '../proto/livekit_rtc.pb.dart' as lk_rtc;
|
||||
import '../track/local/local.dart';
|
||||
import 'track_publication.dart';
|
||||
|
||||
@@ -27,4 +33,40 @@ class LocalTrackPublication<T extends LocalTrack> extends TrackPublication<T> {
|
||||
|
||||
/// Unmute the track associated with this publication
|
||||
Future<void> unmute() async => await track?.unmute();
|
||||
|
||||
@internal
|
||||
void updatePublishingLayers(List<lk_rtc.SubscribedQuality> layers) async {
|
||||
//
|
||||
final params = track?.sender?.parameters;
|
||||
if (params == null) return;
|
||||
|
||||
final encodings = params.encodings;
|
||||
if (encodings == null) return;
|
||||
|
||||
bool didChange = false;
|
||||
|
||||
for (final encoding in encodings) {
|
||||
final layer = layers.firstWhereOrNull((e) =>
|
||||
// If there is exact match, use it
|
||||
(e.quality.toRid() == encoding.rid) ||
|
||||
// Use low layer if rid is null (not simulcast)
|
||||
(encoding.rid == null && e.quality == lk_models.VideoQuality.LOW));
|
||||
if (layer != null && encoding.active != layer.enabled) {
|
||||
encoding.active = layer.enabled;
|
||||
logger.fine('Setting layer ${layer.quality} to ${layer.enabled}');
|
||||
// FireFox does not support setting encoding.active to false, so we
|
||||
// have a workaround of lowering its bitrate and resolution to the min.
|
||||
// TODO: Workaround for firefox
|
||||
didChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (didChange) {
|
||||
params.encodings = encodings;
|
||||
final result = await track?.sender?.setParameters(params);
|
||||
if (result == false) {
|
||||
logger.warning('Failed to update sender parameters');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user