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