Documentation
This commit is contained in:
@@ -11,6 +11,7 @@ import '../track/track.dart';
|
||||
import '../track/track_publication.dart';
|
||||
import 'participant.dart';
|
||||
|
||||
/// Represents the current participant in the room.
|
||||
class LocalParticipant extends Participant {
|
||||
RTCEngine _engine;
|
||||
|
||||
@@ -22,6 +23,8 @@ class LocalParticipant extends Participant {
|
||||
updateFromInfo(info);
|
||||
}
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
RTCEngine get engine => _engine;
|
||||
|
||||
/// publish an audio track to the room
|
||||
@@ -53,7 +56,7 @@ class LocalParticipant extends Participant {
|
||||
}
|
||||
}
|
||||
|
||||
/// publish a video track to the room
|
||||
/// Publish a video track to the room
|
||||
Future<TrackPublication> publishVideoTrack(LocalVideoTrack track) async {
|
||||
if (videoTracks.values.any(
|
||||
(element) => element.track?.mediaTrack.id == track.mediaTrack.id)) {
|
||||
@@ -83,6 +86,7 @@ class LocalParticipant extends Participant {
|
||||
}
|
||||
}
|
||||
|
||||
/// Unpublish a track that's already published
|
||||
unpublishTrack(Track track) {
|
||||
var existing = tracks.values.where((element) => element.track == track);
|
||||
if (existing.isEmpty) {
|
||||
@@ -107,6 +111,8 @@ class LocalParticipant extends Participant {
|
||||
}
|
||||
}
|
||||
|
||||
/// Publish a new data payload to the room.
|
||||
/// @param destinationSids When empty, data will be forwarded to each participant in the room.
|
||||
publishData(List<int> data, DataPacket_Kind reliability,
|
||||
{List<String>? destinationSids}) {
|
||||
RTCDataChannel? channel;
|
||||
@@ -135,6 +141,9 @@ class LocalParticipant extends Participant {
|
||||
channel.send(RTCDataChannelMessage.fromBinary(buffer));
|
||||
}
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
@override
|
||||
updateFromInfo(ParticipantInfo info) {
|
||||
super.updateFromInfo(info);
|
||||
}
|
||||
|
||||
@@ -6,20 +6,42 @@ import '../track/remote_track_publication.dart';
|
||||
import '../track/track.dart';
|
||||
import '../track/track_publication.dart';
|
||||
|
||||
/// Callbacks for participant changes
|
||||
mixin ParticipantDelegate {
|
||||
/// The participant's metadata has changed
|
||||
void onMetadataChanged(Participant participant) {}
|
||||
|
||||
/// The participant's isSpeaking property has changed
|
||||
void onSpeakingChanged(Participant participant, bool speaking) {}
|
||||
|
||||
/// This participant has muted one of their tracks
|
||||
void onTrackMuted(Participant participant, TrackPublication publication) {}
|
||||
|
||||
/// This participant has unmuted one of their tracks
|
||||
void onTrackUnmuted(Participant participant, TrackPublication publication) {}
|
||||
|
||||
/// This participant has published a new [Track] to the [Room].
|
||||
void onTrackPublished(
|
||||
RemoteParticipant participant, RemoteTrackPublication publication) {}
|
||||
|
||||
/// This participant has unpublished one of their [Track].
|
||||
void onTrackUnpublished(
|
||||
RemoteParticipant participant, RemoteTrackPublication publication) {}
|
||||
|
||||
/// The [LocalParticipant] has subscribed to a new track published by this
|
||||
/// [RemoteParticipant]
|
||||
void onTrackSubscribed(RemoteParticipant participant, Track track,
|
||||
RemoteTrackPublication publication) {}
|
||||
|
||||
/// The [LocalParticipant] has unsubscribed from a track published by this
|
||||
/// [RemoteParticipant]. This event is fired when the track was unpublished
|
||||
void onTrackUnsubscribed(RemoteParticipant participant, Track track,
|
||||
RemoteTrackPublication publication) {}
|
||||
|
||||
/// Data received from this [RemoteParticipant].
|
||||
void onDataReceived(RemoteParticipant participant, List<int> data) {}
|
||||
|
||||
/// An error has occured during track subscription.
|
||||
void onTrackSubscriptionFailed(
|
||||
RemoteParticipant participant, String sid, String? message) {}
|
||||
}
|
||||
@@ -97,11 +119,14 @@ class Participant extends ChangeNotifier {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// internal use
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
bool get hasInfo => _participantInfo != null;
|
||||
|
||||
Participant(this.sid, this.identity);
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
set isSpeaking(bool speaking) {
|
||||
if (_isSpeaking == speaking) {
|
||||
return;
|
||||
@@ -125,6 +150,8 @@ class Participant extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
updateFromInfo(ParticipantInfo info) {
|
||||
this.identity = info.identity;
|
||||
this.sid = info.sid;
|
||||
@@ -134,10 +161,14 @@ class Participant extends ChangeNotifier {
|
||||
this._participantInfo = info;
|
||||
}
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
muteChanged() {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
addTrackPublication(TrackPublication pub) {
|
||||
pub.track?.sid = pub.sid;
|
||||
tracks[pub.sid] = pub;
|
||||
|
||||
@@ -7,6 +7,7 @@ import '../track/track.dart';
|
||||
import '../track/video_track.dart';
|
||||
import 'participant.dart';
|
||||
|
||||
/// Represents other participant in the [Room].
|
||||
class RemoteParticipant extends Participant {
|
||||
SignalClient _client;
|
||||
|
||||
@@ -27,6 +28,8 @@ class RemoteParticipant extends Participant {
|
||||
}
|
||||
}
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
addSubscribedMediaTrack(
|
||||
MediaStreamTrack mediaTrack, MediaStream stream, String? sid) async {
|
||||
if (sid == null) {
|
||||
@@ -70,6 +73,8 @@ class RemoteParticipant extends Participant {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// for internal use
|
||||
/// {@nodoc}
|
||||
@override
|
||||
void updateFromInfo(ParticipantInfo info) {
|
||||
var hadInfo = hasInfo;
|
||||
|
||||
Reference in New Issue
Block a user