more docs & clean up
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../core/room.dart';
|
||||
import '../events.dart';
|
||||
@@ -19,7 +20,7 @@ import 'participant.dart';
|
||||
/// Represents the current participant in the room. Instance of [LocalParticipant] is automatically
|
||||
/// created after successfully connecting to a [Room] and will be accessible from [Room.localParticipant].
|
||||
class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
//
|
||||
@internal
|
||||
LocalParticipant({
|
||||
required Room room,
|
||||
required lk_models.ParticipantInfo info,
|
||||
@@ -240,10 +241,6 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
await room.engine.sendDataPacket(packet);
|
||||
}
|
||||
|
||||
@override
|
||||
List<LocalTrackPublication> get subscribedTracks =>
|
||||
super.subscribedTracks.cast<LocalTrackPublication>().toList();
|
||||
|
||||
/// A convenience property to get all video tracks.
|
||||
@override
|
||||
List<LocalTrackPublication<LocalVideoTrack>> get videoTracks =>
|
||||
|
||||
@@ -80,21 +80,16 @@ abstract class Participant<T extends TrackPublication>
|
||||
/// Connection quality between the [Participant] and the Server.
|
||||
ConnectionQuality get connectionQuality => _connectionQuality;
|
||||
|
||||
/// [Track]s that this [Participant] is subscribed to.
|
||||
List<T> get subscribedTracks =>
|
||||
trackPublications.values.where((e) => e.subscribed).toList();
|
||||
|
||||
// Must be implemented by child class.
|
||||
List<T> get videoTracks;
|
||||
|
||||
// Must be implemented by child class.
|
||||
List<T> get audioTracks;
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
@internal
|
||||
bool get hasInfo => _participantInfo != null;
|
||||
|
||||
@internal
|
||||
Participant({
|
||||
required this.room,
|
||||
required this.sid,
|
||||
|
||||
@@ -17,22 +17,7 @@ import 'participant.dart';
|
||||
|
||||
/// Represents other participant in the [Room].
|
||||
class RemoteParticipant extends Participant<RemoteTrackPublication> {
|
||||
@override
|
||||
List<RemoteTrackPublication> get subscribedTracks =>
|
||||
super.subscribedTracks.cast<RemoteTrackPublication>().toList();
|
||||
|
||||
@override
|
||||
List<RemoteTrackPublication<RemoteVideoTrack>> get videoTracks =>
|
||||
trackPublications.values
|
||||
.whereType<RemoteTrackPublication<RemoteVideoTrack>>()
|
||||
.toList();
|
||||
|
||||
@override
|
||||
List<RemoteTrackPublication<RemoteAudioTrack>> get audioTracks =>
|
||||
trackPublications.values
|
||||
.whereType<RemoteTrackPublication<RemoteAudioTrack>>()
|
||||
.toList();
|
||||
|
||||
@internal
|
||||
RemoteParticipant({
|
||||
required Room room,
|
||||
required String sid,
|
||||
@@ -43,6 +28,7 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
|
||||
identity: identity,
|
||||
);
|
||||
|
||||
@internal
|
||||
RemoteParticipant.fromInfo({
|
||||
required Room room,
|
||||
required lk_models.ParticipantInfo info,
|
||||
@@ -54,6 +40,25 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
|
||||
updateFromInfo(info);
|
||||
}
|
||||
|
||||
/// A convenience property to get all video tracks.
|
||||
@override
|
||||
List<RemoteTrackPublication<RemoteVideoTrack>> get videoTracks =>
|
||||
trackPublications.values
|
||||
.whereType<RemoteTrackPublication<RemoteVideoTrack>>()
|
||||
.toList();
|
||||
|
||||
/// A convenience property to get all audio tracks.
|
||||
@override
|
||||
List<RemoteTrackPublication<RemoteAudioTrack>> get audioTracks =>
|
||||
trackPublications.values
|
||||
.whereType<RemoteTrackPublication<RemoteAudioTrack>>()
|
||||
.toList();
|
||||
|
||||
List<RemoteTrackPublication> get subscribedTracks => trackPublications.values
|
||||
.where((e) => e.subscribed)
|
||||
.cast<RemoteTrackPublication>()
|
||||
.toList();
|
||||
|
||||
RemoteTrackPublication? getTrackPublication(String sid) {
|
||||
final pub = trackPublications[sid];
|
||||
if (pub is RemoteTrackPublication) return pub;
|
||||
|
||||
Reference in New Issue
Block a user