Simulcast, Screen sharing & Various improvements (#4)
* Respect `RTCIceTransportPolicy` enum and organize * Simplify syntax where possible etc. * Combine `VideoPreset` and `VideoPresets` * Default values for `ConnectOptions` * Build URI instead of String manipulation * Slight modifications to Exception * `LiveKitTheme` for example * `VideoEncoding` class * Organize imports * First simulcast implementation * Remove unnecessary try-catches * Update Android settings * Remember uri and token * example improvements * `fit` parameter for VideoTrackRenderer * Simulcast option for example * Pass `defaultPublishOptions` * Show only `VideoQuality` * Pass tests * Better buildUri logic * Named parameter to positional * Explicit imports * `VideoParameter` instead of `VideoPreset` * Use `mediaTrack.getSettings` when possible * Safer dispose logic * Safer `PCTransport` Update transport.dart * Synchronized events for `SignalClient` * Use logger instead of print * Make example compile for iOS * First screen share implementation * Make example work with screen share * Example improvement * Code optimization * Don't depend on web_socket_channel * Fix: Unpublish track bug * Show participant mute state & identity * Update protos * Remote mute/unmute * iOS Background mode * Separate `createCameraTrack` and `createScreenTrack` * Clean up * PB fix * format * Fix analyzer warning * Android clean up * Update README.md * Clean up
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'remote_participant.dart';
|
||||
import '../proto/livekit_models.pb.dart';
|
||||
import '../proto/livekit_models.pb.dart' as lk_models;
|
||||
import '../track/remote_track_publication.dart';
|
||||
import '../track/track.dart';
|
||||
import '../track/track_publication.dart';
|
||||
import 'remote_participant.dart';
|
||||
|
||||
/// Callbacks for participant changes
|
||||
mixin ParticipantDelegate {
|
||||
@@ -51,9 +51,6 @@ mixin ParticipantDelegate {
|
||||
/// - added/removed subscribed tracks
|
||||
/// - metadata changed
|
||||
class Participant extends ChangeNotifier {
|
||||
Map<String, TrackPublication> audioTracks = {};
|
||||
Map<String, TrackPublication> videoTracks = {};
|
||||
|
||||
/// map of track sid => published track
|
||||
Map<String, TrackPublication> tracks = {};
|
||||
|
||||
@@ -77,7 +74,7 @@ class Participant extends ChangeNotifier {
|
||||
/// delegate to receive participant callbacks
|
||||
ParticipantDelegate? delegate;
|
||||
|
||||
ParticipantInfo? _participantInfo;
|
||||
lk_models.ParticipantInfo? _participantInfo;
|
||||
bool _isSpeaking = false;
|
||||
|
||||
/// when the participant joined the room
|
||||
@@ -94,10 +91,8 @@ class Participant extends ChangeNotifier {
|
||||
|
||||
/// true if participant is publishing an audio track and is muted
|
||||
bool get isMuted {
|
||||
if (audioTracks.values.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
return audioTracks.values.first.muted;
|
||||
if (audioTracks.isEmpty) return false;
|
||||
return audioTracks.first.muted;
|
||||
}
|
||||
|
||||
bool get hasAudio => audioTracks.isNotEmpty;
|
||||
@@ -105,15 +100,7 @@ class Participant extends ChangeNotifier {
|
||||
bool get hasVideo => videoTracks.isNotEmpty;
|
||||
|
||||
/// tracks that are subscribed to
|
||||
List<TrackPublication> get subscribedTracks {
|
||||
List<TrackPublication> result = [];
|
||||
for (final track in tracks.values) {
|
||||
if (track.subscribed) {
|
||||
result.add(track);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
List<TrackPublication> get subscribedTracks => tracks.values.where((e) => e.subscribed).toList();
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
@@ -148,7 +135,7 @@ class Participant extends ChangeNotifier {
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
void updateFromInfo(ParticipantInfo info) {
|
||||
void updateFromInfo(lk_models.ParticipantInfo info) {
|
||||
identity = info.identity;
|
||||
sid = info.sid;
|
||||
if (info.metadata.isNotEmpty) {
|
||||
@@ -168,15 +155,14 @@ class Participant extends ChangeNotifier {
|
||||
void addTrackPublication(TrackPublication pub) {
|
||||
pub.track?.sid = pub.sid;
|
||||
tracks[pub.sid] = pub;
|
||||
switch (pub.kind) {
|
||||
case TrackType.AUDIO:
|
||||
audioTracks[pub.sid] = pub;
|
||||
break;
|
||||
case TrackType.VIDEO:
|
||||
videoTracks[pub.sid] = pub;
|
||||
break;
|
||||
default:
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convenience extension
|
||||
extension LKParticipantExt on Participant {
|
||||
List<TrackPublication> get videoTracks =>
|
||||
tracks.values.where((e) => e.kind == lk_models.TrackType.VIDEO).toList();
|
||||
|
||||
List<TrackPublication> get audioTracks =>
|
||||
tracks.values.where((e) => e.kind == lk_models.TrackType.AUDIO).toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user