6445b8d2a8
* `SignalEvents` and `synchronized` mode for `EventsListenable` * cascade syntax * clean up * `RoomEvents` * `ParticipantEvents` * all events implemented * make it compile with M1 macs * dispose logic * cleaner connect logic * ask to publish * fix initial EngineTrackAddedEvent glitch * fix unpublishTrack bug * clean up * better events docs * organize event types * clean up * cleaner wait logic * wait for event instead of using Completer * notifyListeners
49 lines
1.3 KiB
Dart
49 lines
1.3 KiB
Dart
import '../proto/livekit_models.pb.dart' as lk_models;
|
|
import '../types.dart';
|
|
import 'track.dart';
|
|
|
|
/// Represents a track that's published to the server. This class contains
|
|
/// metadata associated with tracks.
|
|
///
|
|
/// Base for [RemoteTrackPublication] and [LocalTrackPublication],
|
|
/// can not be instantiated directly.
|
|
|
|
abstract class TrackPublication {
|
|
final String name;
|
|
final String sid;
|
|
final lk_models.TrackType kind;
|
|
|
|
Track? track;
|
|
bool muted = false;
|
|
bool simulcasted = false;
|
|
TrackDimension? dimension;
|
|
|
|
bool get subscribed => track != null;
|
|
|
|
TrackPublication.fromInfo(lk_models.TrackInfo info)
|
|
: sid = info.sid,
|
|
name = info.name,
|
|
kind = info.type {
|
|
updateFromInfo(info);
|
|
}
|
|
|
|
/// True when the track is published with name [Track.screenShareName].
|
|
bool get isScreenShare => kind == lk_models.TrackType.VIDEO && name == Track.screenShareName;
|
|
|
|
void updateFromInfo(lk_models.TrackInfo info) {
|
|
muted = info.muted;
|
|
simulcasted = info.simulcast;
|
|
if (info.type == lk_models.TrackType.VIDEO) {
|
|
dimension = TrackDimension(info.width, info.height);
|
|
}
|
|
}
|
|
|
|
// Equality operators
|
|
// Object is considered equal when sid is equal
|
|
@override
|
|
int get hashCode => sid.hashCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) => other is TrackPublication && sid == other.sid;
|
|
}
|