Subscriber as primary (#8)
* Update protos * Signal client * Improve transport * First implementation * Fix publish * Update `PCTransport` for debounce negotiation * debounce func * reconnect & events * Update debounce func * engine events * make sure events don't emit after dispose * prefix flutter_webrtc * Cleaner `iceServers` update * don't mutate user provided params * fix tests * event manager * Fix: `Room.onDisconnected` gets fired multiple times * data publish in example * cleaner logic * safer events * un-prefix with LK * organize imports * Clean up * remove `Tuple` * `EventsEmitter` can now be directly listened to `EventsEmitter` extends `EventsListenable`
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// LiveKit
|
||||
//
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'extensions.dart';
|
||||
|
||||
typedef CancelListenFunc = Function();
|
||||
|
||||
enum Reliability {
|
||||
reliable,
|
||||
lossy,
|
||||
}
|
||||
|
||||
enum RTCIceTransportPolicy {
|
||||
all,
|
||||
relay,
|
||||
}
|
||||
|
||||
@immutable
|
||||
class RTCOfferOptions {
|
||||
final bool iceRestart;
|
||||
|
||||
const RTCOfferOptions({
|
||||
this.iceRestart = false,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() => <String, dynamic>{
|
||||
if (iceRestart) 'iceRestart': true,
|
||||
};
|
||||
}
|
||||
|
||||
@immutable
|
||||
class RTCConfiguration {
|
||||
final int? iceCandidatePoolSize;
|
||||
final List<RTCIceServer>? iceServers;
|
||||
final RTCIceTransportPolicy? iceTransportPolicy;
|
||||
|
||||
const RTCConfiguration({
|
||||
this.iceCandidatePoolSize,
|
||||
this.iceServers,
|
||||
this.iceTransportPolicy,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final iceServersMap = <Map<String, dynamic>>[
|
||||
if (iceServers != null)
|
||||
for (final e in iceServers!) e.toMap()
|
||||
];
|
||||
|
||||
return <String, dynamic>{
|
||||
// only supports unified plan
|
||||
'sdpSemantics': 'unified-plan',
|
||||
if (iceServersMap.isNotEmpty) 'iceServers': iceServersMap,
|
||||
if (iceCandidatePoolSize != null) 'iceCandidatePoolSize': iceCandidatePoolSize,
|
||||
if (iceTransportPolicy != null) 'iceTransportPolicy': iceTransportPolicy!.toStringValue(),
|
||||
};
|
||||
}
|
||||
|
||||
// Returns new options with updated properties
|
||||
RTCConfiguration copyWith({
|
||||
int? iceCandidatePoolSize,
|
||||
List<RTCIceServer>? iceServers,
|
||||
RTCIceTransportPolicy? iceTransportPolicy,
|
||||
}) =>
|
||||
RTCConfiguration(
|
||||
iceCandidatePoolSize: iceCandidatePoolSize ?? this.iceCandidatePoolSize,
|
||||
iceServers: iceServers ?? this.iceServers,
|
||||
iceTransportPolicy: iceTransportPolicy ?? this.iceTransportPolicy,
|
||||
);
|
||||
}
|
||||
|
||||
@immutable
|
||||
class RTCIceServer {
|
||||
final List<String>? urls;
|
||||
final String? username;
|
||||
final String? credential;
|
||||
|
||||
const RTCIceServer({
|
||||
this.urls,
|
||||
this.username,
|
||||
this.credential,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() => <String, dynamic>{
|
||||
if (urls?.isNotEmpty ?? false) 'urls': urls,
|
||||
if (username?.isNotEmpty ?? false) 'username': username,
|
||||
if (credential?.isNotEmpty ?? false) 'credential': credential,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user