From fccc7c24a851ff187c4d43d53aab13f0d9542b62 Mon Sep 17 00:00:00 2001 From: lambiengcode Date: Thu, 30 May 2024 09:46:34 +0700 Subject: [PATCH] chore: bump version 1.3.17 --- CHANGELOG.md | 5 +++++ README.md | 2 +- .../datasources/auth_local_datasource.dart | 4 ++-- lib/core/api/base/dio_configuration.dart | 22 +++++++++---------- lib/core/webrtc/webrtc.dart | 2 +- .../interfaces/socket_handler_interface.dart | 2 ++ lib/core/websocket/socket_handler.dart | 22 ++++++++++++++----- lib/types/enums/video_quality.dart | 8 +++---- lib/types/extensions/index.dart | 1 + lib/types/extensions/string_ext.dart | 6 +++++ lib/types/index.dart | 1 + lib/waterbus_sdk_impl.dart | 4 ++-- pubspec.yaml | 4 ++-- 13 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 lib/types/extensions/index.dart create mode 100644 lib/types/extensions/string_ext.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index ae40fb2..c0d3c11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.3.17 + +* Upgrade flutter_webrtc to support GPUPixel on Android +* Fix socket connection + ## 1.3.16 * Refactor: websocket connection diff --git a/README.md b/README.md index 83e060e..f687938 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Flutter plugin of [Waterbus](https://docs.waterbus.tech). Build video call or on | Feature | Subscribe/Publish | Screen Sharing | Picture in Picture | Virtual Background | Beauty Filters | End to End Encryption | | ------------------ | ----------------- | -------------- | ------------------ | ------------------ | -------------- | --------------------- | -| Android | 🟢 | 🟢 | 🟢 | 🟢 | 🟡 | 🟢 | +| Android | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | | iOS | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | | MacOS | 🟢 | 🟢 | 🔴 | 🟢 | 🟢 | 🟢 | | Web | 🟢 | 🟢 | 🟢 | 🟢 | 🟡 | 🟢 | diff --git a/lib/core/api/auth/datasources/auth_local_datasource.dart b/lib/core/api/auth/datasources/auth_local_datasource.dart index a06f020..b3f1dda 100644 --- a/lib/core/api/auth/datasources/auth_local_datasource.dart +++ b/lib/core/api/auth/datasources/auth_local_datasource.dart @@ -34,9 +34,9 @@ class AuthLocalDataSourceImpl implements AuthLocalDataSource { @override String get accessToken => - _hiveBox.get(StorageKeys.accessToken, defaultValue: null) ?? ""; + _hiveBox.get(StorageKeys.accessToken, defaultValue: ""); @override String get refreshToken => - _hiveBox.get(StorageKeys.refreshToken, defaultValue: null) ?? ""; + _hiveBox.get(StorageKeys.refreshToken, defaultValue: ""); } diff --git a/lib/core/api/base/dio_configuration.dart b/lib/core/api/base/dio_configuration.dart index b1e0f07..b417a83 100644 --- a/lib/core/api/base/dio_configuration.dart +++ b/lib/core/api/base/dio_configuration.dart @@ -11,6 +11,11 @@ import 'package:waterbus_sdk/core/api/base/base_remote_data.dart'; import 'package:waterbus_sdk/utils/extensions/duration_extensions.dart'; import 'package:waterbus_sdk/utils/queues/completer_queue.dart'; +typedef TokensCallback = Function( + String accessToken, + String refreshToken, +); + @singleton class DioConfiguration { final BaseRemoteData _remoteData; @@ -56,8 +61,9 @@ class DioConfiguration { final String oldAccessToken = response.requestOptions.headers['Authorization']; - final (String accessToken, String _) = - await onRefreshToken(oldAccessToken: oldAccessToken); + final (String accessToken, String _) = await onRefreshToken( + oldAccessToken: oldAccessToken.split(' ').last, + ); response.requestOptions.headers['Authorization'] = 'Bearer $accessToken'; @@ -88,12 +94,9 @@ class DioConfiguration { Future<(String, String)> onRefreshToken({ String oldAccessToken = '', - Function( - String accessToken, - String refreshToken, - )? callback, + TokensCallback? callback, }) async { - if (oldAccessToken != 'Bearer ${_authLocal.accessToken}') { + if (oldAccessToken != _authLocal.accessToken) { return (_authLocal.accessToken, _authLocal.refreshToken); } @@ -116,10 +119,7 @@ class DioConfiguration { // MARK: Private methods Future<(String, String)> _performRefreshToken({ - Function( - String accessToken, - String refreshToken, - )? callback, + TokensCallback? callback, }) async { if (_authLocal.refreshToken.isEmpty) { if (_authLocal.accessToken.isNotEmpty) { diff --git a/lib/core/webrtc/webrtc.dart b/lib/core/webrtc/webrtc.dart index f7e8ff5..df5a711 100644 --- a/lib/core/webrtc/webrtc.dart +++ b/lib/core/webrtc/webrtc.dart @@ -216,7 +216,7 @@ class WaterbusWebRTCManagerIpml extends WaterbusWebRTCManager { participant: _mParticipant!, ); - _nativeService.startCallKit(roomId); + _nativeService.startCallKit(roomId.roomCodeFormatted); _stats.initialize(); _audioStats.initialize(); } diff --git a/lib/core/websocket/interfaces/socket_handler_interface.dart b/lib/core/websocket/interfaces/socket_handler_interface.dart index 7231d4a..f722e76 100644 --- a/lib/core/websocket/interfaces/socket_handler_interface.dart +++ b/lib/core/websocket/interfaces/socket_handler_interface.dart @@ -5,4 +5,6 @@ abstract class SocketHandler { void disconnection(); Socket? get socket; + + bool get isConnected; } diff --git a/lib/core/websocket/socket_handler.dart b/lib/core/websocket/socket_handler.dart index 2c9c730..4b7f741 100644 --- a/lib/core/websocket/socket_handler.dart +++ b/lib/core/websocket/socket_handler.dart @@ -27,13 +27,18 @@ class SocketHandlerImpl extends SocketHandler { Socket? _socket; @override - void establishConnection({bool forceConnection = false}) { + void establishConnection({ + bool forceConnection = false, + String? forceAccessToken, + }) { if (_authLocal.accessToken.isEmpty || (_socket != null && !forceConnection)) { return; } - final String mAccessToken = _authLocal.accessToken; + disconnection(); + + final String mAccessToken = forceAccessToken ?? _authLocal.accessToken; _socket = io( WaterbusSdk.wsUrl, @@ -51,10 +56,14 @@ class SocketHandlerImpl extends SocketHandler { _socket?.onError((data) async { if (_authLocal.accessToken.isEmpty) return; - final (_, _) = - await _dioConfig.onRefreshToken(oldAccessToken: mAccessToken); + final (String newAccessToken, _) = await _dioConfig.onRefreshToken( + oldAccessToken: mAccessToken, + ); - establishConnection(); + establishConnection( + forceConnection: true, + forceAccessToken: newAccessToken, + ); }); _socket?.onConnect((_) async { @@ -241,4 +250,7 @@ class SocketHandlerImpl extends SocketHandler { @override Socket? get socket => _socket; + + @override + bool get isConnected => _socket != null && _socket!.connected; } diff --git a/lib/types/enums/video_quality.dart b/lib/types/enums/video_quality.dart index 00d54f7..8267ed6 100644 --- a/lib/types/enums/video_quality.dart +++ b/lib/types/enums/video_quality.dart @@ -13,12 +13,12 @@ extension VideoQualityX on VideoQuality { // VGA case VideoQuality.low: return { - 'minHeight': '480', - 'minWidth': '640', + 'minHeight': '360', + 'minWidth': '480', 'minFrameRate': '15', 'frameRate': '15', - 'height': '720', - 'width': '1280', + 'height': '480', + 'width': '800', }; // SVGA case VideoQuality.auto: diff --git a/lib/types/extensions/index.dart b/lib/types/extensions/index.dart new file mode 100644 index 0000000..a889e81 --- /dev/null +++ b/lib/types/extensions/index.dart @@ -0,0 +1 @@ +export './string_ext.dart'; diff --git a/lib/types/extensions/string_ext.dart b/lib/types/extensions/string_ext.dart new file mode 100644 index 0000000..4fbc597 --- /dev/null +++ b/lib/types/extensions/string_ext.dart @@ -0,0 +1,6 @@ +extension StringX on String { + String get roomCodeFormatted { + final String paddedCode = padLeft(9, '0'); + return "${paddedCode.substring(0, 3)}-${paddedCode.substring(3, 6)}-${paddedCode.substring(6)}"; + } +} diff --git a/lib/types/index.dart b/lib/types/index.dart index f6e723d..6d8b95b 100644 --- a/lib/types/index.dart +++ b/lib/types/index.dart @@ -1,2 +1,3 @@ export './models/index.dart'; export './enums/index.dart'; +export './extensions/index.dart'; diff --git a/lib/waterbus_sdk_impl.dart b/lib/waterbus_sdk_impl.dart index 01a5daf..2b9b87b 100644 --- a/lib/waterbus_sdk_impl.dart +++ b/lib/waterbus_sdk_impl.dart @@ -47,7 +47,7 @@ class SdkCore extends WaterbusSdkInterface { await _baseLocalData.initialize(); await _baseRepository.initialize(); - _webSocket.establishConnection(); + _webSocket.establishConnection(forceConnection: true); _rtcManager.notifyChanged.listen((event) { WaterbusSdk.onEventChanged?.call(event); @@ -76,7 +76,7 @@ class SdkCore extends WaterbusSdkInterface { required String password, required int? userId, }) async { - if (!(_webSocket.socket?.connected ?? false)) return null; + if (!_webSocket.isConnected) return null; late final Meeting? room; diff --git a/pubspec.yaml b/pubspec.yaml index e2ccca5..168f15e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: waterbus_sdk description: Flutter plugin of Waterbus. Build video call or online meeting application with SFU model. Supports iOS, Android. -version: 1.3.16 +version: 1.3.17 homepage: https://docs.waterbus.tech repository: https://github.com/waterbustech/waterbus-flutter-sdk issue_tracker: https://github.com/waterbustech/waterbus-flutter-sdk/issues @@ -39,7 +39,7 @@ dependencies: sdp_transform: ^0.3.2 h264_profile_level_id: ^0.2.1 dart_webrtc_plus: ^1.4.4+2 - flutter_webrtc_plus: ^0.10.3+6 + flutter_webrtc_plus: ^0.10.3+9 # flutter_webrtc_plus: # path: /Users/lambiengcode/Documents/webrtc/flutter-webrtc