Skip to content

Commit b8e50f9

Browse files
committed
more docs & clean up
1 parent fc2890e commit b8e50f9

File tree

9 files changed

+59
-62
lines changed

9 files changed

+59
-62
lines changed

lib/src/core/engine.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import 'dart:async';
22

3-
import 'package:flutter/foundation.dart';
4-
53
import 'package:collection/collection.dart';
4+
import 'package:flutter/foundation.dart';
65
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
76
import 'package:meta/meta.dart';
87

@@ -11,6 +10,7 @@ import '../events.dart';
1110
import '../exceptions.dart';
1211
import '../extensions.dart';
1312
import '../internal/events.dart';
13+
import '../internal/types.dart';
1414
import '../logger.dart';
1515
import '../managers/delay.dart';
1616
import '../managers/event.dart';

lib/src/core/transport.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
44

55
import '../constants.dart';
66
import '../extensions.dart';
7+
import '../internal/types.dart';
78
import '../logger.dart';
89
import '../support/disposable.dart';
910
import '../types.dart';

lib/src/internal/types.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1-
21
import 'dart:ui';
32

43
import 'package:meta/meta.dart';
54

65
@internal
6+
@immutable
77
class RendererVisibility {
88
final String rendererId;
99
final String trackId;
1010
final bool visible;
1111
final Size size;
12-
RendererVisibility({
12+
const RendererVisibility({
1313
required this.rendererId,
1414
required this.trackId,
1515
required this.visible,
1616
required this.size,
1717
});
18-
}
18+
}
19+
20+
@internal
21+
@immutable
22+
class RTCOfferOptions {
23+
final bool iceRestart;
24+
25+
const RTCOfferOptions({
26+
this.iceRestart = false,
27+
});
28+
29+
Map<String, dynamic> toMap() => <String, dynamic>{
30+
if (iceRestart) 'iceRestart': true,
31+
};
32+
}

lib/src/managers/event.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,6 @@ abstract class EventsListenable<T> extends Disposable {
8686
}
8787
}
8888

