move reference to engine to parent (Participant) class

This commit is contained in:
Hiroshi Horie
2021-12-03 00:17:03 +07:00
parent 08d9575ec5
commit e597e4f2fd
4 changed files with 31 additions and 27 deletions
+4 -5
View File
@@ -19,8 +19,6 @@ import 'participant.dart';
/// Represents the current participant in the room.
class LocalParticipant extends Participant {
@internal
final RTCEngine engine;
@internal
final VideoPublishOptions? defaultVideoPublishOptions;
@internal
@@ -30,14 +28,15 @@ class LocalParticipant extends Participant {
covariant Map<String, LocalTrackPublication> trackPublications = {};
LocalParticipant({
required this.engine,
required RTCEngine engine,
required lk_models.ParticipantInfo info,
this.defaultVideoPublishOptions,
this.defaultAudioPublishOptions,
required EventsEmitter<RoomEvent> roomEvents,
}) : super(
info.sid,
info.identity,
engine: engine,
sid: info.sid,
identity: info.identity,
roomEvents: roomEvents,
) {
updateFromInfo(info);
+9 -3
View File
@@ -6,6 +6,7 @@ import '../extensions.dart';
import '../logger.dart';
import '../managers/event.dart';
import '../proto/livekit_models.pb.dart' as lk_models;
import '../rtc_engine.dart';
import '../support/disposable.dart';
import '../track/track.dart';
import '../publication/track_publication.dart';
@@ -24,6 +25,10 @@ import 'remote_participant.dart';
/// can not be instantiated directly.
abstract class Participant extends DisposableChangeNotifier
with EventsEmittable<ParticipantEvent> {
/// Reference to [RTCEngine]
@internal
final RTCEngine engine;
/// map of track sid => published track
abstract final Map<String, TrackPublication> trackPublications;
@@ -88,9 +93,10 @@ abstract class Participant extends DisposableChangeNotifier
@internal
bool get hasInfo => _participantInfo != null;
Participant(
this.sid,
this.identity, {
Participant({
required this.engine,
required this.sid,
required this.identity,
required this.roomEvents,
}) {
// Any event emitted will trigger ChangeNotifier
+13 -14
View File
@@ -18,9 +18,6 @@ import 'participant.dart';
/// Represents other participant in the [Room].
class RemoteParticipant extends Participant {
final RTCEngine _engine;
RTCEngine get engine => _engine;
@override
covariant Map<String, RemoteTrackPublication> trackPublications = {};
@@ -40,24 +37,26 @@ class RemoteParticipant extends Participant {
.whereType<RemoteTrackPublication<RemoteAudioTrack>>()
.toList();
RemoteParticipant(
this._engine,
String sid,
String identity, {
RemoteParticipant({
required RTCEngine engine,
required String sid,
required String identity,
required EventsEmitter<RoomEvent> roomEvents,
}) : super(
sid,
identity,
engine: engine,
sid: sid,
identity: identity,
roomEvents: roomEvents,
);
RemoteParticipant.fromInfo(
this._engine,
lk_models.ParticipantInfo info, {
RemoteParticipant.fromInfo({
required RTCEngine engine,
required lk_models.ParticipantInfo info,
required EventsEmitter<RoomEvent> roomEvents,
}) : super(
info.sid,
info.identity,
engine: engine,
sid: info.sid,
identity: info.identity,
roomEvents: roomEvents,
) {
updateFromInfo(info);
+5 -5
View File
@@ -235,15 +235,15 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
if (info == null) {
participant = RemoteParticipant(
engine,
sid,
'',
engine: engine,
sid: sid,
identity: '',
roomEvents: events,
);
} else {
participant = RemoteParticipant.fromInfo(
engine,
info,
engine: engine,
info: info,
roomEvents: events,
);
}