Create android & web plugins (#15)
* create android & web plugins * apply `flutter format .`
This commit is contained in:
@@ -40,7 +40,8 @@ class LocalParticipant extends Participant {
|
||||
|
||||
/// publish an audio track to the room
|
||||
Future<TrackPublication> publishAudioTrack(LocalAudioTrack track) async {
|
||||
if (audioTracks.any((e) => e.track?.mediaStreamTrack.id == track.mediaStreamTrack.id)) {
|
||||
if (audioTracks.any(
|
||||
(e) => e.track?.mediaStreamTrack.id == track.mediaStreamTrack.id)) {
|
||||
throw TrackPublishException('track already exists');
|
||||
}
|
||||
|
||||
@@ -82,7 +83,8 @@ class LocalParticipant extends Participant {
|
||||
LocalVideoTrack track, {
|
||||
TrackPublishOptions? options,
|
||||
}) async {
|
||||
if (videoTracks.any((e) => e.track?.mediaStreamTrack.id == track.mediaStreamTrack.id)) {
|
||||
if (videoTracks.any(
|
||||
(e) => e.track?.mediaStreamTrack.id == track.mediaStreamTrack.id)) {
|
||||
throw TrackPublishException('track already exists');
|
||||
}
|
||||
|
||||
@@ -117,7 +119,8 @@ class LocalParticipant extends Participant {
|
||||
}
|
||||
}
|
||||
|
||||
logger.fine('Compute encodings with resolution: ${width}x${height}, options: ${options}');
|
||||
logger.fine(
|
||||
'Compute encodings with resolution: ${width}x${height}, options: ${options}');
|
||||
|
||||
final encodings = Utils.computeVideoEncodings(
|
||||
width: width,
|
||||
|
||||
@@ -20,7 +20,8 @@ import 'remote_participant.dart';
|
||||
|
||||
/// Base for [RemoteParticipant] and [LocalParticipant],
|
||||
/// can not be instantiated directly.
|
||||
abstract class Participant extends DisposableChangeNotifier with EventsEmittable<ParticipantEvent> {
|
||||
abstract class Participant extends DisposableChangeNotifier
|
||||
with EventsEmittable<ParticipantEvent> {
|
||||
/// map of track sid => published track
|
||||
final trackPublications = <String, TrackPublication>{};
|
||||
|
||||
@@ -49,7 +50,8 @@ abstract class Participant extends DisposableChangeNotifier with EventsEmittable
|
||||
DateTime get joinedAt {
|
||||
final pi = _participantInfo;
|
||||
if (pi != null) {
|
||||
return DateTime.fromMillisecondsSinceEpoch(pi.joinedAt.toInt() * 1000, isUtc: true);
|
||||
return DateTime.fromMillisecondsSinceEpoch(pi.joinedAt.toInt() * 1000,
|
||||
isUtc: true);
|
||||
}
|
||||
return DateTime.now();
|
||||
}
|
||||
@@ -160,9 +162,11 @@ abstract class Participant extends DisposableChangeNotifier with EventsEmittable
|
||||
|
||||
// Convenience extension
|
||||
extension ParticipantExt on Participant {
|
||||
List<TrackPublication> get videoTracks =>
|
||||
trackPublications.values.where((e) => e.kind == lk_models.TrackType.VIDEO).toList();
|
||||
List<TrackPublication> get videoTracks => trackPublications.values
|
||||
.where((e) => e.kind == lk_models.TrackType.VIDEO)
|
||||
.toList();
|
||||
|
||||
List<TrackPublication> get audioTracks =>
|
||||
trackPublications.values.where((e) => e.kind == lk_models.TrackType.AUDIO).toList();
|
||||
List<TrackPublication> get audioTracks => trackPublications.values
|
||||
.where((e) => e.kind == lk_models.TrackType.AUDIO)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -65,7 +65,8 @@ class RemoteParticipant extends Participant {
|
||||
logger.fine('addSubscribedMediaTrack() pub is null, will wait...');
|
||||
// Wait for the metadata to arrive
|
||||
final event = await events.waitFor<TrackPublishedEvent>(
|
||||
filter: (event) => event.participant == this && event.publication.sid == trackSid,
|
||||
filter: (event) =>
|
||||
event.participant == this && event.publication.sid == trackSid,
|
||||
duration: Timeouts.publish,
|
||||
onTimeout: () => throw TrackSubscriptionExceptionEvent(
|
||||
participant: this,
|
||||
@@ -78,7 +79,8 @@ class RemoteParticipant extends Participant {
|
||||
}
|
||||
|
||||
// Check if track type is supported, throw if not.
|
||||
if (![lk_models.TrackType.AUDIO, lk_models.TrackType.VIDEO].contains(pub.kind)) {
|
||||
if (![lk_models.TrackType.AUDIO, lk_models.TrackType.VIDEO]
|
||||
.contains(pub.kind)) {
|
||||
throw TrackSubscriptionExceptionEvent(
|
||||
participant: this,
|
||||
sid: trackSid,
|
||||
@@ -145,7 +147,8 @@ class RemoteParticipant extends Participant {
|
||||
|
||||
// unpublish any track that is not in the info
|
||||
final validSids = info.tracks.map((e) => e.sid);
|
||||
final removeSids = trackPublications.keys.where((e) => !validSids.contains(e)).toSet();
|
||||
final removeSids =
|
||||
trackPublications.keys.where((e) => !validSids.contains(e)).toSet();
|
||||
for (final sid in removeSids) {
|
||||
await unpublishTrack(sid, notify: true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user