89-
// @override
90-
// @mustCallSuper
91-
// Future<bool> dispose() async {
92-
// // mark as disposed
93-
// final didDispose = await super.dispose();
94-
// if (didDispose && _listeners.isNotEmpty) {
95-
// // Stop listening to all events
96-
// logger.fine('${objectId} dispose() cancelling ${_listeners.length} event(s)');
97-
// for (final listener in _listeners) {
98-
// await listener.cancel();
99-
// }
100-
// }
101-
102-
// return didDispose;
103-
// }
104-
10589
// listens to all events, guaranteed to be cancelled on dispose
10690
CancelListenFunc listen(FutureOr<void> Function(T) onEvent) {
10791
//

lib/src/participant/local.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/foundation.dart';
22
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
3+
import 'package:meta/meta.dart';
34

45
import '../core/room.dart';
56
import '../events.dart';
@@ -19,7 +20,7 @@ import 'participant.dart';
1920
/// Represents the current participant in the room. Instance of [LocalParticipant] is automatically
2021
/// created after successfully connecting to a [Room] and will be accessible from [Room.localParticipant].
2122
class LocalParticipant extends Participant<LocalTrackPublication> {
22-
//
23+
@internal
2324
LocalParticipant({
2425
required Room room,
2526
required lk_models.ParticipantInfo info,
@@ -240,10 +241,6 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
240241
await room.engine.sendDataPacket(packet);
241242
}
242243

243-
@override
244-
List<LocalTrackPublication> get subscribedTracks =>
245-
super.subscribedTracks.cast<LocalTrackPublication>().toList();
246-
247244
/// A convenience property to get all video tracks.
248245
@override
249246
List<LocalTrackPublication<LocalVideoTrack>> get videoTracks =>

lib/src/participant/participant.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,16 @@ abstract class Participant<T extends TrackPublication>
8080
/// Connection quality between the [Participant] and the Server.
8181
ConnectionQuality get connectionQuality => _connectionQuality;
8282

83-
/// [Track]s that this [Participant] is subscribed to.
84-
List<T> get subscribedTracks =>
85-
trackPublications.values.where((e) => e.subscribed).toList();
86-
8783
// Must be implemented by child class.
8884
List<T> get videoTracks;
8985

9086
// Must be implemented by child class.
9187
List<T> get audioTracks;
9288

93-
/// for internal use
94-
/// {@nodoc}
9589
@internal
9690
bool get hasInfo => _participantInfo != null;
9791

92+
@internal
9893
Participant({
9994
required this.room,
10095
required this.sid,

lib/src/participant/remote.dart

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,7 @@ import 'participant.dart';
1717

1818
/// Represents other participant in the [Room].
1919
class RemoteParticipant extends Participant<RemoteTrackPublication> {
20-
@override
21-
List<RemoteTrackPublication> get subscribedTracks =>
22-
super.subscribedTracks.cast<RemoteTrackPublication>().toList();
23-
24-
@override
25-
List<RemoteTrackPublication<RemoteVideoTrack>> get videoTracks =>
26-
trackPublications.values
27-
.whereType<RemoteTrackPublication<RemoteVideoTrack>>()
28-
.toList();
29-
30-
@override
31-
List<RemoteTrackPublication<RemoteAudioTrack>> get audioTracks =>
32-
trackPublications.values
33-
.whereType<RemoteTrackPublication<RemoteAudioTrack>>()
34-
.toList();
35-
20+
@internal
3621
RemoteParticipant({
3722
required Room room,
3823
required String sid,
@@ -43,6 +28,7 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
4328
identity: identity,
4429
);
4530

31+
@internal
4632
RemoteParticipant.fromInfo({
4733
required Room room,
4834
required lk_models.ParticipantInfo info,
@@ -54,6 +40,25 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
5440
updateFromInfo(info);
5541
}
5642

43+
/// A convenience property to get all video tracks.
44+
@override
45+
List<RemoteTrackPublication<RemoteVideoTrack>> get videoTracks =>
46+
trackPublications.values
47+
.whereType<RemoteTrackPublication<RemoteVideoTrack>>()
48+
.toList();
49+
50+
/// A convenience property to get all audio tracks.
51+
@override
52+
List<RemoteTrackPublication<RemoteAudioTrack>> get audioTracks =>
53+
trackPublications.values
54+
.whereType<RemoteTrackPublication<RemoteAudioTrack>>()
55+
.toList();
56+
57+
List<RemoteTrackPublication> get subscribedTracks => trackPublications.values
58+
.where((e) => e.subscribed)
59+
.cast<RemoteTrackPublication>()
60+
.toList();
61+
5762
RemoteTrackPublication? getTrackPublication(String sid) {
5863
final pub = trackPublications[sid];
5964
if (pub is RemoteTrackPublication) return pub;

lib/src/publication/local.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import '../proto/livekit_models.pb.dart' as lk_models;
33
import '../track/local/local.dart';
44
import 'track_publication.dart';
55

6+
/// A [TrackPublication] which belongs to the [LocalParticipant].
67
class LocalTrackPublication<T extends LocalTrack> extends TrackPublication<T> {
8+
/// The [LocalParticipant] this instance belongs to.
79
@override
810
final LocalParticipant participant;
911

lib/src/types.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,35 @@ import 'dart:math' as math;
33
import 'package:flutter/material.dart';
44

55
import 'extensions.dart';
6+
import 'participant/participant.dart';
67

78
typedef CancelListenFunc = Function();
89

10+
/// Protocol version to use when connecting to server.
11+
/// Usually it's not recommended to change this.
912
enum ProtocolVersion {
1013
v2,
1114
v3,
1215
v4,
1316
v5,
1417
}
1518

19+
/// Connection state type used throughout the SDK.
1620
enum ConnectionState {
1721
disconnected,
1822
connected,
1923
reconnecting,
2024
}
2125

26+
/// Connection quality between the [Participant] and server.
2227
enum ConnectionQuality {
2328
unknown,
2429
poor,
2530
good,
2631
excellent,
2732
}
2833

34+
/// Reliability used for publishing data through data channel.
2935
enum Reliability {
3036
reliable,
3137
lossy,
@@ -39,6 +45,8 @@ enum TrackSource {
3945
screenShareAudio,
4046
}
4147

48+
/// The state of track data stream.
49+
/// This is controlled by server to optimize bandwidth.
4250
enum StreamState {
4351
paused,
4452
active,
@@ -49,31 +57,21 @@ enum CloseReason {
4957
// ...
5058
}
5159

60+
/// The reason why a track failed to publish.
5261
enum TrackSubscribeFailReason {
5362
invalidServerResponse,
5463
notTrackMetadataFound,
5564
unsupportedTrackType,
5665
// ...
5766
}
5867

68+
/// The iceTransportPolicy used for [RTCConfiguration].
69+
/// See https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection
5970
enum RTCIceTransportPolicy {
6071
all,
6172
relay,
6273
}
6374

64-
@immutable
65-
class RTCOfferOptions {
66-
final bool iceRestart;
67-
68-
const RTCOfferOptions({
69-
this.iceRestart = false,
70-
});
71-
72-
Map<String, dynamic> toMap() => <String, dynamic>{
73-
if (iceRestart) 'iceRestart': true,
74-
};
75-
}
76-
7775
@immutable
7876
class RTCConfiguration {
7977
final int? iceCandidatePoolSize;
@@ -135,6 +133,7 @@ class RTCIceServer {
135133
};
136134
}
137135

136+
/// A simple class that represents dimensions of video.
138137
@immutable
139138
class VideoDimensions {
140139
final int width;
@@ -146,7 +145,7 @@ class VideoDimensions {
146145
);
147146

148147
@override
149-
String toString() => 'VideoDimensions(${width}×${height})';
148+
String toString() => '${runtimeType}(${width}x${height})';
150149

151150
/// Returns the larger value
152151
int max() => math.max(width, height);

0 commit comments

Comments
 (0)