Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changes/json-serializable
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patch type="changed" "Migrate manual json serialization to json_serializable code generation"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ There are several breaking changes between v1 and v2. Please consult our [migrat
* `Room.{audio/video}Tracks` was renamed to `Room.{audio/video}TrackPublications`
* `LocalParticipant.publishData` now uses participant identity as destinations instead of participant sids.
* `Room.sid` now changed to `await room.getSid();`.
* Removed `VideoQuality.OFF` from `VideoQuality` enum.
* Removed `VideoQuality.off` from `VideoQuality` enum.

## Removal of previously deprecated APIs

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class _VideoViewState extends State<VideoView> {

void _onParticipantChanged() {
var subscribedVideos = widget.participant.videoTracks.values.where((pub) {
return pub.kind == TrackType.VIDEO &&
return pub.kind == TrackType.video &&
!pub.isScreenShare &&
pub.subscribed;
});
Expand Down
24 changes: 24 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2024 LiveKit, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

targets:
$default:
sources:
exclude:
- example/**
builders:
json_serializable:
options:
include_if_null: false
explicit_to_json: true
8 changes: 4 additions & 4 deletions example/lib/widgets/participant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class ParticipantWidget extends StatefulWidget {
final VideoQuality quality;

const ParticipantWidget({
this.quality = VideoQuality.MEDIUM,
this.quality = VideoQuality.medium,
super.key,
});
}
Expand Down Expand Up @@ -345,15 +345,15 @@ class RemoteTrackQualityMenuWidget extends StatelessWidget {
itemBuilder: (BuildContext context) => <PopupMenuEntry<Function>>[
PopupMenuItem(
child: const Text('HIGH'),
value: () => pub.setVideoQuality(VideoQuality.HIGH),
value: () => pub.setVideoQuality(VideoQuality.high),
),
PopupMenuItem(
child: const Text('MEDIUM'),
value: () => pub.setVideoQuality(VideoQuality.MEDIUM),
value: () => pub.setVideoQuality(VideoQuality.medium),
),
PopupMenuItem(
child: const Text('LOW'),
value: () => pub.setVideoQuality(VideoQuality.LOW),
value: () => pub.setVideoQuality(VideoQuality.low),
),
],
),
Expand Down
8 changes: 4 additions & 4 deletions lib/src/core/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
await events.waitFor<EngineJoinResponseEvent>(
duration: this.connectOptions.timeouts.connection,
onTimeout: () => throw ConnectException('Timed out waiting for SignalJoinResponseEvent',
reason: ConnectionErrorReason.Timeout),
reason: ConnectionErrorReason.timeout),
);

logger.fine('Waiting for engine to connect...');
Expand Down Expand Up @@ -853,7 +853,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
}
}

void _emitDataPacket(lk_models.DataPacket dp, {EncryptionType encryptionType = EncryptionType.kNone}) {
void _emitDataPacket(lk_models.DataPacket dp, {EncryptionType encryptionType = EncryptionType.none}) {
if (dp.whichValue() == lk_models.DataPacket_Value.speaker) {
// Speaker packet
events.emit(EngineActiveSpeakersUpdateEvent(
Expand Down Expand Up @@ -1003,7 +1003,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
filter: (event) => !event.state.contains(ConnectivityResult.none),
onTimeout: () => throw ConnectException(
'attemptReconnect: Timed out waiting for SignalConnectivityChangedEvent',
reason: ConnectionErrorReason.Timeout),
reason: ConnectionErrorReason.timeout),
);
}

Expand Down Expand Up @@ -1060,7 +1060,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
await events.waitFor<SignalReconnectedEvent>(
duration: connectOptions.timeouts.connection,
onTimeout: () => throw ConnectException('resumeConnection: Timed out waiting for SignalReconnectedEvent',
reason: ConnectionErrorReason.Timeout),
reason: ConnectionErrorReason.timeout),
);

logger.fine('resumeConnection: reason: ${reason.name}');
Expand Down
20 changes: 10 additions & 10 deletions lib/src/core/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
} catch (e) {
logger.warning('could not connect to $url $e');
if (_regionUrlProvider != null && e is WebSocketException ||
(e is ConnectException && e.reason != ConnectionErrorReason.NotAllowed)) {
(e is ConnectException && e.reason != ConnectionErrorReason.notAllowed)) {
String? nextUrl;
try {
nextUrl = await _regionUrlProvider!.getNextBestRegionUrl();
Expand Down Expand Up @@ -1249,7 +1249,7 @@ extension DataStreamRoomMethods on Room {
if (_textStreamHandlers.containsKey(topic)) {
throw DataStreamError(
message: 'A text stream handler for topic "${topic}" has already been set.',
reason: DataStreamErrorReason.HandlerAlreadyRegistered,
reason: DataStreamErrorReason.handlerAlreadyRegistered,
);
}
_textStreamHandlers[topic] = callback;
Expand All @@ -1263,7 +1263,7 @@ extension DataStreamRoomMethods on Room {
if (_byteStreamHandlers.containsKey(topic)) {
throw DataStreamError(
message: 'A byte stream handler for topic "${topic}" has already been set.',
reason: DataStreamErrorReason.HandlerAlreadyRegistered,
reason: DataStreamErrorReason.handlerAlreadyRegistered,
);
}
_byteStreamHandlers[topic] = callback;
Expand Down Expand Up @@ -1304,7 +1304,7 @@ extension DataStreamRoomMethods on Room {
if (_byteStreamControllers.containsKey(streamHeader.streamId)) {
throw DataStreamError(
message: 'A data stream read is already in progress for a stream with id ${streamHeader.streamId}.',
reason: DataStreamErrorReason.AlreadyOpened,
reason: DataStreamErrorReason.alreadyOpened,
);
}

Expand Down Expand Up @@ -1349,7 +1349,7 @@ extension DataStreamRoomMethods on Room {
if (_textStreamControllers.containsKey(streamHeader.streamId)) {
throw DataStreamError(
message: 'A data stream read is already in progress for a stream with id ${streamHeader.streamId}.',
reason: DataStreamErrorReason.AlreadyOpened,
reason: DataStreamErrorReason.alreadyOpened,
);
}

Expand All @@ -1371,7 +1371,7 @@ extension DataStreamRoomMethods on Room {
DataStreamError(
message:
'Encryption type mismatch for stream ${chunk.streamId}. Expected ${encryptionType}, got ${fileBuffer.info.encryptionType}',
reason: DataStreamErrorReason.EncryptionTypeMismatch,
reason: DataStreamErrorReason.encryptionTypeMismatch,
),
);

Expand All @@ -1389,7 +1389,7 @@ extension DataStreamRoomMethods on Room {
DataStreamError(
message:
'Encryption type mismatch for stream ${chunk.streamId}. Expected ${encryptionType}, got ${textBuffer.info.encryptionType}',
reason: DataStreamErrorReason.EncryptionTypeMismatch,
reason: DataStreamErrorReason.encryptionTypeMismatch,
),
);

Expand All @@ -1410,7 +1410,7 @@ extension DataStreamRoomMethods on Room {
DataStreamError(
message:
'Encryption type mismatch for stream ${trailer.streamId}. Expected ${encryptionType}, got ${textBuffer.info.encryptionType}',
reason: DataStreamErrorReason.EncryptionTypeMismatch,
reason: DataStreamErrorReason.encryptionTypeMismatch,
),
);

Expand All @@ -1433,7 +1433,7 @@ extension DataStreamRoomMethods on Room {
DataStreamError(
message:
'Encryption type mismatch for stream ${trailer.streamId}. Expected ${encryptionType}, got ${fileBuffer.info.encryptionType}',
reason: DataStreamErrorReason.EncryptionTypeMismatch,
reason: DataStreamErrorReason.encryptionTypeMismatch,
),
);

Expand All @@ -1460,7 +1460,7 @@ extension DataStreamRoomMethods on Room {
byteStreamsBeingSentByDisconnectingParticipant.isNotEmpty) {
final abnormalEndError = DataStreamError(
message: 'Participant ${participantIdentity} unexpectedly disconnected in the middle of sending data',
reason: DataStreamErrorReason.AbnormalEnd,
reason: DataStreamErrorReason.abnormalEnd,
);
for (var controller in byteStreamsBeingSentByDisconnectingParticipant) {
controller.error(abnormalEndError);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/core/signal_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class SignalClient extends Disposable with EventsEmittable<SignalEvent> {

if (_connectivityResult.contains(ConnectivityResult.none)) {
logger.warning('no internet connection');
throw ConnectException('no internet connection', reason: ConnectionErrorReason.InternalError, statusCode: 503);
throw ConnectException('no internet connection', reason: ConnectionErrorReason.internalError, statusCode: 503);
}
}

Expand Down Expand Up @@ -182,8 +182,8 @@ class SignalClient extends Disposable with EventsEmittable<SignalEvent> {
if (validateResponse.statusCode != 200) {
finalError = ConnectException(validateResponse.body,
reason: validateResponse.statusCode >= 400
? ConnectionErrorReason.NotAllowed
: ConnectionErrorReason.InternalError,
? ConnectionErrorReason.notAllowed
: ConnectionErrorReason.internalError,
statusCode: validateResponse.statusCode);
}
} catch (error) {
Expand Down
14 changes: 7 additions & 7 deletions lib/src/data_stream/errors.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
enum DataStreamErrorReason {
// Unable to open a stream with the same ID more than once.
AlreadyOpened,
alreadyOpened,

// Stream closed abnormally by remote participant.
AbnormalEnd,
abnormalEnd,

// Incoming chunk data could not be decoded.
DecodeFailed,
decodeFailed,

// Read length exceeded total length specified in stream header.
LengthExceeded,
lengthExceeded,

// Read length less than total length specified in stream header.
Incomplete,
incomplete,

// Unable to register a stream handler more than once.
HandlerAlreadyRegistered,
handlerAlreadyRegistered,

// Encryption type mismatch.
EncryptionTypeMismatch,
encryptionTypeMismatch,
}

class DataStreamError implements Exception {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/data_stream/stream_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ abstract class BaseStreamReader<T extends BaseStreamInfo, U> {
throw DataStreamError(
message:
'Not enough chunk(s) received - expected $_totalByteSize bytes of data total, only received $_bytesReceived bytes',
reason: DataStreamErrorReason.Incomplete,
reason: DataStreamErrorReason.incomplete,
);
} else if (_bytesReceived > _totalByteSize) {
throw DataStreamError(
message:
'Extra chunk(s) received - expected $_totalByteSize bytes of data total, received $_bytesReceived bytes',
reason: DataStreamErrorReason.LengthExceeded,
reason: DataStreamErrorReason.lengthExceeded,
);
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ class TextStreamReader extends BaseStreamReader<TextStreamInfo, String> with Str
} catch (e) {
throw DataStreamError(
message: 'Failed to decode chunk data: $e',
reason: DataStreamErrorReason.DecodeFailed,
reason: DataStreamErrorReason.decodeFailed,
);
}
}
Expand Down
18 changes: 9 additions & 9 deletions lib/src/e2ee/e2ee_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class E2EEManager {
_listener = _room!.createListener();
_listener!
..on<LocalTrackPublishedEvent>((event) async {
if (event.publication.encryptionType == EncryptionType.kNone ||
if (event.publication.encryptionType == EncryptionType.none ||
isSVCCodec(event.publication.track?.codec ?? '')) {
// no need to setup frame cryptor
return;
Expand Down Expand Up @@ -81,7 +81,7 @@ class E2EEManager {
})
..on<TrackSubscribedEvent>((event) async {
final codec = event.publication.mimeType.split('/')[1];
if (event.publication.encryptionType == EncryptionType.kNone || isSVCCodec(codec)) {
if (event.publication.encryptionType == EncryptionType.none || isSVCCodec(codec)) {
// no need to setup frame cryptor
return;
}
Expand Down Expand Up @@ -211,19 +211,19 @@ class E2EEManager {
E2EEState _e2eeStateFromFrameCryptoState(FrameCryptorState state) {
switch (state) {
case FrameCryptorState.FrameCryptorStateNew:
return E2EEState.kNew;
return E2EEState.newState;
case FrameCryptorState.FrameCryptorStateOk:
return E2EEState.kOk;
return E2EEState.ok;
case FrameCryptorState.FrameCryptorStateMissingKey:
return E2EEState.kMissingKey;
return E2EEState.missingKey;
case FrameCryptorState.FrameCryptorStateEncryptionFailed:
return E2EEState.kEncryptionFailed;
return E2EEState.encryptionFailed;
case FrameCryptorState.FrameCryptorStateDecryptionFailed:
return E2EEState.kDecryptionFailed;
return E2EEState.decryptionFailed;
case FrameCryptorState.FrameCryptorStateInternalError:
return E2EEState.kInternalError;
return E2EEState.internalError;
case FrameCryptorState.FrameCryptorStateKeyRatcheted:
return E2EEState.kKeyRatcheted;
return E2EEState.keyRatcheted;
}
}

Expand Down
14 changes: 7 additions & 7 deletions lib/src/e2ee/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import '../../livekit_client.dart';

enum E2EEState {
kNew,
kOk,
kKeyRatcheted,
kMissingKey,
kEncryptionFailed,
kDecryptionFailed,
kInternalError,
newState,
ok,
keyRatcheted,
missingKey,
encryptionFailed,
decryptionFailed,
internalError,
}

/// The [E2EEState] on the track.
Expand Down
8 changes: 4 additions & 4 deletions lib/src/e2ee/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import 'key_provider.dart';

enum EncryptionType {
kNone,
kGcm,
kCustom,
none,
gcm,
custom,
}

class E2EEOptions {
final BaseKeyProvider keyProvider;
final EncryptionType encryptionType = EncryptionType.kGcm;
final EncryptionType encryptionType = EncryptionType.gcm;
const E2EEOptions({required this.keyProvider});
}
6 changes: 3 additions & 3 deletions lib/src/exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ abstract class LiveKitException implements Exception {
}

enum ConnectionErrorReason {
NotAllowed,
InternalError,
Timeout,
notAllowed,
internalError,
timeout,
}

/// An exception occured while attempting to connect.
Expand Down
Loading