From c4620a358aad486290bb654ed2e076c2e8a7a638 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Fri, 21 Apr 2023 17:24:51 +0530 Subject: [PATCH 01/88] =?UTF-8?q?released=20sample=20app=20version=201.4.9?= =?UTF-8?q?4=20(229)=20=F0=9F=8D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 4 ++-- example/ios/Podfile.lock | 24 ++++++++++++------------ example/ios/Runner/Info.plist | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 69edaf1ec..bf6d97510 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 228 - versionName "1.4.93" + versionCode 229 + versionName "1.4.94" } signingConfigs { diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f1d60f3a6..f7be2d02c 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -50,22 +50,22 @@ PODS: - Firebase/Performance (10.7.0): - Firebase/CoreOnly - FirebasePerformance (~> 10.7.0) - - firebase_analytics (10.2.0): + - firebase_analytics (10.2.1): - Firebase/Analytics (= 10.7.0) - firebase_core - Flutter - - firebase_core (2.9.0): + - firebase_core (2.10.0): - Firebase/CoreOnly (= 10.7.0) - Flutter - - firebase_crashlytics (3.1.0): + - firebase_crashlytics (3.1.1): - Firebase/Crashlytics (= 10.7.0) - firebase_core - Flutter - - firebase_dynamic_links (5.1.0): + - firebase_dynamic_links (5.1.1): - Firebase/DynamicLinks (= 10.7.0) - firebase_core - Flutter - - firebase_performance (0.9.1): + - firebase_performance (0.9.1-1): - Firebase/Performance (= 10.7.0) - firebase_core - Flutter @@ -194,7 +194,7 @@ PODS: - HMSSDK (0.9.2): - HMSAnalyticsSDK (= 0.0.2) - HMSWebRTC (= 1.0.5115) - - hmssdk_flutter (1.5.0): + - hmssdk_flutter (1.6.0): - Flutter - HMSBroadcastExtensionSDK (= 0.0.9) - HMSSDK (= 0.9.2) @@ -354,11 +354,11 @@ SPEC CHECKSUMS: DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: ce3938a0df3cc1ef404671531facef740d03f920 Firebase: 0219acf760880eeec8ce479895bd7767466d9f81 - firebase_analytics: 8954db5c9b63075214fa1b3ad2cdced9646f45a0 - firebase_core: d85432877e814811e040e7659f9c82faeab66e04 - firebase_crashlytics: 4c90334dc536ffa73b92f3e978426a0d1e339c74 - firebase_dynamic_links: eb6716a5419a7b1ad5ef4860c84290c48a30be91 - firebase_performance: 5f227f9d3c97ede796821299aabbe75e42dc3629 + firebase_analytics: e8e294333de66e5429d4aac365966281b4dbfb7d + firebase_core: 18d44f087248303a4a8f05d0099a000c46e3c77a + firebase_crashlytics: 6c15c2f507d82746dd62214964acf56146eab53f + firebase_dynamic_links: 464b974eeb7a5b4b7c970062c49a3e39ff924f47 + firebase_performance: 7dd98298ea2f19f480efd59ccbfcad3972ced984 FirebaseABTesting: 0c7038e4dce273821e417bdc2b0373ee0e0e8df3 FirebaseAnalytics: f8133442ee6f8512e28ff19e62ce15398bfaeace FirebaseCore: e317665b9d744727a97e623edbbed009320afdd7 @@ -380,7 +380,7 @@ SPEC CHECKSUMS: HMSAnalyticsSDK: 4d2a88a729b1eb42f3d25f217c28937ec318a5b7 HMSBroadcastExtensionSDK: d80fe325f6c928bd8e5176290b5a4b7ae15d6fbb HMSSDK: 1bd8f954ecccf50611c9b9af431798ffed7fcb30 - hmssdk_flutter: 87627396158eb17797b2e8ebe6b1b7e3ee633603 + hmssdk_flutter: 99343f2773e2c66e80ee52e32c2e3491f565ab09 HMSWebRTC: d74cd5e5ecfe701219dd4042ec67fed02ea5d6db image_gallery_saver: 259eab68fb271cfd57d599904f7acdc7832e7ef2 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 13b9e098b..5df5d3760 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.93 + 1.4.94 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 228 + 229 ITSAppUsesNonExemptEncryption LSApplicationCategoryType From 472af2327d6fbb3a698c7f4b01b820ef52190ecb Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Fri, 21 Apr 2023 17:26:02 +0530 Subject: [PATCH 02/88] updated SDK version --- example/ExampleAppChangelog.txt | 2 +- example/android/Gemfile.lock | 4 +-- example/ios/Gemfile.lock | 4 +-- example/pubspec.lock | 58 ++++++++++++++++----------------- lib/assets/sdk-versions.json | 2 +- pubspec.yaml | 2 +- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/example/ExampleAppChangelog.txt b/example/ExampleAppChangelog.txt index 0e553870c..10dbeda73 100644 --- a/example/ExampleAppChangelog.txt +++ b/example/ExampleAppChangelog.txt @@ -15,6 +15,6 @@ https://github.com/100mslive/100ms-flutter/issues/1141 - Added support to Capture Snapshot at the highest resolution offered by the camera https://github.com/100mslive/100ms-flutter/issues/1230 -Flutter SDK: 1.5.0 +Flutter SDK: 1.6.0 Android SDK: 2.6.1 iOS SDK: 0.9.2 diff --git a/example/android/Gemfile.lock b/example/android/Gemfile.lock index 2433d0974..897cc9b93 100644 --- a/example/android/Gemfile.lock +++ b/example/android/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.749.0) + aws-partitions (1.751.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) @@ -17,7 +17,7 @@ GEM aws-sdk-kms (1.63.0) aws-sdk-core (~> 3, >= 3.165.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.120.1) + aws-sdk-s3 (1.121.0) aws-sdk-core (~> 3, >= 3.165.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) diff --git a/example/ios/Gemfile.lock b/example/ios/Gemfile.lock index 275da54cc..80182c4da 100644 --- a/example/ios/Gemfile.lock +++ b/example/ios/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.749.0) + aws-partitions (1.751.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) @@ -17,7 +17,7 @@ GEM aws-sdk-kms (1.63.0) aws-sdk-core (~> 3, >= 3.165.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.120.1) + aws-sdk-s3 (1.121.0) aws-sdk-core (~> 3, >= 3.165.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) diff --git a/example/pubspec.lock b/example/pubspec.lock index 39097fee5..7146bec47 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: _flutterfire_internals - sha256: f175bc1414e4edf8c5b83372c98eeabecf8353f39c9da423c2cfdf1f1f508788 + sha256: "6a0ad72b2bcdb461749e40c01c478212a78db848dfcb2f10f2a461988bc5fb29" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" archive: dependency: transitive description: @@ -189,42 +189,42 @@ packages: dependency: "direct main" description: name: file_picker - sha256: dcde5ad1a0cebcf3715ea3f24d0db1888bf77027a26c77d7779e8ef63b8ade62 + sha256: b85eb92b175767fdaa0c543bf3b0d1f610fe966412ea72845fe5ba7801e763ff url: "https://pub.dev" source: hosted - version: "5.2.9" + version: "5.2.10" firebase_analytics: dependency: "direct main" description: name: firebase_analytics - sha256: acba5361bdc2b2f711c47ae09171d9864c1e5f46156ec5ad8c4ce619dc55b968 + sha256: "2d8f475f79658a8e1865ee8a9e2e8eea70de5e487e3a646d9073dc3d1520d3e8" url: "https://pub.dev" source: hosted - version: "10.2.0" + version: "10.2.1" firebase_analytics_platform_interface: dependency: transitive description: name: firebase_analytics_platform_interface - sha256: "5019bb18deed5b92e0f22b11b496e8265548034179e55ac7a12987fabf133d16" + sha256: a667807edbcd3f5a6336275a21c8802de8f98f0a91b8c97abb76119b142aa91d url: "https://pub.dev" source: hosted - version: "3.4.0" + version: "3.4.1" firebase_analytics_web: dependency: transitive description: name: firebase_analytics_web - sha256: "5bcdf3a63d1c6fe2426e22252b41d8579b8b7dd121225bcd623f4920d4cef4f9" + sha256: "907285030d59570d7c1a8d721912db990957ab9b87736e50a9457491c16bcffe" url: "https://pub.dev" source: hosted - version: "0.5.2" + version: "0.5.2+1" firebase_core: dependency: "direct main" description: name: firebase_core - sha256: ed611fb8e67e43ecc7956f242cecca383d87cf71aace27287aa5dd4bdba4ac07 + sha256: "239e4ac688674a7e7b5476fd16b0d8e2b5a453d464f32091af3ce1df4ebb7316" url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.10.0" firebase_core_platform_interface: dependency: transitive description: @@ -245,58 +245,58 @@ packages: dependency: "direct main" description: name: firebase_crashlytics - sha256: "42cf6a137eaae7e485e6cc9794336e8e518c506b691aa6e19ff918206c535bec" + sha256: bfc662a87df622e7d95c360536a4999f06474f53eda5a219af9e29193d498529 url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.1" firebase_crashlytics_platform_interface: dependency: transitive description: name: firebase_crashlytics_platform_interface - sha256: baa4c3d4af426d29800f0d80d165f31df4548985db151fd761346e07ed433d31 + sha256: b9c7b8498c877a2901ad323fc92c10f672be1597bc82d08f121f6228f321a7e0 url: "https://pub.dev" source: hosted - version: "3.4.0" + version: "3.4.1" firebase_dynamic_links: dependency: "direct main" description: name: firebase_dynamic_links - sha256: "07534e65f1417e2a59f64fa1f551d8f33b3cfe959fc24fd3833e8a810b9239c6" + sha256: e23f9d7323efc4532226d18cf1b7c05d1e348267a1a52bc1a18576a4d5f76849 url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "5.1.1" firebase_dynamic_links_platform_interface: dependency: transitive description: name: firebase_dynamic_links_platform_interface - sha256: "8f9e655dbaba284b656549a8aa8eb4cade7354f37ef56aa415ec9ec65cef3118" + sha256: afcefb6b49416f4c0631fb5a80f516729fc39cd8163de27e287f2d72ac017fbc url: "https://pub.dev" source: hosted - version: "0.2.4" + version: "0.2.4+1" firebase_performance: dependency: "direct main" description: name: firebase_performance - sha256: cd5fd125a002c8e46e050d5b16c90033e6a90395ee2c44cc50a7c1178f0dd2e0 + sha256: "14f4d1e89e757f0aa1dec83c13ca390bbd728aca1ccc3ad19e6a23e2710f45b7" url: "https://pub.dev" source: hosted - version: "0.9.1" + version: "0.9.1+1" firebase_performance_platform_interface: dependency: transitive description: name: firebase_performance_platform_interface - sha256: "587d23cfea672563fe1429f5dd47f4066fcb71e9a1ae82140647d14e36bd9767" + sha256: "0914a49c4ca2cc74ac4c7fde719f280896b4c1d1bbe5fa72e059da0803cbc493" url: "https://pub.dev" source: hosted - version: "0.1.2" + version: "0.1.2+1" firebase_performance_web: dependency: transitive description: name: firebase_performance_web - sha256: "99c5ba2f56e397ef2710ca60e65a2af036447ac6794328fb8ebabede4569c125" + sha256: "8192e4e112e9e09d2c9bbc8ab51d7c4e34ea618d15452d0ecfa6141e8babbd40" url: "https://pub.dev" source: hosted - version: "0.1.2" + version: "0.1.2+1" flutter: dependency: "direct main" description: flutter @@ -398,7 +398,7 @@ packages: path: ".." relative: true source: path - version: "1.5.0" + version: "1.6.0" html: dependency: transitive description: @@ -443,10 +443,10 @@ packages: dependency: "direct main" description: name: intl - sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" url: "https://pub.dev" source: hosted - version: "0.18.0" + version: "0.18.1" js: dependency: transitive description: diff --git a/lib/assets/sdk-versions.json b/lib/assets/sdk-versions.json index 435740882..f26d360d6 100644 --- a/lib/assets/sdk-versions.json +++ b/lib/assets/sdk-versions.json @@ -1,5 +1,5 @@ { - "flutter": "1.5.0", + "flutter": "1.6.0", "ios": "0.9.2", "iOSBroadcastExtension": "0.0.9", "android": "2.6.1" diff --git a/pubspec.yaml b/pubspec.yaml index 75e49bbc1..77d5bf2b2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: hmssdk_flutter description: Add Real Time Audio & Video calls, Interactive Live Streaming & Recording, Chat, HLS, RTMP, PiP, CallKit, VoIP, Video conferencing, Stream Player & WebRTC-based communications API -version: 1.5.0 +version: 1.6.0 homepage: https://www.100ms.live/ repository: https://github.com/100mslive/100ms-flutter issue_tracker: https://github.com/100mslive/100ms-flutter/issues From ae7afc290c602ea5afd7f5a617136def89aba854 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Mon, 24 Apr 2023 12:01:02 +0530 Subject: [PATCH 03/88] updated Example app Changelog --- example/ExampleAppChangelog.txt | 15 +-------------- example/android/Gemfile.lock | 4 ++-- example/ios/Gemfile.lock | 4 ++-- example/ios/Podfile.lock | 8 ++++---- ios/Classes/Models/HMSCameraControlsAction.swift | 1 + 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/example/ExampleAppChangelog.txt b/example/ExampleAppChangelog.txt index 10dbeda73..aa935a3b4 100644 --- a/example/ExampleAppChangelog.txt +++ b/example/ExampleAppChangelog.txt @@ -1,19 +1,6 @@ -Board: https://github.com/100mslive/100ms-flutter/projects/17 +Board: https://github.com/100mslive/100ms-flutter/projects/18 -- Added onUserLeaveHint implementation in Android to enable automatic entering into PIP Mode -https://github.com/100mslive/100ms-flutter/issues/1209 -- Showing all previous logs on opening Live Logs View -https://github.com/100mslive/100ms-flutter/issues/1221 - -- Parallelly archiving Android & iOS apps from the Release Script -https://github.com/100mslive/100ms-flutter/pull/1224 - -- Update HMSSDKFlutterPlugin to have only non-static variables -https://github.com/100mslive/100ms-flutter/issues/1141 - -- Added support to Capture Snapshot at the highest resolution offered by the camera -https://github.com/100mslive/100ms-flutter/issues/1230 Flutter SDK: 1.6.0 Android SDK: 2.6.1 diff --git a/example/android/Gemfile.lock b/example/android/Gemfile.lock index 897cc9b93..9d2349c70 100644 --- a/example/android/Gemfile.lock +++ b/example/android/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.751.0) + aws-partitions (1.752.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) @@ -107,7 +107,7 @@ GEM xcpretty-travis-formatter (>= 0.0.3) fastlane-plugin-firebase_app_distribution (0.5.0) gh_inspector (1.1.3) - google-apis-androidpublisher_v3 (0.39.0) + google-apis-androidpublisher_v3 (0.40.0) google-apis-core (>= 0.11.0, < 2.a) google-apis-core (0.11.0) addressable (~> 2.5, >= 2.5.1) diff --git a/example/ios/Gemfile.lock b/example/ios/Gemfile.lock index 80182c4da..addc44854 100644 --- a/example/ios/Gemfile.lock +++ b/example/ios/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.751.0) + aws-partitions (1.752.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) @@ -108,7 +108,7 @@ GEM fastlane-plugin-firebase_app_distribution (0.5.0) fastlane-plugin-versioning (0.5.1) gh_inspector (1.1.3) - google-apis-androidpublisher_v3 (0.39.0) + google-apis-androidpublisher_v3 (0.40.0) google-apis-core (>= 0.11.0, < 2.a) google-apis-core (0.11.0) addressable (~> 2.5, >= 2.5.1) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f7be2d02c..4e60dc70f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -232,9 +232,9 @@ PODS: - qr_code_scanner (0.2.0): - Flutter - MTBBarcodeScanner - - SDWebImage (5.15.5): - - SDWebImage/Core (= 5.15.5) - - SDWebImage/Core (5.15.5) + - SDWebImage (5.15.6): + - SDWebImage/Core (= 5.15.6) + - SDWebImage/Core (5.15.6) - share_plus (0.0.1): - Flutter - shared_preferences_foundation (0.0.1): @@ -394,7 +394,7 @@ SPEC CHECKSUMS: PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef PromisesSwift: cf9eb58666a43bbe007302226e510b16c1e10959 qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e - SDWebImage: fd7e1a22f00303e058058278639bf6196ee431fe + SDWebImage: d47d81bea8a77187896b620dc79c3c528e8906b9 share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472 SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f diff --git a/ios/Classes/Models/HMSCameraControlsAction.swift b/ios/Classes/Models/HMSCameraControlsAction.swift index a2a84bbfc..3d8c2b185 100644 --- a/ios/Classes/Models/HMSCameraControlsAction.swift +++ b/ios/Classes/Models/HMSCameraControlsAction.swift @@ -166,6 +166,7 @@ class HMSCameraControlsAction { /// - Returns: the string represents the current time in the time zone of the device running the application. static private func getTimeStamp() -> String { let formatter = DateFormatter() + formatter.timeStyle = .medium return formatter.string(from: Date()) } From 1c57920036aa295d32ce6ac36c59bcc8cb904703 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 25 Apr 2023 14:03:12 +0530 Subject: [PATCH 04/88] updated gems --- example/android/Gemfile.lock | 2 +- example/ios/Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/android/Gemfile.lock b/example/android/Gemfile.lock index 9d2349c70..0bc0ba727 100644 --- a/example/android/Gemfile.lock +++ b/example/android/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.752.0) + aws-partitions (1.753.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) diff --git a/example/ios/Gemfile.lock b/example/ios/Gemfile.lock index addc44854..96546fee3 100644 --- a/example/ios/Gemfile.lock +++ b/example/ios/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.752.0) + aws-partitions (1.753.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) From 8cf4f8e599d74c8a8cb7b919e1792350da177848 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 25 Apr 2023 14:21:23 +0530 Subject: [PATCH 05/88] updated build gradle file --- example/android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index bf6d97510..70695f522 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -69,7 +69,7 @@ flutter { dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'com.google.firebase:firebase-crashlytics:18.3.2' + implementation 'com.google.firebase:firebase-crashlytics:18.3.6' } apply plugin: 'com.google.gms.google-services' From b2abff988f61b20aeb120562946643318cdb1fc5 Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Tue, 25 Apr 2023 17:40:33 +0530 Subject: [PATCH 06/88] Added new sessions store api's --- android/build.gradle | 4 +- .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 69 ++++++++++++++- .../methods/HMSSessionStoreAction.kt | 59 +++++++++++++ example/assets/icons/spotlight.svg | 3 + .../app_dialogs/local_peer_tile_dialog.dart | 32 ++++++- .../app_dialogs/remote_peer_tile_dialog.dart | 32 ++++++- .../bottom_sheets/chat_bottom_sheet.dart | 9 +- .../lib/common/peer_widgets/more_option.dart | 41 +++++++++ example/lib/common/widgets/audio_tile.dart | 41 +++++++++ .../lib/common/widgets/message_container.dart | 6 +- example/lib/enum/session_store_key.dart | 35 ++++++++ example/lib/meeting/meeting_page.dart | 6 +- example/lib/meeting/meeting_store.dart | 86 +++++++++++++++++-- lib/hmssdk_flutter.dart | 2 + lib/src/common/platform_methods.dart | 22 ++++- .../hms_action_result_listener_method.dart | 3 + .../enum/hms_key_change_listener_method.dart | 12 +++ lib/src/enum/hms_update_listener_method.dart | 3 + lib/src/hmssdk.dart | 2 + lib/src/model/hms_key_change_listener.dart | 3 + lib/src/model/hms_session_store.dart | 67 +++++++++++++++ lib/src/model/hms_update_listener.dart | 3 + lib/src/model/platform_method_response.dart | 9 ++ lib/src/service/platform_service.dart | 55 ++++++++++++ 24 files changed, 583 insertions(+), 21 deletions(-) create mode 100644 android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt create mode 100644 example/assets/icons/spotlight.svg create mode 100644 example/lib/enum/session_store_key.dart create mode 100644 lib/src/enum/hms_key_change_listener_method.dart create mode 100644 lib/src/model/hms_key_change_listener.dart create mode 100644 lib/src/model/hms_session_store.dart diff --git a/android/build.gradle b/android/build.gradle index 68a1da0c5..2ddaabebb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -39,9 +39,9 @@ android { minSdkVersion 21 } } - +def hmsVersion = "an719-SNAPSHOT" dependencies { - implementation "live.100ms:android-sdk:${sdkVersions['android']}" + implementation "com.github.100mslive.android-sdk:lib:$hmsVersion" implementation "live.100ms:video-view:${sdkVersions['android']}" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0' diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index 902c0255d..ef4fd4cfc 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -21,10 +21,7 @@ import io.flutter.plugin.common.MethodChannel.Result import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import live.hms.hmssdk_flutter.methods.HMSCameraControlsAction -import live.hms.hmssdk_flutter.methods.HMSPipAction -import live.hms.hmssdk_flutter.methods.HMSRemoteVideoTrackAction -import live.hms.hmssdk_flutter.methods.HMSSessionMetadataAction +import live.hms.hmssdk_flutter.methods.* import live.hms.hmssdk_flutter.views.HMSVideoViewFactory import live.hms.video.audio.HMSAudioManager.* import live.hms.video.connection.stats.* @@ -39,6 +36,8 @@ import live.hms.video.sdk.models.enums.HMSRoomUpdate import live.hms.video.sdk.models.enums.HMSTrackUpdate import live.hms.video.sdk.models.role.HMSRole import live.hms.video.sdk.models.trackchangerequest.HMSChangeTrackStateRequest +import live.hms.video.sessionstore.HMSKeyChangeListener +import live.hms.video.sessionstore.HmsSessionStore import live.hms.video.signal.init.TokenRequest import live.hms.video.signal.init.TokenRequestOptions import live.hms.video.utils.HMSLogger @@ -56,15 +55,18 @@ class HmssdkFlutterPlugin : private var previewChannel: EventChannel? = null private var logsEventChannel: EventChannel? = null private var rtcStatsChannel: EventChannel? = null + private var sessionStoreChannel : EventChannel? = null private var eventSink: EventChannel.EventSink? = null private var previewSink: EventChannel.EventSink? = null private var logsSink: EventChannel.EventSink? = null private var rtcSink: EventChannel.EventSink? = null + private var sessionStoreSink: EventChannel.EventSink? = null private lateinit var activity: Activity var hmssdk: HMSSDK? = null private lateinit var hmsVideoFactory: HMSVideoViewFactory private var requestChange: HMSRoleChangeRequest? = null var hmssdkFlutterPlugin: HmssdkFlutterPlugin? = null + private var hmsSessionStore: HmsSessionStore? = null override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { if (hmssdkFlutterPlugin == null) { @@ -80,11 +82,15 @@ class HmssdkFlutterPlugin : this.rtcStatsChannel = EventChannel(flutterPluginBinding.binaryMessenger, "rtc_event_channel") + this.sessionStoreChannel = + EventChannel(flutterPluginBinding.binaryMessenger,"session_event_channel") + this.meetingEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Meeting event channel not found") this.channel?.setMethodCallHandler(this) ?: Log.e("Channel Error", "Event channel not found") this.previewChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Preview channel not found") this.logsEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Logs event channel not found") this.rtcStatsChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "RTC Stats channel not found") + this.sessionStoreChannel?.setStreamHandler(this) ?: Log.e("Channel Error","Session Store channel not found") this.hmsVideoFactory = HMSVideoViewFactory(this) flutterPluginBinding.platformViewRegistry.registerViewFactory( @@ -195,6 +201,15 @@ class HmssdkFlutterPlugin : "is_tap_to_focus_supported", "capture_image_at_max_supported_resolution", "is_zoom_supported", "is_flash_supported", "toggle_flash" -> { HMSCameraControlsAction.cameraControlsAction(call, result, hmssdk!!, activity.applicationContext) } + "get_session_metadata_for_key", "set_session_metadata_for_key" -> { + HMSSessionStoreAction.sessionStoreActions(call,result,hmsSessionStore) + } + "add_key_change_listener"-> { + addKeyChangeListener(call,result) + } + "remove_key_change_listener" -> { + removeKeyChangeListener() + } else -> { result.notImplemented() } @@ -368,10 +383,12 @@ class HmssdkFlutterPlugin : previewChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Preview channel not found") logsEventChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Logs event channel not found") rtcStatsChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "RTC Stats channel not found") + sessionStoreChannel?.setStreamHandler(null)?:Log.e("Channel Error","Session Store channel not found") eventSink = null previewSink = null rtcSink = null logsSink = null + sessionStoreSink = null hmssdkFlutterPlugin = null } else { Log.e("Plugin Error", "hmssdkFlutterPlugin is null in onDetachedFromEngine") @@ -454,6 +471,7 @@ class HmssdkFlutterPlugin : private fun leave(result: Result) { hmssdk!!.leave(hmsActionResultListener = HMSCommonAction.getActionListener(result)) disposePIP() + removeKeyChangeListener() } private fun destroy(result: Result) { @@ -471,6 +489,8 @@ class HmssdkFlutterPlugin : this.logsSink = events } else if (nameOfEventSink == "rtc_stats") { this.rtcSink = events + } else if(nameOfEventSink == "session_store") { + this.sessionStoreSink = events } } @@ -668,6 +688,7 @@ class HmssdkFlutterPlugin : hmsActionResultListener = HMSCommonAction.getActionListener(result) ) disposePIP() + removeKeyChangeListener() } private fun isAllowedToEndMeeting(): Boolean? { @@ -851,6 +872,7 @@ class HmssdkFlutterPlugin : if (HMSPipAction.isPIPActive(activity)) { activity.moveTaskToBack(true) disposePIP() + removeKeyChangeListener() } if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { @@ -886,6 +908,17 @@ class HmssdkFlutterPlugin : } } } + + override fun onSessionStoreAvailable(sessionStore: HmsSessionStore) { + val args = HashMap() + args["event_name"] = "on_session_store_available" + args["data"] = null + hmsSessionStore = sessionStore + CoroutineScope(Dispatchers.Main).launch { + eventSink?.success(args) + } + } + } private val hmsPreviewListener = object : HMSPreviewListener { @@ -1182,6 +1215,34 @@ class HmssdkFlutterPlugin : } } + private val keyChangeListener = object : HMSKeyChangeListener { + override fun onKeyChanged(key: String, value: String?) { + val args = HashMap() + args["event_name"] = "on_key_changed" + val keyValuePair = HashMap() + keyValuePair["key"] = key + keyValuePair["value"] = value + args["data"] = keyValuePair + CoroutineScope(Dispatchers.Main).launch { + sessionStoreSink?.success(args) + } + } + } + private fun addKeyChangeListener(call: MethodCall,result: Result){ + + val keys = call.argument>("keys") ?: run { + HMSErrorLogger.returnArgumentsError("keys parameter is null") + } + + keys.let { keys as List + hmsSessionStore?.addKeyChangeListener(keys,keyChangeListener,HMSCommonAction.getActionListener(result)) + } + } + + private fun removeKeyChangeListener(){ + hmsSessionStore?.removeKeyChangeListener(keyChangeListener) + } + private val hmsStatsListener = object : HMSStatsObserver { override fun onRemoteVideoStats( diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt new file mode 100644 index 000000000..e86633632 --- /dev/null +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt @@ -0,0 +1,59 @@ +package live.hms.hmssdk_flutter.methods + +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel.Result +import live.hms.hmssdk_flutter.HMSCommonAction +import live.hms.hmssdk_flutter.HMSErrorLogger +import live.hms.hmssdk_flutter.HMSExceptionExtension +import live.hms.hmssdk_flutter.HMSResultExtension +import live.hms.video.error.HMSException +import live.hms.video.sdk.HMSSessionMetadataListener +import live.hms.video.sessionstore.HmsSessionStore + +class HMSSessionStoreAction { + + companion object{ + + fun sessionStoreActions(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?){ + when(call.method){ + "get_session_metadata_for_key" -> { + getSessionMetadataForKey(call,result,hmsSessionStore) + } + "set_session_metadata_for_key" -> { + setSessionMetadataForKey(call,result,hmsSessionStore) + } + } + } + + private fun getSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ + val key = call.argument("key") ?: run { + HMSErrorLogger.returnArgumentsError("key is null") + } + + key?.let { key as String + hmsSessionStore?.get(key,object:HMSSessionMetadataListener{ + override fun onError(error: HMSException) { + result.success(HMSResultExtension.toDictionary(false,HMSExceptionExtension.toDictionary(error))) + } + + override fun onSuccess(sessionMetadata: String?) { + result.success(HMSResultExtension.toDictionary(true,sessionMetadata)) + } + }) + } + } + + private fun setSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ + val key = call.argument("key") ?: run { + HMSErrorLogger.returnArgumentsError("key is null") + } + + val data = call.argument("data") + + key?.let { key as String + hmsSessionStore?.set(data,key,HMSCommonAction.getActionListener(result)) + } + } + + } +} \ No newline at end of file diff --git a/example/assets/icons/spotlight.svg b/example/assets/icons/spotlight.svg new file mode 100644 index 000000000..721b68792 --- /dev/null +++ b/example/assets/icons/spotlight.svg @@ -0,0 +1,3 @@ + + + diff --git a/example/lib/common/app_dialogs/local_peer_tile_dialog.dart b/example/lib/common/app_dialogs/local_peer_tile_dialog.dart index 7c166c077..f49011b63 100644 --- a/example/lib/common/app_dialogs/local_peer_tile_dialog.dart +++ b/example/lib/common/app_dialogs/local_peer_tile_dialog.dart @@ -17,6 +17,8 @@ class LocalPeerTileDialog extends StatefulWidget { final Function()? captureSnapshot; final Function()? localImageCapture; final Function()? toggleFlash; + final Function() setOnSpotlight; + final bool isSpotlightedPeer; const LocalPeerTileDialog( {required this.isAudioMode, this.isVideoOn = false, @@ -28,7 +30,9 @@ class LocalPeerTileDialog extends StatefulWidget { this.captureSnapshot, this.isCaptureSnapshot, this.localImageCapture, - this.toggleFlash}); + this.toggleFlash, + required this.setOnSpotlight, + this.isSpotlightedPeer = false}); @override _LocalPeerTileDialogState createState() => _LocalPeerTileDialogState(); @@ -187,6 +191,32 @@ class _LocalPeerTileDialogState extends State { ), ), ), + GestureDetector( + onTap: () { + Navigator.pop(context); + widget.setOnSpotlight(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Row( + children: [ + SvgPicture.asset( + "assets/icons/spotlight.svg", + color: iconColor, + ), + SizedBox( + width: 16, + ), + Text( + widget.isSpotlightedPeer + ? "Remove From Spotlight" + : "Spotlight Tile", + style: GoogleFonts.inter(color: iconColor), + ) + ], + ), + ), + ), ], ), ), diff --git a/example/lib/common/app_dialogs/remote_peer_tile_dialog.dart b/example/lib/common/app_dialogs/remote_peer_tile_dialog.dart index 031999c44..e6b92744a 100644 --- a/example/lib/common/app_dialogs/remote_peer_tile_dialog.dart +++ b/example/lib/common/app_dialogs/remote_peer_tile_dialog.dart @@ -15,6 +15,7 @@ class RemotePeerTileDialog extends StatefulWidget { final bool simulcast; final bool pinTile; final bool? isCaptureSnapshot; + final bool isSpotlightedPeer; final Function(bool, bool) changeVideoTrack; final Function(bool, bool) changeAudioTrack; final Function() removePeer; @@ -22,6 +23,7 @@ class RemotePeerTileDialog extends StatefulWidget { final Function() changeLayer; final Function() changePinTileStatus; final Function()? captureSnapshot; + final Function() setOnSpotlight; const RemotePeerTileDialog( {required this.isVideoMuted, required this.isAudioMuted, @@ -39,7 +41,9 @@ class RemotePeerTileDialog extends StatefulWidget { required this.pinTile, required this.changePinTileStatus, this.isCaptureSnapshot, - this.captureSnapshot}); + this.captureSnapshot, + required this.setOnSpotlight, + this.isSpotlightedPeer = false}); @override _RemotePeerTileDialogState createState() => _RemotePeerTileDialogState(); @@ -243,6 +247,32 @@ class _RemotePeerTileDialogState extends State { ), ), ), + GestureDetector( + onTap: () { + Navigator.pop(context); + widget.setOnSpotlight(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Row( + children: [ + SvgPicture.asset( + "assets/icons/spotlight.svg", + color: iconColor, + ), + SizedBox( + width: 16, + ), + Text( + widget.isSpotlightedPeer + ? "Remove From Spotlight" + : "Spotlight Tile", + style: GoogleFonts.inter(color: iconColor), + ) + ], + ), + ), + ), ], ), ), diff --git a/example/lib/common/bottom_sheets/chat_bottom_sheet.dart b/example/lib/common/bottom_sheets/chat_bottom_sheet.dart index 012ee1787..e0880f64d 100644 --- a/example/lib/common/bottom_sheets/chat_bottom_sheet.dart +++ b/example/lib/common/bottom_sheets/chat_bottom_sheet.dart @@ -9,6 +9,7 @@ import 'package:hmssdk_flutter_example/common/util/app_color.dart'; import 'package:hmssdk_flutter_example/common/util/utility_function.dart'; import 'package:hmssdk_flutter_example/common/widgets/hms_dropdown.dart'; import 'package:hmssdk_flutter_example/common/widgets/message_container.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:tuple/tuple.dart'; @@ -366,9 +367,11 @@ class _ChatBottomSheetState extends State { ), GestureDetector( onTap: () { - context - .read() - .setSessionMetadata(null); + context.read().setSessionMetadata( + key: SessionStoreKeyValues + .getNameFromMethod(SessionStoreKey + .PINNED_MESSAGE_SESSION_KEY), + metadata: null); }, child: SvgPicture.asset( "assets/icons/close.svg")) diff --git a/example/lib/common/peer_widgets/more_option.dart b/example/lib/common/peer_widgets/more_option.dart index bbd45956f..d410c0164 100644 --- a/example/lib/common/peer_widgets/more_option.dart +++ b/example/lib/common/peer_widgets/more_option.dart @@ -11,6 +11,7 @@ import 'package:hmssdk_flutter_example/common/app_dialogs/remote_peer_tile_dialo import 'package:hmssdk_flutter_example/common/util/app_color.dart'; import 'package:hmssdk_flutter_example/common/util/utility_components.dart'; import 'package:hmssdk_flutter_example/common/util/utility_function.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:hmssdk_flutter_example/meeting/meeting_store.dart'; import 'package:hmssdk_flutter_example/model/peer_track_node.dart'; import 'package:image_gallery_saver/image_gallery_saver.dart'; @@ -58,6 +59,26 @@ class MoreOption extends StatelessWidget { _meetingStore.changeTrackState( peerTrackNode.audioTrack!, mute); }, + isSpotlightedPeer: + context.read().spotLightPeer?.uid == + peerTrackNode.uid, + setOnSpotlight: () { + if (context.read().spotLightPeer?.uid == + peerTrackNode.uid) { + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: null); + return; + } + String? metadata = (peerTrackNode.track == null) + ? peerTrackNode.audioTrack?.trackId + : peerTrackNode.track?.trackId; + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: metadata); + }, removePeer: () async { Navigator.pop(context); var peer = await _meetingStore.getPeer( @@ -245,6 +266,26 @@ class MoreOption extends StatelessWidget { toggleFlash: () { context.read().toggleFlash(); }, + isSpotlightedPeer: + context.read().spotLightPeer?.uid == + peerTrackNode.uid, + setOnSpotlight: () { + if (context.read().spotLightPeer?.uid == + peerTrackNode.uid) { + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: null); + return; + } + String? metadata = (peerTrackNode.track == null) + ? peerTrackNode.audioTrack?.trackId + : peerTrackNode.track?.trackId; + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: metadata); + }, changeRole: () { Navigator.pop(context); showDialog( diff --git a/example/lib/common/widgets/audio_tile.dart b/example/lib/common/widgets/audio_tile.dart index d1c734319..9291b1da2 100644 --- a/example/lib/common/widgets/audio_tile.dart +++ b/example/lib/common/widgets/audio_tile.dart @@ -12,6 +12,7 @@ import 'package:hmssdk_flutter_example/common/peer_widgets/rtc_stats_view.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/tile_border.dart'; import 'package:hmssdk_flutter_example/common/util/app_color.dart'; import 'package:hmssdk_flutter_example/common/util/utility_components.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:provider/provider.dart'; // Project imports @@ -63,6 +64,26 @@ class AudioTile extends StatelessWidget { _meetingStore.changeTrackState( peerTrackNode.track!, mute); }, + isSpotlightedPeer: + context.read().spotLightPeer?.uid == + peerTrackNode.uid, + setOnSpotlight: () { + if (context.read().spotLightPeer?.uid == + peerTrackNode.uid) { + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: null); + return; + } + String? metadata = (peerTrackNode.track == null) + ? peerTrackNode.audioTrack?.trackId + : peerTrackNode.track?.trackId; + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: metadata); + }, changeAudioTrack: (mute, isAudioTrack) { Navigator.pop(context); _meetingStore.changeTrackState( @@ -143,6 +164,26 @@ class AudioTile extends StatelessWidget { }, )); }, + isSpotlightedPeer: + context.read().spotLightPeer?.uid == + peerTrackNode.uid, + setOnSpotlight: () { + if (context.read().spotLightPeer?.uid == + peerTrackNode.uid) { + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: null); + } + String? metadata = (peerTrackNode.track == null) + ? peerTrackNode.audioTrack?.trackId + : peerTrackNode.track?.trackId; + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: metadata); + return; + }, roles: changeRolePermission, changeName: () async { String name = await UtilityComponents.showInputDialog( diff --git a/example/lib/common/widgets/message_container.dart b/example/lib/common/widgets/message_container.dart index c7e31b9f0..a529d05c9 100644 --- a/example/lib/common/widgets/message_container.dart +++ b/example/lib/common/widgets/message_container.dart @@ -5,6 +5,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hmssdk_flutter_example/common/widgets/subtitle_text.dart'; import 'package:hmssdk_flutter_example/common/widgets/title_text.dart'; import 'package:hmssdk_flutter_example/common/util/app_color.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../meeting/meeting_store.dart'; @@ -187,7 +188,10 @@ class MessageContainer extends StatelessWidget { child: Text('Pin Message'), onTap: () => context .read() - .setSessionMetadata(senderName! + ": " + message), + .setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.PINNED_MESSAGE_SESSION_KEY), + metadata: senderName! + ": " + message), ); }); }, diff --git a/example/lib/enum/session_store_key.dart b/example/lib/enum/session_store_key.dart new file mode 100644 index 000000000..5f0c0e841 --- /dev/null +++ b/example/lib/enum/session_store_key.dart @@ -0,0 +1,35 @@ +enum SessionStoreKey { PINNED_MESSAGE_SESSION_KEY, SPOTLIGHT, unknown } + +extension SessionStoreKeyValues on SessionStoreKey { + static String getNameFromMethod(SessionStoreKey method) { + switch (method) { + case SessionStoreKey.PINNED_MESSAGE_SESSION_KEY: + return "pinnedMessage"; + case SessionStoreKey.SPOTLIGHT: + return "spotlight"; + default: + return ""; + } + } + + static SessionStoreKey getMethodFromName(String key) { + switch (key) { + case "pinnedMessage": + return SessionStoreKey.PINNED_MESSAGE_SESSION_KEY; + case "spotlight": + return SessionStoreKey.SPOTLIGHT; + default: + return SessionStoreKey.unknown; + } + } + + static List getSessionStoreKeys() { + List _keys = []; + SessionStoreKey.values.forEach((key) { + if (key != SessionStoreKey.unknown) { + _keys.add(getNameFromMethod(key)); + } + }); + return _keys; + } +} diff --git a/example/lib/meeting/meeting_page.dart b/example/lib/meeting/meeting_page.dart index 6495dc091..6d8b52858 100644 --- a/example/lib/meeting/meeting_page.dart +++ b/example/lib/meeting/meeting_page.dart @@ -11,6 +11,7 @@ import 'package:hmssdk_flutter_example/common/widgets/hms_embedded_button.dart'; import 'package:hmssdk_flutter_example/common/widgets/stream_timer.dart'; import 'package:hmssdk_flutter_example/common/widgets/subtitle_text.dart'; import 'package:hmssdk_flutter_example/common/widgets/title_text.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:hmssdk_flutter_example/meeting_modes/full_screen_mode.dart'; import 'package:hmssdk_flutter_example/meeting_modes/audio_mode.dart'; import 'package:hmssdk_flutter_example/meeting_modes/hero_mode.dart'; @@ -709,7 +710,10 @@ class _MeetingPageState extends State { context .read< MeetingStore>() - .getSessionMetadata(), + .getSessionMetadata( + SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey + .PINNED_MESSAGE_SESSION_KEY)), context .read< MeetingStore>() diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index e54ccb7f7..ce61f2a7e 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -10,6 +10,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_foreground_task/flutter_foreground_task.dart'; import 'package:hmssdk_flutter_example/common/util/log_writer.dart'; import 'package:hmssdk_flutter_example/app_secrets.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:hmssdk_flutter_example/service/constant.dart'; import 'package:hmssdk_flutter_example/common/widgets/title_text.dart'; import 'package:hmssdk_flutter_example/common/util/app_color.dart'; @@ -39,7 +40,8 @@ class MeetingStore extends ChangeNotifier HMSUpdateListener, HMSActionResultListener, HMSStatsListener, - HMSLogListener { + HMSLogListener, + HMSKeyChangeListener { late HMSSDKInteractor _hmsSDKInteractor; MeetingStore({required HMSSDKInteractor hmsSDKInteractor}) { @@ -188,6 +190,9 @@ class MeetingStore extends ChangeNotifier bool isFlashOn = false; + HMSSessionStore? _hmsSessionStore; + + PeerTrackNode? spotLightPeer; Future join(String userName, String roomUrl, {HMSConfig? roomConfig}) async { //If roomConfig is null then only we call the methods to get the authToken @@ -709,7 +714,6 @@ class MeetingStore extends ChangeNotifier log("onMessage-> sender: ${message.sender} message: ${message.message} time: ${message.time}, type: ${message.type}"); switch (message.type) { case "metadata": - getSessionMetadata(); break; default: addMessage(message); @@ -1001,6 +1005,8 @@ class MeetingStore extends ChangeNotifier } _hmsSDKInteractor.removeHMSLogger(); _hmsSDKInteractor.destroy(); + _hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeListener: this); + _hmsSessionStore = null; peerTracks.clear(); isRoomEnded = true; screenShareCount = 0; @@ -1303,6 +1309,53 @@ class MeetingStore extends ChangeNotifier } } + @override + void onSessionStoreAvailable({HMSSessionStore? hmsSessionStore}) { + _hmsSessionStore = hmsSessionStore; + _hmsSessionStore?.addKeyChangeListener( + keys: SessionStoreKeyValues.getSessionStoreKeys(), + hmsKeyChangeListener: this, + hmsActionResultListener: this); + } + + @override + void onKeyChanged({required String key, required String? value}) { + log("onKeyChanged --> key: $key value: $value"); + SessionStoreKey keyType = SessionStoreKeyValues.getMethodFromName(key); + switch (keyType) { + case SessionStoreKey.PINNED_MESSAGE_SESSION_KEY: + sessionMetadata = value; + break; + case SessionStoreKey.SPOTLIGHT: + setPeerToSpotlight(value); + break; + case SessionStoreKey.unknown: + break; + } + notifyListeners(); + } + + void setPeerToSpotlight(String? value) { + int currentSpotlightPeerIndex = + peerTracks.indexWhere((node) => node.uid == spotLightPeer?.uid); + if (currentSpotlightPeerIndex != -1) { + peerTracks[currentSpotlightPeerIndex].pinTile = false; + spotLightPeer = null; + } + if (value != null) { + int index = + peerTracks.indexWhere((node) => node.track?.trackId == (value)); + if (index != -1) { + Utilities.showToast("${peerTracks[index].peer.name} is in spotlight"); + spotLightPeer = peerTracks[index]; + changePinTileStatus(peerTracks[index]); + } else { + Utilities.showToast("Failed to set spotlight for the peer"); + } + } + notifyListeners(); + } + void setMode(MeetingMode meetingMode) { //Turning the videos on if the previously mode was audio if (this.meetingMode == MeetingMode.Audio && @@ -1430,13 +1483,22 @@ class MeetingStore extends ChangeNotifier audioPlayerVolume = volume; } - void setSessionMetadata(String? metadata) { - _hmsSDKInteractor.setSessionMetadata( - metadata: metadata, hmsActionResultListener: this); + void setSessionMetadata({required String key, String? metadata}) { + _hmsSessionStore?.setSessionMetadataForKey( + key: key, data: metadata, hmsActionResultListener: this); } - void getSessionMetadata() async { - sessionMetadata = await _hmsSDKInteractor.getSessionMetadata(); + void getSessionMetadata(String key) async { + dynamic result = await _hmsSessionStore?.getSessionMetadataForKey(key: key); + if (result is HMSException) { + Utilities.showToast( + "Error Occured: code: ${result.code?.errorCode}, description: ${result.description}, message: ${result.message}", + time: 5); + return; + } + if (result != null) { + sessionMetadata = result as String; + } notifyListeners(); } @@ -1733,6 +1795,10 @@ class MeetingStore extends ChangeNotifier case HMSActionResultListenerMethod.changeRoleOfPeersWithRoles: Utilities.showToast("Change Role successful"); break; + case HMSActionResultListenerMethod.setSessionMetadataForKey: + break; + case HMSActionResultListenerMethod.addKeyChangeListener: + break; } } @@ -1809,6 +1875,12 @@ class MeetingStore extends ChangeNotifier case HMSActionResultListenerMethod.changeRoleOfPeersWithRoles: Utilities.showToast("Change role failed"); break; + case HMSActionResultListenerMethod.setSessionMetadataForKey: + Utilities.showToast("Set session metadata failed"); + break; + case HMSActionResultListenerMethod.addKeyChangeListener: + Utilities.showToast("Add key change listener failed"); + break; } notifyListeners(); } diff --git a/lib/hmssdk_flutter.dart b/lib/hmssdk_flutter.dart index 3ac1cb5db..ca2a4c96a 100644 --- a/lib/hmssdk_flutter.dart +++ b/lib/hmssdk_flutter.dart @@ -89,3 +89,5 @@ export 'src/model/hms_ios_pip_controller.dart'; export 'src/model/hms_ios_screenshare_config.dart'; export 'src/model/hms_log_list.dart'; export 'src/model/hms_camera_controls.dart'; +export 'src/model/hms_session_store.dart'; +export 'src/model/hms_key_change_listener.dart'; diff --git a/lib/src/common/platform_methods.dart b/lib/src/common/platform_methods.dart index c47f3bd9e..c505e8258 100644 --- a/lib/src/common/platform_methods.dart +++ b/lib/src/common/platform_methods.dart @@ -169,7 +169,11 @@ enum PlatformMethod { getAuthTokenByRoomCode, captureImageAtMaxSupportedResolution, isFlashSupported, - toggleFlash + toggleFlash, + getSessionMetadataForKey, + setSessionMetadataForKey, + addKeyChangeListener, + removeKeyChangeListener } extension PlatformMethodValues on PlatformMethod { @@ -409,6 +413,14 @@ extension PlatformMethodValues on PlatformMethod { return "is_flash_supported"; case PlatformMethod.toggleFlash: return "toggle_flash"; + case PlatformMethod.getSessionMetadataForKey: + return "get_session_metadata_for_key"; + case PlatformMethod.setSessionMetadataForKey: + return "set_session_metadata_for_key"; + case PlatformMethod.addKeyChangeListener: + return "add_key_change_listener"; + case PlatformMethod.removeKeyChangeListener: + return "remove_key_change_listener"; default: return 'unknown'; } @@ -650,6 +662,14 @@ extension PlatformMethodValues on PlatformMethod { return PlatformMethod.isFlashSupported; case "toggle_flash": return PlatformMethod.toggleFlash; + case "get_session_metadata_for_key": + return PlatformMethod.getSessionMetadataForKey; + case "set_session_metadata_for_key": + return PlatformMethod.setSessionMetadataForKey; + case "add_key_change_listener": + return PlatformMethod.addKeyChangeListener; + case "remove_key_change_listener": + return PlatformMethod.removeKeyChangeListener; default: return PlatformMethod.unknown; } diff --git a/lib/src/enum/hms_action_result_listener_method.dart b/lib/src/enum/hms_action_result_listener_method.dart index ea103ab95..455bc2c7f 100644 --- a/lib/src/enum/hms_action_result_listener_method.dart +++ b/lib/src/enum/hms_action_result_listener_method.dart @@ -21,8 +21,11 @@ enum HMSActionResultListenerMethod { stopScreenShare, startAudioShare, stopAudioShare, + @Deprecated('use [setSessionMetadataForKey]') setSessionMetadata, switchCamera, changeRoleOfPeersWithRoles, + setSessionMetadataForKey, + addKeyChangeListener, unknown } diff --git a/lib/src/enum/hms_key_change_listener_method.dart b/lib/src/enum/hms_key_change_listener_method.dart new file mode 100644 index 000000000..0dadf6716 --- /dev/null +++ b/lib/src/enum/hms_key_change_listener_method.dart @@ -0,0 +1,12 @@ +enum HMSKeyChangeListenerMethod { onKeyChanged, unknown } + +extension HMSKeyChangeListenerMethodValues on HMSKeyChangeListenerMethod { + static HMSKeyChangeListenerMethod getMethodFromName(String name) { + switch (name) { + case "on_key_changed": + return HMSKeyChangeListenerMethod.onKeyChanged; + default: + return HMSKeyChangeListenerMethod.unknown; + } + } +} diff --git a/lib/src/enum/hms_update_listener_method.dart b/lib/src/enum/hms_update_listener_method.dart index c70ddd0bd..1cac55dfb 100644 --- a/lib/src/enum/hms_update_listener_method.dart +++ b/lib/src/enum/hms_update_listener_method.dart @@ -12,6 +12,7 @@ enum HMSUpdateListenerMethod { onChangeTrackStateRequest, onRemovedFromRoom, onAudioDeviceChanged, + onSessionStoreAvailable, unknown } @@ -44,6 +45,8 @@ extension HMSUpdateListenerMethodValues on HMSUpdateListenerMethod { return HMSUpdateListenerMethod.onRemovedFromRoom; case 'on_audio_device_changed': return HMSUpdateListenerMethod.onAudioDeviceChanged; + case 'on_session_store_available': + return HMSUpdateListenerMethod.onSessionStoreAvailable; default: return HMSUpdateListenerMethod.unknown; } diff --git a/lib/src/hmssdk.dart b/lib/src/hmssdk.dart index 13bae2e33..1d09cf9d1 100644 --- a/lib/src/hmssdk.dart +++ b/lib/src/hmssdk.dart @@ -1235,6 +1235,7 @@ class HMSSDK { /// **hmsActionResultListener** - [hmsActionResultListener] is a callback instance on which [HMSActionResultListener.onSuccess] and [HMSActionResultListener.onException] will be called. /// ///Refer [session metadata guide here](https://www.100ms.live/docs/flutter/v2/features/session-metadata) + @Deprecated('Use [setSessionMetadataForKey]') Future setSessionMetadata( {required String? metadata, HMSActionResultListener? hmsActionResultListener}) async { @@ -1260,6 +1261,7 @@ class HMSSDK { ///Method to fetch the latest metadata from the server and returns it /// ///Refer [session metadata guide here](https://www.100ms.live/docs/flutter/v2/features/session-metadata) + @Deprecated('Use [getSessionMetadataForKey]') Future getSessionMetadata() async { var result = await PlatformService.invokeMethod(PlatformMethod.getSessionMetadata); diff --git a/lib/src/model/hms_key_change_listener.dart b/lib/src/model/hms_key_change_listener.dart new file mode 100644 index 000000000..58b36d2a1 --- /dev/null +++ b/lib/src/model/hms_key_change_listener.dart @@ -0,0 +1,3 @@ +abstract class HMSKeyChangeListener { + void onKeyChanged({required String key, required String? value}) {} +} diff --git a/lib/src/model/hms_session_store.dart b/lib/src/model/hms_session_store.dart new file mode 100644 index 000000000..cdae2fead --- /dev/null +++ b/lib/src/model/hms_session_store.dart @@ -0,0 +1,67 @@ +import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter/src/service/platform_service.dart'; + +class HMSSessionStore { + Future addKeyChangeListener( + {required List keys, + required HMSKeyChangeListener hmsKeyChangeListener, + HMSActionResultListener? hmsActionResultListener}) async { + dynamic result = await PlatformService.invokeMethod( + PlatformMethod.addKeyChangeListener, + arguments: { + "keys": keys, + }); + if (hmsActionResultListener != null) { + if (result == null) { + PlatformService.addKeyChangeListener(hmsKeyChangeListener); + hmsActionResultListener.onSuccess( + methodType: HMSActionResultListenerMethod.addKeyChangeListener); + } else { + hmsActionResultListener.onException( + methodType: HMSActionResultListenerMethod.addKeyChangeListener, + hmsException: HMSException.fromMap(result["data"])); + } + } + } + + Future removeKeyChangeListener( + {required HMSKeyChangeListener hmsKeyChangeListener}) async { + await PlatformService.invokeMethod(PlatformMethod.removeKeyChangeListener); + PlatformService.removeKeyChangeListener(hmsKeyChangeListener); + } + + Future getSessionMetadataForKey({required String key}) async { + dynamic result = await PlatformService.invokeMethod( + PlatformMethod.getSessionMetadataForKey, + arguments: {"key": key}); + if (result["success"]) { + return result["data"]; + } else { + return HMSException.fromMap(result["data"]["error"]); + } + } + + Future setSessionMetadataForKey( + {required String key, + required String? data, + HMSActionResultListener? hmsActionResultListener}) async { + Map arguments = { + "key": key, + "data": data, + }; + dynamic result = await PlatformService.invokeMethod( + PlatformMethod.setSessionMetadataForKey, + arguments: arguments); + if (hmsActionResultListener != null) { + if (result == null) { + hmsActionResultListener.onSuccess( + methodType: HMSActionResultListenerMethod.setSessionMetadataForKey, + arguments: arguments); + } else { + hmsActionResultListener.onException( + methodType: HMSActionResultListenerMethod.setSessionMetadataForKey, + hmsException: HMSException.fromMap(result["error"])); + } + } + } +} diff --git a/lib/src/model/hms_update_listener.dart b/lib/src/model/hms_update_listener.dart index d9d6a3ca1..09380a69e 100644 --- a/lib/src/model/hms_update_listener.dart +++ b/lib/src/model/hms_update_listener.dart @@ -99,4 +99,7 @@ abstract class HMSUpdateListener { void onAudioDeviceChanged( {HMSAudioDevice? currentAudioDevice, List? availableAudioDevice}); + + /// + void onSessionStoreAvailable({HMSSessionStore? hmsSessionStore}); } diff --git a/lib/src/model/platform_method_response.dart b/lib/src/model/platform_method_response.dart index 289fde41f..ad3f2b72d 100644 --- a/lib/src/model/platform_method_response.dart +++ b/lib/src/model/platform_method_response.dart @@ -1,5 +1,6 @@ // Project imports: import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter/src/enum/hms_key_change_listener_method.dart'; import 'package:hmssdk_flutter/src/enum/hms_logs_update_listener.dart'; ///PlatformMethodResponse contains all the responses sent back from the platform @@ -59,3 +60,11 @@ class HMSStatsListenerMethodResponse { HMSStatsListenerMethodResponse( {required this.method, required this.data, required this.response}); } + +class HMSKeyChangeListenerMethodResponse { + final HMSKeyChangeListenerMethod method; + final Map data; + + HMSKeyChangeListenerMethodResponse( + {required this.method, required this.data}); +} diff --git a/lib/src/service/platform_service.dart b/lib/src/service/platform_service.dart index fabc23c1e..1ebf91542 100644 --- a/lib/src/service/platform_service.dart +++ b/lib/src/service/platform_service.dart @@ -13,6 +13,7 @@ import 'dart:async'; import 'package:flutter/services.dart'; // Project imports: import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter/src/enum/hms_key_change_listener_method.dart'; import 'package:hmssdk_flutter/src/enum/hms_logs_update_listener.dart'; class PlatformService { @@ -34,6 +35,10 @@ class PlatformService { static const EventChannel _rtcStatsChannel = const EventChannel("rtc_event_channel"); + ///used to get stream of session store changes + static const EventChannel _sessionStoreChannel = + const EventChannel("session_event_channel"); + ///add meeting listeners. static List updateListeners = []; @@ -42,6 +47,8 @@ class PlatformService { ///add preview listeners. static List previewListeners = []; + static List keyChangeListeners = []; + ///List for event Listener static List statsListeners = []; static bool isStartedListening = false; @@ -92,6 +99,15 @@ class PlatformService { logsListeners.remove(hmsLogListener); } + static void addKeyChangeListener(HMSKeyChangeListener hmsKeyChangeListener) { + keyChangeListeners.add(hmsKeyChangeListener); + } + + static void removeKeyChangeListener( + HMSKeyChangeListener hmsKeyChangeListener) { + keyChangeListeners.remove(hmsKeyChangeListener); + } + ///used to invoke different methods at platform side and returns something but not neccessarily static Future invokeMethod(PlatformMethod method, {Map? arguments}) async { @@ -230,6 +246,10 @@ class PlatformService { }); break; + case HMSUpdateListenerMethod.onSessionStoreAvailable: + notifyUpdateListeners(method, {}); + break; + case HMSUpdateListenerMethod.unknown: break; } @@ -421,6 +441,24 @@ class PlatformService { break; } }); + + _sessionStoreChannel + .receiveBroadcastStream({'name': 'session_store'}).map((event) { + HMSKeyChangeListenerMethod method = + HMSKeyChangeListenerMethodValues.getMethodFromName( + event['event_name']); + Map data = event['data']; + return HMSKeyChangeListenerMethodResponse(method: method, data: data); + }).listen((event) { + HMSKeyChangeListenerMethod method = event.method; + switch (method) { + case HMSKeyChangeListenerMethod.onKeyChanged: + notifySessionStoreListeners(method, event.data); + break; + case HMSKeyChangeListenerMethod.unknown: + break; + } + }); } static void notifyLogsUpdateListeners( @@ -571,8 +609,25 @@ class PlatformService { availableAudioDevice: arguments["available_audio_device"])); break; + case HMSUpdateListenerMethod.onSessionStoreAvailable: + updateListeners.forEach((e) => + e.onSessionStoreAvailable(hmsSessionStore: HMSSessionStore())); + break; + case HMSUpdateListenerMethod.unknown: break; } } + + static void notifySessionStoreListeners( + HMSKeyChangeListenerMethod method, Map arguments) { + switch (method) { + case HMSKeyChangeListenerMethod.onKeyChanged: + keyChangeListeners.forEach((e) => + e.onKeyChanged(key: arguments["key"], value: arguments["value"])); + break; + case HMSKeyChangeListenerMethod.unknown: + break; + } + } } From 922f9f6a1c4e4fe2b4e2ca922517b9fbd70b05eb Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:11:12 +0530 Subject: [PATCH 07/88] Removed unnecessary code (#1277) --- example/lib/hls_viewer/hls_viewer_page.dart | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/example/lib/hls_viewer/hls_viewer_page.dart b/example/lib/hls_viewer/hls_viewer_page.dart index b7dd318cd..83116c2be 100644 --- a/example/lib/hls_viewer/hls_viewer_page.dart +++ b/example/lib/hls_viewer/hls_viewer_page.dart @@ -93,18 +93,6 @@ class _HLSViewerPageState extends State { Navigator.of(context).popUntil((route) => route.isFirst); }); } - if (!(context.read().hasHlsStarted || - widget.streamUrl != null)) { - return Scaffold( - body: Center( - child: Padding( - padding: const EdgeInsets.only(bottom: 8.0), - child: TitleText( - text: "Waiting for HLS to start...", - textColor: themeDefaultColor)), - ), - ); - } return Scaffold( resizeToAvoidBottomInset: false, body: SafeArea( From 1f3aa0cee6e69dfa2b2b0277f297be4e565270c8 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:36:24 +0530 Subject: [PATCH 08/88] Updated icons (#1278) --- example/assets/icons/local_capture.svg | 5 +++++ example/assets/icons/snapshot.svg | 6 ++++++ .../lib/common/app_dialogs/local_peer_tile_dialog.dart | 10 ++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 example/assets/icons/local_capture.svg create mode 100644 example/assets/icons/snapshot.svg diff --git a/example/assets/icons/local_capture.svg b/example/assets/icons/local_capture.svg new file mode 100644 index 000000000..a2aade8cf --- /dev/null +++ b/example/assets/icons/local_capture.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/example/assets/icons/snapshot.svg b/example/assets/icons/snapshot.svg new file mode 100644 index 000000000..fe7d2a230 --- /dev/null +++ b/example/assets/icons/snapshot.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/example/lib/common/app_dialogs/local_peer_tile_dialog.dart b/example/lib/common/app_dialogs/local_peer_tile_dialog.dart index 7c166c077..1efe97fe2 100644 --- a/example/lib/common/app_dialogs/local_peer_tile_dialog.dart +++ b/example/lib/common/app_dialogs/local_peer_tile_dialog.dart @@ -154,7 +154,10 @@ class _LocalPeerTileDialogState extends State { padding: const EdgeInsets.only(bottom: 20.0), child: Row( children: [ - Icon(Icons.camera_alt), + SvgPicture.asset( + "assets/icons/snapshot.svg", + color: iconColor, + ), SizedBox( width: 16, ), @@ -175,7 +178,10 @@ class _LocalPeerTileDialogState extends State { padding: const EdgeInsets.only(bottom: 20.0), child: Row( children: [ - Icon(Icons.image_outlined), + SvgPicture.asset( + "assets/icons/local_capture.svg", + color: iconColor, + ), SizedBox( width: 16, ), From bbb2997374a4a24a3bc0a845a71c189d8f1d9bd9 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 25 Apr 2023 22:23:31 +0530 Subject: [PATCH 09/88] updated pods --- example/ios/Podfile.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 4e60dc70f..2cfb7b58b 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -69,7 +69,7 @@ PODS: - Firebase/Performance (= 10.7.0) - firebase_core - Flutter - - FirebaseABTesting (10.8.0): + - FirebaseABTesting (10.9.0): - FirebaseCore (~> 10.0) - FirebaseAnalytics (10.7.0): - FirebaseAnalytics/AdIdSupport (= 10.7.0) @@ -93,9 +93,9 @@ PODS: - FirebaseCoreInternal (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/Logger (~> 7.8) - - FirebaseCoreExtension (10.8.0): + - FirebaseCoreExtension (10.9.0): - FirebaseCore (~> 10.0) - - FirebaseCoreInternal (10.8.0): + - FirebaseCoreInternal (10.9.0): - "GoogleUtilities/NSData+zlib (~> 7.8)" - FirebaseCrashlytics (10.7.0): - FirebaseCore (~> 10.5) @@ -107,7 +107,7 @@ PODS: - PromisesObjC (~> 2.1) - FirebaseDynamicLinks (10.7.0): - FirebaseCore (~> 10.0) - - FirebaseInstallations (10.8.0): + - FirebaseInstallations (10.9.0): - FirebaseCore (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) @@ -122,13 +122,13 @@ PODS: - GoogleUtilities/ISASwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - nanopb (< 2.30910.0, >= 2.30908.0) - - FirebaseRemoteConfig (10.8.0): + - FirebaseRemoteConfig (10.9.0): - FirebaseABTesting (~> 10.0) - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - - FirebaseSessions (10.8.0): + - FirebaseSessions (10.9.0): - FirebaseCore (~> 10.5) - FirebaseCoreExtension (~> 10.0) - FirebaseInstallations (~> 10.0) @@ -359,17 +359,17 @@ SPEC CHECKSUMS: firebase_crashlytics: 6c15c2f507d82746dd62214964acf56146eab53f firebase_dynamic_links: 464b974eeb7a5b4b7c970062c49a3e39ff924f47 firebase_performance: 7dd98298ea2f19f480efd59ccbfcad3972ced984 - FirebaseABTesting: 0c7038e4dce273821e417bdc2b0373ee0e0e8df3 + FirebaseABTesting: 005b70969e2817e2a1e631e8dba29134a04c0622 FirebaseAnalytics: f8133442ee6f8512e28ff19e62ce15398bfaeace FirebaseCore: e317665b9d744727a97e623edbbed009320afdd7 - FirebaseCoreExtension: d815fd6fec8bb3a0940bc02dd5e3e641ea7229d8 - FirebaseCoreInternal: fa2899eb1f340054858d289e5a0fb935a0a74e52 + FirebaseCoreExtension: d3e9bba2930a8033042112397cd9f006a1bb203d + FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e FirebaseCrashlytics: 35fdd1a433b31e28adcf5c8933f4c526691a1e0b FirebaseDynamicLinks: 16a8fae3697fba66fed7a1d646fe59f30d42aa31 - FirebaseInstallations: b2a05a3fe707df764345d68685534d07d0664af3 + FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0 FirebasePerformance: 8281bbaf08aad194001018b932115b7d58a6f00b - FirebaseRemoteConfig: ffd8c40611809c92526783da146be93a15cc3f00 - FirebaseSessions: d4e22e13e5523e58fcd625671c59bed7ccee8736 + FirebaseRemoteConfig: 5ea5834e8c518f377bf1af2d97ebd611914ebf2d + FirebaseSessions: 44a6782502eb279a214d4adca20891353278760c Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_foreground_task: 21ef182ab0a29a3005cc72cd70e5f45cb7f7f817 GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 From d6bf597a092bfbcf05656d9a496339ff95c2c275 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 25 Apr 2023 22:30:05 +0530 Subject: [PATCH 10/88] corrected pragma markings --- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 0bdbc470c..db28d6fd1 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -138,6 +138,9 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene case "switch_audio", "is_audio_mute", "mute_room_audio_locally", "un_mute_room_audio_locally", "set_volume", "toggle_mic_mute_state": HMSAudioAction.audioActions(call, result, hmsSDK) + + case "set_playback_allowed_for_track": + setPlaybackAllowedForTrack(call, result) // MARK: - Video Helpers @@ -182,24 +185,35 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene case "start_screen_share", "stop_screen_share", "is_screen_share_active": screenShareActions(call, result) - + + // MARK: - Track Settings + case "get_track_settings": trackSettingsAction(call, result) break + + // MARK: - Local Audio Share + case "play_audio_share", "stop_audio_share", "pause_audio_share", "resume_audio_share", "set_audio_share_volume", "audio_share_playing", "audio_share_current_time", "audio_share_duration": audioShareAction(call, result) + + // MARK: - Switch Audio Output + case "switch_audio_output", "get_audio_devices_list": HMSAudioDeviceAction.audioActions(call, result, hmsSDK) + + // MARK: - Session Metadata case "get_session_metadata", "set_session_metadata": sessionMetadataAction(call, result) - case "set_playback_allowed_for_track": - setPlaybackAllowedForTrack(call, result) + // MARK: - Simulcast case "set_simulcast_layer", "get_layer", "get_layer_definition": HMSRemoteVideoTrackExtension.remoteVideoTrackActions(call, result, hmsSDK!) + // MARK: - PIP Mode + case "setup_pip", "start_pip", "stop_pip", "is_pip_available", "is_pip_active", "change_track_pip", "change_text_pip", "destroy_pip": guard #available(iOS 15.0, *) else { print(#function, HMSErrorExtension.getError("iOS 15 or above is required")) @@ -207,9 +221,13 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene return } HMSPIPAction.pipAction(call, result, hmsSDK, self) + // MARK: - Capture HMSVideoView Snapshot + case "capture_snapshot": captureSnapshot(call, result) + // MARK: - Advanced Camera Controls + case "capture_image_at_max_supported_resolution", "is_tap_to_focus_supported", "is_zoom_supported", "is_flash_supported", "toggle_flash": HMSCameraControlsAction.cameraControlsAction(call, result, hmsSDK) From 90c2a8df439b73e1e80996646279d0eec4496437 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 25 Apr 2023 22:36:56 +0530 Subject: [PATCH 11/88] added stub functions for sessions store --- ios/Classes/Models/HMSSessionStoreAction.swift | 16 ++++++++++++++++ ios/Classes/SwiftHmssdkFlutterPlugin.swift | 6 ++++++ 2 files changed, 22 insertions(+) create mode 100644 ios/Classes/Models/HMSSessionStoreAction.swift diff --git a/ios/Classes/Models/HMSSessionStoreAction.swift b/ios/Classes/Models/HMSSessionStoreAction.swift new file mode 100644 index 000000000..d0dff0c82 --- /dev/null +++ b/ios/Classes/Models/HMSSessionStoreAction.swift @@ -0,0 +1,16 @@ +// +// HMSSessionStoreAction.swift +// hmssdk_flutter +// +// Created by Yogesh Singh on 25/04/23. +// + +import Foundation +import HMSSDK + +class HMSSessionStoreAction { + + static func sessionStoreActions(_ call: FlutterMethodCall, _ result: FlutterResult, _ hmsSDK: HMSSDK?) { + + } +} diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index db28d6fd1..feca1445a 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -231,6 +231,12 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene case "capture_image_at_max_supported_resolution", "is_tap_to_focus_supported", "is_zoom_supported", "is_flash_supported", "toggle_flash": HMSCameraControlsAction.cameraControlsAction(call, result, hmsSDK) + // MARK: - Session Store + + case "get_session_metadata_for_key", "set_session_metadata_for_key": + HMSSessionStoreAction.sessionStoreActions(call, result, hmsSDK) + + default: result(FlutterMethodNotImplemented) } From 3294c3bfba6b74a30fce2afae3d54ce4a84431b8 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:06:02 +0530 Subject: [PATCH 12/88] updated gems --- example/android/Gemfile.lock | 2 +- example/ios/Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/android/Gemfile.lock b/example/android/Gemfile.lock index 0bc0ba727..1bd8a1e80 100644 --- a/example/android/Gemfile.lock +++ b/example/android/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.753.0) + aws-partitions (1.754.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) diff --git a/example/ios/Gemfile.lock b/example/ios/Gemfile.lock index 96546fee3..3f8c61dd6 100644 --- a/example/ios/Gemfile.lock +++ b/example/ios/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.753.0) + aws-partitions (1.754.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) From b349c71ce78cebb6709166f1b645266912fe19dd Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:06:09 +0530 Subject: [PATCH 13/88] updated pubspec --- example/pubspec.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 7146bec47..d7ddb9fe9 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -515,10 +515,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: cbff87676c352d97116af6dbea05aa28c4d65eb0f6d5677a520c11a69ca9a24d + sha256: de41e74b0ea9a3e524c68f35099af1fdeb4885625aeb277d2e01a42d6bd7b293 url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.1" package_info_plus_platform_interface: dependency: transitive description: @@ -595,10 +595,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130 + sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6 url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.6" pedantic: dependency: transitive description: @@ -715,10 +715,10 @@ packages: dependency: "direct main" description: name: share_plus - sha256: "692261968a494e47323dcc8bc66d8d52e81bc27cb4b808e4e8d7e8079d4cc01a" + sha256: "4ec54a9bf4b84a9b8e68e39557e8fd7939249def6697c92a4c4e1ce1509acb06" url: "https://pub.dev" source: hosted - version: "6.3.2" + version: "6.3.3" share_plus_platform_interface: dependency: transitive description: From d8435ace123f327ef363b8a804f3f656063462de Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:06:28 +0530 Subject: [PATCH 14/88] fixed type warnings --- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index feca1445a..8c93043fb 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -987,7 +987,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "data": [ "room": HMSRoomExtension.toDictionary(room), "local_tracks": tracks - ] + ] as [String : Any] ] as [String: Any] previewEnded = false previewSink?(data) @@ -1011,7 +1011,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "data": [ "room": HMSRoomExtension.toDictionary(room), "update": HMSRoomExtension.getValueOf(update) - ] + ] as [String : Any] ] as [String: Any] if previewEnded { eventSink?(data) @@ -1029,7 +1029,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "data": [ "peer": HMSPeerExtension.toDictionary(peer), "update": HMSPeerExtension.getValueOf(update) - ] + ] as [String : Any] ] as [String: Any] if previewEnded { @@ -1047,7 +1047,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "peer": HMSPeerExtension.toDictionary(peer), "track": HMSTrackExtension.toDictionary(track), "update": HMSTrackExtension.getValueOf(update) - ] + ] as [String : Any] ] as [String: Any] if peer.isLocal && track.source.uppercased() == "SCREEN" { if update == .trackAdded { @@ -1173,7 +1173,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "local_video_stats": HMSStatsExtension.toDictionary(localVideoStats), "track": HMSTrackExtension.toDictionary(track), "peer": HMSPeerExtension.toDictionary(peer) - ] + ] as [String : Any] ] as [String: Any] rtcSink?(data) From 8343175beffcfc63fe5f69d8c17b7f47d2e09146 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:06:47 +0530 Subject: [PATCH 15/88] added session store reference --- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 8c93043fb..3d578afc6 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -24,6 +24,8 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene internal var hmsSDK: HMSSDK? private var isStatsActive = false + + private var sessionStore: HMSSessionStore? // MARK: - Flutter Setup @@ -236,6 +238,13 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene case "get_session_metadata_for_key", "set_session_metadata_for_key": HMSSessionStoreAction.sessionStoreActions(call, result, hmsSDK) + case "add_key_change_listener": + print(#function) +// addKeyChangeListener(call,result) + + case "remove_key_change_listener": + print(#function) +// removeKeyChangeListener() default: result(FlutterMethodNotImplemented) @@ -1222,6 +1231,10 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene rtcSink?(data) } } + + public func on(sessionStoreAvailable store: HMSSessionStore) { + sessionStore = store + } // MARK: - Helper Functions From 2404a4c501c241e24630e20775ebeefd39364c12 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:07:12 +0530 Subject: [PATCH 16/88] updated plugin file --- .../Models/HMSSessionStoreAction.swift | 4 +- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 44 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ios/Classes/Models/HMSSessionStoreAction.swift b/ios/Classes/Models/HMSSessionStoreAction.swift index d0dff0c82..232e5e2bc 100644 --- a/ios/Classes/Models/HMSSessionStoreAction.swift +++ b/ios/Classes/Models/HMSSessionStoreAction.swift @@ -9,8 +9,8 @@ import Foundation import HMSSDK class HMSSessionStoreAction { - + static func sessionStoreActions(_ call: FlutterMethodCall, _ result: FlutterResult, _ hmsSDK: HMSSDK?) { - + } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 3d578afc6..d5ad92402 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -24,7 +24,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene internal var hmsSDK: HMSSDK? private var isStatsActive = false - + private var sessionStore: HMSSessionStore? // MARK: - Flutter Setup @@ -140,7 +140,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene case "switch_audio", "is_audio_mute", "mute_room_audio_locally", "un_mute_room_audio_locally", "set_volume", "toggle_mic_mute_state": HMSAudioAction.audioActions(call, result, hmsSDK) - + case "set_playback_allowed_for_track": setPlaybackAllowedForTrack(call, result) @@ -187,23 +187,23 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene case "start_screen_share", "stop_screen_share", "is_screen_share_active": screenShareActions(call, result) - + // MARK: - Track Settings - + case "get_track_settings": trackSettingsAction(call, result) break - + // MARK: - Local Audio Share - + case "play_audio_share", "stop_audio_share", "pause_audio_share", "resume_audio_share", "set_audio_share_volume", "audio_share_playing", "audio_share_current_time", "audio_share_duration": audioShareAction(call, result) - + // MARK: - Switch Audio Output - + case "switch_audio_output", "get_audio_devices_list": HMSAudioDeviceAction.audioActions(call, result, hmsSDK) - + // MARK: - Session Metadata case "get_session_metadata", "set_session_metadata": @@ -215,7 +215,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene HMSRemoteVideoTrackExtension.remoteVideoTrackActions(call, result, hmsSDK!) // MARK: - PIP Mode - + case "setup_pip", "start_pip", "stop_pip", "is_pip_available", "is_pip_active", "change_track_pip", "change_text_pip", "destroy_pip": guard #available(iOS 15.0, *) else { print(#function, HMSErrorExtension.getError("iOS 15 or above is required")) @@ -224,28 +224,28 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene HMSPIPAction.pipAction(call, result, hmsSDK, self) // MARK: - Capture HMSVideoView Snapshot - + case "capture_snapshot": captureSnapshot(call, result) // MARK: - Advanced Camera Controls - + case "capture_image_at_max_supported_resolution", "is_tap_to_focus_supported", "is_zoom_supported", "is_flash_supported", "toggle_flash": HMSCameraControlsAction.cameraControlsAction(call, result, hmsSDK) // MARK: - Session Store - + case "get_session_metadata_for_key", "set_session_metadata_for_key": HMSSessionStoreAction.sessionStoreActions(call, result, hmsSDK) - + case "add_key_change_listener": print(#function) // addKeyChangeListener(call,result) - + case "remove_key_change_listener": print(#function) // removeKeyChangeListener() - + default: result(FlutterMethodNotImplemented) } @@ -996,7 +996,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "data": [ "room": HMSRoomExtension.toDictionary(room), "local_tracks": tracks - ] as [String : Any] + ] as [String: Any] ] as [String: Any] previewEnded = false previewSink?(data) @@ -1020,7 +1020,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "data": [ "room": HMSRoomExtension.toDictionary(room), "update": HMSRoomExtension.getValueOf(update) - ] as [String : Any] + ] as [String: Any] ] as [String: Any] if previewEnded { eventSink?(data) @@ -1038,7 +1038,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "data": [ "peer": HMSPeerExtension.toDictionary(peer), "update": HMSPeerExtension.getValueOf(update) - ] as [String : Any] + ] as [String: Any] ] as [String: Any] if previewEnded { @@ -1056,7 +1056,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "peer": HMSPeerExtension.toDictionary(peer), "track": HMSTrackExtension.toDictionary(track), "update": HMSTrackExtension.getValueOf(update) - ] as [String : Any] + ] as [String: Any] ] as [String: Any] if peer.isLocal && track.source.uppercased() == "SCREEN" { if update == .trackAdded { @@ -1182,7 +1182,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene "local_video_stats": HMSStatsExtension.toDictionary(localVideoStats), "track": HMSTrackExtension.toDictionary(track), "peer": HMSPeerExtension.toDictionary(peer) - ] as [String : Any] + ] as [String: Any] ] as [String: Any] rtcSink?(data) @@ -1231,7 +1231,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene rtcSink?(data) } } - + public func on(sessionStoreAvailable store: HMSSessionStore) { sessionStore = store } From 2df8948913d1e4ffab0f2bce8cb9122173215213 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:16:24 +0530 Subject: [PATCH 17/88] added stub functions for session store --- .../Models/HMSSessionStoreAction.swift | 22 ++++++++++++++++++- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ios/Classes/Models/HMSSessionStoreAction.swift b/ios/Classes/Models/HMSSessionStoreAction.swift index 232e5e2bc..b412bfe29 100644 --- a/ios/Classes/Models/HMSSessionStoreAction.swift +++ b/ios/Classes/Models/HMSSessionStoreAction.swift @@ -10,7 +10,27 @@ import HMSSDK class HMSSessionStoreAction { - static func sessionStoreActions(_ call: FlutterMethodCall, _ result: FlutterResult, _ hmsSDK: HMSSDK?) { + static func sessionStoreActions(_ call: FlutterMethodCall, _ result: @escaping FlutterResult, _ plugin: SwiftHmssdkFlutterPlugin) { + switch call.method { + case "get_session_metadata_for_key": + getSessionMetadata(call, result, plugin) + + case "set_session_metadata_for_key": + setSessionMetadata(call, result, plugin) + + default: + result(FlutterMethodNotImplemented) + } + } + + + static private func getSessionMetadata(_ call: FlutterMethodCall, _ result: @escaping FlutterResult, _ plugin: SwiftHmssdkFlutterPlugin) { + + } + + + static private func setSessionMetadata(_ call: FlutterMethodCall, _ result: @escaping FlutterResult, _ plugin: SwiftHmssdkFlutterPlugin) { + } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index d5ad92402..fbe9f64e2 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -25,7 +25,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene private var isStatsActive = false - private var sessionStore: HMSSessionStore? + internal var sessionStore: HMSSessionStore? // MARK: - Flutter Setup @@ -236,7 +236,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene // MARK: - Session Store case "get_session_metadata_for_key", "set_session_metadata_for_key": - HMSSessionStoreAction.sessionStoreActions(call, result, hmsSDK) + HMSSessionStoreAction.sessionStoreActions(call, result, self) case "add_key_change_listener": print(#function) From ca8109001a47ad7bc96613d2f4c16a7349f4910e Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:40:00 +0530 Subject: [PATCH 18/88] added a question to be asked --- .../src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt index 1f389ecb5..27e41c16e 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt @@ -24,6 +24,8 @@ class HMSErrorLogger { */ fun returnArgumentsError(errorMessage: String): Unit? { HMSLogger.e("FL_HMSSDK Args Error", errorMessage) + + // TODO: why is this return null required? return null } From eed01b22d34a1868bf0f207bea1ed3c14cd7e1f1 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:40:09 +0530 Subject: [PATCH 19/88] updated method signature --- ios/Classes/Models/HMSErrorLogger.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/Models/HMSErrorLogger.swift b/ios/Classes/Models/HMSErrorLogger.swift index 8133bb303..a8b83c06d 100644 --- a/ios/Classes/Models/HMSErrorLogger.swift +++ b/ios/Classes/Models/HMSErrorLogger.swift @@ -24,7 +24,7 @@ class HMSErrorLogger { * This method is used to log of arguments passed from flutter channel is null * This does not stop the function execution. Function still executes normally */ - static func returnArgumentsError(errorMessage: String) { + static func returnArgumentsError(_ errorMessage: String) { print("FL_HMSSDK Args Error \(errorMessage)") } From 6f692fce203bc7303dfe92f9aeefba71fc36c213 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:40:27 +0530 Subject: [PATCH 20/88] added func to get object for key from session store --- .../Models/HMSSessionStoreAction.swift | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/ios/Classes/Models/HMSSessionStoreAction.swift b/ios/Classes/Models/HMSSessionStoreAction.swift index b412bfe29..3715bb179 100644 --- a/ios/Classes/Models/HMSSessionStoreAction.swift +++ b/ios/Classes/Models/HMSSessionStoreAction.swift @@ -15,22 +15,48 @@ class HMSSessionStoreAction { switch call.method { case "get_session_metadata_for_key": getSessionMetadata(call, result, plugin) - + case "set_session_metadata_for_key": setSessionMetadata(call, result, plugin) - + default: result(FlutterMethodNotImplemented) } } - - + static private func getSessionMetadata(_ call: FlutterMethodCall, _ result: @escaping FlutterResult, _ plugin: SwiftHmssdkFlutterPlugin) { - + + guard let store = plugin.sessionStore + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Session Store is null."))) + return + } + + guard let arguments = call.arguments as? [AnyHashable: Any], + let key = arguments["key"] as? String + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Key to be fetched from Session Store is null."))) + return + } + + store.object(forKey: key) { value, error in + + if let error = error { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)"))) + } + + guard let value = value + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in fetching key: \(key) from Session Store due to an unknown error"))) + return + } + + result(HMSResultExtension.toDictionary(true, value)) + } + } - - + static private func setSessionMetadata(_ call: FlutterMethodCall, _ result: @escaping FlutterResult, _ plugin: SwiftHmssdkFlutterPlugin) { - + } } From 1bea23dba4d6dc9f429d1b056e23d0000f39af71 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 16:53:49 +0530 Subject: [PATCH 21/88] added function to set object for key in Session Store --- .../Models/HMSSessionStoreAction.swift | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/ios/Classes/Models/HMSSessionStoreAction.swift b/ios/Classes/Models/HMSSessionStoreAction.swift index 3715bb179..9dca7d0f8 100644 --- a/ios/Classes/Models/HMSSessionStoreAction.swift +++ b/ios/Classes/Models/HMSSessionStoreAction.swift @@ -43,11 +43,12 @@ class HMSSessionStoreAction { if let error = error { result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)"))) + return } guard let value = value else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in fetching key: \(key) from Session Store due to an unknown error"))) + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Unknown error in fetching key: \(key) from Session Store."))) return } @@ -58,5 +59,39 @@ class HMSSessionStoreAction { static private func setSessionMetadata(_ call: FlutterMethodCall, _ result: @escaping FlutterResult, _ plugin: SwiftHmssdkFlutterPlugin) { + guard let store = plugin.sessionStore + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Session Store is null."))) + return + } + + guard let arguments = call.arguments as? [AnyHashable: Any], + let key = arguments["key"] as? String + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Key for the object to be set in Session Store is null."))) + return + } + + guard let data = arguments["data"] + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Data for the key - \(key) to be set in Session Store is null."))) + return + } + + store.set(data, forKey: key) { value, error in + + if let error = error { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in setting data: \(data) for key: \(key) to the Session Store. Error: \(error.localizedDescription)"))) + return + } + + guard let value = value + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Unknown Error in setting data: \(data) for key: \(key) to the Session Store."))) + return + } + + result(HMSResultExtension.toDictionary(true, value)) + } } } From 657d1000da7ba78c61e270ace1280c51b69c30dc Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 17:25:56 +0530 Subject: [PATCH 22/88] sending sink message on receiving session store update --- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 35 +++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index fbe9f64e2..5da601313 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -14,11 +14,14 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene var previewEventChannel: FlutterEventChannel? var logsEventChannel: FlutterEventChannel? var rtcStatsEventChannel: FlutterEventChannel? + var sessionEventChannel: FlutterEventChannel? var eventSink: FlutterEventSink? var previewSink: FlutterEventSink? var logsSink: FlutterEventSink? var rtcSink: FlutterEventSink? + var sessionSink: FlutterEventSink? + var roleChangeRequest: HMSRoleChangeRequest? internal var hmsSDK: HMSSDK? @@ -37,12 +40,15 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene let previewChannel = FlutterEventChannel(name: "preview_event_channel", binaryMessenger: registrar.messenger()) let logsChannel = FlutterEventChannel(name: "logs_event_channel", binaryMessenger: registrar.messenger()) let rtcChannel = FlutterEventChannel(name: "rtc_event_channel", binaryMessenger: registrar.messenger()) + let sessionChannel = FlutterEventChannel(name: "session_event_channel", binaryMessenger: registrar.messenger()) + let instance = SwiftHmssdkFlutterPlugin(channel: channel, meetingEventChannel: eventChannel, previewEventChannel: previewChannel, logsEventChannel: logsChannel, - rtcStatsEventChannel: rtcChannel) + rtcStatsEventChannel: rtcChannel, + sessionEventChannel: sessionChannel) let videoViewFactory = HMSFlutterPlatformViewFactory(plugin: instance) registrar.register(videoViewFactory, withId: "HMSFlutterPlatformView") @@ -51,7 +57,8 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene previewChannel.setStreamHandler(instance) logsChannel.setStreamHandler(instance) rtcChannel.setStreamHandler(instance) - + sessionChannel.setStreamHandler(instance) + registrar.addMethodCallDelegate(instance, channel: channel) } @@ -59,13 +66,15 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene meetingEventChannel: FlutterEventChannel, previewEventChannel: FlutterEventChannel, logsEventChannel: FlutterEventChannel, - rtcStatsEventChannel: FlutterEventChannel) { + rtcStatsEventChannel: FlutterEventChannel, + sessionEventChannel: FlutterEventChannel) { self.channel = channel self.meetingEventChannel = meetingEventChannel self.previewEventChannel = previewEventChannel self.logsEventChannel = logsEventChannel self.rtcStatsEventChannel = rtcStatsEventChannel + self.sessionEventChannel = sessionEventChannel } public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { @@ -84,6 +93,8 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene logsSink = events case "rtc_stats": rtcSink = events + case "session_store": + sessionSink = events default: return FlutterError(code: #function, message: "invalid event sink name", details: arguments) } @@ -100,25 +111,31 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene meetingEventChannel!.setStreamHandler(nil) eventSink = nil } else { - print("meetingEventChannel not found", #function) + print(#function, "meetingEventChannel not found") } if previewEventChannel != nil { previewEventChannel!.setStreamHandler(nil) previewSink = nil } else { - print("previewEventChannel not found", #function) + print(#function, "previewEventChannel not found") } if logsEventChannel != nil { logsEventChannel!.setStreamHandler(nil) logsSink = nil } else { - print("logsEventChannel not found", #function) + print(#function, "logsEventChannel not found") } if rtcStatsEventChannel != nil { rtcStatsEventChannel!.setStreamHandler(nil) rtcSink = nil } else { - print("rtcStatsEventChannel not found", #function) + print(#function, "rtcStatsEventChannel not found") + } + if sessionEventChannel != nil { + sessionEventChannel!.setStreamHandler(nil) + sessionEventChannel = nil + } else { + print(#function, "sessionEventChannel not found") } } @@ -1234,6 +1251,10 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene public func on(sessionStoreAvailable store: HMSSessionStore) { sessionStore = store + + let data = ["event_name": "on_session_store_available"] + + eventSink?(data) } // MARK: - Helper Functions From c4fbbb1b47d1d746aa9686e3a66d425d64c7d21e Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 19:22:48 +0530 Subject: [PATCH 23/88] updated trunk settings --- .trunk/.gitignore | 1 + .trunk/trunk.yaml | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.trunk/.gitignore b/.trunk/.gitignore index cf2f25470..8130ba6d1 100644 --- a/.trunk/.gitignore +++ b/.trunk/.gitignore @@ -5,3 +5,4 @@ plugins user_trunk.yaml user.yaml +shims diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index a88bef0b0..1ef1d7713 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,21 +1,21 @@ version: 0.1 cli: - version: 1.1.0 + version: 1.8.1 plugins: sources: - id: trunk - ref: v0.0.6 + ref: v0.0.14 uri: https://github.com/trunk-io/plugins lint: enabled: - - markdownlint@0.32.2 - - prettier@2.8.1 + - markdownlint@0.33.0 + - prettier@2.8.8 - git-diff-check - shfmt@3.5.0 - - shellcheck@0.8.0 - - gitleaks@8.15.2 + - shellcheck@0.9.0 + - gitleaks@8.16.3 - svgo@3.0.2 - - ktlint@0.47.1 + - ktlint@0.49.0 runtimes: enabled: - go@1.18.3 @@ -23,4 +23,7 @@ runtimes: - node@16.14.2 actions: enabled: + - trunk-announce + - trunk-check-pre-push + - trunk-fmt-pre-commit - trunk-upgrade-available From ac13943233010550701af5314671974bbb47a20e Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 20:13:23 +0530 Subject: [PATCH 24/88] made arguments an optional parameter --- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 5da601313..fcdf0ef73 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -487,14 +487,14 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene // MARK: - Room Actions private func build(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { - let arguments = call.arguments as! [AnyHashable: Any] + let arguments = call.arguments as? [AnyHashable: Any] // TODO: add checks for 100ms Extension Target - if let prefExtension = arguments["preferred_extension"] as? String { + if let prefExtension = arguments?["preferred_extension"] as? String { preferredExtension = prefExtension } - if let iOSScreenshareConfig = arguments["ios_screenshare_config"] as? [String: String] { + if let iOSScreenshareConfig = arguments?["ios_screenshare_config"] as? [String: String] { if let prefExtension = iOSScreenshareConfig["preferred_extension"] { preferredExtension = prefExtension } else { @@ -504,13 +504,13 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene } var setLogger = false - if let hmsLogSettings = arguments["hms_log_settings"] as? [AnyHashable: Any] { + if let hmsLogSettings = arguments?["hms_log_settings"] as? [AnyHashable: Any] { let level = hmsLogSettings["log_level"] as! String logLevel = getLogLevel(from: level) setLogger = true } - let dartSDKVersion = arguments["dart_sdk_version"] as! String - let hmsSDKVersion = arguments["hmssdk_version"] as! String + let dartSDKVersion = arguments?["dart_sdk_version"] as! String + let hmsSDKVersion = arguments?["hmssdk_version"] as! String let framework = HMSFrameworkInfo(type: .flutter, version: dartSDKVersion, sdkVersion: hmsSDKVersion) audioMixerSourceMap = [:] @@ -520,11 +520,11 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene result(false) return } - if let appGroup = arguments["app_group"] as? String { + if let appGroup = arguments?["app_group"] as? String { sdk.appGroup = appGroup } - if let iOSScreenshareConfig = arguments["ios_screenshare_config"] as? [String: String] { + if let iOSScreenshareConfig = arguments?["ios_screenshare_config"] as? [String: String] { if let appGroup = iOSScreenshareConfig["app_group"] { sdk.appGroup = appGroup } else { @@ -540,7 +540,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene } var trackSettings: HMSTrackSettings? - if let settingsDict = arguments["hms_track_setting"] as? [AnyHashable: Any] { + if let settingsDict = arguments?["hms_track_setting"] as? [AnyHashable: Any] { self.audioMixerSourceInit(settingsDict, sdk, result) trackSettings = HMSTrackSettingsExtension.setTrackSetting(settingsDict, self.audioMixerSourceMap, result) } From 52acd7a6d50113a38d58fdb0f23e08f5bc0afe54 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 21:30:35 +0530 Subject: [PATCH 25/88] observing changes to keys on Session Store --- .../HMSSessionStoreKeyChangeListener.swift | 20 +++++ ios/Classes/SwiftHmssdkFlutterPlugin.swift | 76 +++++++++++++++++-- 2 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 ios/Classes/Models/HMSSessionStoreKeyChangeListener.swift diff --git a/ios/Classes/Models/HMSSessionStoreKeyChangeListener.swift b/ios/Classes/Models/HMSSessionStoreKeyChangeListener.swift new file mode 100644 index 000000000..457a27954 --- /dev/null +++ b/ios/Classes/Models/HMSSessionStoreKeyChangeListener.swift @@ -0,0 +1,20 @@ +// +// HMSSessionStoreKeyChangeListener.swift +// hmssdk_flutter +// +// Created by Yogesh Singh on 26/04/23. +// + +import Foundation + +class HMSSessionStoreKeyChangeListener: NSObject { + + let identifier: String + + let observer: NSObjectProtocol + + init(_ identifier: String, _ observer: NSObjectProtocol) { + self.identifier = identifier + self.observer = observer + } +} diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index fcdf0ef73..bfe6c6271 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -21,7 +21,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene var logsSink: FlutterEventSink? var rtcSink: FlutterEventSink? var sessionSink: FlutterEventSink? - + var roleChangeRequest: HMSRoleChangeRequest? internal var hmsSDK: HMSSDK? @@ -30,6 +30,8 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene internal var sessionStore: HMSSessionStore? + private var sessionStoreChangeObservers = [HMSSessionStoreKeyChangeListener]() + // MARK: - Flutter Setup public static func register(with registrar: FlutterPluginRegistrar) { @@ -41,7 +43,6 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene let logsChannel = FlutterEventChannel(name: "logs_event_channel", binaryMessenger: registrar.messenger()) let rtcChannel = FlutterEventChannel(name: "rtc_event_channel", binaryMessenger: registrar.messenger()) let sessionChannel = FlutterEventChannel(name: "session_event_channel", binaryMessenger: registrar.messenger()) - let instance = SwiftHmssdkFlutterPlugin(channel: channel, meetingEventChannel: eventChannel, @@ -58,7 +59,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene logsChannel.setStreamHandler(instance) rtcChannel.setStreamHandler(instance) sessionChannel.setStreamHandler(instance) - + registrar.addMethodCallDelegate(instance, channel: channel) } @@ -485,6 +486,71 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene } } + // MARK: - Session Store + + private func addKeyChangeListener(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { + + guard let store = sessionStore + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Session Store is null."))) + return + } + + guard let arguments = call.arguments as? [AnyHashable: Any] + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No arguments passed which can be attached to Key Change Listener on the Session Store."))) + return + } + + guard let keys = arguments["keys"] as? [String] + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)"))) + return + } + + store.observeChanges(forKeys: keys, changeObserver: { [weak self] key, value in + + var data = [String: Any]() + + data["event_name"] = "on_key_changed" + + var dict: [String: Any] = ["key": key] + + if let value = value { + dict["value"] = value + } + + data["data"] = dict + + self?.sessionSink?(data) + + }) { [weak self] observer, error in + + if let error = error { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)"))) + return + } + + guard let observer = observer + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Unknown Error in observing changes for key: \(keys) in the Session Store."))) + return + } + + guard let self = self + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Could not find self instance while observing changes for key: \(keys) in the Session Store."))) + return + } + + let identifier = keys.map({$0}).joined(separator: ",") + + self.sessionStoreChangeObservers.append(HMSSessionStoreKeyChangeListener(identifier, observer)) + + result(true) + } + } + // MARK: - Room Actions private func build(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { let arguments = call.arguments as? [AnyHashable: Any] @@ -1251,9 +1317,9 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene public func on(sessionStoreAvailable store: HMSSessionStore) { sessionStore = store - + let data = ["event_name": "on_session_store_available"] - + eventSink?(data) } From a9d715b82a8642d761cdb00b5faa45aa5e1b18d5 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 21:35:24 +0530 Subject: [PATCH 26/88] added Actions folder to improve structure --- ios/Classes/{Models => Actions}/HMSAudioAction.swift | 0 ios/Classes/{Models => Actions}/HMSAudioDeviceAction.swift | 0 ios/Classes/{Models => Actions}/HMSCameraControlsAction.swift | 0 ios/Classes/{Models => Actions}/HMSCommonAction.swift | 0 ios/Classes/{Models => Actions}/HMSHLSAction.swift | 0 ios/Classes/{Models => Actions}/HMSMessageAction.swift | 0 ios/Classes/{Models => Actions}/HMSPIPAction.swift | 0 ios/Classes/{Models => Actions}/HMSRecordingAction.swift | 0 ios/Classes/{Models => Actions}/HMSRemoteVideoTrackAction.swift | 0 ios/Classes/{Models => Actions}/HMSRoomAction.swift | 0 ios/Classes/{Models => Actions}/HMSSessionStoreAction.swift | 0 ios/Classes/{Models => Actions}/HMSVideoAction.swift | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename ios/Classes/{Models => Actions}/HMSAudioAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSAudioDeviceAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSCameraControlsAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSCommonAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSHLSAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSMessageAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSPIPAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSRecordingAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSRemoteVideoTrackAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSRoomAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSSessionStoreAction.swift (100%) rename ios/Classes/{Models => Actions}/HMSVideoAction.swift (100%) diff --git a/ios/Classes/Models/HMSAudioAction.swift b/ios/Classes/Actions/HMSAudioAction.swift similarity index 100% rename from ios/Classes/Models/HMSAudioAction.swift rename to ios/Classes/Actions/HMSAudioAction.swift diff --git a/ios/Classes/Models/HMSAudioDeviceAction.swift b/ios/Classes/Actions/HMSAudioDeviceAction.swift similarity index 100% rename from ios/Classes/Models/HMSAudioDeviceAction.swift rename to ios/Classes/Actions/HMSAudioDeviceAction.swift diff --git a/ios/Classes/Models/HMSCameraControlsAction.swift b/ios/Classes/Actions/HMSCameraControlsAction.swift similarity index 100% rename from ios/Classes/Models/HMSCameraControlsAction.swift rename to ios/Classes/Actions/HMSCameraControlsAction.swift diff --git a/ios/Classes/Models/HMSCommonAction.swift b/ios/Classes/Actions/HMSCommonAction.swift similarity index 100% rename from ios/Classes/Models/HMSCommonAction.swift rename to ios/Classes/Actions/HMSCommonAction.swift diff --git a/ios/Classes/Models/HMSHLSAction.swift b/ios/Classes/Actions/HMSHLSAction.swift similarity index 100% rename from ios/Classes/Models/HMSHLSAction.swift rename to ios/Classes/Actions/HMSHLSAction.swift diff --git a/ios/Classes/Models/HMSMessageAction.swift b/ios/Classes/Actions/HMSMessageAction.swift similarity index 100% rename from ios/Classes/Models/HMSMessageAction.swift rename to ios/Classes/Actions/HMSMessageAction.swift diff --git a/ios/Classes/Models/HMSPIPAction.swift b/ios/Classes/Actions/HMSPIPAction.swift similarity index 100% rename from ios/Classes/Models/HMSPIPAction.swift rename to ios/Classes/Actions/HMSPIPAction.swift diff --git a/ios/Classes/Models/HMSRecordingAction.swift b/ios/Classes/Actions/HMSRecordingAction.swift similarity index 100% rename from ios/Classes/Models/HMSRecordingAction.swift rename to ios/Classes/Actions/HMSRecordingAction.swift diff --git a/ios/Classes/Models/HMSRemoteVideoTrackAction.swift b/ios/Classes/Actions/HMSRemoteVideoTrackAction.swift similarity index 100% rename from ios/Classes/Models/HMSRemoteVideoTrackAction.swift rename to ios/Classes/Actions/HMSRemoteVideoTrackAction.swift diff --git a/ios/Classes/Models/HMSRoomAction.swift b/ios/Classes/Actions/HMSRoomAction.swift similarity index 100% rename from ios/Classes/Models/HMSRoomAction.swift rename to ios/Classes/Actions/HMSRoomAction.swift diff --git a/ios/Classes/Models/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift similarity index 100% rename from ios/Classes/Models/HMSSessionStoreAction.swift rename to ios/Classes/Actions/HMSSessionStoreAction.swift diff --git a/ios/Classes/Models/HMSVideoAction.swift b/ios/Classes/Actions/HMSVideoAction.swift similarity index 100% rename from ios/Classes/Models/HMSVideoAction.swift rename to ios/Classes/Actions/HMSVideoAction.swift From b1d578e3625847f1edb4b1207fd0b4b12bb1fa81 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 21:47:49 +0530 Subject: [PATCH 27/88] added remove session store observer --- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index bfe6c6271..3e684f1cb 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -257,12 +257,10 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene HMSSessionStoreAction.sessionStoreActions(call, result, self) case "add_key_change_listener": - print(#function) -// addKeyChangeListener(call,result) + addKeyChangeListener(call, result) case "remove_key_change_listener": - print(#function) -// removeKeyChangeListener() + removeKeyChangeListener(call, result) default: result(FlutterMethodNotImplemented) @@ -551,6 +549,35 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene } } + private func removeKeyChangeListener(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { + + guard let store = sessionStore + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Session Store is null."))) + return + } + + guard let arguments = call.arguments as? [AnyHashable: Any] + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No arguments to identify which Key Change Listener should be removed from the Session Store."))) + return + } + + guard let identifier = arguments["identifier"] as? String + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No identifier passed which can be used. Available arguments: \(arguments)"))) + return + } + + let keyChangeListenersToBeRemoved = sessionStoreChangeObservers.filter { $0.identifier == identifier } + + for listener in keyChangeListenersToBeRemoved { + store.removeObserver(listener.observer) + } + + sessionStoreChangeObservers.removeAll { $0.identifier == identifier } + } + // MARK: - Room Actions private func build(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { let arguments = call.arguments as? [AnyHashable: Any] From 6b57ffd317b947cf38ec6f77120b4dcb233e3104 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 21:58:27 +0530 Subject: [PATCH 28/88] corrected PIP view naming --- ios/Classes/Actions/HMSPIPAction.swift | 2 +- ios/Classes/{PiPView.swift => Views/HMSPiPView.swift} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename ios/Classes/{PiPView.swift => Views/HMSPiPView.swift} (98%) diff --git a/ios/Classes/Actions/HMSPIPAction.swift b/ios/Classes/Actions/HMSPIPAction.swift index 02d11fde9..34e1977de 100644 --- a/ios/Classes/Actions/HMSPIPAction.swift +++ b/ios/Classes/Actions/HMSPIPAction.swift @@ -78,7 +78,7 @@ class HMSPIPAction { model?.color = .black } - let controller = UIHostingController(rootView: PiPView(model: model!)) + let controller = UIHostingController(rootView: HMSPiPView(model: model!)) pipVideoCallViewController.view.addConstrained(subview: controller.view) diff --git a/ios/Classes/PiPView.swift b/ios/Classes/Views/HMSPiPView.swift similarity index 98% rename from ios/Classes/PiPView.swift rename to ios/Classes/Views/HMSPiPView.swift index 2edce07ef..fcb6b439a 100644 --- a/ios/Classes/PiPView.swift +++ b/ios/Classes/Views/HMSPiPView.swift @@ -1,5 +1,5 @@ // -// PiPView.swift +// HMSPiPView.swift // HMSSDK // // Copyright © 2022 100ms. All rights reserved. @@ -9,7 +9,7 @@ import SwiftUI import HMSSDK @available(iOS 15.0, *) -struct PiPView: View { +struct HMSPiPView: View { @ObservedObject var model: PiPModel From e1feeba91f4184c5673c7680bd289538b157ddce Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 21:58:49 +0530 Subject: [PATCH 29/88] added session store cleanup helper function --- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 3e684f1cb..7eec41036 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -578,7 +578,13 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene sessionStoreChangeObservers.removeAll { $0.identifier == identifier } } + private func sessionStoreCleanup() { + sessionStore = nil + sessionStoreChangeObservers = [] + } + // MARK: - Room Actions + private func build(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { let arguments = call.arguments as? [AnyHashable: Any] @@ -690,11 +696,11 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene } private func leave(_ result: @escaping FlutterResult) { - hmsSDK?.leave { _, error in + hmsSDK?.leave { [weak self] _, error in if let error = error { result(HMSErrorExtension.toDictionary(error)) } else { - self.destroyPIPController() + self?.performCleanupOnLeavingRoom() result(nil) } } @@ -794,11 +800,11 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene let lock = arguments["lock"] as? Bool ?? false let reason = arguments["reason"] as? String ?? "End room invoked" - hmsSDK?.endRoom(lock: lock, reason: reason) { _, error in + hmsSDK?.endRoom(lock: lock, reason: reason) { [weak self] _, error in if let error = error { result(HMSErrorExtension.toDictionary(error)) } else { - self.destroyPIPController() + self?.performCleanupOnLeavingRoom() result(nil) } } @@ -1252,7 +1258,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene ] ] as [String: Any] - destroyPIPController() + performCleanupOnLeavingRoom() eventSink?(data) } @@ -1427,11 +1433,16 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene eventSink?(data) } - func destroyPIPController() { + private func destroyPIPController() { if #available(iOS 15.0, *) { if HMSPIPAction.pipController != nil { HMSPIPAction.disposePIP(nil) } } } + + private func performCleanupOnLeavingRoom() { + destroyPIPController() + sessionStoreCleanup() + } } From 717b16d85e75709f85be805c025d61f1d430adc6 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 22:53:17 +0530 Subject: [PATCH 30/88] updated return values of result on success --- ios/Classes/Actions/HMSSessionStoreAction.swift | 8 +------- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 4 +++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index 9dca7d0f8..f600525a6 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -85,13 +85,7 @@ class HMSSessionStoreAction { return } - guard let value = value - else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Unknown Error in setting data: \(data) for key: \(key) to the Session Store."))) - return - } - - result(HMSResultExtension.toDictionary(true, value)) + result(nil) } } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 7eec41036..2b8618ad7 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -545,7 +545,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene self.sessionStoreChangeObservers.append(HMSSessionStoreKeyChangeListener(identifier, observer)) - result(true) + result(nil) } } @@ -576,6 +576,8 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene } sessionStoreChangeObservers.removeAll { $0.identifier == identifier } + + result(nil) } private func sessionStoreCleanup() { From 9fe5e5498daa0f7d8b598163bbfae4dc700237e9 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 26 Apr 2023 22:54:12 +0530 Subject: [PATCH 31/88] corrected lint warnings --- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 2b8618ad7..da0b03974 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -576,7 +576,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene } sessionStoreChangeObservers.removeAll { $0.identifier == identifier } - + result(nil) } From f3dc30c6880b7098d860de09c8bf22e4eaa0a0aa Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Thu, 27 Apr 2023 00:00:42 +0530 Subject: [PATCH 32/88] Fixed comments --- .../main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index ef4fd4cfc..d10eefe83 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -1234,7 +1234,7 @@ class HmssdkFlutterPlugin : HMSErrorLogger.returnArgumentsError("keys parameter is null") } - keys.let { keys as List + keys?.let { keys as List hmsSessionStore?.addKeyChangeListener(keys,keyChangeListener,HMSCommonAction.getActionListener(result)) } } From 38d82b152eb95e7dea0889423cf81a6c1477515f Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Thu, 27 Apr 2023 00:58:46 +0530 Subject: [PATCH 33/88] Added comments in code --- .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 20 ++++++++++ .../methods/HMSSessionStoreAction.kt | 17 +++++++++ example/lib/enum/session_store_key.dart | 3 ++ example/lib/meeting/meeting_store.dart | 9 +++++ .../enum/hms_key_change_listener_method.dart | 1 + lib/src/model/hms_key_change_listener.dart | 14 +++++++ lib/src/model/hms_session_store.dart | 37 +++++++++++++++++++ lib/src/model/hms_update_listener.dart | 5 ++- lib/src/model/platform_method_response.dart | 3 ++ 9 files changed, 108 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index d10eefe83..c57120a5f 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -1215,6 +1215,12 @@ class HmssdkFlutterPlugin : } } + /** + * [HMSKeyChangeListener] gets update regarding the changes to the + * metadata of the keys for which it was attached + * It has [onKeyChanged] method which is called + * everytime there is change in metadata for a key + */ private val keyChangeListener = object : HMSKeyChangeListener { override fun onKeyChanged(key: String, value: String?) { val args = HashMap() @@ -1228,6 +1234,16 @@ class HmssdkFlutterPlugin : } } } + + /** + * This method is used to add key change listener for + * keys passed while calling this method + * + * Parameters: + * - keys: List List of keys for which metadata updates need to be listened. + * - keyChangeListener: Instance of HMSKeyChangeListener to listen to the metadata changes for corresponding keys + * - hmsActionResultListener: Instance of HMSActionResultListener to notify success or failure of the method call + */ private fun addKeyChangeListener(call: MethodCall,result: Result){ val keys = call.argument>("keys") ?: run { @@ -1239,6 +1255,10 @@ class HmssdkFlutterPlugin : } } + /*** + * This method is used to remove the attached key change listeners + * attached using [addKeyChangeListener] method + */ private fun removeKeyChangeListener(){ hmsSessionStore?.removeKeyChangeListener(keyChangeListener) } diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt index e86633632..648f4fd54 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt @@ -25,6 +25,14 @@ class HMSSessionStoreAction { } } + /*** + * This is used to get session metadata corresponding to the provided key + * + * If the key is null we log the error and return from method since we have the let + * block in place already + * + * This method returns [sessionMetadata] is the session metadata is available for corresponding key + */ private fun getSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ val key = call.argument("key") ?: run { HMSErrorLogger.returnArgumentsError("key is null") @@ -43,6 +51,15 @@ class HMSSessionStoreAction { } } + /*** + * This is used to set session metadata corresponding to the provided key + * + * If the key is null we log the error and return from method since we have the let + * block in place already + * + * This method sets the [data] provided during the method call + * The completion of this method is marked by actionResultListener's [onSuccess] or [onError] callback + */ private fun setSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ val key = call.argument("key") ?: run { HMSErrorLogger.returnArgumentsError("key is null") diff --git a/example/lib/enum/session_store_key.dart b/example/lib/enum/session_store_key.dart index 5f0c0e841..a6d3de343 100644 --- a/example/lib/enum/session_store_key.dart +++ b/example/lib/enum/session_store_key.dart @@ -1,3 +1,6 @@ +//Enum to store the session metadata keys +// PINNED_MESSAGE_SESSION_KEY: for pinning messages +// SPOTLIGHT: for adding spotlight feature in application enum SessionStoreKey { PINNED_MESSAGE_SESSION_KEY, SPOTLIGHT, unknown } extension SessionStoreKeyValues on SessionStoreKey { diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index ce61f2a7e..50147db76 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -193,6 +193,7 @@ class MeetingStore extends ChangeNotifier HMSSessionStore? _hmsSessionStore; PeerTrackNode? spotLightPeer; + Future join(String userName, String roomUrl, {HMSConfig? roomConfig}) async { //If roomConfig is null then only we call the methods to get the authToken @@ -1309,6 +1310,8 @@ class MeetingStore extends ChangeNotifier } } + ///Here we get the instance of HMSSessionStore using which + ///we will be performing the session metadata actions @override void onSessionStoreAvailable({HMSSessionStore? hmsSessionStore}) { _hmsSessionStore = hmsSessionStore; @@ -1318,6 +1321,10 @@ class MeetingStore extends ChangeNotifier hmsActionResultListener: this); } + ///We get this call everytime metadata corresponding to a key is changed + /// + ///Note: This only gets called when we have attached [HMSKeyChangeListener] using + /// addKeyChangeListener method with keys to be listened @override void onKeyChanged({required String key, required String? value}) { log("onKeyChanged --> key: $key value: $value"); @@ -1335,6 +1342,8 @@ class MeetingStore extends ChangeNotifier notifyListeners(); } + ///This method sets the peer to spotlight + ///this also handles removing a peer from spotlight case void setPeerToSpotlight(String? value) { int currentSpotlightPeerIndex = peerTracks.indexWhere((node) => node.uid == spotLightPeer?.uid); diff --git a/lib/src/enum/hms_key_change_listener_method.dart b/lib/src/enum/hms_key_change_listener_method.dart index 0dadf6716..090069072 100644 --- a/lib/src/enum/hms_key_change_listener_method.dart +++ b/lib/src/enum/hms_key_change_listener_method.dart @@ -1,3 +1,4 @@ +/// Enum for key change listener methods enum HMSKeyChangeListenerMethod { onKeyChanged, unknown } extension HMSKeyChangeListenerMethodValues on HMSKeyChangeListenerMethod { diff --git a/lib/src/model/hms_key_change_listener.dart b/lib/src/model/hms_key_change_listener.dart index 58b36d2a1..89bf968b2 100644 --- a/lib/src/model/hms_key_change_listener.dart +++ b/lib/src/model/hms_key_change_listener.dart @@ -1,3 +1,17 @@ +/// 100ms HMSKeyChangeListener +/// +/// 100ms SDK provides callback whenever a key in session metadata is changed +/// +/// Implement this listener in the class wherever you wish to listen to changes to those keys +/// +/// Remember to call HMSSessionStore's [addKeyChangeListener] method with corresponding keys to get the updates abstract class HMSKeyChangeListener { + ///This gets called whenever data corresponding to a key is changed + /// + ///This also gets called when key is set for the first time or set to null + /// + /// - Parameters: + /// - key: the key whose metadata is changed + /// - value: new value of the corresponding key void onKeyChanged({required String key, required String? value}) {} } diff --git a/lib/src/model/hms_session_store.dart b/lib/src/model/hms_session_store.dart index cdae2fead..0ca90c52d 100644 --- a/lib/src/model/hms_session_store.dart +++ b/lib/src/model/hms_session_store.dart @@ -1,7 +1,21 @@ import 'package:hmssdk_flutter/hmssdk_flutter.dart'; import 'package:hmssdk_flutter/src/service/platform_service.dart'; +/// [HMSSessionStore] class takes care of the session metadata for a session +/// +/// HMSUpdateListener's [onSessionStoreAvailable] method returns a object of [HMSSessionStore] +/// which can be used to call session metadata methods +/// class HMSSessionStore { + ///[addKeyChangeListener] method is used to attach listener to particular keys + /// + /// **Parameters**: + /// + /// **keys** A list of keys to be listened + /// + /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] implemented in the class where changes needs to be listened + /// + /// **hmsActionResultListener** [hmsActionResultListener] is a callback instance on which [HMSActionResultListener.onSuccess] and [HMSActionResultListener.onException] will be called. Future addKeyChangeListener( {required List keys, required HMSKeyChangeListener hmsKeyChangeListener, @@ -24,12 +38,25 @@ class HMSSessionStore { } } + ///[removeKeyChangeListener] method is used to remove a key change listener + /// + /// **Parameters**: + /// + /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] which was attaced earlier in [addKeyChangeListener] + /// Future removeKeyChangeListener( {required HMSKeyChangeListener hmsKeyChangeListener}) async { await PlatformService.invokeMethod(PlatformMethod.removeKeyChangeListener); PlatformService.removeKeyChangeListener(hmsKeyChangeListener); } + ///[getSessionMetadataForKey] method is used to get metadata corresponding to the given key. + /// If there is no data corresponding to the given key it returns null. + /// + /// **Parameters**: + /// + /// **key** key for which metadata is required + /// Future getSessionMetadataForKey({required String key}) async { dynamic result = await PlatformService.invokeMethod( PlatformMethod.getSessionMetadataForKey, @@ -41,6 +68,16 @@ class HMSSessionStore { } } + ///[setSessionMetadataForKey] is used to set metadata for a particular key + /// + /// **Parameters**: + /// + /// **key** key for metadata needs to be set + /// + /// **data** data corresponding to the given key + /// + /// **hmsActionResultListener** [hmsActionResultListener] is a callback instance on which [HMSActionResultListener.onSuccess] and [HMSActionResultListener.onException] will be called. + /// Future setSessionMetadataForKey( {required String key, required String? data, diff --git a/lib/src/model/hms_update_listener.dart b/lib/src/model/hms_update_listener.dart index 09380a69e..9baf13a25 100644 --- a/lib/src/model/hms_update_listener.dart +++ b/lib/src/model/hms_update_listener.dart @@ -100,6 +100,9 @@ abstract class HMSUpdateListener { {HMSAudioDevice? currentAudioDevice, List? availableAudioDevice}); - /// + /// Whenever a user joins a room [onSessionStoreAvailable] is fired to get an instance of [HMSSessionStore] + /// which can be used to perform session metadata operations + /// - Parameters: + /// - hmsSessionStore: An instance of HMSSessionStore which will be used to call session metadata methods void onSessionStoreAvailable({HMSSessionStore? hmsSessionStore}); } diff --git a/lib/src/model/platform_method_response.dart b/lib/src/model/platform_method_response.dart index ad3f2b72d..f53865bb5 100644 --- a/lib/src/model/platform_method_response.dart +++ b/lib/src/model/platform_method_response.dart @@ -61,6 +61,9 @@ class HMSStatsListenerMethodResponse { {required this.method, required this.data, required this.response}); } +///HMSKeyChangeListenerMethodResponse contains all the responses sent from the session store channel +/// +/// Checkout different responses in [HMSKeyChangeListenerMethod] enum class HMSKeyChangeListenerMethodResponse { final HMSKeyChangeListenerMethod method; final Map data; From f9570bac77b1542ceb49e275e51d118981791431 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:18:05 +0530 Subject: [PATCH 34/88] Fixed grid logic and audio view tile (#1283) --- example/lib/common/widgets/audio_tile.dart | 213 ++++-------------- example/lib/meeting_modes/audio_mode.dart | 3 +- .../lib/meeting_modes/basic_grid_view.dart | 3 +- example/lib/meeting_modes/hero_mode.dart | 2 +- 4 files changed, 49 insertions(+), 172 deletions(-) diff --git a/example/lib/common/widgets/audio_tile.dart b/example/lib/common/widgets/audio_tile.dart index d1c734319..925502e0d 100644 --- a/example/lib/common/widgets/audio_tile.dart +++ b/example/lib/common/widgets/audio_tile.dart @@ -7,6 +7,7 @@ import 'package:hmssdk_flutter_example/common/peer_widgets/audio_level_avatar.da import 'package:hmssdk_flutter_example/common/peer_widgets/audio_mute_status.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/brb_tag.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/hand_raise.dart'; +import 'package:hmssdk_flutter_example/common/peer_widgets/more_option.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/network_icon_widget.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/rtc_stats_view.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/tile_border.dart'; @@ -30,177 +31,55 @@ class AudioTile extends StatelessWidget { @override Widget build(BuildContext context) { - MeetingStore _meetingStore = context.read(); - - bool mutePermission = - _meetingStore.localPeer?.role.permissions.mute ?? false; - bool unMutePermission = - _meetingStore.localPeer?.role.permissions.unMute ?? false; - bool removePeerPermission = - _meetingStore.localPeer?.role.permissions.removeOthers ?? false; - bool changeRolePermission = - _meetingStore.localPeer?.role.permissions.changeRole ?? false; - - return InkWell( - onLongPress: () { - var peerTrackNode = context.read(); - HMSPeer peerNode = peerTrackNode.peer; - if (!mutePermission || - !unMutePermission || - !removePeerPermission || - !changeRolePermission) return; - if (peerTrackNode.peer.peerId != _meetingStore.localPeer!.peerId) - showDialog( - context: context, - builder: (_) => RemotePeerTileDialog( - isAudioMuted: peerTrackNode.audioTrack?.isMute ?? true, - isVideoMuted: peerTrackNode.track == null - ? true - : peerTrackNode.track!.isMute, - peerName: peerNode.name, - changeVideoTrack: (mute, isVideoTrack) { - Navigator.pop(context); - _meetingStore.changeTrackState( - peerTrackNode.track!, mute); - }, - changeAudioTrack: (mute, isAudioTrack) { - Navigator.pop(context); - _meetingStore.changeTrackState( - peerTrackNode.audioTrack!, mute); - }, - removePeer: () async { - Navigator.pop(context); - var peer = - await _meetingStore.getPeer(peerId: peerNode.peerId); - _meetingStore.removePeerFromRoom(peer!); - }, - changeRole: () { - Navigator.pop(context); - showDialog( - context: context, - builder: (_) => ChangeRoleOptionDialog( - peerName: peerNode.name, - roles: _meetingStore.roles, - peer: peerNode, - changeRole: (role, forceChange) { - Navigator.pop(context); - _meetingStore.changeRoleOfPeer( - peer: peerNode, - roleName: role, - forceChange: forceChange); - }, - )); - }, - changeLayer: () async { - Navigator.pop(context); - HMSRemoteVideoTrack track = - peerTrackNode.track as HMSRemoteVideoTrack; - List layerDefinitions = - await track.getLayerDefinition(); - HMSSimulcastLayer selectedLayer = await track.getLayer(); - if (layerDefinitions.isNotEmpty) - showDialog( - context: context, - builder: (_) => ChangeSimulcastLayerOptionDialog( - layerDefinitions: layerDefinitions, - selectedLayer: selectedLayer, - track: track)); - }, - mute: mutePermission, - unMute: unMutePermission, - removeOthers: removePeerPermission, - roles: changeRolePermission, - simulcast: false, - pinTile: peerTrackNode.pinTile, - changePinTileStatus: () { - _meetingStore.changePinTileStatus(peerTrackNode); - Navigator.pop(context); - }, - )); - else - showDialog( - context: context, - builder: (_) => LocalPeerTileDialog( - isAudioMode: true, - toggleCamera: () { - if (_meetingStore.isVideoOn) _meetingStore.switchCamera(); - }, - peerName: peerNode.name, - changeRole: () { - Navigator.pop(context); - showDialog( - context: context, - builder: (_) => ChangeRoleOptionDialog( - peerName: peerNode.name, - roles: _meetingStore.roles, - peer: peerNode, - changeRole: (role, forceChange) { - Navigator.pop(context); - _meetingStore.changeRoleOfPeer( - peer: peerNode, - roleName: role, - forceChange: forceChange); - }, - )); - }, - roles: changeRolePermission, - changeName: () async { - String name = await UtilityComponents.showInputDialog( - context: context, placeholder: "Enter Name"); - if (name.isNotEmpty) { - _meetingStore.changeName(name: name); - } - })); - }, - child: Container( - key: key, - padding: EdgeInsets.all(2), - margin: EdgeInsets.all(2), - height: itemHeight + 110, - width: itemWidth - 5.0, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: themeBottomSheetColor, - ), - child: Semantics( - label: "${context.read().peer.name}_audio", - child: Stack( - children: [ - Center(child: AudioLevelAvatar()), - Positioned( - //Bottom left - bottom: 5, - left: 5, - child: Container( - decoration: BoxDecoration( - color: Color.fromRGBO(0, 0, 0, 0.9), - borderRadius: BorderRadius.circular(8)), - child: Center( - child: Padding( - padding: const EdgeInsets.all(4), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - NetworkIconWidget(), - PeerName(), - ], - ), + return Container( + key: key, + padding: EdgeInsets.all(2), + margin: EdgeInsets.all(2), + height: itemHeight + 110, + width: itemWidth - 5.0, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: themeBottomSheetColor, + ), + child: Semantics( + label: "${context.read().peer.name}_audio", + child: Stack( + children: [ + Center(child: AudioLevelAvatar()), + Positioned( + //Bottom left + bottom: 5, + left: 5, + child: Container( + decoration: BoxDecoration( + color: Color.fromRGBO(0, 0, 0, 0.9), + borderRadius: BorderRadius.circular(8)), + child: Center( + child: Padding( + padding: const EdgeInsets.all(4), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + NetworkIconWidget(), + PeerName(), + ], ), ), ), ), - HandRaise(), //bottom left - BRBTag(), //top right - AudioMuteStatus(), //bottom center - RTCStatsView(isLocal: context.read().peer.isLocal), - TileBorder( - name: context.read().peer.name, - itemHeight: itemHeight, - itemWidth: itemWidth, - uid: context.read().uid) - ], - ), + ), + HandRaise(), //bottom left + BRBTag(), //top right + AudioMuteStatus(), + TileBorder( + name: context.read().peer.name, + itemHeight: itemHeight, + itemWidth: itemWidth, + uid: context.read().uid), + RTCStatsView(isLocal: context.read().peer.isLocal), + MoreOption(), //bottom center + ], ), ), ); diff --git a/example/lib/meeting_modes/audio_mode.dart b/example/lib/meeting_modes/audio_mode.dart index d22f02ac5..680dd83da 100644 --- a/example/lib/meeting_modes/audio_mode.dart +++ b/example/lib/meeting_modes/audio_mode.dart @@ -47,8 +47,7 @@ List portraitPattern( tiles.add(StairedGridTile(1, ratio)); pinTileCount++; } - int gridView = (peerTrack.length - pinTileCount) ~/ 6; - int tileLeft = (peerTrack.length - pinTileCount) - (gridView * 6); + int tileLeft = (peerTrack.length - pinTileCount) % 6; for (int i = 0; i < (peerTrack.length - pinTileCount - tileLeft); i++) { tiles.add(StairedGridTile(1 / 3, ratio / 1.5)); } diff --git a/example/lib/meeting_modes/basic_grid_view.dart b/example/lib/meeting_modes/basic_grid_view.dart index 96fe3ee0d..dbc738d3b 100644 --- a/example/lib/meeting_modes/basic_grid_view.dart +++ b/example/lib/meeting_modes/basic_grid_view.dart @@ -123,8 +123,7 @@ List portraitPattern(List peerTrack, pinTileCount++; } int normalTile = peerTrack.length - screenShareCount - pinTileCount; - int gridView = normalTile ~/ 4; - int tileLeft = normalTile - (gridView * 4); + int tileLeft = normalTile % 4; for (int i = 0; i < (normalTile - tileLeft); i++) { tiles.add(StairedGridTile(0.5, ratio)); } diff --git a/example/lib/meeting_modes/hero_mode.dart b/example/lib/meeting_modes/hero_mode.dart index a0ae072ed..0f9fed4fa 100644 --- a/example/lib/meeting_modes/hero_mode.dart +++ b/example/lib/meeting_modes/hero_mode.dart @@ -127,7 +127,7 @@ List portraitPattern( tiles.add(StairedGridTile(0.33, ratio / 0.6)); } int gridView = normalTile ~/ 4; - int tileLeft = normalTile - (gridView * 4); + int tileLeft = normalTile % 4; for (int i = 0; i < (normalTile - tileLeft - 4); i++) { tiles.add(StairedGridTile(0.5, ratio)); } From 0d421a788494066d5dd94099c8e9aaa23c71830f Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:22:07 +0530 Subject: [PATCH 35/88] Updated crashlytics implementation (#1280) * Updated crashlytics implementation * Added comments --- example/lib/main.dart | 13 ++++++++++++- example/lib/meeting/meeting_store.dart | 8 +++++--- example/lib/preview/preview_store.dart | 2 -- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 5fd53b5f4..d5e80377c 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -29,7 +29,18 @@ StreamSubscription? _streamSubscription; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); - FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); + + //This sends all the fatal crashes in the application to crashlytics + FlutterError.onError = (errorDetails) { + FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails); + }; + + //This sends all the errors in the application(be it in flutter or native layer) to crashlytics + PlatformDispatcher.instance.onError = (error, stack) { + FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + return true; + }; + Wakelock.enable(); Provider.debugCheckInvalidValueType = null; diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index e54ccb7f7..562c5876d 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -229,7 +229,6 @@ class MeetingStore extends ChangeNotifier endPoint: _roomData?[1] == "true" ? "" : '$qaInitEndPoint', ); } else { - FirebaseCrashlytics.instance.setUserIdentifier(_tokenData.toString()); return _tokenData; } } @@ -1744,7 +1743,11 @@ class MeetingStore extends ChangeNotifier required HMSException hmsException}) { this.hmsException = hmsException; log("ActionResultListener onException-> method: ${methodType.toString()} , Error code : ${hmsException.code} , Description : ${hmsException.description} , Message : ${hmsException.message}"); - FirebaseCrashlytics.instance.log(hmsException.toString()); + FirebaseAnalytics.instance + .logEvent(name: "HMSActionResultListenerLogs", parameters: { + "data": + "ActionResultListener onException-> method: ${methodType.toString()} , Error code : ${hmsException.code} , Description : ${hmsException.description} , Message : ${hmsException.message}" + }); switch (methodType) { case HMSActionResultListenerMethod.leave: break; @@ -1900,7 +1903,6 @@ class MeetingStore extends ChangeNotifier @override void onLogMessage({required HMSLogList hmsLogList}) { - FirebaseCrashlytics.instance.log(hmsLogList.toString()); FirebaseAnalytics.instance.logEvent( name: "SDK_Logs", parameters: {"data": hmsLogList.toString()}); applicationLogs.hmsLog.addAll(hmsLogList.hmsLog); diff --git a/example/lib/preview/preview_store.dart b/example/lib/preview/preview_store.dart index f9080a99b..65c359e06 100644 --- a/example/lib/preview/preview_store.dart +++ b/example/lib/preview/preview_store.dart @@ -143,8 +143,6 @@ class PreviewStore extends ChangeNotifier meetingUrl = meetingLink; return null; } - - FirebaseCrashlytics.instance.setUserIdentifier(_tokenData.toString()); return _tokenData; } From 9bbf089d7a59dd32f9a8001eb3e1c1bd21138cfd Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:22:37 +0530 Subject: [PATCH 36/88] Added docs link in method comments (#1282) * Added docs link in method comments * Added parameters in method description in SDK --- lib/src/model/hms_camera_controls.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/src/model/hms_camera_controls.dart b/lib/src/model/hms_camera_controls.dart index 1528fc218..431296ee2 100644 --- a/lib/src/model/hms_camera_controls.dart +++ b/lib/src/model/hms_camera_controls.dart @@ -3,15 +3,21 @@ import 'package:hmssdk_flutter/src/exceptions/hms_exception.dart'; import 'package:hmssdk_flutter/src/service/platform_service.dart'; ///[HMSCameraControls] contains the common camera functions for android and iOS +/// +///Refer [camera controls guide here](https://www.100ms.live/docs/flutter/v2/how-to-guides/configure-your-device/camera/camera-controls) class HMSCameraControls { ///[captureImageAtMaxSupportedResolution] is used to capture images at the original camera ///resolution. - ///[withFlash] parameter turns flash ON if set to TRUE. Default value is FALSE + /// + /// **Parameters**: + /// + /// **withFlash** - parameter turns flash ON if set to TRUE. Default value is FALSE /// ///Note: [withFlash] only works if current facing camera supports flash. If it doesn't support flash /// then image will be captured without flash even if [withFlash] is set as TRUE /// To avoid this consider checking the flash capabilities using [isFlashSupported] method /// before calling [captureImageAtMaxSupportedResolution] method + ///Refer: Read more about captureImageAtMaxSupportedResolution [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/configure-your-device/camera/camera-controls#capture-at-the-highest-resolution-offered-by-the-camera) static Future captureImageAtMaxSupportedResolution( {bool withFlash = false}) async { var result = await PlatformService.invokeMethod( @@ -26,6 +32,8 @@ class HMSCameraControls { ///[isFlashSupported] is used to check whether the current facing camera supports /// flash or not. + /// + ///Refer: Read more about isFlashSupported [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/configure-your-device/camera/camera-controls#check-if-flash-feature-is-available) static Future isFlashSupported() async { var result = await PlatformService.invokeMethod(PlatformMethod.isFlashSupported); @@ -44,6 +52,7 @@ class HMSCameraControls { /// ///Note: [toggleFlash] only works if camera is turned ON /// i.e. video is unmuted. + ///Read more about toggleFlash [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/configure-your-device/camera/camera-controls#toggle-flash) static Future toggleFlash() async { var result = await PlatformService.invokeMethod(PlatformMethod.toggleFlash); if (result["success"]) { From 3e3d25cdbb9ef29af5314e54a4fb7007eab72a3d Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Thu, 27 Apr 2023 16:46:36 +0530 Subject: [PATCH 37/88] Updated implementation --- .../hmssdk_flutter/HMSKeyChangeObserver.kt | 5 ++ .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 84 ++++++++++++------- example/lib/meeting/meeting_store.dart | 8 +- .../hms_action_result_listener_method.dart | 1 - lib/src/model/hms_key_change_observer.dart | 8 ++ lib/src/model/hms_session_store.dart | 35 ++++---- lib/src/service/platform_service.dart | 29 +++++-- 7 files changed, 105 insertions(+), 65 deletions(-) create mode 100644 android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt create mode 100644 lib/src/model/hms_key_change_observer.dart diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt new file mode 100644 index 000000000..3759e3d59 --- /dev/null +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt @@ -0,0 +1,5 @@ +package live.hms.hmssdk_flutter + +import live.hms.video.sessionstore.HMSKeyChangeListener + +class HMSKeyChangeObserver(val uid: String,val keyChangeListener: HMSKeyChangeListener) {} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index c57120a5f..1ec2d3925 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -67,6 +67,7 @@ class HmssdkFlutterPlugin : private var requestChange: HMSRoleChangeRequest? = null var hmssdkFlutterPlugin: HmssdkFlutterPlugin? = null private var hmsSessionStore: HmsSessionStore? = null + private var hmsKeyChangeObserverList = ArrayList() override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { if (hmssdkFlutterPlugin == null) { @@ -208,7 +209,7 @@ class HmssdkFlutterPlugin : addKeyChangeListener(call,result) } "remove_key_change_listener" -> { - removeKeyChangeListener() + removeKeyChangeListener(call) } else -> { result.notImplemented() @@ -471,7 +472,7 @@ class HmssdkFlutterPlugin : private fun leave(result: Result) { hmssdk!!.leave(hmsActionResultListener = HMSCommonAction.getActionListener(result)) disposePIP() - removeKeyChangeListener() + removeAllKeyChangeListener() } private fun destroy(result: Result) { @@ -688,7 +689,7 @@ class HmssdkFlutterPlugin : hmsActionResultListener = HMSCommonAction.getActionListener(result) ) disposePIP() - removeKeyChangeListener() + removeAllKeyChangeListener() } private fun isAllowedToEndMeeting(): Boolean? { @@ -872,7 +873,7 @@ class HmssdkFlutterPlugin : if (HMSPipAction.isPIPActive(activity)) { activity.moveTaskToBack(true) disposePIP() - removeKeyChangeListener() + removeAllKeyChangeListener() } if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { @@ -1215,26 +1216,6 @@ class HmssdkFlutterPlugin : } } - /** - * [HMSKeyChangeListener] gets update regarding the changes to the - * metadata of the keys for which it was attached - * It has [onKeyChanged] method which is called - * everytime there is change in metadata for a key - */ - private val keyChangeListener = object : HMSKeyChangeListener { - override fun onKeyChanged(key: String, value: String?) { - val args = HashMap() - args["event_name"] = "on_key_changed" - val keyValuePair = HashMap() - keyValuePair["key"] = key - keyValuePair["value"] = value - args["data"] = keyValuePair - CoroutineScope(Dispatchers.Main).launch { - sessionStoreSink?.success(args) - } - } - } - /** * This method is used to add key change listener for * keys passed while calling this method @@ -1250,8 +1231,29 @@ class HmssdkFlutterPlugin : HMSErrorLogger.returnArgumentsError("keys parameter is null") } - keys?.let { keys as List - hmsSessionStore?.addKeyChangeListener(keys,keyChangeListener,HMSCommonAction.getActionListener(result)) + val uid = call.argument("uid")?: run { + HMSErrorLogger.returnArgumentsError("uid is null") + } + + uid.let { + val keyChangeListener = object : HMSKeyChangeListener { + override fun onKeyChanged(key: String, value: String?) { + val args = HashMap() + args["event_name"] = "on_key_changed" + val newData = HashMap() + newData["key"] = key + newData["value"] = value + newData["uid"] = uid as String + args["data"] = newData + CoroutineScope(Dispatchers.Main).launch { + sessionStoreSink?.success(args) + } + } + } + hmsKeyChangeObserverList.add(HMSKeyChangeObserver(uid as String,keyChangeListener)) + keys.let { keys as List + hmsSessionStore?.addKeyChangeListener(keys,keyChangeListener,HMSCommonAction.getActionListener(result)) + } } } @@ -1259,8 +1261,34 @@ class HmssdkFlutterPlugin : * This method is used to remove the attached key change listeners * attached using [addKeyChangeListener] method */ - private fun removeKeyChangeListener(){ - hmsSessionStore?.removeKeyChangeListener(keyChangeListener) + private fun removeKeyChangeListener(call: MethodCall){ + + val uid = call.argument("uid")?: run { + HMSErrorLogger.returnArgumentsError("uid is null") + } + + uid?.let { + hmsKeyChangeObserverList.forEach{ + hmsKeyChangeObserver -> + if(hmsKeyChangeObserver.uid == uid){ + hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) + hmsKeyChangeObserverList.remove(hmsKeyChangeObserver) + return + } + } + } + } + + /** + * This method removes all the key change listeners attached during the session + * This is used while cleaning the room state i.e after calling leave room, + * onRemovedFromRoom or endRoom + */ + private fun removeAllKeyChangeListener(){ + hmsKeyChangeObserverList.forEach{ + hmsKeyChangeObserver -> hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) + } + hmsKeyChangeObserverList.clear() } private val hmsStatsListener = object : HMSStatsObserver { diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index 50147db76..bbceeb7d2 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -1317,8 +1317,7 @@ class MeetingStore extends ChangeNotifier _hmsSessionStore = hmsSessionStore; _hmsSessionStore?.addKeyChangeListener( keys: SessionStoreKeyValues.getSessionStoreKeys(), - hmsKeyChangeListener: this, - hmsActionResultListener: this); + hmsKeyChangeListener: this); } ///We get this call everytime metadata corresponding to a key is changed @@ -1806,8 +1805,6 @@ class MeetingStore extends ChangeNotifier break; case HMSActionResultListenerMethod.setSessionMetadataForKey: break; - case HMSActionResultListenerMethod.addKeyChangeListener: - break; } } @@ -1887,9 +1884,6 @@ class MeetingStore extends ChangeNotifier case HMSActionResultListenerMethod.setSessionMetadataForKey: Utilities.showToast("Set session metadata failed"); break; - case HMSActionResultListenerMethod.addKeyChangeListener: - Utilities.showToast("Add key change listener failed"); - break; } notifyListeners(); } diff --git a/lib/src/enum/hms_action_result_listener_method.dart b/lib/src/enum/hms_action_result_listener_method.dart index 455bc2c7f..b3b9f935f 100644 --- a/lib/src/enum/hms_action_result_listener_method.dart +++ b/lib/src/enum/hms_action_result_listener_method.dart @@ -26,6 +26,5 @@ enum HMSActionResultListenerMethod { switchCamera, changeRoleOfPeersWithRoles, setSessionMetadataForKey, - addKeyChangeListener, unknown } diff --git a/lib/src/model/hms_key_change_observer.dart b/lib/src/model/hms_key_change_observer.dart new file mode 100644 index 000000000..5e809fc94 --- /dev/null +++ b/lib/src/model/hms_key_change_observer.dart @@ -0,0 +1,8 @@ +import 'package:hmssdk_flutter/src/model/hms_key_change_listener.dart'; + +class HMSKeyChangeObserver { + final String uid; + final HMSKeyChangeListener hmsKeyChangeListener; + + HMSKeyChangeObserver({required this.uid, required this.hmsKeyChangeListener}); +} diff --git a/lib/src/model/hms_session_store.dart b/lib/src/model/hms_session_store.dart index 0ca90c52d..240d568d5 100644 --- a/lib/src/model/hms_session_store.dart +++ b/lib/src/model/hms_session_store.dart @@ -1,4 +1,5 @@ import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter/src/model/hms_key_change_observer.dart'; import 'package:hmssdk_flutter/src/service/platform_service.dart'; /// [HMSSessionStore] class takes care of the session metadata for a session @@ -15,26 +16,19 @@ class HMSSessionStore { /// /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] implemented in the class where changes needs to be listened /// - /// **hmsActionResultListener** [hmsActionResultListener] is a callback instance on which [HMSActionResultListener.onSuccess] and [HMSActionResultListener.onException] will be called. - Future addKeyChangeListener( + Future addKeyChangeListener( {required List keys, - required HMSKeyChangeListener hmsKeyChangeListener, - HMSActionResultListener? hmsActionResultListener}) async { + required HMSKeyChangeListener hmsKeyChangeListener}) async { + String uid = DateTime.now().millisecondsSinceEpoch.toString(); dynamic result = await PlatformService.invokeMethod( PlatformMethod.addKeyChangeListener, - arguments: { - "keys": keys, - }); - if (hmsActionResultListener != null) { - if (result == null) { - PlatformService.addKeyChangeListener(hmsKeyChangeListener); - hmsActionResultListener.onSuccess( - methodType: HMSActionResultListenerMethod.addKeyChangeListener); - } else { - hmsActionResultListener.onException( - methodType: HMSActionResultListenerMethod.addKeyChangeListener, - hmsException: HMSException.fromMap(result["data"])); - } + arguments: {"keys": keys, "uid": uid}); + if (result == null) { + PlatformService.addKeyChangeObserver(HMSKeyChangeObserver( + uid: uid, hmsKeyChangeListener: hmsKeyChangeListener)); + return null; + } else { + return HMSException.fromMap(result["data"]); } } @@ -44,10 +38,9 @@ class HMSSessionStore { /// /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] which was attaced earlier in [addKeyChangeListener] /// - Future removeKeyChangeListener( - {required HMSKeyChangeListener hmsKeyChangeListener}) async { - await PlatformService.invokeMethod(PlatformMethod.removeKeyChangeListener); - PlatformService.removeKeyChangeListener(hmsKeyChangeListener); + void removeKeyChangeListener( + {required HMSKeyChangeListener hmsKeyChangeListener}) { + PlatformService.removeKeyChangeObserver(hmsKeyChangeListener); } ///[getSessionMetadataForKey] method is used to get metadata corresponding to the given key. diff --git a/lib/src/service/platform_service.dart b/lib/src/service/platform_service.dart index 1ebf91542..c2720115c 100644 --- a/lib/src/service/platform_service.dart +++ b/lib/src/service/platform_service.dart @@ -15,6 +15,7 @@ import 'package:flutter/services.dart'; import 'package:hmssdk_flutter/hmssdk_flutter.dart'; import 'package:hmssdk_flutter/src/enum/hms_key_change_listener_method.dart'; import 'package:hmssdk_flutter/src/enum/hms_logs_update_listener.dart'; +import 'package:hmssdk_flutter/src/model/hms_key_change_observer.dart'; class PlatformService { ///used to pass data to platform using methods @@ -47,7 +48,7 @@ class PlatformService { ///add preview listeners. static List previewListeners = []; - static List keyChangeListeners = []; + static List keyChangeObservers = []; ///List for event Listener static List statsListeners = []; @@ -99,13 +100,20 @@ class PlatformService { logsListeners.remove(hmsLogListener); } - static void addKeyChangeListener(HMSKeyChangeListener hmsKeyChangeListener) { - keyChangeListeners.add(hmsKeyChangeListener); + static void addKeyChangeObserver(HMSKeyChangeObserver hmsKeyChangeObserver) { + keyChangeObservers.add(hmsKeyChangeObserver); } - static void removeKeyChangeListener( - HMSKeyChangeListener hmsKeyChangeListener) { - keyChangeListeners.remove(hmsKeyChangeListener); + static void removeKeyChangeObserver( + HMSKeyChangeListener hmsKeyChangeListener) async { + int index = keyChangeObservers.indexWhere((observer) => + observer.hmsKeyChangeListener.hashCode == + hmsKeyChangeListener.hashCode); + if (index != -1) { + invokeMethod(PlatformMethod.removeKeyChangeListener, + arguments: {"uid": keyChangeObservers[index].uid}); + keyChangeObservers.removeAt(index); + } } ///used to invoke different methods at platform side and returns something but not neccessarily @@ -623,8 +631,13 @@ class PlatformService { HMSKeyChangeListenerMethod method, Map arguments) { switch (method) { case HMSKeyChangeListenerMethod.onKeyChanged: - keyChangeListeners.forEach((e) => - e.onKeyChanged(key: arguments["key"], value: arguments["value"])); + int index = keyChangeObservers + .indexWhere((observer) => observer.uid == arguments["uid"]); + if (index != -1) { + keyChangeObservers[index] + .hmsKeyChangeListener + .onKeyChanged(key: arguments["key"], value: arguments["value"]); + } break; case HMSKeyChangeListenerMethod.unknown: break; From b9cbdb9dbd209babc31689019cc82aa2e711efec Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 27 Apr 2023 17:33:24 +0530 Subject: [PATCH 38/88] updated Example app Changelog --- example/ExampleAppChangelog.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/example/ExampleAppChangelog.txt b/example/ExampleAppChangelog.txt index aa935a3b4..d272c49dc 100644 --- a/example/ExampleAppChangelog.txt +++ b/example/ExampleAppChangelog.txt @@ -1,5 +1,19 @@ Board: https://github.com/100mslive/100ms-flutter/projects/18 +- Add Session Store APIs +https://github.com/100mslive/100ms-flutter/issues/1259 + +- Add support for setting a Tile in Spotlight Mode using Session Store +https://github.com/100mslive/100ms-flutter/issues/1252 + +- Fixed Role change request popup taking time to dismiss +https://github.com/100mslive/100ms-flutter/issues/1271 + +- Fixed grid logic and audio view tile +https://github.com/100mslive/100ms-flutter/pull/1283 + +- Updated crashlytics implementation +https://github.com/100mslive/100ms-flutter/pull/1280 Flutter SDK: 1.6.0 From 35858809fe0d60b283c75e266123310435ba2e43 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 27 Apr 2023 17:33:54 +0530 Subject: [PATCH 39/88] =?UTF-8?q?released=20sample=20app=20version=201.4.9?= =?UTF-8?q?5=20(230)=20=F0=9F=8D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/Gemfile.lock | 2 +- example/android/app/build.gradle | 4 ++-- example/ios/Gemfile.lock | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 26 ++++++++++----------- example/ios/Runner/Info.plist | 4 ++-- example/pubspec.lock | 40 ++++++++++++++++---------------- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/example/android/Gemfile.lock b/example/android/Gemfile.lock index 9d2349c70..cba42a053 100644 --- a/example/android/Gemfile.lock +++ b/example/android/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.752.0) + aws-partitions (1.755.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index bf6d97510..d1f5f3d47 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 229 - versionName "1.4.94" + versionCode 230 + versionName "1.4.95" } signingConfigs { diff --git a/example/ios/Gemfile.lock b/example/ios/Gemfile.lock index addc44854..ec839bbe8 100644 --- a/example/ios/Gemfile.lock +++ b/example/ios/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.752.0) + aws-partitions (1.755.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) diff --git a/example/ios/Podfile b/example/ios/Podfile index 57daa976a..63c668f27 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -46,7 +46,7 @@ post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |config| - config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" +# config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" config.build_settings['ENABLE_BITCODE'] = 'NO' end end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 4e60dc70f..798deb82e 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -69,7 +69,7 @@ PODS: - Firebase/Performance (= 10.7.0) - firebase_core - Flutter - - FirebaseABTesting (10.8.0): + - FirebaseABTesting (10.9.0): - FirebaseCore (~> 10.0) - FirebaseAnalytics (10.7.0): - FirebaseAnalytics/AdIdSupport (= 10.7.0) @@ -93,9 +93,9 @@ PODS: - FirebaseCoreInternal (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/Logger (~> 7.8) - - FirebaseCoreExtension (10.8.0): + - FirebaseCoreExtension (10.9.0): - FirebaseCore (~> 10.0) - - FirebaseCoreInternal (10.8.0): + - FirebaseCoreInternal (10.9.0): - "GoogleUtilities/NSData+zlib (~> 7.8)" - FirebaseCrashlytics (10.7.0): - FirebaseCore (~> 10.5) @@ -107,7 +107,7 @@ PODS: - PromisesObjC (~> 2.1) - FirebaseDynamicLinks (10.7.0): - FirebaseCore (~> 10.0) - - FirebaseInstallations (10.8.0): + - FirebaseInstallations (10.9.0): - FirebaseCore (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) @@ -122,13 +122,13 @@ PODS: - GoogleUtilities/ISASwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - nanopb (< 2.30910.0, >= 2.30908.0) - - FirebaseRemoteConfig (10.8.0): + - FirebaseRemoteConfig (10.9.0): - FirebaseABTesting (~> 10.0) - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - - FirebaseSessions (10.8.0): + - FirebaseSessions (10.9.0): - FirebaseCore (~> 10.5) - FirebaseCoreExtension (~> 10.0) - FirebaseInstallations (~> 10.0) @@ -359,17 +359,17 @@ SPEC CHECKSUMS: firebase_crashlytics: 6c15c2f507d82746dd62214964acf56146eab53f firebase_dynamic_links: 464b974eeb7a5b4b7c970062c49a3e39ff924f47 firebase_performance: 7dd98298ea2f19f480efd59ccbfcad3972ced984 - FirebaseABTesting: 0c7038e4dce273821e417bdc2b0373ee0e0e8df3 + FirebaseABTesting: 005b70969e2817e2a1e631e8dba29134a04c0622 FirebaseAnalytics: f8133442ee6f8512e28ff19e62ce15398bfaeace FirebaseCore: e317665b9d744727a97e623edbbed009320afdd7 - FirebaseCoreExtension: d815fd6fec8bb3a0940bc02dd5e3e641ea7229d8 - FirebaseCoreInternal: fa2899eb1f340054858d289e5a0fb935a0a74e52 + FirebaseCoreExtension: d3e9bba2930a8033042112397cd9f006a1bb203d + FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e FirebaseCrashlytics: 35fdd1a433b31e28adcf5c8933f4c526691a1e0b FirebaseDynamicLinks: 16a8fae3697fba66fed7a1d646fe59f30d42aa31 - FirebaseInstallations: b2a05a3fe707df764345d68685534d07d0664af3 + FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0 FirebasePerformance: 8281bbaf08aad194001018b932115b7d58a6f00b - FirebaseRemoteConfig: ffd8c40611809c92526783da146be93a15cc3f00 - FirebaseSessions: d4e22e13e5523e58fcd625671c59bed7ccee8736 + FirebaseRemoteConfig: 5ea5834e8c518f377bf1af2d97ebd611914ebf2d + FirebaseSessions: 44a6782502eb279a214d4adca20891353278760c Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_foreground_task: 21ef182ab0a29a3005cc72cd70e5f45cb7f7f817 GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 @@ -402,6 +402,6 @@ SPEC CHECKSUMS: url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f -PODFILE CHECKSUM: 576bcfbc69c41c8e1c7e04a8ea0da7225b4b2db0 +PODFILE CHECKSUM: be0979b1605a070d72f7b3642279b7f60a395416 COCOAPODS: 1.12.1 diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 5df5d3760..421fe56f7 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.94 + 1.4.95 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 229 + 230 ITSAppUsesNonExemptEncryption LSApplicationCategoryType diff --git a/example/pubspec.lock b/example/pubspec.lock index 7146bec47..ce7055f26 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -330,10 +330,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: c224ac897bed083dabf11f238dd11a239809b446740be0c2044608c50029ffdf + sha256: "2818f5233cf8fa5fc51f6d78ce0028feb4e7c18d0b6d40b57b91f366eea7e656" url: "https://pub.dev" source: hosted - version: "2.0.9" + version: "2.0.12" flutter_staggered_grid_view: dependency: "direct main" description: @@ -388,10 +388,10 @@ packages: dependency: "direct main" description: name: google_fonts - sha256: "927573f2e8a8d65c17931e21918ad0ab0666b1b636537de7c4932bdb487b190f" + sha256: "6b6f10f0ce3c42f6552d1c70d2c28d764cf22bb487f50f66cca31dcd5194f4d6" url: "https://pub.dev" source: hosted - version: "4.0.3" + version: "4.0.4" hmssdk_flutter: dependency: "direct main" description: @@ -515,10 +515,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: cbff87676c352d97116af6dbea05aa28c4d65eb0f6d5677a520c11a69ca9a24d + sha256: de41e74b0ea9a3e524c68f35099af1fdeb4885625aeb277d2e01a42d6bd7b293 url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.1" package_info_plus_platform_interface: dependency: transitive description: @@ -563,10 +563,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: da97262be945a72270513700a92b39dd2f4a54dad55d061687e2e37a6390366a + sha256: "3e58242edc02624f2c712e3f8bea88e0e341c4ae1abd3a6ff661318a3aefd829" url: "https://pub.dev" source: hosted - version: "2.0.25" + version: "2.0.26" path_provider_foundation: dependency: transitive description: @@ -595,10 +595,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130 + sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6 url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.6" pedantic: dependency: transitive description: @@ -715,10 +715,10 @@ packages: dependency: "direct main" description: name: share_plus - sha256: "692261968a494e47323dcc8bc66d8d52e81bc27cb4b808e4e8d7e8079d4cc01a" + sha256: "4ec54a9bf4b84a9b8e68e39557e8fd7939249def6697c92a4c4e1ce1509acb06" url: "https://pub.dev" source: hosted - version: "6.3.2" + version: "6.3.3" share_plus_platform_interface: dependency: transitive description: @@ -739,10 +739,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "7fa90471a6875d26ad78c7e4a675874b2043874586891128dc5899662c97db46" + sha256: "5d7b3bd0400bdd0c03e59a3d3d5314651141a145b58196cd9018b12a2adc0c1b" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.3" shared_preferences_foundation: dependency: transitive description: @@ -888,10 +888,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: a52628068d282d01a07cd86e6ba99e497aa45ce8c91159015b2416907d78e411 + sha256: "40612cd31902fe46b5158693faa65781b1ca7adfb883d77fa6f0d6dcf0317d85" url: "https://pub.dev" source: hosted - version: "6.0.27" + version: "6.0.30" url_launcher_ios: dependency: transitive description: @@ -904,10 +904,10 @@ packages: dependency: transitive description: name: url_launcher_linux - sha256: "206fb8334a700ef7754d6a9ed119e7349bc830448098f21a69bf1b4ed038cabc" + sha256: "207f4ddda99b95b4d4868320a352d374b0b7e05eefad95a4a26f57da413443f5" url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "3.0.5" url_launcher_macos: dependency: transitive description: @@ -936,10 +936,10 @@ packages: dependency: transitive description: name: url_launcher_windows - sha256: a83ba3607a507758669cfafb03f9de09bf6e6280c14d9b9cb18f013e406dcacd + sha256: "254708f17f7c20a9c8c471f67d86d76d4a3f9c1591aad1e15292008aceb82771" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.6" uuid: dependency: transitive description: From 87c9ea002ac1053c105780ad7f97ee1011f91850 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 27 Apr 2023 17:51:13 +0530 Subject: [PATCH 40/88] updated Podfile --- example/ios/Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/ios/Podfile b/example/ios/Podfile index 63c668f27..57daa976a 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -46,7 +46,7 @@ post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |config| -# config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" + config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" config.build_settings['ENABLE_BITCODE'] = 'NO' end end From 75771ed2b5a5aebb61817efe56b1e6bed1d1bef6 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 27 Apr 2023 19:26:29 +0530 Subject: [PATCH 41/88] updated Native iOS SDK --- example/android/Gemfile.lock | 2 +- example/ios/Gemfile.lock | 2 +- example/ios/Podfile.lock | 38 +++++++++++++++++----------------- example/pubspec.lock | 40 ++++++++++++++++++------------------ lib/assets/sdk-versions.json | 2 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/example/android/Gemfile.lock b/example/android/Gemfile.lock index 9d2349c70..cba42a053 100644 --- a/example/android/Gemfile.lock +++ b/example/android/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.752.0) + aws-partitions (1.755.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) diff --git a/example/ios/Gemfile.lock b/example/ios/Gemfile.lock index addc44854..ec839bbe8 100644 --- a/example/ios/Gemfile.lock +++ b/example/ios/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.752.0) + aws-partitions (1.755.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 4e60dc70f..56f108ed6 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -69,7 +69,7 @@ PODS: - Firebase/Performance (= 10.7.0) - firebase_core - Flutter - - FirebaseABTesting (10.8.0): + - FirebaseABTesting (10.9.0): - FirebaseCore (~> 10.0) - FirebaseAnalytics (10.7.0): - FirebaseAnalytics/AdIdSupport (= 10.7.0) @@ -93,9 +93,9 @@ PODS: - FirebaseCoreInternal (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/Logger (~> 7.8) - - FirebaseCoreExtension (10.8.0): + - FirebaseCoreExtension (10.9.0): - FirebaseCore (~> 10.0) - - FirebaseCoreInternal (10.8.0): + - FirebaseCoreInternal (10.9.0): - "GoogleUtilities/NSData+zlib (~> 7.8)" - FirebaseCrashlytics (10.7.0): - FirebaseCore (~> 10.5) @@ -107,7 +107,7 @@ PODS: - PromisesObjC (~> 2.1) - FirebaseDynamicLinks (10.7.0): - FirebaseCore (~> 10.0) - - FirebaseInstallations (10.8.0): + - FirebaseInstallations (10.9.0): - FirebaseCore (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) @@ -122,13 +122,13 @@ PODS: - GoogleUtilities/ISASwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - nanopb (< 2.30910.0, >= 2.30908.0) - - FirebaseRemoteConfig (10.8.0): + - FirebaseRemoteConfig (10.9.0): - FirebaseABTesting (~> 10.0) - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - - FirebaseSessions (10.8.0): + - FirebaseSessions (10.9.0): - FirebaseCore (~> 10.5) - FirebaseCoreExtension (~> 10.0) - FirebaseInstallations (~> 10.0) @@ -191,14 +191,14 @@ PODS: - PINCache (>= 3.0.1-beta.3) - HMSAnalyticsSDK (0.0.2) - HMSBroadcastExtensionSDK (0.0.9) - - HMSSDK (0.9.2): + - HMSSDK (0.9.3): - HMSAnalyticsSDK (= 0.0.2) - - HMSWebRTC (= 1.0.5115) + - HMSWebRTC (= 1.0.5116) - hmssdk_flutter (1.6.0): - Flutter - HMSBroadcastExtensionSDK (= 0.0.9) - - HMSSDK (= 0.9.2) - - HMSWebRTC (1.0.5115) + - HMSSDK (= 0.9.3) + - HMSWebRTC (1.0.5116) - image_gallery_saver (1.5.0): - Flutter - MTBBarcodeScanner (5.0.11) @@ -359,17 +359,17 @@ SPEC CHECKSUMS: firebase_crashlytics: 6c15c2f507d82746dd62214964acf56146eab53f firebase_dynamic_links: 464b974eeb7a5b4b7c970062c49a3e39ff924f47 firebase_performance: 7dd98298ea2f19f480efd59ccbfcad3972ced984 - FirebaseABTesting: 0c7038e4dce273821e417bdc2b0373ee0e0e8df3 + FirebaseABTesting: 005b70969e2817e2a1e631e8dba29134a04c0622 FirebaseAnalytics: f8133442ee6f8512e28ff19e62ce15398bfaeace FirebaseCore: e317665b9d744727a97e623edbbed009320afdd7 - FirebaseCoreExtension: d815fd6fec8bb3a0940bc02dd5e3e641ea7229d8 - FirebaseCoreInternal: fa2899eb1f340054858d289e5a0fb935a0a74e52 + FirebaseCoreExtension: d3e9bba2930a8033042112397cd9f006a1bb203d + FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e FirebaseCrashlytics: 35fdd1a433b31e28adcf5c8933f4c526691a1e0b FirebaseDynamicLinks: 16a8fae3697fba66fed7a1d646fe59f30d42aa31 - FirebaseInstallations: b2a05a3fe707df764345d68685534d07d0664af3 + FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0 FirebasePerformance: 8281bbaf08aad194001018b932115b7d58a6f00b - FirebaseRemoteConfig: ffd8c40611809c92526783da146be93a15cc3f00 - FirebaseSessions: d4e22e13e5523e58fcd625671c59bed7ccee8736 + FirebaseRemoteConfig: 5ea5834e8c518f377bf1af2d97ebd611914ebf2d + FirebaseSessions: 44a6782502eb279a214d4adca20891353278760c Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_foreground_task: 21ef182ab0a29a3005cc72cd70e5f45cb7f7f817 GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 @@ -379,9 +379,9 @@ SPEC CHECKSUMS: HLSCachingReverseProxyServer: 59935e1e0244ad7f3375d75b5ef46e8eb26ab181 HMSAnalyticsSDK: 4d2a88a729b1eb42f3d25f217c28937ec318a5b7 HMSBroadcastExtensionSDK: d80fe325f6c928bd8e5176290b5a4b7ae15d6fbb - HMSSDK: 1bd8f954ecccf50611c9b9af431798ffed7fcb30 - hmssdk_flutter: 99343f2773e2c66e80ee52e32c2e3491f565ab09 - HMSWebRTC: d74cd5e5ecfe701219dd4042ec67fed02ea5d6db + HMSSDK: 0b25c97c4575e19e0e20acc49ca5fa8bdf1df626 + hmssdk_flutter: de578436ee99bd89458160c0ac6a4df599d3f826 + HMSWebRTC: ae54e9dd91b869051b283b43b14f57d43b7bf8e1 image_gallery_saver: 259eab68fb271cfd57d599904f7acdc7832e7ef2 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 diff --git a/example/pubspec.lock b/example/pubspec.lock index 7146bec47..ce7055f26 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -330,10 +330,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: c224ac897bed083dabf11f238dd11a239809b446740be0c2044608c50029ffdf + sha256: "2818f5233cf8fa5fc51f6d78ce0028feb4e7c18d0b6d40b57b91f366eea7e656" url: "https://pub.dev" source: hosted - version: "2.0.9" + version: "2.0.12" flutter_staggered_grid_view: dependency: "direct main" description: @@ -388,10 +388,10 @@ packages: dependency: "direct main" description: name: google_fonts - sha256: "927573f2e8a8d65c17931e21918ad0ab0666b1b636537de7c4932bdb487b190f" + sha256: "6b6f10f0ce3c42f6552d1c70d2c28d764cf22bb487f50f66cca31dcd5194f4d6" url: "https://pub.dev" source: hosted - version: "4.0.3" + version: "4.0.4" hmssdk_flutter: dependency: "direct main" description: @@ -515,10 +515,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: cbff87676c352d97116af6dbea05aa28c4d65eb0f6d5677a520c11a69ca9a24d + sha256: de41e74b0ea9a3e524c68f35099af1fdeb4885625aeb277d2e01a42d6bd7b293 url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.1" package_info_plus_platform_interface: dependency: transitive description: @@ -563,10 +563,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: da97262be945a72270513700a92b39dd2f4a54dad55d061687e2e37a6390366a + sha256: "3e58242edc02624f2c712e3f8bea88e0e341c4ae1abd3a6ff661318a3aefd829" url: "https://pub.dev" source: hosted - version: "2.0.25" + version: "2.0.26" path_provider_foundation: dependency: transitive description: @@ -595,10 +595,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130 + sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6 url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.6" pedantic: dependency: transitive description: @@ -715,10 +715,10 @@ packages: dependency: "direct main" description: name: share_plus - sha256: "692261968a494e47323dcc8bc66d8d52e81bc27cb4b808e4e8d7e8079d4cc01a" + sha256: "4ec54a9bf4b84a9b8e68e39557e8fd7939249def6697c92a4c4e1ce1509acb06" url: "https://pub.dev" source: hosted - version: "6.3.2" + version: "6.3.3" share_plus_platform_interface: dependency: transitive description: @@ -739,10 +739,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "7fa90471a6875d26ad78c7e4a675874b2043874586891128dc5899662c97db46" + sha256: "5d7b3bd0400bdd0c03e59a3d3d5314651141a145b58196cd9018b12a2adc0c1b" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.3" shared_preferences_foundation: dependency: transitive description: @@ -888,10 +888,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: a52628068d282d01a07cd86e6ba99e497aa45ce8c91159015b2416907d78e411 + sha256: "40612cd31902fe46b5158693faa65781b1ca7adfb883d77fa6f0d6dcf0317d85" url: "https://pub.dev" source: hosted - version: "6.0.27" + version: "6.0.30" url_launcher_ios: dependency: transitive description: @@ -904,10 +904,10 @@ packages: dependency: transitive description: name: url_launcher_linux - sha256: "206fb8334a700ef7754d6a9ed119e7349bc830448098f21a69bf1b4ed038cabc" + sha256: "207f4ddda99b95b4d4868320a352d374b0b7e05eefad95a4a26f57da413443f5" url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "3.0.5" url_launcher_macos: dependency: transitive description: @@ -936,10 +936,10 @@ packages: dependency: transitive description: name: url_launcher_windows - sha256: a83ba3607a507758669cfafb03f9de09bf6e6280c14d9b9cb18f013e406dcacd + sha256: "254708f17f7c20a9c8c471f67d86d76d4a3f9c1591aad1e15292008aceb82771" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.6" uuid: dependency: transitive description: diff --git a/lib/assets/sdk-versions.json b/lib/assets/sdk-versions.json index f26d360d6..c130a256d 100644 --- a/lib/assets/sdk-versions.json +++ b/lib/assets/sdk-versions.json @@ -1,6 +1,6 @@ { "flutter": "1.6.0", - "ios": "0.9.2", + "ios": "0.9.3", "iOSBroadcastExtension": "0.0.9", "android": "2.6.1" } From b60cf80e6d270cbda800a55b2a97a6dd19f06008 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 27 Apr 2023 19:28:04 +0530 Subject: [PATCH 42/88] updated Example Changelog --- example/ExampleAppChangelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/ExampleAppChangelog.txt b/example/ExampleAppChangelog.txt index aa935a3b4..bc870e4eb 100644 --- a/example/ExampleAppChangelog.txt +++ b/example/ExampleAppChangelog.txt @@ -4,4 +4,4 @@ Board: https://github.com/100mslive/100ms-flutter/projects/18 Flutter SDK: 1.6.0 Android SDK: 2.6.1 -iOS SDK: 0.9.2 +iOS SDK: 0.9.3 From 60abd868d4f2918dd70d831db503a44f69a64889 Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Fri, 28 Apr 2023 00:26:21 +0530 Subject: [PATCH 43/88] Updated iOS implementation --- example/ios/Podfile.lock | 22 ++++---- .../HMSSessionStoreKeyChangeListener.swift | 6 +-- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 53 +++++++++++++++---- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 2cfb7b58b..98e7e305b 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -50,22 +50,22 @@ PODS: - Firebase/Performance (10.7.0): - Firebase/CoreOnly - FirebasePerformance (~> 10.7.0) - - firebase_analytics (10.2.1): + - firebase_analytics (10.2.0): - Firebase/Analytics (= 10.7.0) - firebase_core - Flutter - - firebase_core (2.10.0): + - firebase_core (2.9.0): - Firebase/CoreOnly (= 10.7.0) - Flutter - - firebase_crashlytics (3.1.1): + - firebase_crashlytics (3.1.0): - Firebase/Crashlytics (= 10.7.0) - firebase_core - Flutter - - firebase_dynamic_links (5.1.1): + - firebase_dynamic_links (5.1.0): - Firebase/DynamicLinks (= 10.7.0) - firebase_core - Flutter - - firebase_performance (0.9.1-1): + - firebase_performance (0.9.1): - Firebase/Performance (= 10.7.0) - firebase_core - Flutter @@ -354,11 +354,11 @@ SPEC CHECKSUMS: DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: ce3938a0df3cc1ef404671531facef740d03f920 Firebase: 0219acf760880eeec8ce479895bd7767466d9f81 - firebase_analytics: e8e294333de66e5429d4aac365966281b4dbfb7d - firebase_core: 18d44f087248303a4a8f05d0099a000c46e3c77a - firebase_crashlytics: 6c15c2f507d82746dd62214964acf56146eab53f - firebase_dynamic_links: 464b974eeb7a5b4b7c970062c49a3e39ff924f47 - firebase_performance: 7dd98298ea2f19f480efd59ccbfcad3972ced984 + firebase_analytics: 8954db5c9b63075214fa1b3ad2cdced9646f45a0 + firebase_core: d85432877e814811e040e7659f9c82faeab66e04 + firebase_crashlytics: 4c90334dc536ffa73b92f3e978426a0d1e339c74 + firebase_dynamic_links: eb6716a5419a7b1ad5ef4860c84290c48a30be91 + firebase_performance: 5f227f9d3c97ede796821299aabbe75e42dc3629 FirebaseABTesting: 005b70969e2817e2a1e631e8dba29134a04c0622 FirebaseAnalytics: f8133442ee6f8512e28ff19e62ce15398bfaeace FirebaseCore: e317665b9d744727a97e623edbbed009320afdd7 @@ -404,4 +404,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 576bcfbc69c41c8e1c7e04a8ea0da7225b4b2db0 -COCOAPODS: 1.12.1 +COCOAPODS: 1.12.0 diff --git a/ios/Classes/Models/HMSSessionStoreKeyChangeListener.swift b/ios/Classes/Models/HMSSessionStoreKeyChangeListener.swift index 457a27954..cd4e83b76 100644 --- a/ios/Classes/Models/HMSSessionStoreKeyChangeListener.swift +++ b/ios/Classes/Models/HMSSessionStoreKeyChangeListener.swift @@ -9,12 +9,12 @@ import Foundation class HMSSessionStoreKeyChangeListener: NSObject { - let identifier: String + let uid: String let observer: NSObjectProtocol - init(_ identifier: String, _ observer: NSObjectProtocol) { - self.identifier = identifier + init(_ uid: String, _ observer: NSObjectProtocol) { + self.uid = uid self.observer = observer } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index da0b03974..0cfd71ed1 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -486,6 +486,14 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene // MARK: - Session Store + /** + * This method is used to add key change listener for + * keys passed while calling this method + * + * Parameters: + * - keys: List List of keys for which metadata updates need to be listened. + * - keyChangeListener: Instance of HMSKeyChangeListener to listen to the metadata changes for corresponding keys + */ private func addKeyChangeListener(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { guard let store = sessionStore @@ -505,6 +513,12 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)"))) return } + + guard let uid = arguments["uid"] as? String + else { + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No uid passed for key change listener Available arguments: \(arguments)"))) + return + } store.observeChanges(forKeys: keys, changeObserver: { [weak self] key, value in @@ -516,6 +530,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene if let value = value { dict["value"] = value + dict["uid"] = uid } data["data"] = dict @@ -541,14 +556,16 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene return } - let identifier = keys.map({$0}).joined(separator: ",") - - self.sessionStoreChangeObservers.append(HMSSessionStoreKeyChangeListener(identifier, observer)) + self.sessionStoreChangeObservers.append(HMSSessionStoreKeyChangeListener(uid, observer)) result(nil) } } + /*** + * This method is used to remove the attached key change listeners + * attached using [addKeyChangeListener] method + */ private func removeKeyChangeListener(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { guard let store = sessionStore @@ -563,22 +580,39 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene return } - guard let identifier = arguments["identifier"] as? String + guard let uid = arguments["uid"] as? String else { result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No identifier passed which can be used. Available arguments: \(arguments)"))) return } - let keyChangeListenersToBeRemoved = sessionStoreChangeObservers.filter { $0.identifier == identifier } - - for listener in keyChangeListenersToBeRemoved { - store.removeObserver(listener.observer) + guard let keyChangeListenersToBeRemovedIndex = sessionStoreChangeObservers.firstIndex(where: { + $0.uid == uid + }) + else{ + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No listener found to remove"))) + return } - sessionStoreChangeObservers.removeAll { $0.identifier == identifier } + + store.removeObserver(sessionStoreChangeObservers[keyChangeListenersToBeRemovedIndex].observer) + + sessionStoreChangeObservers.remove(at: keyChangeListenersToBeRemovedIndex) result(nil) } + + /** + This takes care of removing all the key change listeners attached during the session + This is used while cleaning the room state i.e after calling leave room, + onRemovedFromRoom or endRoom + */ + private func removeAllKeyChangeListener(){ + sessionStoreChangeObservers.forEach{ + hmsSessionStoreObserver in + sessionStore?.removeObserver(hmsSessionStoreObserver.observer) + } + } private func sessionStoreCleanup() { sessionStore = nil @@ -1445,6 +1479,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene private func performCleanupOnLeavingRoom() { destroyPIPController() + removeAllKeyChangeListener() sessionStoreCleanup() } } From 259a1844498acdc9363933fc072bccbdab9576d0 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Fri, 28 Apr 2023 12:51:58 +0530 Subject: [PATCH 44/88] updated packages --- example/android/Gemfile.lock | 2 +- example/ios/Gemfile.lock | 2 +- example/ios/Podfile.lock | 4 ++-- example/pubspec.lock | 28 ++++++++++++++-------------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/example/android/Gemfile.lock b/example/android/Gemfile.lock index cba42a053..2a7168aa7 100644 --- a/example/android/Gemfile.lock +++ b/example/android/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.755.0) + aws-partitions (1.756.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) diff --git a/example/ios/Gemfile.lock b/example/ios/Gemfile.lock index ec839bbe8..5fdb088ec 100644 --- a/example/ios/Gemfile.lock +++ b/example/ios/Gemfile.lock @@ -8,7 +8,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.755.0) + aws-partitions (1.756.0) aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 56f108ed6..ad9f58740 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -57,7 +57,7 @@ PODS: - firebase_core (2.10.0): - Firebase/CoreOnly (= 10.7.0) - Flutter - - firebase_crashlytics (3.1.1): + - firebase_crashlytics (3.1.2): - Firebase/Crashlytics (= 10.7.0) - firebase_core - Flutter @@ -356,7 +356,7 @@ SPEC CHECKSUMS: Firebase: 0219acf760880eeec8ce479895bd7767466d9f81 firebase_analytics: e8e294333de66e5429d4aac365966281b4dbfb7d firebase_core: 18d44f087248303a4a8f05d0099a000c46e3c77a - firebase_crashlytics: 6c15c2f507d82746dd62214964acf56146eab53f + firebase_crashlytics: 621d91c0c5752e8219f8fe05a4d1e76394f4896a firebase_dynamic_links: 464b974eeb7a5b4b7c970062c49a3e39ff924f47 firebase_performance: 7dd98298ea2f19f480efd59ccbfcad3972ced984 FirebaseABTesting: 005b70969e2817e2a1e631e8dba29134a04c0622 diff --git a/example/pubspec.lock b/example/pubspec.lock index ce7055f26..e727d3665 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -245,10 +245,10 @@ packages: dependency: "direct main" description: name: firebase_crashlytics - sha256: bfc662a87df622e7d95c360536a4999f06474f53eda5a219af9e29193d498529 + sha256: "02ce958507138d938b4611e3a4910667a44b969b0c20a810bbc97bbf967ba0d7" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" firebase_crashlytics_platform_interface: dependency: transitive description: @@ -330,10 +330,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "2818f5233cf8fa5fc51f6d78ce0028feb4e7c18d0b6d40b57b91f366eea7e656" + sha256: "8ffe990dac54a4a5492747added38571a5ab474c8e5d196809ea08849c69b1bb" url: "https://pub.dev" source: hosted - version: "2.0.12" + version: "2.0.13" flutter_staggered_grid_view: dependency: "direct main" description: @@ -515,10 +515,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: de41e74b0ea9a3e524c68f35099af1fdeb4885625aeb277d2e01a42d6bd7b293 + sha256: "10259b111176fba5c505b102e3a5b022b51dd97e30522e906d6922c745584745" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" package_info_plus_platform_interface: dependency: transitive description: @@ -563,10 +563,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "3e58242edc02624f2c712e3f8bea88e0e341c4ae1abd3a6ff661318a3aefd829" + sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" url: "https://pub.dev" source: hosted - version: "2.0.26" + version: "2.0.27" path_provider_foundation: dependency: transitive description: @@ -715,10 +715,10 @@ packages: dependency: "direct main" description: name: share_plus - sha256: "4ec54a9bf4b84a9b8e68e39557e8fd7939249def6697c92a4c4e1ce1509acb06" + sha256: b1f15232d41e9701ab2f04181f21610c36c83a12ae426b79b4bd011c567934b1 url: "https://pub.dev" source: hosted - version: "6.3.3" + version: "6.3.4" share_plus_platform_interface: dependency: transitive description: @@ -739,10 +739,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "5d7b3bd0400bdd0c03e59a3d3d5314651141a145b58196cd9018b12a2adc0c1b" + sha256: "6478c6bbbecfe9aced34c483171e90d7c078f5883558b30ec3163cf18402c749" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" shared_preferences_foundation: dependency: transitive description: @@ -888,10 +888,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: "40612cd31902fe46b5158693faa65781b1ca7adfb883d77fa6f0d6dcf0317d85" + sha256: "22f8db4a72be26e9e3a4aa3f194b1f7afbc76d20ec141f84be1d787db2155cbd" url: "https://pub.dev" source: hosted - version: "6.0.30" + version: "6.0.31" url_launcher_ios: dependency: transitive description: From 08c6af68cf88fa51401fe3459e0e53224bcbb1bf Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Fri, 28 Apr 2023 14:25:34 +0530 Subject: [PATCH 45/88] added helper func to get audio mode from input string --- ios/Classes/Models/HMSTrackSettingsExtension.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ios/Classes/Models/HMSTrackSettingsExtension.swift b/ios/Classes/Models/HMSTrackSettingsExtension.swift index 360dcda6c..49e13edca 100644 --- a/ios/Classes/Models/HMSTrackSettingsExtension.swift +++ b/ios/Classes/Models/HMSTrackSettingsExtension.swift @@ -111,4 +111,16 @@ class HMSTrackSettingsExtension { return HMSTrackMuteState.mute } + static private func getAudioMode(from mode: String?) -> HMSAudioMode? { + switch mode { + case "voice": + return .voice + + case "music": + return .music + + default: + return nil + } + } } From 0d0dd21d18324ff9e83752f741ad530b7b99ea2d Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Fri, 28 Apr 2023 14:26:20 +0530 Subject: [PATCH 46/88] added support for music mode --- .../Models/HMSTrackSettingsExtension.swift | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/ios/Classes/Models/HMSTrackSettingsExtension.swift b/ios/Classes/Models/HMSTrackSettingsExtension.swift index 49e13edca..a013eba76 100644 --- a/ios/Classes/Models/HMSTrackSettingsExtension.swift +++ b/ios/Classes/Models/HMSTrackSettingsExtension.swift @@ -59,21 +59,46 @@ class HMSTrackSettingsExtension { static func setTrackSetting(_ settingsDict: [AnyHashable: Any], _ audioMixerSourceMap: [String: HMSAudioNode], _ result: @escaping FlutterResult) -> HMSTrackSettings? { var audioSettings: HMSAudioTrackSettings? - if let audioSettingsDict = settingsDict["audio_track_setting"] as? [AnyHashable: Any], - let initialMuteState = audioSettingsDict["track_initial_state"] as? String { + + if let audioSettingsDict = settingsDict["audio_track_setting"] as? [AnyHashable: Any] { + + var initialMuteState: HMSTrackMuteState? + if let muteState = audioSettingsDict["track_initial_state"] as? String { + initialMuteState = getinitialMuteState(from: muteState) + } if #available(iOS 13.0, *), !audioMixerSourceMap.isEmpty { do { let audioMixerSource = try HMSAudioMixerSource(nodes: audioMixerSourceMap.values.map {$0}) - audioSettings = HMSAudioTrackSettings(maxBitrate: 32, trackDescription: "track_description", initialMuteState: getinitialMuteState(from: initialMuteState), audioSource: audioMixerSource) + audioSettings = HMSAudioTrackSettings.build({ builder in + + builder.audioSource = audioMixerSource + + if let muteState = initialMuteState { + builder.initialMuteState = muteState + } + + if let mode = getAudioMode(from: audioSettingsDict["audioMode"] as? String) { + builder.audioMode = mode + } + }) } catch { print(#function, HMSErrorExtension.toDictionary(error)) result(false) } } else { - audioSettings = HMSAudioTrackSettings(maxBitrate: 32, trackDescription: "track_description", initialMuteState: getinitialMuteState(from: initialMuteState), audioSource: nil) + audioSettings = HMSAudioTrackSettings.build({ builder in + + if let muteState = initialMuteState { + builder.initialMuteState = muteState + } + + if let mode = getAudioMode(from: audioSettingsDict["audioMode"] as? String) { + builder.audioMode = mode + } + }) } } From 11a11455df99fc445e7308ce02238157a383bc8d Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Fri, 28 Apr 2023 18:02:16 +0530 Subject: [PATCH 47/88] Updated implementation --- example/ios/Podfile.lock | 2 +- ios/Classes/Actions/HMSSessionStoreAction.swift | 12 ++++++------ ios/Classes/SwiftHmssdkFlutterPlugin.swift | 10 +++++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 98e7e305b..2c2809c20 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -402,6 +402,6 @@ SPEC CHECKSUMS: url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f -PODFILE CHECKSUM: 576bcfbc69c41c8e1c7e04a8ea0da7225b4b2db0 +PODFILE CHECKSUM: a0b59c63d9b54988c9b8cc35fa25fa533b7b0bad COCOAPODS: 1.12.0 diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index f600525a6..30d27d5e2 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -46,13 +46,13 @@ class HMSSessionStoreAction { return } - guard let value = value - else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Unknown error in fetching key: \(key) from Session Store."))) - return + if(value is String?){ + result(HMSResultExtension.toDictionary(true, value)) } - - result(HMSResultExtension.toDictionary(true, value)) + else{ + HMSErrorLogger.returnHMSException(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error",result) + } + } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 0cfd71ed1..41b278dae 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -528,11 +528,15 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene var dict: [String: Any] = ["key": key] - if let value = value { + if(value is String?){ dict["value"] = value - dict["uid"] = uid } - + else{ + HMSErrorLogger.logError(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + dict["value"] = nil + } + + dict["uid"] = uid data["data"] = dict self?.sessionSink?(data) From 0ef8d8961e21307ccd912cd4cdb0eda6a74e7400 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Sun, 30 Apr 2023 08:43:46 +0530 Subject: [PATCH 48/88] Improved error logs (#1294) --- .../Actions/HMSSessionStoreAction.swift | 16 +++++++------- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 21 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index 30d27d5e2..dd19add49 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -28,21 +28,22 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Session Store is null."))) + HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) return } guard let arguments = call.arguments as? [AnyHashable: Any], let key = arguments["key"] as? String else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Key to be fetched from Session Store is null."))) + HMSErrorLogger.returnArgumentsError("key is null") + HMSErrorLogger.returnHMSException(#function,"Key to be fetched from Session Store is null.","NULL ERROR",result) return } store.object(forKey: key) { value, error in if let error = error { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)"))) + HMSErrorLogger.returnHMSException(#function,"Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)","Key Fetching error",result) return } @@ -61,30 +62,29 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Session Store is null."))) + HMSErrorLogger.returnHMSException(#function,"Session Store is null.", "NULL ERROR",result) return } guard let arguments = call.arguments as? [AnyHashable: Any], let key = arguments["key"] as? String else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Key for the object to be set in Session Store is null."))) + HMSErrorLogger.returnHMSException(#function,"Key for the object to be set in Session Store is null.","NULL ERROR",result) return } guard let data = arguments["data"] else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Data for the key - \(key) to be set in Session Store is null."))) + HMSErrorLogger.returnHMSException(#function,"Data for the key - \(key) to be set in Session Store is null.","NULL ERROR",result) return } store.set(data, forKey: key) { value, error in if let error = error { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in setting data: \(data) for key: \(key) to the Session Store. Error: \(error.localizedDescription)"))) + HMSErrorLogger.returnHMSException(#function,"Error in setting data: \(data) for key: \(key) to the Session Store. Error: \(error.localizedDescription)","Key Error",result) return } - result(nil) } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 41b278dae..ff2cfd95e 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -498,25 +498,26 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Session Store is null."))) + HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) return } guard let arguments = call.arguments as? [AnyHashable: Any] else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No arguments passed which can be attached to Key Change Listener on the Session Store."))) + HMSErrorLogger.returnArgumentsError("keys is null") + HMSErrorLogger.returnHMSException(#function,"No arguments passed which can be attached to Key Change Listener on the Session Store.","NULL ERROR",result) return } guard let keys = arguments["keys"] as? [String] else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)"))) + HMSErrorLogger.returnHMSException(#function,"No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)","NULL ERROR",result) return } guard let uid = arguments["uid"] as? String else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No uid passed for key change listener Available arguments: \(arguments)"))) + HMSErrorLogger.returnHMSException(#function,"No uid passed for key change listener Available arguments: \(arguments)","NULL ERROR",result) return } @@ -544,19 +545,19 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene }) { [weak self] observer, error in if let error = error { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)"))) + HMSErrorLogger.returnHMSException(#function,"Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)","KEY CHANGE ERROR",result) return } guard let observer = observer else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Unknown Error in observing changes for key: \(keys) in the Session Store."))) + HMSErrorLogger.returnHMSException(#function,"Unknown Error in observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR",result) return } guard let self = self else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Could not find self instance while observing changes for key: \(keys) in the Session Store."))) + HMSErrorLogger.returnHMSException(#function,"Could not find self instance while observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR",result) return } @@ -580,13 +581,13 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let arguments = call.arguments as? [AnyHashable: Any] else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No arguments to identify which Key Change Listener should be removed from the Session Store."))) + HMSErrorLogger.returnHMSException(#function,"No arguments to identify which Key Change Listener should be removed from the Session Store.","Remove Key Error",result) return } guard let uid = arguments["uid"] as? String else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No identifier passed which can be used. Available arguments: \(arguments)"))) + HMSErrorLogger.returnHMSException(#function,"No identifier passed which can be used. Available arguments: \(arguments)","Unique Id Error",result) return } @@ -594,7 +595,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene $0.uid == uid }) else{ - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) No listener found to remove"))) + HMSErrorLogger.returnHMSException(#function,"No listener found to remove","Listener Error",result) return } From 52a2c2527c3b281793b0d1080e8794a2236adf74 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Mon, 1 May 2023 16:44:41 +0530 Subject: [PATCH 49/88] Added audio mode ui (#1295) --- example/assets/icons/audio_mode.svg | 3 + example/ios/Podfile.lock | 2 +- .../app_dialogs/audio_mode_select_dialog.dart | 162 ++++++++++++++++++ .../app_settings_bottom_sheet.dart | 43 +++++ example/lib/common/util/utility_function.dart | 11 +- example/lib/hms_sdk_interactor.dart | 8 +- .../lib/home_screen/user_detail_screen.dart | 17 +- .../Models/HMSTrackSettingsExtension.swift | 4 +- lib/hmssdk_flutter.dart | 1 + lib/src/enum/hms_audio_mode.dart | 25 +++ lib/src/model/hms_audio_track_setting.dart | 14 +- 11 files changed, 271 insertions(+), 19 deletions(-) create mode 100644 example/assets/icons/audio_mode.svg create mode 100644 example/lib/common/app_dialogs/audio_mode_select_dialog.dart create mode 100644 lib/src/enum/hms_audio_mode.dart diff --git a/example/assets/icons/audio_mode.svg b/example/assets/icons/audio_mode.svg new file mode 100644 index 000000000..65f9bc606 --- /dev/null +++ b/example/assets/icons/audio_mode.svg @@ -0,0 +1,3 @@ + + + diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ad9f58740..4a87c7abe 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -404,4 +404,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 576bcfbc69c41c8e1c7e04a8ea0da7225b4b2db0 -COCOAPODS: 1.12.1 +COCOAPODS: 1.12.0 diff --git a/example/lib/common/app_dialogs/audio_mode_select_dialog.dart b/example/lib/common/app_dialogs/audio_mode_select_dialog.dart new file mode 100644 index 000000000..9522a1333 --- /dev/null +++ b/example/lib/common/app_dialogs/audio_mode_select_dialog.dart @@ -0,0 +1,162 @@ +//Package imports +import 'package:dropdown_button2/dropdown_button2.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +//Project imports +import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter_example/common/widgets/hms_dropdown.dart'; +import 'package:hmssdk_flutter_example/common/widgets/subtitle_text.dart'; +import 'package:hmssdk_flutter_example/common/widgets/title_text.dart'; +import 'package:hmssdk_flutter_example/common/util/app_color.dart'; +import 'package:hmssdk_flutter_example/common/util/utility_function.dart'; + +class AudioModeSelectDialog extends StatefulWidget { + final HMSAudioMode currentAudioMode; + final Function(HMSAudioMode) changeAudioMode; + + AudioModeSelectDialog({required this.currentAudioMode,required this.changeAudioMode}); + + @override + _AudioModeSelectDialogState createState() => + _AudioModeSelectDialogState(); +} + +class _AudioModeSelectDialogState extends State { + HMSAudioMode? valueChoose; + + void _updateDropDownValue(dynamic newValue) { + valueChoose = newValue; + } + + @override + void initState() { + super.initState(); + valueChoose = widget.currentAudioMode; + } + + @override + Widget build(BuildContext context) { + String message = "Select the audio mode"; + double width = MediaQuery.of(context).size.width; + return AlertDialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + actionsPadding: EdgeInsets.only(left: 20, right: 20, bottom: 10), + backgroundColor: themeBottomSheetColor, + insetPadding: EdgeInsets.symmetric(horizontal: 20, vertical: 8), + contentPadding: EdgeInsets.only(top: 20, bottom: 15, left: 24, right: 24), + title: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TitleText( + text: "Change Audio Mode", + fontSize: 20, + letterSpacing: 0.15, + textColor: themeDefaultColor, + ), + SizedBox( + height: 8, + ), + SubtitleText(text: message, textColor: themeSubHeadingColor), + ], + ), + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + padding: EdgeInsets.only(left: 10, right: 5), + decoration: BoxDecoration( + color: themeSurfaceColor, + borderRadius: BorderRadius.circular(10.0), + border: Border.all( + color: borderColor, style: BorderStyle.solid, width: 0.80), + ), + child: DropdownButtonHideUnderline( + child: HMSDropDown( + dropDownItems: [ + ...HMSAudioMode.values + .map((audioMode) => DropdownMenuItem( + child: TitleText( + text: audioMode.name, + textColor: themeDefaultColor, + fontWeight: FontWeight.w400, + ), + value: audioMode, + )) + .toList(), + ], + iconStyleData: IconStyleData( + icon: Icon(Icons.keyboard_arrow_down), + iconEnabledColor: themeDefaultColor, + ), + selectedValue: valueChoose, + updateSelectedValue: _updateDropDownValue)), + ), + ], + ), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ElevatedButton( + style: ButtonStyle( + shadowColor: MaterialStateProperty.all(themeSurfaceColor), + backgroundColor: + MaterialStateProperty.all(themeBottomSheetColor), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + side: BorderSide( + width: 1, color: Color.fromRGBO(107, 125, 153, 1)), + borderRadius: BorderRadius.circular(8.0), + ))), + onPressed: () => Navigator.pop(context, false), + child: Padding( + padding: + const EdgeInsets.symmetric(vertical: 12, horizontal: 10), + child: Text('Cancel', + style: GoogleFonts.inter( + color: themeDefaultColor, + fontSize: 16, + fontWeight: FontWeight.w600, + letterSpacing: 0.50)), + )), + ElevatedButton( + style: ButtonStyle( + shadowColor: MaterialStateProperty.all(themeSurfaceColor), + backgroundColor: MaterialStateProperty.all(hmsdefaultColor), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + side: BorderSide(width: 1, color: hmsdefaultColor), + borderRadius: BorderRadius.circular(8.0), + ))), + onPressed: () => { + if (valueChoose == null) + { + Utilities.showToast("Please select audioMode"), + } + else + { + Navigator.pop(context), + widget.changeAudioMode(valueChoose!) + } + }, + child: Padding( + padding: + const EdgeInsets.symmetric(vertical: 12, horizontal: 10), + child: Text( + 'Change', + style: GoogleFonts.inter( + color: themeDefaultColor, + fontSize: 16, + fontWeight: FontWeight.w600, + letterSpacing: 0.50), + ), + ), + ), + ], + ) + ], + ); + } +} diff --git a/example/lib/common/bottom_sheets/app_settings_bottom_sheet.dart b/example/lib/common/bottom_sheets/app_settings_bottom_sheet.dart index a7e62d645..a74656a06 100644 --- a/example/lib/common/bottom_sheets/app_settings_bottom_sheet.dart +++ b/example/lib/common/bottom_sheets/app_settings_bottom_sheet.dart @@ -5,6 +5,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter_example/common/app_dialogs/audio_mode_select_dialog.dart'; import 'package:hmssdk_flutter_example/common/bottom_sheets/notification_settings_bottom_sheet.dart'; import 'package:hmssdk_flutter_example/common/util/log_writer.dart'; import 'package:hmssdk_flutter_example/common/widgets/title_text.dart'; @@ -31,6 +33,7 @@ class _AppSettingsBottomSheetState extends State { bool isSoftwareDecoderDisabled = true; bool isAudioMixerDisabled = true; bool isAutoSimulcast = true; + HMSAudioMode currentAudioMode = HMSAudioMode.VOICE; var versions = {}; @override @@ -66,6 +69,8 @@ class _AppSettingsBottomSheetState extends State { await Utilities.getBoolData(key: 'audio-mixer-disabled') ?? true; isAutoSimulcast = await Utilities.getBoolData(key: 'is-auto-simulcast') ?? true; + int audio_mode_index = await Utilities.getIntData(key: 'audio-mode'); + currentAudioMode = await HMSAudioMode.values[audio_mode_index]; WidgetsBinding.instance.addPostFrameCallback((_) { setState(() {}); }); @@ -78,6 +83,11 @@ class _AppSettingsBottomSheetState extends State { } } + void setAudioMode(HMSAudioMode newMode) { + currentAudioMode = newMode; + setState(() {}); + } + @override Widget build(BuildContext context) { return FractionallySizedBox( @@ -387,6 +397,39 @@ class _AppSettingsBottomSheetState extends State { setState(() {}) }), ), + GestureDetector( + onTap: () { + showDialog( + context: context, + builder: (_) => AudioModeSelectDialog( + currentAudioMode: currentAudioMode, + changeAudioMode: (newMode) { + setAudioMode(newMode); + Utilities.saveIntData( + key: "audio-mode", value: newMode.index); + })); + }, + child: ListTile( + horizontalTitleGap: 2, + enabled: false, + contentPadding: EdgeInsets.zero, + leading: SvgPicture.asset( + "assets/icons/audio_mode.svg", + fit: BoxFit.scaleDown, + color: themeDefaultColor, + ), + title: Text( + "Audio Mode", + semanticsLabel: "fl_audio_mode", + style: GoogleFonts.inter( + fontSize: 14, + color: themeDefaultColor, + letterSpacing: 0.25, + fontWeight: FontWeight.w600), + ), + trailing: Text(currentAudioMode.name), + ), + ), ListTile( horizontalTitleGap: 2, onTap: () async { diff --git a/example/lib/common/util/utility_function.dart b/example/lib/common/util/utility_function.dart index 9a0400b7c..8846ccc5b 100644 --- a/example/lib/common/util/utility_function.dart +++ b/example/lib/common/util/utility_function.dart @@ -226,13 +226,15 @@ class Utilities { {required bool isAudioMixerDisabled, required bool joinWithMutedVideo, required bool joinWithMutedAudio, - required bool isSoftwareDecoderDisabled}) { + required bool isSoftwareDecoderDisabled, + required HMSAudioMode audioMode}) { return isAudioMixerDisabled ? HMSTrackSetting( audioTrackSetting: HMSAudioTrackSetting( trackInitialState: joinWithMutedAudio ? HMSTrackInitState.MUTED - : HMSTrackInitState.UNMUTED), + : HMSTrackInitState.UNMUTED, + audioMode: audioMode), videoTrackSetting: HMSVideoTrackSetting( trackInitialState: joinWithMutedVideo ? HMSTrackInitState.MUTED @@ -243,11 +245,12 @@ class Utilities { audioSource: HMSAudioMixerSource(node: [ HMSAudioFilePlayerNode("audioFilePlayerNode"), HMSMicNode(), - HMSScreenBroadcastAudioReceiverNode() + HMSScreenBroadcastAudioReceiverNode(), ]), trackInitialState: joinWithMutedAudio ? HMSTrackInitState.MUTED - : HMSTrackInitState.UNMUTED), + : HMSTrackInitState.UNMUTED, + audioMode: audioMode), videoTrackSetting: HMSVideoTrackSetting( trackInitialState: joinWithMutedVideo ? HMSTrackInitState.MUTED diff --git a/example/lib/hms_sdk_interactor.dart b/example/lib/hms_sdk_interactor.dart index 7b425d711..4e4c4368b 100644 --- a/example/lib/hms_sdk_interactor.dart +++ b/example/lib/hms_sdk_interactor.dart @@ -18,7 +18,8 @@ class HMSSDKInteractor { bool joinWithMutedAudio = true, bool joinWithMutedVideo = true, bool isSoftwareDecoderDisabled = true, - bool isAudioMixerDisabled = true}) { + bool isAudioMixerDisabled = true, + HMSAudioMode audioMode = HMSAudioMode.VOICE}) { HMSLogSettings hmsLogSettings = HMSLogSettings( maxDirSizeInBytes: 1000000, isLogStorageEnabled: true, @@ -28,14 +29,15 @@ class HMSSDKInteractor { isAudioMixerDisabled: (Platform.isIOS && isAudioMixerDisabled), joinWithMutedVideo: joinWithMutedVideo, joinWithMutedAudio: joinWithMutedAudio, - isSoftwareDecoderDisabled: isSoftwareDecoderDisabled); + isSoftwareDecoderDisabled: isSoftwareDecoderDisabled, + audioMode: audioMode); hmsSDK = HMSSDK( iOSScreenshareConfig: iOSScreenshareConfig, hmsLogSettings: hmsLogSettings, hmsTrackSetting: trackSetting); } - + Future build() async { await hmsSDK.build(); } diff --git a/example/lib/home_screen/user_detail_screen.dart b/example/lib/home_screen/user_detail_screen.dart index 6232aad71..9b9cf47d3 100644 --- a/example/lib/home_screen/user_detail_screen.dart +++ b/example/lib/home_screen/user_detail_screen.dart @@ -41,7 +41,8 @@ class _UserDetailScreenState extends State { {required bool joinWithMutedAudio, required bool joinWithMutedVideo, required bool isSoftwareDecoderDisabled, - required bool isAudioMixerDisabled}) async { + required bool isAudioMixerDisabled, + required HMSAudioMode audioMode}) async { /// [iOSScreenshareConfig] of [HMSSDKInteractor] are optional values only required for implementing Screen & Audio Share on iOS. They are not required for Android. /// Remove [appGroup] & [preferredExtension] if your app does not implements Screen or Audio Share on iOS. /// [joinWithMutedAudio] & [joinWithMutedVideo] are required to set the initial audio/video state i.e what should be camera and mic @@ -57,7 +58,8 @@ class _UserDetailScreenState extends State { joinWithMutedAudio: joinWithMutedAudio, joinWithMutedVideo: joinWithMutedVideo, isSoftwareDecoderDisabled: isSoftwareDecoderDisabled, - isAudioMixerDisabled: isAudioMixerDisabled); + isAudioMixerDisabled: isAudioMixerDisabled, + audioMode: audioMode); //build call should be a blocking call await _hmsSDKInteractor.build(); } @@ -85,12 +87,15 @@ class _UserDetailScreenState extends State { await Utilities.getBoolData(key: 'software-decoder-disabled') ?? true; bool isAudioMixerDisabled = await Utilities.getBoolData(key: 'audio-mixer-disabled') ?? true; + int audioModeIndex = await Utilities.getIntData(key: 'audio-mode'); if (res) { await setHMSSDKInteractor( - joinWithMutedAudio: joinWithMutedAudio, - joinWithMutedVideo: joinWithMutedVideo, - isSoftwareDecoderDisabled: isSoftwareDecoderDisabled, - isAudioMixerDisabled: isAudioMixerDisabled); + joinWithMutedAudio: joinWithMutedAudio, + joinWithMutedVideo: joinWithMutedVideo, + isSoftwareDecoderDisabled: isSoftwareDecoderDisabled, + isAudioMixerDisabled: isAudioMixerDisabled, + audioMode: HMSAudioMode.values[audioModeIndex] + ); if (!skipPreview) { _previewStore = PreviewStore(hmsSDKInteractor: _hmsSDKInteractor); diff --git a/ios/Classes/Models/HMSTrackSettingsExtension.swift b/ios/Classes/Models/HMSTrackSettingsExtension.swift index a013eba76..d0110166c 100644 --- a/ios/Classes/Models/HMSTrackSettingsExtension.swift +++ b/ios/Classes/Models/HMSTrackSettingsExtension.swift @@ -79,7 +79,7 @@ class HMSTrackSettingsExtension { builder.initialMuteState = muteState } - if let mode = getAudioMode(from: audioSettingsDict["audioMode"] as? String) { + if let mode = getAudioMode(from: audioSettingsDict["audio_mode"] as? String) { builder.audioMode = mode } }) @@ -95,7 +95,7 @@ class HMSTrackSettingsExtension { builder.initialMuteState = muteState } - if let mode = getAudioMode(from: audioSettingsDict["audioMode"] as? String) { + if let mode = getAudioMode(from: audioSettingsDict["audio_mode"] as? String) { builder.audioMode = mode } }) diff --git a/lib/hmssdk_flutter.dart b/lib/hmssdk_flutter.dart index 3ac1cb5db..ba4cf70c2 100644 --- a/lib/hmssdk_flutter.dart +++ b/lib/hmssdk_flutter.dart @@ -20,6 +20,7 @@ export 'src/enum/hms_stats_listener_method.dart'; export 'src/enum/hms_track_init_state.dart'; export 'src/enum/hms_Quality_limitation_reason.dart'; export 'src/enum/hms_simulcast_layer.dart'; +export 'src/enum/hms_audio_mode.dart'; //EXCEPTIONS export 'src/exceptions/hms_exception.dart'; export 'src/exceptions/hms_in_sufficient_data.dart'; diff --git a/lib/src/enum/hms_audio_mode.dart b/lib/src/enum/hms_audio_mode.dart new file mode 100644 index 000000000..596f6e781 --- /dev/null +++ b/lib/src/enum/hms_audio_mode.dart @@ -0,0 +1,25 @@ +enum HMSAudioMode { VOICE, MUSIC} + +extension HMSAudioModeValues on HMSAudioMode { + static HMSAudioMode getAudioModeFromName(String name) { + switch (name) { + case "voice": + return HMSAudioMode.VOICE; + case "music": + return HMSAudioMode.MUSIC; + default: + return HMSAudioMode.VOICE; + } + } + + static String getNameFromHMSAudioMode(HMSAudioMode mode) { + switch (mode) { + case HMSAudioMode.VOICE: + return "voice"; + case HMSAudioMode.MUSIC: + return "music"; + default: + return "voice"; + } + } +} diff --git a/lib/src/model/hms_audio_track_setting.dart b/lib/src/model/hms_audio_track_setting.dart index 9bfb49fa4..0256233ea 100644 --- a/lib/src/model/hms_audio_track_setting.dart +++ b/lib/src/model/hms_audio_track_setting.dart @@ -20,10 +20,14 @@ class HMSAudioTrackSetting { ///[trackInitialState] property to set the initial state of the audio track i.e Mute/Unmute.By default it's unmuted. final HMSTrackInitState? trackInitialState; + ///[audioMode] property to set the audio mode of audio track i.e voice or music mode + final HMSAudioMode audioMode; + HMSAudioTrackSetting( {this.useHardwareAcousticEchoCanceler, this.audioSource, - this.trackInitialState = HMSTrackInitState.UNMUTED}); + this.trackInitialState = HMSTrackInitState.UNMUTED, + this.audioMode = HMSAudioMode.VOICE}); factory HMSAudioTrackSetting.fromMap(Map map) { List nodeList = []; @@ -40,6 +44,8 @@ class HMSAudioTrackSetting { audioMixerSource = HMSAudioMixerSource(node: nodeList); } HMSAudioMixerSource(node: nodeList); + + HMSAudioMode audioMode = map["audio_mode"] ?? HMSAudioMode.VOICE; return HMSAudioTrackSetting( useHardwareAcousticEchoCanceler: map['user_hardware_acoustic_echo_canceler'] ?? null, @@ -47,7 +53,8 @@ class HMSAudioTrackSetting { trackInitialState: map.containsKey("track_initial_state") ? HMSTrackInitStateValue.getHMSTrackInitStateFromName( map['track_initial_state']) - : HMSTrackInitState.UNMUTED); + : HMSTrackInitState.UNMUTED, + audioMode: audioMode); } Map toMap() { @@ -56,7 +63,8 @@ class HMSAudioTrackSetting { 'audio_source': audioSource?.toList(), 'track_initial_state': HMSTrackInitStateValue.getValuefromHMSTrackInitState( - trackInitialState) + trackInitialState), + 'audio_mode': HMSAudioModeValues.getNameFromHMSAudioMode(audioMode) }; } } From 6018e813b1031024bc2d2763242ee96229d13d01 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Mon, 1 May 2023 23:37:58 +0530 Subject: [PATCH 50/88] updated android SDK version (#1298) --- lib/assets/sdk-versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assets/sdk-versions.json b/lib/assets/sdk-versions.json index c130a256d..1c2f57684 100644 --- a/lib/assets/sdk-versions.json +++ b/lib/assets/sdk-versions.json @@ -2,5 +2,5 @@ "flutter": "1.6.0", "ios": "0.9.3", "iOSBroadcastExtension": "0.0.9", - "android": "2.6.1" + "android": "2.6.2" } From d06ad526fb5e08338194a2470170aad5bf91aa5a Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Tue, 2 May 2023 11:36:00 +0530 Subject: [PATCH 51/88] Added parsing fix --- lib/src/model/hms_audio_track_setting.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/model/hms_audio_track_setting.dart b/lib/src/model/hms_audio_track_setting.dart index 0256233ea..63c1f72a2 100644 --- a/lib/src/model/hms_audio_track_setting.dart +++ b/lib/src/model/hms_audio_track_setting.dart @@ -45,7 +45,7 @@ class HMSAudioTrackSetting { } HMSAudioMixerSource(node: nodeList); - HMSAudioMode audioMode = map["audio_mode"] ?? HMSAudioMode.VOICE; + HMSAudioMode audioMode = HMSAudioModeValues.getAudioModeFromName(map["audio_mode"]); return HMSAudioTrackSetting( useHardwareAcousticEchoCanceler: map['user_hardware_acoustic_echo_canceler'] ?? null, From 8bb0e4d0ec9a5b1ee8ff5cbafef550d14d13d2e5 Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Tue, 2 May 2023 11:55:55 +0530 Subject: [PATCH 52/88] Updated getTrackSetting method --- ios/Classes/Models/HMSTrackSettingsExtension.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ios/Classes/Models/HMSTrackSettingsExtension.swift b/ios/Classes/Models/HMSTrackSettingsExtension.swift index d0110166c..5060846bf 100644 --- a/ios/Classes/Models/HMSTrackSettingsExtension.swift +++ b/ios/Classes/Models/HMSTrackSettingsExtension.swift @@ -53,6 +53,7 @@ class HMSTrackSettingsExtension { dict["track_description"] = hmsAudioTrackSettings.trackDescription dict["max_bitrate"] = hmsAudioTrackSettings.maxBitrate dict["audio_source"] = audioMixerSourceMap.keys.map {$0} + dict["audio_mode"] = getStringFromAudioMode(from: hmsAudioTrackSettings.audioMode) return dict } @@ -148,4 +149,17 @@ class HMSTrackSettingsExtension { return nil } } + + static private func getStringFromAudioMode(from mode: HMSAudioMode) -> String? { + switch mode{ + case .music: + return "music" + + case .voice: + return "voice" + + default: + return nil + } + } } From 67d0a5417d245d6b84d0fa7bf54fece450b73e3e Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Tue, 2 May 2023 16:46:29 +0530 Subject: [PATCH 53/88] Added null changes to data --- ios/Classes/Actions/HMSSessionStoreAction.swift | 12 ++++-------- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index dd19add49..0b408c398 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -47,7 +47,7 @@ class HMSSessionStoreAction { return } - if(value is String?){ + if(value is String || value is NSNull){ result(HMSResultExtension.toDictionary(true, value)) } else{ @@ -73,16 +73,12 @@ class HMSSessionStoreAction { return } - guard let data = arguments["data"] - else { - HMSErrorLogger.returnHMSException(#function,"Data for the key - \(key) to be set in Session Store is null.","NULL ERROR",result) - return - } + let data = arguments["data"] - store.set(data, forKey: key) { value, error in + store.set(data as Any, forKey: key) { value, error in if let error = error { - HMSErrorLogger.returnHMSException(#function,"Error in setting data: \(data) for key: \(key) to the Session Store. Error: \(error.localizedDescription)","Key Error",result) + HMSErrorLogger.returnHMSException(#function,"Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)","Key Error",result) return } result(nil) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index ff2cfd95e..ab106ee1d 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -529,7 +529,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene var dict: [String: Any] = ["key": key] - if(value is String?){ + if(value is String || value is NSNull){ dict["value"] = value } else{ @@ -575,7 +575,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.getError("\(#function) Session Store is null."))) + HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) return } From 012ef8e7d33d114fd83adff7b0115672f5204e3e Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Tue, 2 May 2023 16:57:00 +0530 Subject: [PATCH 54/88] Audio play fix (#1300) * Added audio mode ui * Fixed iOS file playback * Merged music mode branch --- .../app_dialogs/audio_mode_select_dialog.dart | 11 +++--- example/lib/common/util/utility_function.dart | 6 ++-- example/lib/hms_sdk_interactor.dart | 2 +- .../lib/home_screen/user_detail_screen.dart | 11 +++--- example/lib/meeting/meeting_store.dart | 12 ++++--- .../HMSAudioFilePlayerNodeExtension.swift | 36 +++++++++++++------ ios/Classes/SwiftHmssdkFlutterPlugin.swift | 6 ++-- lib/src/enum/hms_audio_mode.dart | 2 +- lib/src/model/hms_audio_file_player_node.dart | 32 ++++++++--------- lib/src/model/hms_audio_track_setting.dart | 16 +++++---- lib/src/model/hms_camera_controls.dart | 4 +-- 11 files changed, 78 insertions(+), 60 deletions(-) diff --git a/example/lib/common/app_dialogs/audio_mode_select_dialog.dart b/example/lib/common/app_dialogs/audio_mode_select_dialog.dart index 9522a1333..4a95f3d84 100644 --- a/example/lib/common/app_dialogs/audio_mode_select_dialog.dart +++ b/example/lib/common/app_dialogs/audio_mode_select_dialog.dart @@ -15,11 +15,11 @@ class AudioModeSelectDialog extends StatefulWidget { final HMSAudioMode currentAudioMode; final Function(HMSAudioMode) changeAudioMode; - AudioModeSelectDialog({required this.currentAudioMode,required this.changeAudioMode}); + AudioModeSelectDialog( + {required this.currentAudioMode, required this.changeAudioMode}); @override - _AudioModeSelectDialogState createState() => - _AudioModeSelectDialogState(); + _AudioModeSelectDialogState createState() => _AudioModeSelectDialogState(); } class _AudioModeSelectDialogState extends State { @@ -136,10 +136,7 @@ class _AudioModeSelectDialogState extends State { Utilities.showToast("Please select audioMode"), } else - { - Navigator.pop(context), - widget.changeAudioMode(valueChoose!) - } + {Navigator.pop(context), widget.changeAudioMode(valueChoose!)} }, child: Padding( padding: diff --git a/example/lib/common/util/utility_function.dart b/example/lib/common/util/utility_function.dart index 8846ccc5b..d11b58386 100644 --- a/example/lib/common/util/utility_function.dart +++ b/example/lib/common/util/utility_function.dart @@ -227,14 +227,14 @@ class Utilities { required bool joinWithMutedVideo, required bool joinWithMutedAudio, required bool isSoftwareDecoderDisabled, - required HMSAudioMode audioMode}) { + HMSAudioMode? audioMode}) { return isAudioMixerDisabled ? HMSTrackSetting( audioTrackSetting: HMSAudioTrackSetting( trackInitialState: joinWithMutedAudio ? HMSTrackInitState.MUTED : HMSTrackInitState.UNMUTED, - audioMode: audioMode), + audioMode: audioMode), videoTrackSetting: HMSVideoTrackSetting( trackInitialState: joinWithMutedVideo ? HMSTrackInitState.MUTED @@ -250,7 +250,7 @@ class Utilities { trackInitialState: joinWithMutedAudio ? HMSTrackInitState.MUTED : HMSTrackInitState.UNMUTED, - audioMode: audioMode), + audioMode: audioMode), videoTrackSetting: HMSVideoTrackSetting( trackInitialState: joinWithMutedVideo ? HMSTrackInitState.MUTED diff --git a/example/lib/hms_sdk_interactor.dart b/example/lib/hms_sdk_interactor.dart index 4e4c4368b..d2fb7790c 100644 --- a/example/lib/hms_sdk_interactor.dart +++ b/example/lib/hms_sdk_interactor.dart @@ -37,7 +37,7 @@ class HMSSDKInteractor { hmsLogSettings: hmsLogSettings, hmsTrackSetting: trackSetting); } - + Future build() async { await hmsSDK.build(); } diff --git a/example/lib/home_screen/user_detail_screen.dart b/example/lib/home_screen/user_detail_screen.dart index 9b9cf47d3..0b11fdfe1 100644 --- a/example/lib/home_screen/user_detail_screen.dart +++ b/example/lib/home_screen/user_detail_screen.dart @@ -90,12 +90,11 @@ class _UserDetailScreenState extends State { int audioModeIndex = await Utilities.getIntData(key: 'audio-mode'); if (res) { await setHMSSDKInteractor( - joinWithMutedAudio: joinWithMutedAudio, - joinWithMutedVideo: joinWithMutedVideo, - isSoftwareDecoderDisabled: isSoftwareDecoderDisabled, - isAudioMixerDisabled: isAudioMixerDisabled, - audioMode: HMSAudioMode.values[audioModeIndex] - ); + joinWithMutedAudio: joinWithMutedAudio, + joinWithMutedVideo: joinWithMutedVideo, + isSoftwareDecoderDisabled: isSoftwareDecoderDisabled, + isAudioMixerDisabled: isAudioMixerDisabled, + audioMode: HMSAudioMode.values[audioModeIndex]); if (!skipPreview) { _previewStore = PreviewStore(hmsSDKInteractor: _hmsSDKInteractor); diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index 562c5876d..1c5df1624 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -1408,15 +1408,17 @@ class MeetingStore extends ChangeNotifier HMSAudioFilePlayerNode("audioFilePlayerNode"); HMSMicNode micNode = HMSMicNode(); - void playAudioIos(String url) { - audioFilePlayerNode.play(fileUrl: url); + void playAudioIos(String url) async { + HMSException? exception = await audioFilePlayerNode.play(fileUrl: url); + if (exception != null) { + Utilities.showToast(exception.description, time: 5); + } isPlayerRunningIos(); } Future isPlayerRunningIos() async { - bool isPlaying = await audioFilePlayerNode.isPlaying(); - isAudioShareStarted = isPlaying; - return isPlaying; + isAudioShareStarted = await audioFilePlayerNode.isPlaying(); + return isAudioShareStarted; } void stopAudioIos() { diff --git a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift index e83ba062c..6ecc82c0e 100644 --- a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift +++ b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift @@ -11,48 +11,64 @@ import HMSSDK class HMSAudioFilePlayerNodeExtension { static func play(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { - do { - try playerNode.play(fileUrl: URL(string: call["file_url"] as! String)!, loops: call["loops"] as? Bool ?? false, interrupts: call["interrupts"] as? Bool ?? false) + guard let fileURL = call["file_url"] as? String else{ + HMSErrorLogger.returnArgumentsError(errorMessage: "Invalid file") + HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) + return + } + guard let url = URL(string: fileURL) else{ + HMSErrorLogger.returnArgumentsError(errorMessage: "File URL is invalid") + HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) + return + } + do{ + try + playerNode.play(fileUrl: url, loops: call["loops"] as? Bool ?? false, interrupts: call["interrupts"] as? Bool ?? false) + result(HMSResultExtension.toDictionary(true,nil)) } catch { - result(HMSErrorExtension.toDictionary(error)) + result(HMSResultExtension.toDictionary(false,HMSErrorExtension.toDictionary(error))) } } - static func pause( _ playerNode: HMSAudioFilePlayerNode) { + static func pause( _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { playerNode.pause() + result(HMSResultExtension.toDictionary(true,nil)) } static func resume( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { do { try playerNode.resume() + result(HMSResultExtension.toDictionary(true,nil)) } catch { - result(HMSErrorExtension.toDictionary(error)) + result(HMSResultExtension.toDictionary(false,HMSErrorExtension.toDictionary(error))) } } - static func stop( _ playerNode: HMSAudioFilePlayerNode) { + static func stop( _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { playerNode.stop() + result(HMSResultExtension.toDictionary(true,nil)) } - static func setVolume(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode) { + static func setVolume(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { playerNode.volume = Float(call["volume"] as! Double) + result(HMSResultExtension.toDictionary(true,nil)) } static func isPlaying(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["is_playing"] = playerNode.isPlaying - result(dict) + result(HMSResultExtension.toDictionary(true,dict)) } static func currentDuration(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["current_duration"] = playerNode.currentTime - result(dict) + result(HMSResultExtension.toDictionary(true,dict)) } static func duration(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["duration"] = playerNode.duration - result(dict) + result(HMSResultExtension.toDictionary(true,dict)) } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 0bdbc470c..c5fe575fa 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -348,17 +348,17 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene HMSAudioFilePlayerNodeExtension.play(arguments, audioNode as! HMSAudioFilePlayerNode, result) break case "stop_audio_share": - HMSAudioFilePlayerNodeExtension.stop(audioNode as! HMSAudioFilePlayerNode) + HMSAudioFilePlayerNodeExtension.stop(audioNode as! HMSAudioFilePlayerNode,result) break case "pause_audio_share": - HMSAudioFilePlayerNodeExtension.pause(audioNode as! HMSAudioFilePlayerNode) + HMSAudioFilePlayerNodeExtension.pause(audioNode as! HMSAudioFilePlayerNode,result) break case "resume_audio_share": HMSAudioFilePlayerNodeExtension.resume(audioNode as! HMSAudioFilePlayerNode, result) break case "set_audio_share_volume": if arguments["name"] as! String != "mic_node" { - HMSAudioFilePlayerNodeExtension.setVolume(arguments, audioNode as! HMSAudioFilePlayerNode) + HMSAudioFilePlayerNodeExtension.setVolume(arguments, audioNode as! HMSAudioFilePlayerNode,result) } else { HMSMicNodeExtension.setVolume(arguments, audioNode as! HMSMicNode) } diff --git a/lib/src/enum/hms_audio_mode.dart b/lib/src/enum/hms_audio_mode.dart index 596f6e781..1471115f9 100644 --- a/lib/src/enum/hms_audio_mode.dart +++ b/lib/src/enum/hms_audio_mode.dart @@ -1,4 +1,4 @@ -enum HMSAudioMode { VOICE, MUSIC} +enum HMSAudioMode { VOICE, MUSIC } extension HMSAudioModeValues on HMSAudioMode { static HMSAudioMode getAudioModeFromName(String name) { diff --git a/lib/src/model/hms_audio_file_player_node.dart b/lib/src/model/hms_audio_file_player_node.dart index c7fcecc78..ba6f62e05 100644 --- a/lib/src/model/hms_audio_file_player_node.dart +++ b/lib/src/model/hms_audio_file_player_node.dart @@ -45,18 +45,18 @@ class HMSAudioFilePlayerNode extends HMSAudioNode { "loops": loop, "interrupts": interrupts }); - if (result == null) { + if (result["success"]) { return null; } else { - return HMSException.fromMap(result["error"]); + return HMSException.fromMap(result["data"]["error"]); } } ///The [pause] function on [HMSAudioFilePlayerNode] to pause a file on a local device in a meeting room. /// ///Refer [Audio sharing in iOS guide here](https://www.100ms.live/docs/flutter/v2/features/audio_sharing#i-os-setup) - void pause() { - PlatformService.invokeMethod(PlatformMethod.pauseAudioShare, + Future pause() async { + await PlatformService.invokeMethod(PlatformMethod.pauseAudioShare, arguments: {"name": methodName}); } @@ -64,18 +64,18 @@ class HMSAudioFilePlayerNode extends HMSAudioNode { var result = await PlatformService.invokeMethod( PlatformMethod.resumeAudioShare, arguments: {"name": methodName}); - if (result == null) { + if (result["success"]) { return null; } else { - return HMSException.fromMap(result["error"]); + return HMSException.fromMap(result["data"]["error"]); } } ///The [stop] function on [HMSAudioFilePlayerNode] to stop a file on a local device in a meeting room. /// ///Refer [Audio sharing in iOS guide here](https://www.100ms.live/docs/flutter/v2/features/audio_sharing#i-os-setup) - void stop() { - PlatformService.invokeMethod(PlatformMethod.stopAudioShare, + Future stop() async { + await PlatformService.invokeMethod(PlatformMethod.stopAudioShare, arguments: {"name": methodName}); } @@ -86,8 +86,8 @@ class HMSAudioFilePlayerNode extends HMSAudioNode { var result = await PlatformService.invokeMethod( PlatformMethod.audioSharePlaying, arguments: {"name": methodName}); - if (result != null) { - return result["is_playing"]; + if (result["success"]) { + return result["data"]["is_playing"]; } return false; } @@ -95,12 +95,12 @@ class HMSAudioFilePlayerNode extends HMSAudioNode { ///The [currentDuration] function on [HMSAudioFilePlayerNode] will return the current duration of audio shared. /// ///Refer [Audio sharing in iOS guide here](https://www.100ms.live/docs/flutter/v2/features/audio_sharing#i-os-setup) - Future currentDuration() async { + Future currentDuration() async { var result = await PlatformService.invokeMethod( PlatformMethod.audioShareCurrentTime, arguments: {"name": methodName}); - if (result != null) { - return result["current_duration"]; + if (result["success"]) { + return result["data"]["current_duration"]; } return null; } @@ -108,12 +108,12 @@ class HMSAudioFilePlayerNode extends HMSAudioNode { ///The [duration] function on [HMSAudioFilePlayerNode] will return the total duration of audio shared. /// ///Refer [Audio sharing in iOS guide here](https://www.100ms.live/docs/flutter/v2/features/audio_sharing#i-os-setup) - Future duration() async { + Future duration() async { var result = await PlatformService.invokeMethod( PlatformMethod.audioShareDuration, arguments: {"name": methodName}); - if (result != null) { - return result["duration"]; + if (result["success"]) { + return result["data"]["duration"]; } return null; } diff --git a/lib/src/model/hms_audio_track_setting.dart b/lib/src/model/hms_audio_track_setting.dart index 63c1f72a2..6b85a71d2 100644 --- a/lib/src/model/hms_audio_track_setting.dart +++ b/lib/src/model/hms_audio_track_setting.dart @@ -21,13 +21,13 @@ class HMSAudioTrackSetting { final HMSTrackInitState? trackInitialState; ///[audioMode] property to set the audio mode of audio track i.e voice or music mode - final HMSAudioMode audioMode; + final HMSAudioMode? audioMode; HMSAudioTrackSetting( {this.useHardwareAcousticEchoCanceler, this.audioSource, this.trackInitialState = HMSTrackInitState.UNMUTED, - this.audioMode = HMSAudioMode.VOICE}); + this.audioMode}); factory HMSAudioTrackSetting.fromMap(Map map) { List nodeList = []; @@ -44,8 +44,10 @@ class HMSAudioTrackSetting { audioMixerSource = HMSAudioMixerSource(node: nodeList); } HMSAudioMixerSource(node: nodeList); - - HMSAudioMode audioMode = HMSAudioModeValues.getAudioModeFromName(map["audio_mode"]); + HMSAudioMode? audioMode; + if ((map.containsKey("audio_mode")) && (map["audio_mode"] != null)) { + audioMode = HMSAudioModeValues.getAudioModeFromName(map["audio_mode"]); + } return HMSAudioTrackSetting( useHardwareAcousticEchoCanceler: map['user_hardware_acoustic_echo_canceler'] ?? null, @@ -54,7 +56,7 @@ class HMSAudioTrackSetting { ? HMSTrackInitStateValue.getHMSTrackInitStateFromName( map['track_initial_state']) : HMSTrackInitState.UNMUTED, - audioMode: audioMode); + audioMode: audioMode); } Map toMap() { @@ -64,7 +66,9 @@ class HMSAudioTrackSetting { 'track_initial_state': HMSTrackInitStateValue.getValuefromHMSTrackInitState( trackInitialState), - 'audio_mode': HMSAudioModeValues.getNameFromHMSAudioMode(audioMode) + 'audio_mode': (audioMode != null) + ? HMSAudioModeValues.getNameFromHMSAudioMode(audioMode!) + : null }; } } diff --git a/lib/src/model/hms_camera_controls.dart b/lib/src/model/hms_camera_controls.dart index 431296ee2..ed08cf467 100644 --- a/lib/src/model/hms_camera_controls.dart +++ b/lib/src/model/hms_camera_controls.dart @@ -10,7 +10,7 @@ class HMSCameraControls { ///resolution. /// /// **Parameters**: - /// + /// /// **withFlash** - parameter turns flash ON if set to TRUE. Default value is FALSE /// ///Note: [withFlash] only works if current facing camera supports flash. If it doesn't support flash @@ -32,7 +32,7 @@ class HMSCameraControls { ///[isFlashSupported] is used to check whether the current facing camera supports /// flash or not. - /// + /// ///Refer: Read more about isFlashSupported [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/configure-your-device/camera/camera-controls#check-if-flash-feature-is-available) static Future isFlashSupported() async { var result = From 86674192b015a6436c99c067c72987b1fe12d4ac Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 2 May 2023 18:39:09 +0530 Subject: [PATCH 55/88] =?UTF-8?q?released=20sample=20app=20version=201.4.9?= =?UTF-8?q?7=20(232)=20=F0=9F=8D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 4 ++-- example/ios/Runner/Info.plist | 4 ++-- ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 4d4188d57..3f3d6d39c 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 230 - versionName "1.4.95" + versionCode 231 + versionName "1.4.96" } signingConfigs { diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 421fe56f7..e584de8ff 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.95 + 1.4.97 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 230 + 232 ITSAppUsesNonExemptEncryption LSApplicationCategoryType diff --git a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift index 6ecc82c0e..02817a65e 100644 --- a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift +++ b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift @@ -12,12 +12,12 @@ class HMSAudioFilePlayerNodeExtension { static func play(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { guard let fileURL = call["file_url"] as? String else{ - HMSErrorLogger.returnArgumentsError(errorMessage: "Invalid file") + HMSErrorLogger.returnArgumentsError("Invalid file") HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) return } guard let url = URL(string: fileURL) else{ - HMSErrorLogger.returnArgumentsError(errorMessage: "File URL is invalid") + HMSErrorLogger.returnArgumentsError("File URL is invalid") HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) return } From 19723649376a8d65dd1db1601c4f59c61d7baf79 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Tue, 2 May 2023 18:40:12 +0530 Subject: [PATCH 56/88] Fixed session store on iOS (#1301) --- ios/Classes/Actions/HMSSessionStoreAction.swift | 2 +- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index 0b408c398..6cce9a306 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -47,7 +47,7 @@ class HMSSessionStoreAction { return } - if(value is String || value is NSNull){ + if(value is String? || value is NSNull){ result(HMSResultExtension.toDictionary(true, value)) } else{ diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 0b4573f53..13376c136 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -529,7 +529,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene var dict: [String: Any] = ["key": key] - if(value is String || value is NSNull){ + if(value is String? || value is NSNull){ dict["value"] = value } else{ From e006f186308e31b7405fd5487c6e59026defc649 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Tue, 2 May 2023 22:34:28 +0530 Subject: [PATCH 57/88] Added fix for spotlight while joining the room (#1302) --- example/lib/meeting/meeting_store.dart | 12 ++++++++++-- ios/Classes/Actions/HMSSessionStoreAction.swift | 2 +- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index 628a1fb96..c63a8e947 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -190,10 +190,14 @@ class MeetingStore extends ChangeNotifier bool isFlashOn = false; + ///These variables are used in session metadata implementation ************************************************* + HMSSessionStore? _hmsSessionStore; PeerTrackNode? spotLightPeer; + String? spotlightMetadata; + Future join(String userName, String roomUrl, {HMSConfig? roomConfig}) async { //If roomConfig is null then only we call the methods to get the authToken @@ -694,6 +698,10 @@ class MeetingStore extends ChangeNotifier uid: peer.peerId + "mainVideo", stats: RTCStats(), track: track as HMSVideoTrack)); + if (spotlightMetadata == track.trackId) { + setPeerToSpotlight(spotlightMetadata); + spotlightMetadata = null; + } notifyListeners(); return; } @@ -1003,9 +1011,9 @@ class MeetingStore extends ChangeNotifier } else if (Platform.isIOS) { HMSIOSPIPController.destroy(); } + _hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeListener: this); _hmsSDKInteractor.removeHMSLogger(); _hmsSDKInteractor.destroy(); - _hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeListener: this); _hmsSessionStore = null; peerTracks.clear(); isRoomEnded = true; @@ -1357,7 +1365,7 @@ class MeetingStore extends ChangeNotifier spotLightPeer = peerTracks[index]; changePinTileStatus(peerTracks[index]); } else { - Utilities.showToast("Failed to set spotlight for the peer"); + spotlightMetadata = value; } } notifyListeners(); diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index 6cce9a306..49304354f 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -53,7 +53,7 @@ class HMSSessionStoreAction { else{ HMSErrorLogger.returnHMSException(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error",result) } - + } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 13376c136..d6a968a2c 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -617,6 +617,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene hmsSessionStoreObserver in sessionStore?.removeObserver(hmsSessionStoreObserver.observer) } + sessionStoreCleanup() } private func sessionStoreCleanup() { @@ -1485,6 +1486,5 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene private func performCleanupOnLeavingRoom() { destroyPIPController() removeAllKeyChangeListener() - sessionStoreCleanup() } } From 3cc9dae8d0bb2368a031975dbfa079ddc89ac22a Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Tue, 2 May 2023 22:36:23 +0530 Subject: [PATCH 58/88] 1259/session store android (#1276) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added new sessions store api's * Fixed comments * Added comments in code * Updated implementation * updated Example app Changelog * released sample app version 1.4.95 (230) 🍀 * updated Podfile * Updated implementation * Updated version * Updated version --------- Co-authored-by: Yogesh Singh --- android/build.gradle | 4 +- .../hmssdk_flutter/HMSKeyChangeObserver.kt | 5 + .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 123 +++++++++++++++++- .../methods/HMSSessionMetadataAction.kt | 11 +- .../methods/HMSSessionStoreAction.kt | 81 ++++++++++++ example/ExampleAppChangelog.txt | 14 ++ example/android/app/build.gradle | 4 +- example/assets/icons/spotlight.svg | 3 + example/ios/Podfile.lock | 2 +- example/ios/Runner/Info.plist | 4 +- .../app_dialogs/local_peer_tile_dialog.dart | 32 ++++- .../app_dialogs/remote_peer_tile_dialog.dart | 32 ++++- .../bottom_sheets/chat_bottom_sheet.dart | 9 +- .../lib/common/peer_widgets/more_option.dart | 41 ++++++ .../lib/common/widgets/message_container.dart | 6 +- example/lib/enum/session_store_key.dart | 38 ++++++ example/lib/meeting/meeting_page.dart | 6 +- example/lib/meeting/meeting_store.dart | 89 ++++++++++++- lib/assets/sdk-versions.json | 2 +- lib/hmssdk_flutter.dart | 2 + lib/src/common/platform_methods.dart | 22 +++- .../hms_action_result_listener_method.dart | 2 + .../enum/hms_key_change_listener_method.dart | 13 ++ lib/src/enum/hms_update_listener_method.dart | 3 + lib/src/hmssdk.dart | 2 + lib/src/model/hms_key_change_listener.dart | 17 +++ lib/src/model/hms_key_change_observer.dart | 8 ++ lib/src/model/hms_session_store.dart | 97 ++++++++++++++ lib/src/model/hms_update_listener.dart | 6 + lib/src/model/platform_method_response.dart | 12 ++ lib/src/service/platform_service.dart | 68 ++++++++++ 31 files changed, 730 insertions(+), 28 deletions(-) create mode 100644 android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt create mode 100644 android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt create mode 100644 example/assets/icons/spotlight.svg create mode 100644 example/lib/enum/session_store_key.dart create mode 100644 lib/src/enum/hms_key_change_listener_method.dart create mode 100644 lib/src/model/hms_key_change_listener.dart create mode 100644 lib/src/model/hms_key_change_observer.dart create mode 100644 lib/src/model/hms_session_store.dart diff --git a/android/build.gradle b/android/build.gradle index 68a1da0c5..d1eb8c136 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -40,8 +40,10 @@ android { } } +def hmsVersion = "an722-SNAPSHOT" + dependencies { - implementation "live.100ms:android-sdk:${sdkVersions['android']}" + implementation "com.github.100mslive.android-sdk:lib:$hmsVersion" implementation "live.100ms:video-view:${sdkVersions['android']}" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0' diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt new file mode 100644 index 000000000..3759e3d59 --- /dev/null +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt @@ -0,0 +1,5 @@ +package live.hms.hmssdk_flutter + +import live.hms.video.sessionstore.HMSKeyChangeListener + +class HMSKeyChangeObserver(val uid: String,val keyChangeListener: HMSKeyChangeListener) {} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index 902c0255d..5b3c0e72f 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -21,10 +21,7 @@ import io.flutter.plugin.common.MethodChannel.Result import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import live.hms.hmssdk_flutter.methods.HMSCameraControlsAction -import live.hms.hmssdk_flutter.methods.HMSPipAction -import live.hms.hmssdk_flutter.methods.HMSRemoteVideoTrackAction -import live.hms.hmssdk_flutter.methods.HMSSessionMetadataAction +import live.hms.hmssdk_flutter.methods.* import live.hms.hmssdk_flutter.views.HMSVideoViewFactory import live.hms.video.audio.HMSAudioManager.* import live.hms.video.connection.stats.* @@ -39,6 +36,8 @@ import live.hms.video.sdk.models.enums.HMSRoomUpdate import live.hms.video.sdk.models.enums.HMSTrackUpdate import live.hms.video.sdk.models.role.HMSRole import live.hms.video.sdk.models.trackchangerequest.HMSChangeTrackStateRequest +import live.hms.video.sessionstore.HMSKeyChangeListener +import live.hms.video.sessionstore.HmsSessionStore import live.hms.video.signal.init.TokenRequest import live.hms.video.signal.init.TokenRequestOptions import live.hms.video.utils.HMSLogger @@ -56,15 +55,19 @@ class HmssdkFlutterPlugin : private var previewChannel: EventChannel? = null private var logsEventChannel: EventChannel? = null private var rtcStatsChannel: EventChannel? = null + private var sessionStoreChannel : EventChannel? = null private var eventSink: EventChannel.EventSink? = null private var previewSink: EventChannel.EventSink? = null private var logsSink: EventChannel.EventSink? = null private var rtcSink: EventChannel.EventSink? = null + private var sessionStoreSink: EventChannel.EventSink? = null private lateinit var activity: Activity var hmssdk: HMSSDK? = null private lateinit var hmsVideoFactory: HMSVideoViewFactory private var requestChange: HMSRoleChangeRequest? = null var hmssdkFlutterPlugin: HmssdkFlutterPlugin? = null + private var hmsSessionStore: HmsSessionStore? = null + private var hmsKeyChangeObserverList = ArrayList() override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { if (hmssdkFlutterPlugin == null) { @@ -80,11 +83,15 @@ class HmssdkFlutterPlugin : this.rtcStatsChannel = EventChannel(flutterPluginBinding.binaryMessenger, "rtc_event_channel") + this.sessionStoreChannel = + EventChannel(flutterPluginBinding.binaryMessenger,"session_event_channel") + this.meetingEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Meeting event channel not found") this.channel?.setMethodCallHandler(this) ?: Log.e("Channel Error", "Event channel not found") this.previewChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Preview channel not found") this.logsEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Logs event channel not found") this.rtcStatsChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "RTC Stats channel not found") + this.sessionStoreChannel?.setStreamHandler(this) ?: Log.e("Channel Error","Session Store channel not found") this.hmsVideoFactory = HMSVideoViewFactory(this) flutterPluginBinding.platformViewRegistry.registerViewFactory( @@ -195,6 +202,15 @@ class HmssdkFlutterPlugin : "is_tap_to_focus_supported", "capture_image_at_max_supported_resolution", "is_zoom_supported", "is_flash_supported", "toggle_flash" -> { HMSCameraControlsAction.cameraControlsAction(call, result, hmssdk!!, activity.applicationContext) } + "get_session_metadata_for_key", "set_session_metadata_for_key" -> { + HMSSessionStoreAction.sessionStoreActions(call,result,hmsSessionStore) + } + "add_key_change_listener"-> { + addKeyChangeListener(call,result) + } + "remove_key_change_listener" -> { + removeKeyChangeListener(call) + } else -> { result.notImplemented() } @@ -368,10 +384,12 @@ class HmssdkFlutterPlugin : previewChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Preview channel not found") logsEventChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Logs event channel not found") rtcStatsChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "RTC Stats channel not found") + sessionStoreChannel?.setStreamHandler(null)?:Log.e("Channel Error","Session Store channel not found") eventSink = null previewSink = null rtcSink = null logsSink = null + sessionStoreSink = null hmssdkFlutterPlugin = null } else { Log.e("Plugin Error", "hmssdkFlutterPlugin is null in onDetachedFromEngine") @@ -454,6 +472,7 @@ class HmssdkFlutterPlugin : private fun leave(result: Result) { hmssdk!!.leave(hmsActionResultListener = HMSCommonAction.getActionListener(result)) disposePIP() + removeAllKeyChangeListener() } private fun destroy(result: Result) { @@ -471,6 +490,8 @@ class HmssdkFlutterPlugin : this.logsSink = events } else if (nameOfEventSink == "rtc_stats") { this.rtcSink = events + } else if(nameOfEventSink == "session_store") { + this.sessionStoreSink = events } } @@ -668,6 +689,7 @@ class HmssdkFlutterPlugin : hmsActionResultListener = HMSCommonAction.getActionListener(result) ) disposePIP() + removeAllKeyChangeListener() } private fun isAllowedToEndMeeting(): Boolean? { @@ -851,6 +873,7 @@ class HmssdkFlutterPlugin : if (HMSPipAction.isPIPActive(activity)) { activity.moveTaskToBack(true) disposePIP() + removeAllKeyChangeListener() } if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { @@ -886,6 +909,17 @@ class HmssdkFlutterPlugin : } } } + + override fun onSessionStoreAvailable(sessionStore: HmsSessionStore) { + val args = HashMap() + args["event_name"] = "on_session_store_available" + args["data"] = null + hmsSessionStore = sessionStore + CoroutineScope(Dispatchers.Main).launch { + eventSink?.success(args) + } + } + } private val hmsPreviewListener = object : HMSPreviewListener { @@ -1182,6 +1216,87 @@ class HmssdkFlutterPlugin : } } + /** + * This method is used to add key change listener for + * keys passed while calling this method + * + * Parameters: + * - keys: List List of keys for which metadata updates need to be listened. + * - keyChangeListener: Instance of HMSKeyChangeListener to listen to the metadata changes for corresponding keys + * - hmsActionResultListener: Instance of HMSActionResultListener to notify success or failure of the method call + */ + private fun addKeyChangeListener(call: MethodCall,result: Result){ + + val keys = call.argument>("keys") ?: run { + HMSErrorLogger.returnArgumentsError("keys parameter is null") + } + + val uid = call.argument("uid")?: run { + HMSErrorLogger.returnArgumentsError("uid is null") + } + + uid.let { + val keyChangeListener = object : HMSKeyChangeListener { + override fun onKeyChanged(key: String, value: Any?) { + val args = HashMap() + args["event_name"] = "on_key_changed" + val newData = HashMap() + newData["key"] = key + if(value is String?){ + newData["value"] = value + } + else{ + HMSErrorLogger.logError("onKeyChanged","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + newData["value"] = null + } + newData["uid"] = uid as String + args["data"] = newData + CoroutineScope(Dispatchers.Main).launch { + sessionStoreSink?.success(args) + } + } + } + hmsKeyChangeObserverList.add(HMSKeyChangeObserver(uid as String,keyChangeListener)) + keys.let { keys as List + hmsSessionStore?.addKeyChangeListener(keys,keyChangeListener,HMSCommonAction.getActionListener(result)) + } + } + } + + /*** + * This method is used to remove the attached key change listeners + * attached using [addKeyChangeListener] method + */ + private fun removeKeyChangeListener(call: MethodCall){ + + val uid = call.argument("uid")?: run { + HMSErrorLogger.returnArgumentsError("uid is null") + } + + uid?.let { + hmsKeyChangeObserverList.forEach{ + hmsKeyChangeObserver -> + if(hmsKeyChangeObserver.uid == uid){ + hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) + hmsKeyChangeObserverList.remove(hmsKeyChangeObserver) + return + } + } + } + } + + /** + * This method removes all the key change listeners attached during the session + * This is used while cleaning the room state i.e after calling leave room, + * onRemovedFromRoom or endRoom + */ + private fun removeAllKeyChangeListener(){ + hmsKeyChangeObserverList.forEach{ + hmsKeyChangeObserver -> hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) + } + hmsKeyChangeObserverList.clear() + } + private val hmsStatsListener = object : HMSStatsObserver { override fun onRemoteVideoStats( diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt index 4c06868d0..cf01e83e2 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt @@ -6,6 +6,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import live.hms.hmssdk_flutter.HMSCommonAction +import live.hms.hmssdk_flutter.HMSErrorLogger import live.hms.hmssdk_flutter.HMSExceptionExtension import live.hms.hmssdk_flutter.HMSSessionMetadataExtension import live.hms.video.error.HMSException @@ -43,10 +44,16 @@ class HMSSessionMetadataAction { result.success(null) } - override fun onSuccess(sessionMetadata: String?) { + override fun onSuccess(sessionMetadata: Any?) { val args = HashMap() args["event_name"] = "session_metadata" - args["data"] = HMSSessionMetadataExtension.toDictionary(sessionMetadata) + if(sessionMetadata is String?){ + args["data"] = HMSSessionMetadataExtension.toDictionary(sessionMetadata) + } + else{ + HMSErrorLogger.logError("getSessionMetadata","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + args["data"] = null + } if (args["data"] != null) CoroutineScope(Dispatchers.Main).launch { result.success(args) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt new file mode 100644 index 000000000..20cfebacd --- /dev/null +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt @@ -0,0 +1,81 @@ +package live.hms.hmssdk_flutter.methods + +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel.Result +import live.hms.hmssdk_flutter.HMSCommonAction +import live.hms.hmssdk_flutter.HMSErrorLogger +import live.hms.hmssdk_flutter.HMSExceptionExtension +import live.hms.hmssdk_flutter.HMSResultExtension +import live.hms.video.error.HMSException +import live.hms.video.sdk.HMSSessionMetadataListener +import live.hms.video.sessionstore.HmsSessionStore + +class HMSSessionStoreAction { + + companion object{ + + fun sessionStoreActions(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?){ + when(call.method){ + "get_session_metadata_for_key" -> { + getSessionMetadataForKey(call,result,hmsSessionStore) + } + "set_session_metadata_for_key" -> { + setSessionMetadataForKey(call,result,hmsSessionStore) + } + } + } + + /*** + * This is used to get session metadata corresponding to the provided key + * + * If the key is null we log the error and return from method since we have the let + * block in place already + * + * This method returns [sessionMetadata] is the session metadata is available for corresponding key + */ + private fun getSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ + val key = call.argument("key") ?: run { + HMSErrorLogger.returnArgumentsError("key is null") + } + + key?.let { key as String + hmsSessionStore?.get(key,object:HMSSessionMetadataListener{ + override fun onError(error: HMSException) { + result.success(HMSResultExtension.toDictionary(false,HMSExceptionExtension.toDictionary(error))) + } + + override fun onSuccess(sessionMetadata: Any?) { + if(sessionMetadata is String?){ + result.success(HMSResultExtension.toDictionary(true,sessionMetadata)) + } + else{ + HMSErrorLogger.returnHMSException("getSessionMetadataForKey","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error",result) + } + } + }) + } + } + + /*** + * This is used to set session metadata corresponding to the provided key + * + * If the key is null we log the error and return from method since we have the let + * block in place already + * + * This method sets the [data] provided during the method call + * The completion of this method is marked by actionResultListener's [onSuccess] or [onError] callback + */ + private fun setSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ + val key = call.argument("key") ?: run { + HMSErrorLogger.returnArgumentsError("key is null") + } + + val data = call.argument("data") + + key?.let { key as String + hmsSessionStore?.set(data,key,HMSCommonAction.getActionListener(result)) + } + } + + } +} \ No newline at end of file diff --git a/example/ExampleAppChangelog.txt b/example/ExampleAppChangelog.txt index bc870e4eb..c4ef28a3f 100644 --- a/example/ExampleAppChangelog.txt +++ b/example/ExampleAppChangelog.txt @@ -1,5 +1,19 @@ Board: https://github.com/100mslive/100ms-flutter/projects/18 +- Add Session Store APIs +https://github.com/100mslive/100ms-flutter/issues/1259 + +- Add support for setting a Tile in Spotlight Mode using Session Store +https://github.com/100mslive/100ms-flutter/issues/1252 + +- Fixed Role change request popup taking time to dismiss +https://github.com/100mslive/100ms-flutter/issues/1271 + +- Fixed grid logic and audio view tile +https://github.com/100mslive/100ms-flutter/pull/1283 + +- Updated crashlytics implementation +https://github.com/100mslive/100ms-flutter/pull/1280 Flutter SDK: 1.6.0 diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index bf6d97510..d1f5f3d47 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 229 - versionName "1.4.94" + versionCode 230 + versionName "1.4.95" } signingConfigs { diff --git a/example/assets/icons/spotlight.svg b/example/assets/icons/spotlight.svg new file mode 100644 index 000000000..721b68792 --- /dev/null +++ b/example/assets/icons/spotlight.svg @@ -0,0 +1,3 @@ + + + diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 4a87c7abe..44f06daca 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -402,6 +402,6 @@ SPEC CHECKSUMS: url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f -PODFILE CHECKSUM: 576bcfbc69c41c8e1c7e04a8ea0da7225b4b2db0 +PODFILE CHECKSUM: be0979b1605a070d72f7b3642279b7f60a395416 COCOAPODS: 1.12.0 diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 5df5d3760..421fe56f7 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.94 + 1.4.95 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 229 + 230 ITSAppUsesNonExemptEncryption LSApplicationCategoryType diff --git a/example/lib/common/app_dialogs/local_peer_tile_dialog.dart b/example/lib/common/app_dialogs/local_peer_tile_dialog.dart index 1efe97fe2..2b0f5f81d 100644 --- a/example/lib/common/app_dialogs/local_peer_tile_dialog.dart +++ b/example/lib/common/app_dialogs/local_peer_tile_dialog.dart @@ -17,6 +17,8 @@ class LocalPeerTileDialog extends StatefulWidget { final Function()? captureSnapshot; final Function()? localImageCapture; final Function()? toggleFlash; + final Function() setOnSpotlight; + final bool isSpotlightedPeer; const LocalPeerTileDialog( {required this.isAudioMode, this.isVideoOn = false, @@ -28,7 +30,9 @@ class LocalPeerTileDialog extends StatefulWidget { this.captureSnapshot, this.isCaptureSnapshot, this.localImageCapture, - this.toggleFlash}); + this.toggleFlash, + required this.setOnSpotlight, + this.isSpotlightedPeer = false}); @override _LocalPeerTileDialogState createState() => _LocalPeerTileDialogState(); @@ -193,6 +197,32 @@ class _LocalPeerTileDialogState extends State { ), ), ), + GestureDetector( + onTap: () { + Navigator.pop(context); + widget.setOnSpotlight(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Row( + children: [ + SvgPicture.asset( + "assets/icons/spotlight.svg", + color: iconColor, + ), + SizedBox( + width: 16, + ), + Text( + widget.isSpotlightedPeer + ? "Remove From Spotlight" + : "Spotlight Tile", + style: GoogleFonts.inter(color: iconColor), + ) + ], + ), + ), + ), ], ), ), diff --git a/example/lib/common/app_dialogs/remote_peer_tile_dialog.dart b/example/lib/common/app_dialogs/remote_peer_tile_dialog.dart index 031999c44..e6b92744a 100644 --- a/example/lib/common/app_dialogs/remote_peer_tile_dialog.dart +++ b/example/lib/common/app_dialogs/remote_peer_tile_dialog.dart @@ -15,6 +15,7 @@ class RemotePeerTileDialog extends StatefulWidget { final bool simulcast; final bool pinTile; final bool? isCaptureSnapshot; + final bool isSpotlightedPeer; final Function(bool, bool) changeVideoTrack; final Function(bool, bool) changeAudioTrack; final Function() removePeer; @@ -22,6 +23,7 @@ class RemotePeerTileDialog extends StatefulWidget { final Function() changeLayer; final Function() changePinTileStatus; final Function()? captureSnapshot; + final Function() setOnSpotlight; const RemotePeerTileDialog( {required this.isVideoMuted, required this.isAudioMuted, @@ -39,7 +41,9 @@ class RemotePeerTileDialog extends StatefulWidget { required this.pinTile, required this.changePinTileStatus, this.isCaptureSnapshot, - this.captureSnapshot}); + this.captureSnapshot, + required this.setOnSpotlight, + this.isSpotlightedPeer = false}); @override _RemotePeerTileDialogState createState() => _RemotePeerTileDialogState(); @@ -243,6 +247,32 @@ class _RemotePeerTileDialogState extends State { ), ), ), + GestureDetector( + onTap: () { + Navigator.pop(context); + widget.setOnSpotlight(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Row( + children: [ + SvgPicture.asset( + "assets/icons/spotlight.svg", + color: iconColor, + ), + SizedBox( + width: 16, + ), + Text( + widget.isSpotlightedPeer + ? "Remove From Spotlight" + : "Spotlight Tile", + style: GoogleFonts.inter(color: iconColor), + ) + ], + ), + ), + ), ], ), ), diff --git a/example/lib/common/bottom_sheets/chat_bottom_sheet.dart b/example/lib/common/bottom_sheets/chat_bottom_sheet.dart index 012ee1787..e0880f64d 100644 --- a/example/lib/common/bottom_sheets/chat_bottom_sheet.dart +++ b/example/lib/common/bottom_sheets/chat_bottom_sheet.dart @@ -9,6 +9,7 @@ import 'package:hmssdk_flutter_example/common/util/app_color.dart'; import 'package:hmssdk_flutter_example/common/util/utility_function.dart'; import 'package:hmssdk_flutter_example/common/widgets/hms_dropdown.dart'; import 'package:hmssdk_flutter_example/common/widgets/message_container.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:tuple/tuple.dart'; @@ -366,9 +367,11 @@ class _ChatBottomSheetState extends State { ), GestureDetector( onTap: () { - context - .read() - .setSessionMetadata(null); + context.read().setSessionMetadata( + key: SessionStoreKeyValues + .getNameFromMethod(SessionStoreKey + .PINNED_MESSAGE_SESSION_KEY), + metadata: null); }, child: SvgPicture.asset( "assets/icons/close.svg")) diff --git a/example/lib/common/peer_widgets/more_option.dart b/example/lib/common/peer_widgets/more_option.dart index bbd45956f..d410c0164 100644 --- a/example/lib/common/peer_widgets/more_option.dart +++ b/example/lib/common/peer_widgets/more_option.dart @@ -11,6 +11,7 @@ import 'package:hmssdk_flutter_example/common/app_dialogs/remote_peer_tile_dialo import 'package:hmssdk_flutter_example/common/util/app_color.dart'; import 'package:hmssdk_flutter_example/common/util/utility_components.dart'; import 'package:hmssdk_flutter_example/common/util/utility_function.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:hmssdk_flutter_example/meeting/meeting_store.dart'; import 'package:hmssdk_flutter_example/model/peer_track_node.dart'; import 'package:image_gallery_saver/image_gallery_saver.dart'; @@ -58,6 +59,26 @@ class MoreOption extends StatelessWidget { _meetingStore.changeTrackState( peerTrackNode.audioTrack!, mute); }, + isSpotlightedPeer: + context.read().spotLightPeer?.uid == + peerTrackNode.uid, + setOnSpotlight: () { + if (context.read().spotLightPeer?.uid == + peerTrackNode.uid) { + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: null); + return; + } + String? metadata = (peerTrackNode.track == null) + ? peerTrackNode.audioTrack?.trackId + : peerTrackNode.track?.trackId; + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: metadata); + }, removePeer: () async { Navigator.pop(context); var peer = await _meetingStore.getPeer( @@ -245,6 +266,26 @@ class MoreOption extends StatelessWidget { toggleFlash: () { context.read().toggleFlash(); }, + isSpotlightedPeer: + context.read().spotLightPeer?.uid == + peerTrackNode.uid, + setOnSpotlight: () { + if (context.read().spotLightPeer?.uid == + peerTrackNode.uid) { + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: null); + return; + } + String? metadata = (peerTrackNode.track == null) + ? peerTrackNode.audioTrack?.trackId + : peerTrackNode.track?.trackId; + _meetingStore.setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.SPOTLIGHT), + metadata: metadata); + }, changeRole: () { Navigator.pop(context); showDialog( diff --git a/example/lib/common/widgets/message_container.dart b/example/lib/common/widgets/message_container.dart index c7e31b9f0..a529d05c9 100644 --- a/example/lib/common/widgets/message_container.dart +++ b/example/lib/common/widgets/message_container.dart @@ -5,6 +5,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hmssdk_flutter_example/common/widgets/subtitle_text.dart'; import 'package:hmssdk_flutter_example/common/widgets/title_text.dart'; import 'package:hmssdk_flutter_example/common/util/app_color.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../meeting/meeting_store.dart'; @@ -187,7 +188,10 @@ class MessageContainer extends StatelessWidget { child: Text('Pin Message'), onTap: () => context .read() - .setSessionMetadata(senderName! + ": " + message), + .setSessionMetadata( + key: SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey.PINNED_MESSAGE_SESSION_KEY), + metadata: senderName! + ": " + message), ); }); }, diff --git a/example/lib/enum/session_store_key.dart b/example/lib/enum/session_store_key.dart new file mode 100644 index 000000000..a6d3de343 --- /dev/null +++ b/example/lib/enum/session_store_key.dart @@ -0,0 +1,38 @@ +//Enum to store the session metadata keys +// PINNED_MESSAGE_SESSION_KEY: for pinning messages +// SPOTLIGHT: for adding spotlight feature in application +enum SessionStoreKey { PINNED_MESSAGE_SESSION_KEY, SPOTLIGHT, unknown } + +extension SessionStoreKeyValues on SessionStoreKey { + static String getNameFromMethod(SessionStoreKey method) { + switch (method) { + case SessionStoreKey.PINNED_MESSAGE_SESSION_KEY: + return "pinnedMessage"; + case SessionStoreKey.SPOTLIGHT: + return "spotlight"; + default: + return ""; + } + } + + static SessionStoreKey getMethodFromName(String key) { + switch (key) { + case "pinnedMessage": + return SessionStoreKey.PINNED_MESSAGE_SESSION_KEY; + case "spotlight": + return SessionStoreKey.SPOTLIGHT; + default: + return SessionStoreKey.unknown; + } + } + + static List getSessionStoreKeys() { + List _keys = []; + SessionStoreKey.values.forEach((key) { + if (key != SessionStoreKey.unknown) { + _keys.add(getNameFromMethod(key)); + } + }); + return _keys; + } +} diff --git a/example/lib/meeting/meeting_page.dart b/example/lib/meeting/meeting_page.dart index 6495dc091..6d8b52858 100644 --- a/example/lib/meeting/meeting_page.dart +++ b/example/lib/meeting/meeting_page.dart @@ -11,6 +11,7 @@ import 'package:hmssdk_flutter_example/common/widgets/hms_embedded_button.dart'; import 'package:hmssdk_flutter_example/common/widgets/stream_timer.dart'; import 'package:hmssdk_flutter_example/common/widgets/subtitle_text.dart'; import 'package:hmssdk_flutter_example/common/widgets/title_text.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:hmssdk_flutter_example/meeting_modes/full_screen_mode.dart'; import 'package:hmssdk_flutter_example/meeting_modes/audio_mode.dart'; import 'package:hmssdk_flutter_example/meeting_modes/hero_mode.dart'; @@ -709,7 +710,10 @@ class _MeetingPageState extends State { context .read< MeetingStore>() - .getSessionMetadata(), + .getSessionMetadata( + SessionStoreKeyValues.getNameFromMethod( + SessionStoreKey + .PINNED_MESSAGE_SESSION_KEY)), context .read< MeetingStore>() diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index 1c5df1624..628a1fb96 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -10,6 +10,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_foreground_task/flutter_foreground_task.dart'; import 'package:hmssdk_flutter_example/common/util/log_writer.dart'; import 'package:hmssdk_flutter_example/app_secrets.dart'; +import 'package:hmssdk_flutter_example/enum/session_store_key.dart'; import 'package:hmssdk_flutter_example/service/constant.dart'; import 'package:hmssdk_flutter_example/common/widgets/title_text.dart'; import 'package:hmssdk_flutter_example/common/util/app_color.dart'; @@ -39,7 +40,8 @@ class MeetingStore extends ChangeNotifier HMSUpdateListener, HMSActionResultListener, HMSStatsListener, - HMSLogListener { + HMSLogListener, + HMSKeyChangeListener { late HMSSDKInteractor _hmsSDKInteractor; MeetingStore({required HMSSDKInteractor hmsSDKInteractor}) { @@ -188,6 +190,10 @@ class MeetingStore extends ChangeNotifier bool isFlashOn = false; + HMSSessionStore? _hmsSessionStore; + + PeerTrackNode? spotLightPeer; + Future join(String userName, String roomUrl, {HMSConfig? roomConfig}) async { //If roomConfig is null then only we call the methods to get the authToken @@ -708,7 +714,6 @@ class MeetingStore extends ChangeNotifier log("onMessage-> sender: ${message.sender} message: ${message.message} time: ${message.time}, type: ${message.type}"); switch (message.type) { case "metadata": - getSessionMetadata(); break; default: addMessage(message); @@ -1000,6 +1005,8 @@ class MeetingStore extends ChangeNotifier } _hmsSDKInteractor.removeHMSLogger(); _hmsSDKInteractor.destroy(); + _hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeListener: this); + _hmsSessionStore = null; peerTracks.clear(); isRoomEnded = true; screenShareCount = 0; @@ -1302,6 +1309,60 @@ class MeetingStore extends ChangeNotifier } } + ///Here we get the instance of HMSSessionStore using which + ///we will be performing the session metadata actions + @override + void onSessionStoreAvailable({HMSSessionStore? hmsSessionStore}) { + _hmsSessionStore = hmsSessionStore; + _hmsSessionStore?.addKeyChangeListener( + keys: SessionStoreKeyValues.getSessionStoreKeys(), + hmsKeyChangeListener: this); + } + + ///We get this call everytime metadata corresponding to a key is changed + /// + ///Note: This only gets called when we have attached [HMSKeyChangeListener] using + /// addKeyChangeListener method with keys to be listened + @override + void onKeyChanged({required String key, required String? value}) { + log("onKeyChanged --> key: $key value: $value"); + SessionStoreKey keyType = SessionStoreKeyValues.getMethodFromName(key); + switch (keyType) { + case SessionStoreKey.PINNED_MESSAGE_SESSION_KEY: + sessionMetadata = value; + break; + case SessionStoreKey.SPOTLIGHT: + setPeerToSpotlight(value); + break; + case SessionStoreKey.unknown: + break; + } + notifyListeners(); + } + + ///This method sets the peer to spotlight + ///this also handles removing a peer from spotlight case + void setPeerToSpotlight(String? value) { + int currentSpotlightPeerIndex = + peerTracks.indexWhere((node) => node.uid == spotLightPeer?.uid); + if (currentSpotlightPeerIndex != -1) { + peerTracks[currentSpotlightPeerIndex].pinTile = false; + spotLightPeer = null; + } + if (value != null) { + int index = + peerTracks.indexWhere((node) => node.track?.trackId == (value)); + if (index != -1) { + Utilities.showToast("${peerTracks[index].peer.name} is in spotlight"); + spotLightPeer = peerTracks[index]; + changePinTileStatus(peerTracks[index]); + } else { + Utilities.showToast("Failed to set spotlight for the peer"); + } + } + notifyListeners(); + } + void setMode(MeetingMode meetingMode) { //Turning the videos on if the previously mode was audio if (this.meetingMode == MeetingMode.Audio && @@ -1431,13 +1492,22 @@ class MeetingStore extends ChangeNotifier audioPlayerVolume = volume; } - void setSessionMetadata(String? metadata) { - _hmsSDKInteractor.setSessionMetadata( - metadata: metadata, hmsActionResultListener: this); + void setSessionMetadata({required String key, String? metadata}) { + _hmsSessionStore?.setSessionMetadataForKey( + key: key, data: metadata, hmsActionResultListener: this); } - void getSessionMetadata() async { - sessionMetadata = await _hmsSDKInteractor.getSessionMetadata(); + void getSessionMetadata(String key) async { + dynamic result = await _hmsSessionStore?.getSessionMetadataForKey(key: key); + if (result is HMSException) { + Utilities.showToast( + "Error Occured: code: ${result.code?.errorCode}, description: ${result.description}, message: ${result.message}", + time: 5); + return; + } + if (result != null) { + sessionMetadata = result as String; + } notifyListeners(); } @@ -1734,6 +1804,8 @@ class MeetingStore extends ChangeNotifier case HMSActionResultListenerMethod.changeRoleOfPeersWithRoles: Utilities.showToast("Change Role successful"); break; + case HMSActionResultListenerMethod.setSessionMetadataForKey: + break; } } @@ -1814,6 +1886,9 @@ class MeetingStore extends ChangeNotifier case HMSActionResultListenerMethod.changeRoleOfPeersWithRoles: Utilities.showToast("Change role failed"); break; + case HMSActionResultListenerMethod.setSessionMetadataForKey: + Utilities.showToast("Set session metadata failed"); + break; } notifyListeners(); } diff --git a/lib/assets/sdk-versions.json b/lib/assets/sdk-versions.json index 1c2f57684..a890d141f 100644 --- a/lib/assets/sdk-versions.json +++ b/lib/assets/sdk-versions.json @@ -1,6 +1,6 @@ { "flutter": "1.6.0", - "ios": "0.9.3", + "ios": "0.9.2", "iOSBroadcastExtension": "0.0.9", "android": "2.6.2" } diff --git a/lib/hmssdk_flutter.dart b/lib/hmssdk_flutter.dart index ba4cf70c2..7256839ea 100644 --- a/lib/hmssdk_flutter.dart +++ b/lib/hmssdk_flutter.dart @@ -90,3 +90,5 @@ export 'src/model/hms_ios_pip_controller.dart'; export 'src/model/hms_ios_screenshare_config.dart'; export 'src/model/hms_log_list.dart'; export 'src/model/hms_camera_controls.dart'; +export 'src/model/hms_session_store.dart'; +export 'src/model/hms_key_change_listener.dart'; diff --git a/lib/src/common/platform_methods.dart b/lib/src/common/platform_methods.dart index c47f3bd9e..c505e8258 100644 --- a/lib/src/common/platform_methods.dart +++ b/lib/src/common/platform_methods.dart @@ -169,7 +169,11 @@ enum PlatformMethod { getAuthTokenByRoomCode, captureImageAtMaxSupportedResolution, isFlashSupported, - toggleFlash + toggleFlash, + getSessionMetadataForKey, + setSessionMetadataForKey, + addKeyChangeListener, + removeKeyChangeListener } extension PlatformMethodValues on PlatformMethod { @@ -409,6 +413,14 @@ extension PlatformMethodValues on PlatformMethod { return "is_flash_supported"; case PlatformMethod.toggleFlash: return "toggle_flash"; + case PlatformMethod.getSessionMetadataForKey: + return "get_session_metadata_for_key"; + case PlatformMethod.setSessionMetadataForKey: + return "set_session_metadata_for_key"; + case PlatformMethod.addKeyChangeListener: + return "add_key_change_listener"; + case PlatformMethod.removeKeyChangeListener: + return "remove_key_change_listener"; default: return 'unknown'; } @@ -650,6 +662,14 @@ extension PlatformMethodValues on PlatformMethod { return PlatformMethod.isFlashSupported; case "toggle_flash": return PlatformMethod.toggleFlash; + case "get_session_metadata_for_key": + return PlatformMethod.getSessionMetadataForKey; + case "set_session_metadata_for_key": + return PlatformMethod.setSessionMetadataForKey; + case "add_key_change_listener": + return PlatformMethod.addKeyChangeListener; + case "remove_key_change_listener": + return PlatformMethod.removeKeyChangeListener; default: return PlatformMethod.unknown; } diff --git a/lib/src/enum/hms_action_result_listener_method.dart b/lib/src/enum/hms_action_result_listener_method.dart index ea103ab95..b3b9f935f 100644 --- a/lib/src/enum/hms_action_result_listener_method.dart +++ b/lib/src/enum/hms_action_result_listener_method.dart @@ -21,8 +21,10 @@ enum HMSActionResultListenerMethod { stopScreenShare, startAudioShare, stopAudioShare, + @Deprecated('use [setSessionMetadataForKey]') setSessionMetadata, switchCamera, changeRoleOfPeersWithRoles, + setSessionMetadataForKey, unknown } diff --git a/lib/src/enum/hms_key_change_listener_method.dart b/lib/src/enum/hms_key_change_listener_method.dart new file mode 100644 index 000000000..090069072 --- /dev/null +++ b/lib/src/enum/hms_key_change_listener_method.dart @@ -0,0 +1,13 @@ +/// Enum for key change listener methods +enum HMSKeyChangeListenerMethod { onKeyChanged, unknown } + +extension HMSKeyChangeListenerMethodValues on HMSKeyChangeListenerMethod { + static HMSKeyChangeListenerMethod getMethodFromName(String name) { + switch (name) { + case "on_key_changed": + return HMSKeyChangeListenerMethod.onKeyChanged; + default: + return HMSKeyChangeListenerMethod.unknown; + } + } +} diff --git a/lib/src/enum/hms_update_listener_method.dart b/lib/src/enum/hms_update_listener_method.dart index c70ddd0bd..1cac55dfb 100644 --- a/lib/src/enum/hms_update_listener_method.dart +++ b/lib/src/enum/hms_update_listener_method.dart @@ -12,6 +12,7 @@ enum HMSUpdateListenerMethod { onChangeTrackStateRequest, onRemovedFromRoom, onAudioDeviceChanged, + onSessionStoreAvailable, unknown } @@ -44,6 +45,8 @@ extension HMSUpdateListenerMethodValues on HMSUpdateListenerMethod { return HMSUpdateListenerMethod.onRemovedFromRoom; case 'on_audio_device_changed': return HMSUpdateListenerMethod.onAudioDeviceChanged; + case 'on_session_store_available': + return HMSUpdateListenerMethod.onSessionStoreAvailable; default: return HMSUpdateListenerMethod.unknown; } diff --git a/lib/src/hmssdk.dart b/lib/src/hmssdk.dart index 13bae2e33..1d09cf9d1 100644 --- a/lib/src/hmssdk.dart +++ b/lib/src/hmssdk.dart @@ -1235,6 +1235,7 @@ class HMSSDK { /// **hmsActionResultListener** - [hmsActionResultListener] is a callback instance on which [HMSActionResultListener.onSuccess] and [HMSActionResultListener.onException] will be called. /// ///Refer [session metadata guide here](https://www.100ms.live/docs/flutter/v2/features/session-metadata) + @Deprecated('Use [setSessionMetadataForKey]') Future setSessionMetadata( {required String? metadata, HMSActionResultListener? hmsActionResultListener}) async { @@ -1260,6 +1261,7 @@ class HMSSDK { ///Method to fetch the latest metadata from the server and returns it /// ///Refer [session metadata guide here](https://www.100ms.live/docs/flutter/v2/features/session-metadata) + @Deprecated('Use [getSessionMetadataForKey]') Future getSessionMetadata() async { var result = await PlatformService.invokeMethod(PlatformMethod.getSessionMetadata); diff --git a/lib/src/model/hms_key_change_listener.dart b/lib/src/model/hms_key_change_listener.dart new file mode 100644 index 000000000..89bf968b2 --- /dev/null +++ b/lib/src/model/hms_key_change_listener.dart @@ -0,0 +1,17 @@ +/// 100ms HMSKeyChangeListener +/// +/// 100ms SDK provides callback whenever a key in session metadata is changed +/// +/// Implement this listener in the class wherever you wish to listen to changes to those keys +/// +/// Remember to call HMSSessionStore's [addKeyChangeListener] method with corresponding keys to get the updates +abstract class HMSKeyChangeListener { + ///This gets called whenever data corresponding to a key is changed + /// + ///This also gets called when key is set for the first time or set to null + /// + /// - Parameters: + /// - key: the key whose metadata is changed + /// - value: new value of the corresponding key + void onKeyChanged({required String key, required String? value}) {} +} diff --git a/lib/src/model/hms_key_change_observer.dart b/lib/src/model/hms_key_change_observer.dart new file mode 100644 index 000000000..5e809fc94 --- /dev/null +++ b/lib/src/model/hms_key_change_observer.dart @@ -0,0 +1,8 @@ +import 'package:hmssdk_flutter/src/model/hms_key_change_listener.dart'; + +class HMSKeyChangeObserver { + final String uid; + final HMSKeyChangeListener hmsKeyChangeListener; + + HMSKeyChangeObserver({required this.uid, required this.hmsKeyChangeListener}); +} diff --git a/lib/src/model/hms_session_store.dart b/lib/src/model/hms_session_store.dart new file mode 100644 index 000000000..240d568d5 --- /dev/null +++ b/lib/src/model/hms_session_store.dart @@ -0,0 +1,97 @@ +import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter/src/model/hms_key_change_observer.dart'; +import 'package:hmssdk_flutter/src/service/platform_service.dart'; + +/// [HMSSessionStore] class takes care of the session metadata for a session +/// +/// HMSUpdateListener's [onSessionStoreAvailable] method returns a object of [HMSSessionStore] +/// which can be used to call session metadata methods +/// +class HMSSessionStore { + ///[addKeyChangeListener] method is used to attach listener to particular keys + /// + /// **Parameters**: + /// + /// **keys** A list of keys to be listened + /// + /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] implemented in the class where changes needs to be listened + /// + Future addKeyChangeListener( + {required List keys, + required HMSKeyChangeListener hmsKeyChangeListener}) async { + String uid = DateTime.now().millisecondsSinceEpoch.toString(); + dynamic result = await PlatformService.invokeMethod( + PlatformMethod.addKeyChangeListener, + arguments: {"keys": keys, "uid": uid}); + if (result == null) { + PlatformService.addKeyChangeObserver(HMSKeyChangeObserver( + uid: uid, hmsKeyChangeListener: hmsKeyChangeListener)); + return null; + } else { + return HMSException.fromMap(result["data"]); + } + } + + ///[removeKeyChangeListener] method is used to remove a key change listener + /// + /// **Parameters**: + /// + /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] which was attaced earlier in [addKeyChangeListener] + /// + void removeKeyChangeListener( + {required HMSKeyChangeListener hmsKeyChangeListener}) { + PlatformService.removeKeyChangeObserver(hmsKeyChangeListener); + } + + ///[getSessionMetadataForKey] method is used to get metadata corresponding to the given key. + /// If there is no data corresponding to the given key it returns null. + /// + /// **Parameters**: + /// + /// **key** key for which metadata is required + /// + Future getSessionMetadataForKey({required String key}) async { + dynamic result = await PlatformService.invokeMethod( + PlatformMethod.getSessionMetadataForKey, + arguments: {"key": key}); + if (result["success"]) { + return result["data"]; + } else { + return HMSException.fromMap(result["data"]["error"]); + } + } + + ///[setSessionMetadataForKey] is used to set metadata for a particular key + /// + /// **Parameters**: + /// + /// **key** key for metadata needs to be set + /// + /// **data** data corresponding to the given key + /// + /// **hmsActionResultListener** [hmsActionResultListener] is a callback instance on which [HMSActionResultListener.onSuccess] and [HMSActionResultListener.onException] will be called. + /// + Future setSessionMetadataForKey( + {required String key, + required String? data, + HMSActionResultListener? hmsActionResultListener}) async { + Map arguments = { + "key": key, + "data": data, + }; + dynamic result = await PlatformService.invokeMethod( + PlatformMethod.setSessionMetadataForKey, + arguments: arguments); + if (hmsActionResultListener != null) { + if (result == null) { + hmsActionResultListener.onSuccess( + methodType: HMSActionResultListenerMethod.setSessionMetadataForKey, + arguments: arguments); + } else { + hmsActionResultListener.onException( + methodType: HMSActionResultListenerMethod.setSessionMetadataForKey, + hmsException: HMSException.fromMap(result["error"])); + } + } + } +} diff --git a/lib/src/model/hms_update_listener.dart b/lib/src/model/hms_update_listener.dart index d9d6a3ca1..9baf13a25 100644 --- a/lib/src/model/hms_update_listener.dart +++ b/lib/src/model/hms_update_listener.dart @@ -99,4 +99,10 @@ abstract class HMSUpdateListener { void onAudioDeviceChanged( {HMSAudioDevice? currentAudioDevice, List? availableAudioDevice}); + + /// Whenever a user joins a room [onSessionStoreAvailable] is fired to get an instance of [HMSSessionStore] + /// which can be used to perform session metadata operations + /// - Parameters: + /// - hmsSessionStore: An instance of HMSSessionStore which will be used to call session metadata methods + void onSessionStoreAvailable({HMSSessionStore? hmsSessionStore}); } diff --git a/lib/src/model/platform_method_response.dart b/lib/src/model/platform_method_response.dart index 289fde41f..f53865bb5 100644 --- a/lib/src/model/platform_method_response.dart +++ b/lib/src/model/platform_method_response.dart @@ -1,5 +1,6 @@ // Project imports: import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter/src/enum/hms_key_change_listener_method.dart'; import 'package:hmssdk_flutter/src/enum/hms_logs_update_listener.dart'; ///PlatformMethodResponse contains all the responses sent back from the platform @@ -59,3 +60,14 @@ class HMSStatsListenerMethodResponse { HMSStatsListenerMethodResponse( {required this.method, required this.data, required this.response}); } + +///HMSKeyChangeListenerMethodResponse contains all the responses sent from the session store channel +/// +/// Checkout different responses in [HMSKeyChangeListenerMethod] enum +class HMSKeyChangeListenerMethodResponse { + final HMSKeyChangeListenerMethod method; + final Map data; + + HMSKeyChangeListenerMethodResponse( + {required this.method, required this.data}); +} diff --git a/lib/src/service/platform_service.dart b/lib/src/service/platform_service.dart index fabc23c1e..c2720115c 100644 --- a/lib/src/service/platform_service.dart +++ b/lib/src/service/platform_service.dart @@ -13,7 +13,9 @@ import 'dart:async'; import 'package:flutter/services.dart'; // Project imports: import 'package:hmssdk_flutter/hmssdk_flutter.dart'; +import 'package:hmssdk_flutter/src/enum/hms_key_change_listener_method.dart'; import 'package:hmssdk_flutter/src/enum/hms_logs_update_listener.dart'; +import 'package:hmssdk_flutter/src/model/hms_key_change_observer.dart'; class PlatformService { ///used to pass data to platform using methods @@ -34,6 +36,10 @@ class PlatformService { static const EventChannel _rtcStatsChannel = const EventChannel("rtc_event_channel"); + ///used to get stream of session store changes + static const EventChannel _sessionStoreChannel = + const EventChannel("session_event_channel"); + ///add meeting listeners. static List updateListeners = []; @@ -42,6 +48,8 @@ class PlatformService { ///add preview listeners. static List previewListeners = []; + static List keyChangeObservers = []; + ///List for event Listener static List statsListeners = []; static bool isStartedListening = false; @@ -92,6 +100,22 @@ class PlatformService { logsListeners.remove(hmsLogListener); } + static void addKeyChangeObserver(HMSKeyChangeObserver hmsKeyChangeObserver) { + keyChangeObservers.add(hmsKeyChangeObserver); + } + + static void removeKeyChangeObserver( + HMSKeyChangeListener hmsKeyChangeListener) async { + int index = keyChangeObservers.indexWhere((observer) => + observer.hmsKeyChangeListener.hashCode == + hmsKeyChangeListener.hashCode); + if (index != -1) { + invokeMethod(PlatformMethod.removeKeyChangeListener, + arguments: {"uid": keyChangeObservers[index].uid}); + keyChangeObservers.removeAt(index); + } + } + ///used to invoke different methods at platform side and returns something but not neccessarily static Future invokeMethod(PlatformMethod method, {Map? arguments}) async { @@ -230,6 +254,10 @@ class PlatformService { }); break; + case HMSUpdateListenerMethod.onSessionStoreAvailable: + notifyUpdateListeners(method, {}); + break; + case HMSUpdateListenerMethod.unknown: break; } @@ -421,6 +449,24 @@ class PlatformService { break; } }); + + _sessionStoreChannel + .receiveBroadcastStream({'name': 'session_store'}).map((event) { + HMSKeyChangeListenerMethod method = + HMSKeyChangeListenerMethodValues.getMethodFromName( + event['event_name']); + Map data = event['data']; + return HMSKeyChangeListenerMethodResponse(method: method, data: data); + }).listen((event) { + HMSKeyChangeListenerMethod method = event.method; + switch (method) { + case HMSKeyChangeListenerMethod.onKeyChanged: + notifySessionStoreListeners(method, event.data); + break; + case HMSKeyChangeListenerMethod.unknown: + break; + } + }); } static void notifyLogsUpdateListeners( @@ -571,8 +617,30 @@ class PlatformService { availableAudioDevice: arguments["available_audio_device"])); break; + case HMSUpdateListenerMethod.onSessionStoreAvailable: + updateListeners.forEach((e) => + e.onSessionStoreAvailable(hmsSessionStore: HMSSessionStore())); + break; + case HMSUpdateListenerMethod.unknown: break; } } + + static void notifySessionStoreListeners( + HMSKeyChangeListenerMethod method, Map arguments) { + switch (method) { + case HMSKeyChangeListenerMethod.onKeyChanged: + int index = keyChangeObservers + .indexWhere((observer) => observer.uid == arguments["uid"]); + if (index != -1) { + keyChangeObservers[index] + .hmsKeyChangeListener + .onKeyChanged(key: arguments["key"], value: arguments["value"]); + } + break; + case HMSKeyChangeListenerMethod.unknown: + break; + } + } } From 74a12f1690a160452b314140fcb1280b3f6bb54d Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 2 May 2023 23:01:31 +0530 Subject: [PATCH 59/88] fixed Kotlin lint warnings --- android/build.gradle | 4 +- .../HMSAudioTrackSettingsExtension.kt | 12 +- .../HMSChangeTrackStateRequestExtension.kt | 22 ++-- .../hmssdk_flutter/HMSHLSVariantExtension.kt | 16 ++- .../hmssdk_flutter/HMSKeyChangeObserver.kt | 2 +- .../live/hms/hmssdk_flutter/HMSLogSettings.kt | 12 +- .../hms/hmssdk_flutter/HMSLogsExtension.kt | 33 +++-- .../hms/hmssdk_flutter/HMSMessageExtension.kt | 17 +-- .../HMSMessageRecipientExtension.kt | 31 +++-- .../HMSNetworkQualityExtension.kt | 4 +- .../hmssdk_flutter/HMSPeerUpdateExtension.kt | 11 +- .../hms/hmssdk_flutter/HMSPreviewExtension.kt | 13 +- .../HMSRemovedFromRoomExtension.kt | 20 +-- .../hmssdk_flutter/HMSRoleChangedExtension.kt | 18 +-- .../hms/hmssdk_flutter/HMSRoleExtension.kt | 22 ++-- .../hmssdk_flutter/HMSRoomUpdateExtension.kt | 9 +- .../hmssdk_flutter/HMSRtmpStreamingState.kt | 58 ++++----- .../HMSSessionMetadataExtension.kt | 9 +- .../hms/hmssdk_flutter/HMSSpeakerExtension.kt | 18 +-- .../HMSTrackInitStateExtension.kt | 20 +-- .../HMSTrackSettingsExtension.kt | 43 +++---- .../hmssdk_flutter/HMSTrackUpdateExtension.kt | 15 ++- .../HMSVideoResolutionExtension.kt | 17 ++- .../HMSVideoTrackSettingsExtension.kt | 28 ++--- .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 116 +++++++++--------- .../AudioParamsExtension.kt | 26 ++-- .../PermissionParamsExtension.kt | 10 +- .../VideoParamsExtension.kt | 41 +++---- .../methods/HMSAudioDeviceAction.kt | 34 +++-- .../hmssdk_flutter/methods/HMSHLSAction.kt | 61 +++++---- .../methods/HMSMessageAction.kt | 32 ++--- .../hmssdk_flutter/methods/HMSPipAction.kt | 2 +- .../methods/HMSRecordingAction.kt | 34 +++-- .../hmssdk_flutter/methods/HMSRoomAction.kt | 20 +-- .../methods/HMSSessionMetadataAction.kt | 14 +-- .../methods/HMSSessionStoreAction.kt | 51 ++++---- .../hms/hmssdk_flutter/views/HMSVideoView.kt | 2 +- .../views/HMSVideoViewFactory.kt | 8 +- .../kotlin/live/hms/flutter/MainActivity.kt | 2 +- .../Actions/HMSSessionStoreAction.swift | 23 ++-- .../HMSAudioFilePlayerNodeExtension.swift | 36 +++--- .../Models/HMSTrackSettingsExtension.swift | 4 +- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 48 ++++---- .../MainActivity.kt | 15 ++- .../MainActivity.kt | 3 +- .../flutter_hls_quickstart/MainActivity.kt | 3 +- .../flutter_integration_guide/MainActivity.kt | 3 +- .../demo_with_getx_and_100ms/MainActivity.kt | 16 ++- .../kotlin/com/example/zoom/MainActivity.kt | 15 ++- .../example/example_riverpod/MainActivity.kt | 17 ++- 50 files changed, 517 insertions(+), 573 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 2ddaabebb..68a1da0c5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -39,9 +39,9 @@ android { minSdkVersion 21 } } -def hmsVersion = "an719-SNAPSHOT" + dependencies { - implementation "com.github.100mslive.android-sdk:lib:$hmsVersion" + implementation "live.100ms:android-sdk:${sdkVersions['android']}" implementation "live.100ms:video-view:${sdkVersions['android']}" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0' diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSAudioTrackSettingsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSAudioTrackSettingsExtension.kt index 5a089be4e..7ee2a0654 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSAudioTrackSettingsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSAudioTrackSettingsExtension.kt @@ -1,18 +1,14 @@ package live.hms.hmssdk_flutter -import live.hms.hmssdk_flutter.hms_role_components.AudioParamsExtension -import live.hms.video.media.tracks.HMSTrack -import live.hms.video.media.tracks.HMSAudioTrack -import live.hms.video.utils.HMSLogger import live.hms.video.media.settings.HMSAudioTrackSettings class HMSAudioTrackSettingsExtension { - companion object{ - fun toDictionary(hmsAudioTrackSettings: HMSAudioTrackSettings?):HashMap? { - val map = HashMap() + companion object { + fun toDictionary(hmsAudioTrackSettings: HMSAudioTrackSettings?): HashMap? { + val map = HashMap() map["user_hardware_acoustic_echo_canceler"] = hmsAudioTrackSettings?.useHardwareAcousticEchoCanceler!! map["track_initial_state"] = HMSTrackInitStateExtension.getValueFromHMSTrackInitState(hmsAudioTrackSettings.initialState) return map } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSChangeTrackStateRequestExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSChangeTrackStateRequestExtension.kt index 63e6c793d..96a157f8e 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSChangeTrackStateRequestExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSChangeTrackStateRequestExtension.kt @@ -4,18 +4,18 @@ import live.hms.video.sdk.models.trackchangerequest.HMSChangeTrackStateRequest class HMSChangeTrackStateRequestExtension { - companion object{ - fun toDictionary(hmsChangeTrackStateRequest: HMSChangeTrackStateRequest?):HashMap?{ - val hashMap = HashMap() - if(hmsChangeTrackStateRequest==null)return null - hashMap.put("mute",hmsChangeTrackStateRequest.mute) - hashMap.put("requested_by",HMSPeerExtension.toDictionary(hmsChangeTrackStateRequest.requestedBy)) - hashMap.put("track",HMSTrackExtension.toDictionary(hmsChangeTrackStateRequest.track)) + companion object { + fun toDictionary(hmsChangeTrackStateRequest: HMSChangeTrackStateRequest?): HashMap? { + val hashMap = HashMap() + if (hmsChangeTrackStateRequest == null)return null + hashMap.put("mute", hmsChangeTrackStateRequest.mute) + hashMap.put("requested_by", HMSPeerExtension.toDictionary(hmsChangeTrackStateRequest.requestedBy)) + hashMap.put("track", HMSTrackExtension.toDictionary(hmsChangeTrackStateRequest.track)) - val args=HashMap() - args.put("track_change_request",hashMap) + val args = HashMap() + args.put("track_change_request", hashMap) - return args + return args } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSHLSVariantExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSHLSVariantExtension.kt index 3b0cbfd77..ecd84e17c 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSHLSVariantExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSHLSVariantExtension.kt @@ -1,21 +1,19 @@ package live.hms.hmssdk_flutter -import live.hms.video.error.HMSException import live.hms.video.sdk.models.HMSHLSVariant import java.text.SimpleDateFormat class HMSHLSVariantExtension { - companion object{ - fun toDictionary(hmshlsVariant: HMSHLSVariant?):HashMap?{ - val args=HashMap() + companion object { + fun toDictionary(hmshlsVariant: HMSHLSVariant?): HashMap? { + val args = HashMap() if (hmshlsVariant == null)return null - args["hls_stream_url"] = hmshlsVariant.hlsStreamUrl?:"" - args["meeting_url"] = hmshlsVariant.meetingUrl?:"" - args["metadata"] = hmshlsVariant.metadata?:"" + args["hls_stream_url"] = hmshlsVariant.hlsStreamUrl ?: "" + args["meeting_url"] = hmshlsVariant.meetingUrl ?: "" + args["metadata"] = hmshlsVariant.metadata ?: "" args["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmshlsVariant.startedAt).toString() return args } } - -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt index 3759e3d59..0f0b62e16 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt @@ -2,4 +2,4 @@ package live.hms.hmssdk_flutter import live.hms.video.sessionstore.HMSKeyChangeListener -class HMSKeyChangeObserver(val uid: String,val keyChangeListener: HMSKeyChangeListener) {} \ No newline at end of file +class HMSKeyChangeObserver(val uid: String, val keyChangeListener: HMSKeyChangeListener) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogSettings.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogSettings.kt index 851317c60..24564a13a 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogSettings.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogSettings.kt @@ -5,14 +5,14 @@ import live.hms.video.utils.HMSLogger class HMSLogSettings { - companion object{ + companion object { - fun setLogSettings(maxDirSizeInBytes: Double,logStorageEnabled: Boolean,logLevel: String): HMSLogSettings { - return HMSLogSettings(maxDirSizeInBytes = maxDirSizeInBytes.toLong(), isLogStorageEnabled = logStorageEnabled, level = getLogLevel(logLevel)) + fun setLogSettings(maxDirSizeInBytes: Double, logStorageEnabled: Boolean, logLevel: String): HMSLogSettings { + return HMSLogSettings(maxDirSizeInBytes = maxDirSizeInBytes.toLong(), isLogStorageEnabled = logStorageEnabled, level = getLogLevel(logLevel)) } - private fun getLogLevel(logLevel:String?): HMSLogger.LogLevel { - return when(logLevel){ + private fun getLogLevel(logLevel: String?): HMSLogger.LogLevel { + return when (logLevel) { "error" -> HMSLogger.LogLevel.ERROR "off" -> HMSLogger.LogLevel.OFF "verbose" -> HMSLogger.LogLevel.VERBOSE @@ -21,4 +21,4 @@ class HMSLogSettings { } } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogsExtension.kt index 3620e6e0a..32e53508a 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogsExtension.kt @@ -1,18 +1,17 @@ package live.hms.hmssdk_flutter -import live.hms.video.sdk.models.enums.HMSPeerUpdate import live.hms.video.utils.HMSLogger class HMSLogsExtension { - companion object{ + companion object { fun toDictionary( level: HMSLogger.LogLevel, tag: String, message: String, - isWebRtCLog: Boolean - ) : HashMap{ - val map = HashMap() - map["level"]= getValueOfHMSLog(level)!! + isWebRtCLog: Boolean, + ): HashMap { + val map = HashMap() + map["level"] = getValueOfHMSLog(level)!! map["tag"] = tag map["message"] = message map["is_web_rtc_log"] = isWebRtCLog @@ -20,18 +19,18 @@ class HMSLogsExtension { return map } - fun getValueOfHMSLog(level: HMSLogger.LogLevel?):String?{ - if(level==null)return null + fun getValueOfHMSLog(level: HMSLogger.LogLevel?): String? { + if (level == null)return null - return when(level){ - HMSLogger.LogLevel.DEBUG-> "debug" - HMSLogger.LogLevel.ERROR-> "error" - HMSLogger.LogLevel.INFO-> "info" - HMSLogger.LogLevel.OFF-> "off" - HMSLogger.LogLevel.VERBOSE->"verbose" - HMSLogger.LogLevel.WARN->"warn" - else-> "defaultUpdate" + return when (level) { + HMSLogger.LogLevel.DEBUG -> "debug" + HMSLogger.LogLevel.ERROR -> "error" + HMSLogger.LogLevel.INFO -> "info" + HMSLogger.LogLevel.OFF -> "off" + HMSLogger.LogLevel.VERBOSE -> "verbose" + HMSLogger.LogLevel.WARN -> "warn" + else -> "defaultUpdate" } } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageExtension.kt index c1af27ff8..427dbaf05 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageExtension.kt @@ -4,20 +4,21 @@ import live.hms.video.sdk.models.HMSMessage import java.text.SimpleDateFormat class HMSMessageExtension { - companion object{ - fun toDictionary(message:HMSMessage?):HashMap?{ - val args=HashMap() - if(message==null)return null + companion object { + fun toDictionary(message: HMSMessage?): HashMap? { + val args = HashMap() + if (message == null)return null args["message"] = message.message args["time"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(message.serverReceiveTime).toString() args["type"] = message.type - if(message.sender != null) + if (message.sender != null) { args["sender"] = HMSPeerExtension.toDictionary(message.sender)!! + } args["hms_message_recipient"] = HMSMessageRecipientExtension.toDictionary(message.recipient)!! - val messageArgs=HashMap() + val messageArgs = HashMap() messageArgs["message"] = args return messageArgs } - } -} \ No newline at end of file + } +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageRecipientExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageRecipientExtension.kt index 3406c1a66..47f58af95 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageRecipientExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageRecipientExtension.kt @@ -1,36 +1,35 @@ package live.hms.hmssdk_flutter -import io.flutter.Log import live.hms.video.sdk.models.HMSMessageRecipient import live.hms.video.sdk.models.enums.HMSMessageRecipientType class HMSMessageRecipientExtension { - companion object{ - fun toDictionary(hmsMessageRecipient: HMSMessageRecipient?):HashMap?{ - val hashMap = HashMap() - if(hmsMessageRecipient==null)return null + companion object { + fun toDictionary(hmsMessageRecipient: HMSMessageRecipient?): HashMap? { + val hashMap = HashMap() + if (hmsMessageRecipient == null)return null hashMap["recipient_peer"] = HMSPeerExtension.toDictionary(hmsMessageRecipient.recipientPeer) - val recipientRoles = ArrayList?>() + val recipientRoles = ArrayList?>() hmsMessageRecipient.recipientRoles.forEach { recipientRoles.add(HMSRoleExtension.toDictionary(it)) } - hashMap["recipient_roles"] = if(recipientRoles.size!=0)recipientRoles else null + hashMap["recipient_roles"] = if (recipientRoles.size != 0)recipientRoles else null - hashMap["recipient_type"] = getValueOfHMSMessageRecipient(hmsMessageRecipient.recipientType) + hashMap["recipient_type"] = getValueOfHMSMessageRecipient(hmsMessageRecipient.recipientType) return hashMap } - private fun getValueOfHMSMessageRecipient(hmsMessageRecipientType: HMSMessageRecipientType?):String?{ - if(hmsMessageRecipientType==null)return null - return when(hmsMessageRecipientType){ - HMSMessageRecipientType.BROADCAST-> "broadCast" - HMSMessageRecipientType.PEER-> "peer" - HMSMessageRecipientType.ROLES-> "roles" - else-> "defaultRecipient" + private fun getValueOfHMSMessageRecipient(hmsMessageRecipientType: HMSMessageRecipientType?): String? { + if (hmsMessageRecipientType == null)return null + return when (hmsMessageRecipientType) { + HMSMessageRecipientType.BROADCAST -> "broadCast" + HMSMessageRecipientType.PEER -> "peer" + HMSMessageRecipientType.ROLES -> "roles" + else -> "defaultRecipient" } } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSNetworkQualityExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSNetworkQualityExtension.kt index 3bb247bf0..a814152d9 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSNetworkQualityExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSNetworkQualityExtension.kt @@ -1,8 +1,6 @@ package live.hms.hmssdk_flutter import live.hms.video.connection.stats.quality.HMSNetworkQuality -import live.hms.video.sdk.models.HMSPeer -import live.hms.video.sdk.models.enums.HMSPeerUpdate class HMSNetworkQualityExtension { @@ -14,4 +12,4 @@ class HMSNetworkQualityExtension { return args } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerUpdateExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerUpdateExtension.kt index 800620e73..fce6649d4 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerUpdateExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerUpdateExtension.kt @@ -1,18 +1,17 @@ package live.hms.hmssdk_flutter -import io.flutter.Log import live.hms.video.sdk.models.HMSPeer import live.hms.video.sdk.models.enums.HMSPeerUpdate class HMSPeerUpdateExtension { - companion object{ - fun toDictionary(peer:HMSPeer?,update: HMSPeerUpdate?):HashMap?{ - val args=HashMap() - if(peer==null || update==null)return null + companion object { + fun toDictionary(peer: HMSPeer?, update: HMSPeerUpdate?): HashMap? { + val args = HashMap() + if (peer == null || update == null)return null args.put("peer", HMSPeerExtension.toDictionary(peer)!!) args.put("update", HMSPeerExtension.getValueofHMSPeerUpdate(update)!!) return args } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPreviewExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPreviewExtension.kt index 987ecfe86..d6b7989c3 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPreviewExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPreviewExtension.kt @@ -1,16 +1,15 @@ package live.hms.hmssdk_flutter import live.hms.video.media.tracks.HMSTrack -import live.hms.video.sdk.models.HMSPeer import live.hms.video.sdk.models.HMSRoom class HMSPreviewExtension { - companion object{ - fun toDictionary(room: HMSRoom?,allTracks:Array?):HashMap?{ - val args=HashMap() - if(room==null || allTracks==null)return null + companion object { + fun toDictionary(room: HMSRoom?, allTracks: Array?): HashMap? { + val args = HashMap() + if (room == null || allTracks == null)return null args["room"] = HMSRoomExtension.toDictionary(room)!! - val tracks=ArrayList() + val tracks = ArrayList() for (eachTrack in allTracks) { tracks.add(HMSTrackExtension.toDictionary(eachTrack)!!) @@ -19,4 +18,4 @@ class HMSPreviewExtension { return args } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRemovedFromRoomExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRemovedFromRoomExtension.kt index 01dd696c2..0187c4f6e 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRemovedFromRoomExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRemovedFromRoomExtension.kt @@ -3,18 +3,18 @@ package live.hms.hmssdk_flutter import live.hms.video.sdk.models.HMSRemovedFromRoom class HMSRemovedFromRoomExtension { - companion object{ - fun toDictionary(notification:HMSRemovedFromRoom?): HashMap? { - val hashMap = HashMap() + companion object { + fun toDictionary(notification: HMSRemovedFromRoom?): HashMap? { + val hashMap = HashMap() - if(notification==null)return null - hashMap.put("peer_who_removed",HMSPeerExtension.toDictionary(notification.peerWhoRemoved)) - hashMap.put("reason",notification.reason) - hashMap.put("room_was_ended",notification.roomWasEnded) + if (notification == null)return null + hashMap.put("peer_who_removed", HMSPeerExtension.toDictionary(notification.peerWhoRemoved)) + hashMap.put("reason", notification.reason) + hashMap.put("room_was_ended", notification.roomWasEnded) - val roomMap = HashMap() - roomMap.put("removed_from_room",hashMap) + val roomMap = HashMap() + roomMap.put("removed_from_room", hashMap) return roomMap } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleChangedExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleChangedExtension.kt index b46105bae..3c3d1b17d 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleChangedExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleChangedExtension.kt @@ -3,15 +3,15 @@ package live.hms.hmssdk_flutter import live.hms.video.sdk.models.HMSRoleChangeRequest class HMSRoleChangedExtension { - companion object{ - fun toDictionary(role:HMSRoleChangeRequest?):HashMap?{ - val args=HashMap() - if(role==null)return null - args.put("requested_by",HMSPeerExtension.toDictionary(role.requestedBy)) - args.put("suggested_role",HMSRoleExtension.toDictionary(role.suggestedRole)) - val roleChanged=HashMap() - roleChanged.put("role_change_request",args) + companion object { + fun toDictionary(role: HMSRoleChangeRequest?): HashMap? { + val args = HashMap() + if (role == null)return null + args.put("requested_by", HMSPeerExtension.toDictionary(role.requestedBy)) + args.put("suggested_role", HMSRoleExtension.toDictionary(role.suggestedRole)) + val roleChanged = HashMap() + roleChanged.put("role_change_request", args) return roleChanged } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleExtension.kt index c89aad09f..dffe96e1e 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleExtension.kt @@ -1,29 +1,25 @@ package live.hms.hmssdk_flutter import android.annotation.SuppressLint -import android.util.Log import live.hms.hmssdk_flutter.hms_role_components.PermissionParamsExtension import live.hms.hmssdk_flutter.hms_role_components.PublishParamsExtension import live.hms.hmssdk_flutter.hms_role_components.SubscribeSettings import live.hms.video.sdk.models.role.HMSRole -import live.hms.video.sdk.models.role.PermissionsParams -import kotlin.jvm.internal.Intrinsics class HMSRoleExtension { - companion object{ + companion object { @SuppressLint("LongLogTag") - fun toDictionary(role:HMSRole?):HashMap?{ + fun toDictionary(role: HMSRole?): HashMap? { + val hashMap = HashMap() + if (role == null)return null - val hashMap=HashMap() - if(role==null)return null - - hashMap["name"] = role?.name?:"unknown" - hashMap["publish_settings"] = PublishParamsExtension.toDictionary(role?.publishParams?:null) - hashMap["subscribe_settings"] = SubscribeSettings.toDictionary(role?.subscribeParams?:null) + hashMap["name"] = role?.name ?: "unknown" + hashMap["publish_settings"] = PublishParamsExtension.toDictionary(role?.publishParams ?: null) + hashMap["subscribe_settings"] = SubscribeSettings.toDictionary(role?.subscribeParams ?: null) hashMap["priority"] = role?.priority!! - hashMap["permissions"] = PermissionParamsExtension.toDictionary(role.permission?:null) + hashMap["permissions"] = PermissionParamsExtension.toDictionary(role.permission ?: null) return hashMap } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoomUpdateExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoomUpdateExtension.kt index 16a9a0578..27d06984f 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoomUpdateExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoomUpdateExtension.kt @@ -1,15 +1,14 @@ package live.hms.hmssdk_flutter -import android.util.Log import live.hms.video.sdk.models.HMSRoom import live.hms.video.sdk.models.enums.HMSRoomUpdate class HMSRoomUpdateExtension { - companion object{ - fun toDictionary(room:HMSRoom?,update: HMSRoomUpdate?):HashMap?{ - val args=HashMap() + companion object { + fun toDictionary(room: HMSRoom?, update: HMSRoomUpdate?): HashMap? { + val args = HashMap() - if (room==null)return null + if (room == null)return null args.put("room", HMSRoomExtension.toDictionary(room)!!) args.put("update", HMSRoomExtension.getValueofHMSRoomUpdate(update)!!) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRtmpStreamingState.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRtmpStreamingState.kt index aa4a0d9f9..6dae4fa4d 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRtmpStreamingState.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRtmpStreamingState.kt @@ -5,58 +5,60 @@ import live.hms.video.sdk.models.* import java.text.SimpleDateFormat class HMSStreamingState { - companion object{ - fun toDictionary(hmsRtmpStreamingState: HMSRtmpStreamingState?):HashMap?{ - val map = HashMap() - if(hmsRtmpStreamingState == null)return null + companion object { + fun toDictionary(hmsRtmpStreamingState: HMSRtmpStreamingState?): HashMap? { + val map = HashMap() + if (hmsRtmpStreamingState == null)return null map["running"] = hmsRtmpStreamingState.running map["error"] = HMSExceptionExtension.toDictionary(hmsRtmpStreamingState.error) - if(hmsRtmpStreamingState.running) - map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsRtmpStreamingState.startedAt).toString() + if (hmsRtmpStreamingState.running) { + map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsRtmpStreamingState.startedAt).toString() + } return map } - fun toDictionary(hmsServerRecordingState: HMSServerRecordingState?):HashMap?{ - val map = HashMap() - if(hmsServerRecordingState == null)return null + fun toDictionary(hmsServerRecordingState: HMSServerRecordingState?): HashMap? { + val map = HashMap() + if (hmsServerRecordingState == null)return null map["running"] = hmsServerRecordingState.running map["error"] = HMSExceptionExtension.toDictionary(hmsServerRecordingState.error) - if(hmsServerRecordingState.running) - map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsServerRecordingState.startedAt).toString() + if (hmsServerRecordingState.running) { + map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsServerRecordingState.startedAt).toString() + } return map } - fun toDictionary(hmsBrowserRecordingState: HMSBrowserRecordingState?):HashMap?{ - val map = HashMap() - if(hmsBrowserRecordingState == null)return null + fun toDictionary(hmsBrowserRecordingState: HMSBrowserRecordingState?): HashMap? { + val map = HashMap() + if (hmsBrowserRecordingState == null)return null map["running"] = hmsBrowserRecordingState.running map["error"] = HMSExceptionExtension.toDictionary(hmsBrowserRecordingState.error) - if(hmsBrowserRecordingState.running) - map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsBrowserRecordingState.startedAt).toString() + if (hmsBrowserRecordingState.running) { + map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsBrowserRecordingState.startedAt).toString() + } return map } - fun toDictionary(hmsHlsStreamingState: HMSHLSStreamingState?):HashMap?{ - val map = HashMap() - if(hmsHlsStreamingState == null)return null + fun toDictionary(hmsHlsStreamingState: HMSHLSStreamingState?): HashMap? { + val map = HashMap() + if (hmsHlsStreamingState == null)return null map["running"] = hmsHlsStreamingState.running - val args=ArrayList() + val args = ArrayList() hmsHlsStreamingState.variants?.forEach { args.add(HMSHLSVariantExtension.toDictionary(it)!!) } - map["variants"]=args + map["variants"] = args return map } - fun toDictionary(hmsHlsRecordingState: HmsHlsRecordingState?):HashMap?{ - val map = HashMap() - if(hmsHlsRecordingState == null)return null + fun toDictionary(hmsHlsRecordingState: HmsHlsRecordingState?): HashMap? { + val map = HashMap() + if (hmsHlsRecordingState == null)return null map["running"] = hmsHlsRecordingState.running - if(hmsHlsRecordingState.running == true) - map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsHlsRecordingState.startedAt).toString() + if (hmsHlsRecordingState.running == true) { + map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsHlsRecordingState.startedAt).toString() + } return map } - } - } diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSessionMetadataExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSessionMetadataExtension.kt index 25c7bfccb..4a8c8faf6 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSessionMetadataExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSessionMetadataExtension.kt @@ -1,14 +1,13 @@ package live.hms.hmssdk_flutter class HMSSessionMetadataExtension { - companion object{ - fun toDictionary(metadata: String?):HashMap?{ - - val hashMap=HashMap() + companion object { + fun toDictionary(metadata: String?): HashMap? { + val hashMap = HashMap() hashMap["metadata"] = metadata return hashMap } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSpeakerExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSpeakerExtension.kt index f8f5c4242..eb48daa83 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSpeakerExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSpeakerExtension.kt @@ -3,19 +3,19 @@ package live.hms.hmssdk_flutter import live.hms.video.sdk.models.HMSSpeaker class HMSSpeakerExtension { - companion object{ - fun toDictionary(speaker:HMSSpeaker?):HashMap?{ - val hashMap = HashMap() - if(speaker==null)return null - hashMap.put("audioLevel",speaker.level) + companion object { + fun toDictionary(speaker: HMSSpeaker?): HashMap? { + val hashMap = HashMap() + if (speaker == null)return null + hashMap.put("audioLevel", speaker.level) val hmsTrackMap = HMSTrackExtension.toDictionary(speaker.hmsTrack) val hmsPeerMap = HMSPeerExtension.toDictionary(speaker.peer) - if((hmsTrackMap == null) || (hmsPeerMap == null)){ + if ((hmsTrackMap == null) || (hmsPeerMap == null)) { return null } - hashMap.put("track",hmsTrackMap) - hashMap.put("peer",hmsPeerMap) + hashMap.put("track", hmsTrackMap) + hashMap.put("peer", hmsPeerMap) return hashMap } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackInitStateExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackInitStateExtension.kt index a2a28a3c3..360c689bc 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackInitStateExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackInitStateExtension.kt @@ -3,21 +3,21 @@ package live.hms.hmssdk_flutter import live.hms.video.media.settings.HMSTrackSettings class HMSTrackInitStateExtension { - companion object{ - fun getHMSTrackInitStatefromValue(value:String):HMSTrackSettings.InitState{ - return when(value){ + companion object { + fun getHMSTrackInitStatefromValue(value: String): HMSTrackSettings.InitState { + return when (value) { "MUTED" -> HMSTrackSettings.InitState.MUTED "UNMUTED" -> HMSTrackSettings.InitState.UNMUTED - else->HMSTrackSettings.InitState.MUTED + else -> HMSTrackSettings.InitState.MUTED } } - fun getValueFromHMSTrackInitState(hmsTrackInitState:HMSTrackSettings.InitState):String{ - return when(hmsTrackInitState){ - HMSTrackSettings.InitState.UNMUTED-> "UNMUTED" - HMSTrackSettings.InitState.MUTED-> "MUTED" - else->"MUTED" + fun getValueFromHMSTrackInitState(hmsTrackInitState: HMSTrackSettings.InitState): String { + return when (hmsTrackInitState) { + HMSTrackSettings.InitState.UNMUTED -> "UNMUTED" + HMSTrackSettings.InitState.MUTED -> "MUTED" + else -> "MUTED" } } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt index 76887b108..82668bf52 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt @@ -1,9 +1,5 @@ package live.hms.hmssdk_flutter -import live.hms.hmssdk_flutter.hms_role_components.AudioParamsExtension -import live.hms.hmssdk_flutter.hms_role_components.VideoParamsExtension -import live.hms.video.media.codec.HMSAudioCodec -import live.hms.video.media.codec.HMSVideoCodec import live.hms.video.media.settings.HMSAudioTrackSettings import live.hms.video.media.settings.HMSTrackSettings import live.hms.video.media.settings.HMSVideoTrackSettings @@ -11,25 +7,23 @@ import live.hms.video.sdk.HMSSDK class HMSTrackSettingsExtension { - companion object{ - fun toDictionary(hmssdk: HMSSDK):HashMap?{ + companion object { + fun toDictionary(hmssdk: HMSSDK): HashMap? { + val map = HashMap() + val hmsTrackSettings: HMSTrackSettings = hmssdk.hmsSettings - val map = HashMap(); - val hmsTrackSettings:HMSTrackSettings = hmssdk.hmsSettings; - - if(hmsTrackSettings.videoSettings != null){ + if (hmsTrackSettings.videoSettings != null) { map["video_track_setting"] = HMSVideoTrackSettingsExtension.toDictionary(hmsTrackSettings.videoSettings)!! } - if(hmsTrackSettings.audioSettings != null){ + if (hmsTrackSettings.audioSettings != null) { map["audio_track_setting"] = HMSAudioTrackSettingsExtension.toDictionary(hmsTrackSettings.audioSettings)!! } return map } - fun setTrackSettings(hmsAudioTrackHashMap:HashMap?,hmsVideoTrackHashMap: HashMap?):HMSTrackSettings{ - + fun setTrackSettings(hmsAudioTrackHashMap: HashMap?, hmsVideoTrackHashMap: HashMap?): HMSTrackSettings { var hmsAudioTrackSettings = HMSAudioTrackSettings.Builder() if (hmsAudioTrackHashMap != null) { val useHardwareAcousticEchoCanceler = @@ -39,33 +33,32 @@ class HMSTrackSettingsExtension { if (useHardwareAcousticEchoCanceler != null) { hmsAudioTrackSettings = hmsAudioTrackSettings.setUseHardwareAcousticEchoCanceler( - useHardwareAcousticEchoCanceler + useHardwareAcousticEchoCanceler, ) } - if(initialState != null){ + if (initialState != null) { hmsAudioTrackSettings = hmsAudioTrackSettings.initialState(initialState) } } var hmsVideoTrackSettings = HMSVideoTrackSettings.Builder() if (hmsVideoTrackHashMap != null) { - - val cameraFacing = getHMSCameraFacingFromValue(hmsVideoTrackHashMap["camera_facing"] as String?) + val cameraFacing = getHMSCameraFacingFromValue(hmsVideoTrackHashMap["camera_facing"] as String?) val disableAutoResize = hmsVideoTrackHashMap["disable_auto_resize"] as Boolean val initialState = HMSTrackInitStateExtension.getHMSTrackInitStatefromValue(hmsVideoTrackHashMap["track_initial_state"] as String) val forceSoftwareDecoder = hmsVideoTrackHashMap["force_software_decoder"] as Boolean - if(cameraFacing != null){ + if (cameraFacing != null) { hmsVideoTrackSettings = hmsVideoTrackSettings.cameraFacing(cameraFacing) } - if(disableAutoResize != null){ - hmsVideoTrackSettings = hmsVideoTrackSettings.disableAutoResize(disableAutoResize); + if (disableAutoResize != null) { + hmsVideoTrackSettings = hmsVideoTrackSettings.disableAutoResize(disableAutoResize) } - if(initialState != null){ + if (initialState != null) { hmsVideoTrackSettings = hmsVideoTrackSettings.initialState(initialState) } - if(forceSoftwareDecoder != null){ + if (forceSoftwareDecoder != null) { hmsVideoTrackSettings = hmsVideoTrackSettings.forceSoftwareDecoder(forceSoftwareDecoder) } } @@ -73,12 +66,12 @@ class HMSTrackSettingsExtension { return HMSTrackSettings.Builder().audio(hmsAudioTrackSettings.build()).video(hmsVideoTrackSettings.build()).build() } - private fun getHMSCameraFacingFromValue(cameraFacing:String?):HMSVideoTrackSettings.CameraFacing{ - return when(cameraFacing){ + private fun getHMSCameraFacingFromValue(cameraFacing: String?): HMSVideoTrackSettings.CameraFacing { + return when (cameraFacing) { "back" -> HMSVideoTrackSettings.CameraFacing.BACK "front" -> HMSVideoTrackSettings.CameraFacing.FRONT else -> HMSVideoTrackSettings.CameraFacing.FRONT } } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackUpdateExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackUpdateExtension.kt index 707c3f11a..eb86f2321 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackUpdateExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackUpdateExtension.kt @@ -1,21 +1,20 @@ package live.hms.hmssdk_flutter -import android.util.Log import live.hms.video.media.tracks.HMSTrack import live.hms.video.sdk.models.HMSPeer import live.hms.video.sdk.models.enums.HMSTrackUpdate class HMSTrackUpdateExtension { - companion object{ - fun toDictionary(peer:HMSPeer?,track:HMSTrack?,update: HMSTrackUpdate?):HashMap?{ - val hashMap=HashMap() + companion object { + fun toDictionary(peer: HMSPeer?, track: HMSTrack?, update: HMSTrackUpdate?): HashMap? { + val hashMap = HashMap() - if(peer==null || track==null || update==null)return null + if (peer == null || track == null || update == null)return null - hashMap["peer"] = HMSPeerExtension.toDictionary(peer)!! - hashMap["track"] = HMSTrackExtension.toDictionary(track)!! + hashMap["peer"] = HMSPeerExtension.toDictionary(peer)!! + hashMap["track"] = HMSTrackExtension.toDictionary(track)!! hashMap["update"] = HMSTrackExtension.getTrackUpdateInString(update)!! return hashMap } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoResolutionExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoResolutionExtension.kt index 69e5720a8..0a1de7e9b 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoResolutionExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoResolutionExtension.kt @@ -4,16 +4,15 @@ import live.hms.video.media.settings.HMSVideoResolution class HMSVideoResolutionExtension { - companion object{ + companion object { - fun toDictionary(hmsVideoResolution: HMSVideoResolution?):HashMap?{ + fun toDictionary(hmsVideoResolution: HMSVideoResolution?): HashMap? { + val args = HashMap() + if (hmsVideoResolution == null) return null + args["height"] = hmsVideoResolution.height / 1.0 + args["width"] = hmsVideoResolution.width / 1.0 - val args=HashMap() - if(hmsVideoResolution == null) return null - args["height"] = hmsVideoResolution.height/1.0 - args["width"] = hmsVideoResolution.width/1.0 - - return args; + return args } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoTrackSettingsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoTrackSettingsExtension.kt index 1826aa7ed..a9369731c 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoTrackSettingsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoTrackSettingsExtension.kt @@ -1,32 +1,26 @@ package live.hms.hmssdk_flutter -import live.hms.video.media.codec.HMSVideoCodec import live.hms.video.media.settings.HMSVideoTrackSettings -import live.hms.video.media.tracks.HMSTrack -import live.hms.video.media.tracks.HMSVideoTrack -import live.hms.video.utils.HMSLogger class HMSVideoTrackSettingsExtension { - companion object{ - fun toDictionary(hmsVideoTrackSettings: HMSVideoTrackSettings?):HashMap?{ - val map = HashMap() + companion object { + fun toDictionary(hmsVideoTrackSettings: HMSVideoTrackSettings?): HashMap? { + val map = HashMap() map["camera_facing"] = getValueOfHMSCameraFacing(hmsVideoTrackSettings?.cameraFacing)!! map["disable_auto_resize"] = hmsVideoTrackSettings?.disableAutoResize!! map["track_initial_state"] = HMSTrackInitStateExtension.getValueFromHMSTrackInitState(hmsVideoTrackSettings.initialState) map["force_software_decoder"] = hmsVideoTrackSettings.forceSoftwareDecoder - return map + return map } + private fun getValueOfHMSCameraFacing(cameraFacing: HMSVideoTrackSettings.CameraFacing?): String? { + if (cameraFacing == null)return null - private fun getValueOfHMSCameraFacing(cameraFacing: HMSVideoTrackSettings.CameraFacing?):String?{ - if(cameraFacing==null)return null - - return when(cameraFacing){ - HMSVideoTrackSettings.CameraFacing.BACK-> "back" - HMSVideoTrackSettings.CameraFacing.FRONT->"front" - else-> "default" + return when (cameraFacing) { + HMSVideoTrackSettings.CameraFacing.BACK -> "back" + HMSVideoTrackSettings.CameraFacing.FRONT -> "front" + else -> "default" } } - } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index a4034f7a5..277691bbe 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -55,7 +55,7 @@ class HmssdkFlutterPlugin : private var previewChannel: EventChannel? = null private var logsEventChannel: EventChannel? = null private var rtcStatsChannel: EventChannel? = null - private var sessionStoreChannel : EventChannel? = null + private var sessionStoreChannel: EventChannel? = null private var eventSink: EventChannel.EventSink? = null private var previewSink: EventChannel.EventSink? = null private var logsSink: EventChannel.EventSink? = null @@ -67,7 +67,7 @@ class HmssdkFlutterPlugin : private var requestChange: HMSRoleChangeRequest? = null var hmssdkFlutterPlugin: HmssdkFlutterPlugin? = null private var hmsSessionStore: HmsSessionStore? = null - private var hmsKeyChangeObserverList = ArrayList() + private var hmsKeyChangeObserverList = ArrayList() override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { if (hmssdkFlutterPlugin == null) { @@ -84,19 +84,19 @@ class HmssdkFlutterPlugin : EventChannel(flutterPluginBinding.binaryMessenger, "rtc_event_channel") this.sessionStoreChannel = - EventChannel(flutterPluginBinding.binaryMessenger,"session_event_channel") + EventChannel(flutterPluginBinding.binaryMessenger, "session_event_channel") this.meetingEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Meeting event channel not found") this.channel?.setMethodCallHandler(this) ?: Log.e("Channel Error", "Event channel not found") this.previewChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Preview channel not found") this.logsEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Logs event channel not found") this.rtcStatsChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "RTC Stats channel not found") - this.sessionStoreChannel?.setStreamHandler(this) ?: Log.e("Channel Error","Session Store channel not found") + this.sessionStoreChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Session Store channel not found") this.hmsVideoFactory = HMSVideoViewFactory(this) flutterPluginBinding.platformViewRegistry.registerViewFactory( "HMSVideoView", - hmsVideoFactory + hmsVideoFactory, ) hmssdkFlutterPlugin = this } else { @@ -203,10 +203,10 @@ class HmssdkFlutterPlugin : HMSCameraControlsAction.cameraControlsAction(call, result, hmssdk!!, activity.applicationContext) } "get_session_metadata_for_key", "set_session_metadata_for_key" -> { - HMSSessionStoreAction.sessionStoreActions(call,result,hmsSessionStore) + HMSSessionStoreAction.sessionStoreActions(call, result, hmsSessionStore) } - "add_key_change_listener"-> { - addKeyChangeListener(call,result) + "add_key_change_listener" -> { + addKeyChangeListener(call, result) } "remove_key_change_listener" -> { removeKeyChangeListener(call) @@ -384,7 +384,7 @@ class HmssdkFlutterPlugin : previewChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Preview channel not found") logsEventChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Logs event channel not found") rtcStatsChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "RTC Stats channel not found") - sessionStoreChannel?.setStreamHandler(null)?:Log.e("Channel Error","Session Store channel not found") + sessionStoreChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Session Store channel not found") eventSink = null previewSink = null rtcSink = null @@ -419,7 +419,7 @@ class HmssdkFlutterPlugin : } private fun getConfig( - call: MethodCall + call: MethodCall, ): HMSConfig { val userName = call.argument("user_name") val authToken = call.argument("auth_token") @@ -433,7 +433,7 @@ class HmssdkFlutterPlugin : authtoken = authToken!!, metadata = metaData, initEndpoint = endPoint.trim(), - captureNetworkQualityInPreview = captureNetworkQualityInPreview + captureNetworkQualityInPreview = captureNetworkQualityInPreview, ) } @@ -441,7 +441,7 @@ class HmssdkFlutterPlugin : userName = userName!!, authtoken = authToken!!, metadata = metaData, - captureNetworkQualityInPreview = captureNetworkQualityInPreview + captureNetworkQualityInPreview = captureNetworkQualityInPreview, ) } @@ -490,7 +490,7 @@ class HmssdkFlutterPlugin : this.logsSink = events } else if (nameOfEventSink == "rtc_stats") { this.rtcSink = events - } else if(nameOfEventSink == "session_store") { + } else if (nameOfEventSink == "session_store") { this.sessionStoreSink = events } } @@ -537,7 +537,7 @@ class HmssdkFlutterPlugin : code = 6004, description = "Room code is null", message = "Room code is null", - name = "Room code null error" + name = "Room code null error", ) val args = HMSExceptionExtension.toDictionary(hmsException) result.success(HMSResultExtension.toDictionary(false, args)) @@ -561,7 +561,7 @@ class HmssdkFlutterPlugin : peer, roleToChangeTo, forceChange ?: false, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -578,7 +578,7 @@ class HmssdkFlutterPlugin : peer, roleToChangeTo, forceChange ?: false, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -597,7 +597,7 @@ class HmssdkFlutterPlugin : if (requestChange != null) { hmssdk!!.acceptChangeRole( this.requestChange!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) requestChange = null } else { @@ -606,7 +606,7 @@ class HmssdkFlutterPlugin : code = 6004, description = "Role Change Request is Expired.", message = "Role Change Request is Expired.", - name = "Role Change Request Error" + name = "Role Change Request Error", ) val args = HMSExceptionExtension.toDictionary(hmsException) result.success(args) @@ -619,7 +619,7 @@ class HmssdkFlutterPlugin : HMSLogger.i( "onAudioLevelUpdateHMSLogger", - HMSLogger.level.toString() + HMSLogger.level.toString(), ) if (speakers.isNotEmpty()) { @@ -656,7 +656,7 @@ class HmssdkFlutterPlugin : hmssdk!!.changeTrackState( track, mute!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -670,7 +670,7 @@ class HmssdkFlutterPlugin : hmssdk!!.removePeerRequest( peer = peer, hmsActionResultListener = HMSCommonAction.getActionListener(result), - reason = reason + reason = reason, ) } @@ -686,7 +686,7 @@ class HmssdkFlutterPlugin : hmssdk!!.endRoom( lock = lock!!, reason = reason, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) disposePIP() removeAllKeyChangeListener() @@ -712,7 +712,7 @@ class HmssdkFlutterPlugin : type = HMSTrackExtension.getKindFromString(type), source = source, roles = hmsRoles, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -766,7 +766,7 @@ class HmssdkFlutterPlugin : hmssdk!!.changeMetadata( metadata!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -919,7 +919,6 @@ class HmssdkFlutterPlugin : eventSink?.success(args) } } - } private val hmsPreviewListener = object : HMSPreviewListener { @@ -997,7 +996,7 @@ class HmssdkFlutterPlugin : level: HMSLogger.LogLevel, tag: String, message: String, - isWebRtCLog: Boolean + isWebRtCLog: Boolean, ) { /*** * Here we filter the logs based on the level we have set @@ -1032,7 +1031,7 @@ class HmssdkFlutterPlugin : val name = call.argument("name") hmssdk!!.changeName( name = name!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -1049,11 +1048,11 @@ class HmssdkFlutterPlugin : androidScreenshareResult = result activity.applicationContext?.registerReceiver(activityBroadcastReceiver, IntentFilter("ACTIVITY_RECEIVER")) val mediaProjectionManager: MediaProjectionManager = activity.getSystemService( - Context.MEDIA_PROJECTION_SERVICE + Context.MEDIA_PROJECTION_SERVICE, ) as MediaProjectionManager activity.startActivityForResult( mediaProjectionManager.createScreenCaptureIntent(), - Constants.SCREEN_SHARE_INTENT_REQUEST_CODE + Constants.SCREEN_SHARE_INTENT_REQUEST_CODE, ) } @@ -1089,7 +1088,7 @@ class HmssdkFlutterPlugin : } } }, - data + data, ) activity.applicationContext?.unregisterReceiver(activityBroadcastReceiver) } @@ -1105,11 +1104,11 @@ class HmssdkFlutterPlugin : mode = call.argument("audio_mixing_mode") activity.applicationContext?.registerReceiver(activityBroadcastReceiver, IntentFilter("ACTIVITY_RECEIVER")) val mediaProjectionManager: MediaProjectionManager? = activity.getSystemService( - Context.MEDIA_PROJECTION_SERVICE + Context.MEDIA_PROJECTION_SERVICE, ) as MediaProjectionManager activity.startActivityForResult( mediaProjectionManager?.createScreenCaptureIntent(), - Constants.AUDIO_SHARE_INTENT_REQUEST_CODE + Constants.AUDIO_SHARE_INTENT_REQUEST_CODE, ) } @@ -1131,7 +1130,7 @@ class HmssdkFlutterPlugin : } }, data, - audioMixingMode = AudioMixingMode.valueOf(mode!!) + audioMixingMode = AudioMixingMode.valueOf(mode!!), ) activity.applicationContext?.unregisterReceiver(activityBroadcastReceiver) } @@ -1225,13 +1224,12 @@ class HmssdkFlutterPlugin : * - keyChangeListener: Instance of HMSKeyChangeListener to listen to the metadata changes for corresponding keys * - hmsActionResultListener: Instance of HMSActionResultListener to notify success or failure of the method call */ - private fun addKeyChangeListener(call: MethodCall,result: Result){ - + private fun addKeyChangeListener(call: MethodCall, result: Result) { val keys = call.argument>("keys") ?: run { HMSErrorLogger.returnArgumentsError("keys parameter is null") } - val uid = call.argument("uid")?: run { + val uid = call.argument("uid") ?: run { HMSErrorLogger.returnArgumentsError("uid is null") } @@ -1240,13 +1238,12 @@ class HmssdkFlutterPlugin : override fun onKeyChanged(key: String, value: String?) { val args = HashMap() args["event_name"] = "on_key_changed" - val newData = HashMap() + val newData = HashMap() newData["key"] = key if (value is String?) { newData["value"] = value - } - else{ - HMSErrorLogger.logError("onKeyChanged","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + } else { + HMSErrorLogger.logError("onKeyChanged", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") newData["value"] = null } newData["uid"] = uid as String @@ -1256,9 +1253,10 @@ class HmssdkFlutterPlugin : } } } - hmsKeyChangeObserverList.add(HMSKeyChangeObserver(uid as String,keyChangeListener)) - keys.let { keys as List - hmsSessionStore?.addKeyChangeListener(keys,keyChangeListener,HMSCommonAction.getActionListener(result)) + hmsKeyChangeObserverList.add(HMSKeyChangeObserver(uid as String, keyChangeListener)) + keys.let { + keys as List + hmsSessionStore?.addKeyChangeListener(keys, keyChangeListener, HMSCommonAction.getActionListener(result)) } } } @@ -1267,16 +1265,15 @@ class HmssdkFlutterPlugin : * This method is used to remove the attached key change listeners * attached using [addKeyChangeListener] method */ - private fun removeKeyChangeListener(call: MethodCall){ - - val uid = call.argument("uid")?: run { + private fun removeKeyChangeListener(call: MethodCall) { + val uid = call.argument("uid") ?: run { HMSErrorLogger.returnArgumentsError("uid is null") } uid?.let { - hmsKeyChangeObserverList.forEach{ + hmsKeyChangeObserverList.forEach { hmsKeyChangeObserver -> - if(hmsKeyChangeObserver.uid == uid){ + if (hmsKeyChangeObserver.uid == uid) { hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) hmsKeyChangeObserverList.remove(hmsKeyChangeObserver) return @@ -1290,9 +1287,10 @@ class HmssdkFlutterPlugin : * This is used while cleaning the room state i.e after calling leave room, * onRemovedFromRoom or endRoom */ - private fun removeAllKeyChangeListener(){ - hmsKeyChangeObserverList.forEach{ - hmsKeyChangeObserver -> hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) + private fun removeAllKeyChangeListener() { + hmsKeyChangeObserverList.forEach { + hmsKeyChangeObserver -> + hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) } hmsKeyChangeObserverList.clear() } @@ -1302,7 +1300,7 @@ class HmssdkFlutterPlugin : override fun onRemoteVideoStats( videoStats: HMSRemoteVideoStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer? + hmsPeer: HMSPeer?, ) { if (hmsPeer == null) { Log.e("RemoteVideoStats err", "Peer is null") @@ -1319,7 +1317,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsRemoteVideoStats = videoStats, peer = hmsPeer, - track = hmsTrack + track = hmsTrack, ) if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { @@ -1331,7 +1329,7 @@ class HmssdkFlutterPlugin : override fun onRemoteAudioStats( audioStats: HMSRemoteAudioStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer? + hmsPeer: HMSPeer?, ) { if (hmsPeer == null) { Log.e("RemoteAudioStats err", "Peer is null") @@ -1348,7 +1346,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsRemoteAudioStats = audioStats, peer = hmsPeer, - track = hmsTrack + track = hmsTrack, ) if (args["data"] != null) { @@ -1361,7 +1359,7 @@ class HmssdkFlutterPlugin : override fun onLocalVideoStats( videoStats: List, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer? + hmsPeer: HMSPeer?, ) { if (hmsPeer == null) { Log.e("LocalVideoStats err", "Peer is null") @@ -1378,7 +1376,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsLocalVideoStats = videoStats, peer = hmsPeer, - track = hmsTrack + track = hmsTrack, ) if (args["data"] != null) { @@ -1391,7 +1389,7 @@ class HmssdkFlutterPlugin : override fun onLocalAudioStats( audioStats: HMSLocalAudioStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer? + hmsPeer: HMSPeer?, ) { if (hmsPeer == null) { Log.e("LocalAudioStats err", "Peer is null") @@ -1408,7 +1406,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsLocalAudioStats = audioStats, peer = hmsPeer, - track = hmsTrack + track = hmsTrack, ) if (args["data"] != null) { diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/AudioParamsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/AudioParamsExtension.kt index 9ad7a10cf..96ddf7e81 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/AudioParamsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/AudioParamsExtension.kt @@ -3,32 +3,32 @@ package live.hms.hmssdk_flutter.hms_role_components import live.hms.video.media.codec.HMSAudioCodec import live.hms.video.sdk.models.role.AudioParams -class AudioParamsExtension{ - companion object{ - fun toDictionary(audioParams: AudioParams):HashMap? { - val args=HashMap() - if(audioParams==null || audioParams.codec==null)return null - args.put("bit_rate",audioParams.bitRate) +class AudioParamsExtension { + companion object { + fun toDictionary(audioParams: AudioParams): HashMap? { + val args = HashMap() + if (audioParams == null || audioParams.codec == null)return null + args.put("bit_rate", audioParams.bitRate) args.put("codec", getValueOfHMSAudioCodec(audioParams.codec)) return args } - fun getValueOfHMSAudioCodec (codec: HMSAudioCodec):String{ + fun getValueOfHMSAudioCodec(codec: HMSAudioCodec): String { return when (codec) { - HMSAudioCodec.OPUS-> + HMSAudioCodec.OPUS -> "opus" - else-> + else -> "defaultCodec" } } - fun getValueOfHMSAudioCodecFromString (codec:String?):HMSAudioCodec?{ + fun getValueOfHMSAudioCodecFromString(codec: String?): HMSAudioCodec? { return when (codec) { - "opus"-> + "opus" -> HMSAudioCodec.OPUS - else-> + else -> null } } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/PermissionParamsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/PermissionParamsExtension.kt index 46fc659f7..a7123ba96 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/PermissionParamsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/PermissionParamsExtension.kt @@ -3,10 +3,10 @@ package live.hms.hmssdk_flutter.hms_role_components import live.hms.video.sdk.models.role.PermissionsParams class PermissionParamsExtension { - companion object{ - fun toDictionary(permissionsParams: PermissionsParams?):HashMap?{ - val args=HashMap() - if(permissionsParams==null)return null + companion object { + fun toDictionary(permissionsParams: PermissionsParams?): HashMap? { + val args = HashMap() + if (permissionsParams == null)return null args["browser_recording"] = permissionsParams.browserRecording args["change_role"] = permissionsParams.changeRole args["end_room"] = permissionsParams.endRoom @@ -18,4 +18,4 @@ class PermissionParamsExtension { return args } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/VideoParamsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/VideoParamsExtension.kt index 4dbb3a725..fd9c7a7f7 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/VideoParamsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/VideoParamsExtension.kt @@ -1,47 +1,46 @@ package live.hms.hmssdk_flutter.hms_role_components -import live.hms.video.media.codec.HMSAudioCodec import live.hms.video.media.codec.HMSVideoCodec import live.hms.video.sdk.models.role.VideoParams -class VideoParamsExtension{ +class VideoParamsExtension { - companion object{ - fun toDictionary(videoParams: VideoParams):HashMap?{ - val args=HashMap() - if (videoParams==null || videoParams.codec==null)return null - args.put("bit_rate",videoParams.bitRate) - args.put("frame_rate",videoParams.frameRate) - args.put("width",videoParams.width) - args.put("height",videoParams.height) + companion object { + fun toDictionary(videoParams: VideoParams): HashMap? { + val args = HashMap() + if (videoParams == null || videoParams.codec == null)return null + args.put("bit_rate", videoParams.bitRate) + args.put("frame_rate", videoParams.frameRate) + args.put("width", videoParams.width) + args.put("height", videoParams.height) args.put("codec", getValueOfHMSAudioCodec(videoParams.codec)) return args } - fun getValueOfHMSAudioCodec (codec: HMSVideoCodec):String{ + fun getValueOfHMSAudioCodec(codec: HMSVideoCodec): String { return when (codec) { - HMSVideoCodec.H264-> + HMSVideoCodec.H264 -> "h264" - HMSVideoCodec.VP8-> + HMSVideoCodec.VP8 -> "vp8" - HMSVideoCodec.VP9-> + HMSVideoCodec.VP9 -> "vp9" - else-> + else -> "defaultCodec" } } - fun getValueOfHMSAudioCodecFromString(codec: String?):HMSVideoCodec?{ + fun getValueOfHMSAudioCodecFromString(codec: String?): HMSVideoCodec? { return when (codec) { - "h264"->HMSVideoCodec.H264 + "h264" -> HMSVideoCodec.H264 - "vp8"->HMSVideoCodec.VP8 + "vp8" -> HMSVideoCodec.VP8 - "vp9"->HMSVideoCodec.VP9 + "vp9" -> HMSVideoCodec.VP9 - else-> + else -> null } } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSAudioDeviceAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSAudioDeviceAction.kt index 559035eb7..59ff6c3f4 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSAudioDeviceAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSAudioDeviceAction.kt @@ -1,5 +1,4 @@ package live.hms.hmssdk_flutter -import android.util.Log import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel.Result import kotlinx.coroutines.CoroutineScope @@ -10,20 +9,18 @@ import live.hms.video.media.tracks.* import live.hms.video.sdk.* import live.hms.video.sdk.models.* - - class HMSAudioDeviceAction { companion object { - fun audioDeviceActions(call: MethodCall, result: Result,hmssdk:HMSSDK) { + fun audioDeviceActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { when (call.method) { "get_audio_devices_list" -> { - getAudioDevicesList(call, result,hmssdk) + getAudioDevicesList(call, result, hmssdk) } - "get_current_audio_device"-> { - getCurrentDevice(call,result,hmssdk) + "get_current_audio_device" -> { + getCurrentDevice(call, result, hmssdk) } "switch_audio_output" -> { - switchAudioOutput(call,result,hmssdk) + switchAudioOutput(call, result, hmssdk) } else -> { result.notImplemented() @@ -31,29 +28,28 @@ class HMSAudioDeviceAction { } } - private fun getAudioDevicesList(call: MethodCall, result: Result,hmssdk:HMSSDK){ - val audioDevicesList = ArrayList(); - for (device in hmssdk.getAudioDevicesList()){ - audioDevicesList.add(device.name); + private fun getAudioDevicesList(call: MethodCall, result: Result, hmssdk: HMSSDK) { + val audioDevicesList = ArrayList() + for (device in hmssdk.getAudioDevicesList()) { + audioDevicesList.add(device.name) } CoroutineScope(Dispatchers.Main).launch { result.success(audioDevicesList) } } - private fun getCurrentDevice(call: MethodCall, result: Result,hmssdk:HMSSDK){ + private fun getCurrentDevice(call: MethodCall, result: Result, hmssdk: HMSSDK) { CoroutineScope(Dispatchers.Main).launch { result.success(hmssdk.getAudioOutputRouteType().name) } } - private fun switchAudioOutput(call: MethodCall, result: Result,hmssdk:HMSSDK){ - var argument:String? = call.argument("audio_device_name") - if(argument!=null){ - var audioDevice:HMSAudioManager.AudioDevice = HMSAudioManager.AudioDevice.valueOf(argument) + private fun switchAudioOutput(call: MethodCall, result: Result, hmssdk: HMSSDK) { + var argument: String? = call.argument("audio_device_name") + if (argument != null) { + var audioDevice: HMSAudioManager.AudioDevice = HMSAudioManager.AudioDevice.valueOf(argument) hmssdk.switchAudioOutput(audioDevice) } - } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSHLSAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSHLSAction.kt index 8bbfef6f0..f76a85908 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSHLSAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSHLSAction.kt @@ -1,24 +1,23 @@ package live.hms.hmssdk_flutter -import android.util.Log +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel.Result import live.hms.video.sdk.HMSSDK import live.hms.video.sdk.models.HMSHLSConfig import live.hms.video.sdk.models.HMSHLSMeetingURLVariant -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel.Result import live.hms.video.sdk.models.HMSHlsRecordingConfig class HMSHLSAction { - companion object{ + companion object { - fun hlsActions(call: MethodCall, result: Result,hmssdk:HMSSDK){ + fun hlsActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { when (call.method) { - "hls_start_streaming"->{ - hlsStreaming(call, result,hmssdk) + "hls_start_streaming" -> { + hlsStreaming(call, result, hmssdk) } - "hls_stop_streaming"->{ - stopHLSStreaming(call,result,hmssdk) + "hls_stop_streaming" -> { + stopHLSStreaming(call, result, hmssdk) } else -> { result.notImplemented() @@ -26,57 +25,55 @@ class HMSHLSAction { } } - - private fun hlsStreaming(call: MethodCall, result: Result,hmssdk:HMSSDK) { - val meetingUrlVariantsList = call.argument>?>("meeting_url_variants") - val recordingConfig = call.argument?>("recording_config") - var meetingUrlVariant : ArrayList? = null + private fun hlsStreaming(call: MethodCall, result: Result, hmssdk: HMSSDK) { + val meetingUrlVariantsList = call.argument>?>("meeting_url_variants") + val recordingConfig = call.argument?>("recording_config") + var meetingUrlVariant: ArrayList? = null var hmsHLSRecordingConfig: HMSHlsRecordingConfig? = null var hlsConfig: HMSHLSConfig? = null - if(meetingUrlVariantsList!=null) { + if (meetingUrlVariantsList != null) { meetingUrlVariant = ArrayList() meetingUrlVariantsList?.forEach { meetingUrlVariant.add( HMSHLSMeetingURLVariant( meetingUrl = it["meeting_url"]!!, - metadata = it["meta_data"]!! - ) + metadata = it["meta_data"]!!, + ), ) } } - if(recordingConfig!=null){ + if (recordingConfig != null) { hmsHLSRecordingConfig = HMSHlsRecordingConfig( singleFilePerLayer = recordingConfig?.get("single_file_per_layer")!!, - videoOnDemand = recordingConfig?.get("video_on_demand")!! + videoOnDemand = recordingConfig?.get("video_on_demand")!!, ) } - if(meetingUrlVariant!=null || hmsHLSRecordingConfig!=null) { + if (meetingUrlVariant != null || hmsHLSRecordingConfig != null) { hlsConfig = HMSHLSConfig(meetingUrlVariant, hmsHLSRecordingConfig) } hmssdk.startHLSStreaming(config = hlsConfig, hmsActionResultListener = HMSCommonAction.getActionListener(result)) } + private fun stopHLSStreaming(call: MethodCall, result: Result, hmssdk: HMSSDK) { + val meetingUrlVariantsList = call.argument>>("meeting_url_variants") - private fun stopHLSStreaming(call: MethodCall,result: Result,hmssdk:HMSSDK) { - val meetingUrlVariantsList = call.argument>>("meeting_url_variants") - - val meetingUrlVariant1 : ArrayList = ArrayList() + val meetingUrlVariant1: ArrayList = ArrayList() meetingUrlVariantsList?.forEach { meetingUrlVariant1.add( - HMSHLSMeetingURLVariant( - meetingUrl = it["meeting_url"]!!, - metadata = it["meta_data"]!! - ) + HMSHLSMeetingURLVariant( + meetingUrl = it["meeting_url"]!!, + metadata = it["meta_data"]!!, + ), ) } - var hlsConfig : HMSHLSConfig? = null - if(meetingUrlVariant1.isNotEmpty()) + var hlsConfig: HMSHLSConfig? = null + if (meetingUrlVariant1.isNotEmpty()) { hlsConfig = HMSHLSConfig(meetingUrlVariant1) + } hmssdk.stopHLSStreaming(config = hlsConfig, hmsActionResultListener = HMSCommonAction.getActionListener(result)) } - } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSMessageAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSMessageAction.kt index 0f69ba2a3..4e25f31bd 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSMessageAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSMessageAction.kt @@ -1,25 +1,25 @@ package live.hms.hmssdk_flutter import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel.Result -import live.hms.video.sdk.* -import live.hms.video.error.HMSException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import live.hms.video.error.HMSException +import live.hms.video.sdk.* import live.hms.video.sdk.models.HMSMessage class HMSMessageAction { companion object { - fun messageActions(call: MethodCall, result: Result,hmssdk:HMSSDK) { + fun messageActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { when (call.method) { "send_broadcast_message" -> { - sendBroadCastMessage(call, result,hmssdk) + sendBroadCastMessage(call, result, hmssdk) } "send_direct_message" -> { - sendDirectMessage(call, result,hmssdk) + sendDirectMessage(call, result, hmssdk) } "send_group_message" -> { - sendGroupMessage(call, result,hmssdk) + sendGroupMessage(call, result, hmssdk) } else -> { result.notImplemented() @@ -27,14 +27,13 @@ class HMSMessageAction { } } - - private fun sendBroadCastMessage(call: MethodCall, result: Result,hmssdk:HMSSDK) { + private fun sendBroadCastMessage(call: MethodCall, result: Result, hmssdk: HMSSDK) { val message = call.argument("message") val type = call.argument("type") ?: "chat" hmssdk?.sendBroadcastMessage(message!!, type, getMessageResultListener(result)) } - private fun sendGroupMessage(call: MethodCall, result: Result,hmssdk:HMSSDK) { + private fun sendGroupMessage(call: MethodCall, result: Result, hmssdk: HMSSDK) { val message = call.argument("message") val roles: List? = call.argument>("roles") val type = call.argument("type") ?: "chat" @@ -44,35 +43,36 @@ class HMSMessageAction { hmssdk?.sendGroupMessage(message!!, type, hmsRoles, getMessageResultListener(result)) } - private fun sendDirectMessage(call: MethodCall, result: Result,hmssdk:HMSSDK) { + private fun sendDirectMessage(call: MethodCall, result: Result, hmssdk: HMSSDK) { val message = call.argument("message") val peerId = call.argument("peer_id") val type = call.argument("type") ?: "chat" - val peer = HMSCommonAction.getPeerById(peerId!!,hmssdk) + val peer = HMSCommonAction.getPeerById(peerId!!, hmssdk) hmssdk?.sendDirectMessage(message!!, type, peer!!, getMessageResultListener(result)) } - private fun getMessageResultListener(result: Result) = object: HMSMessageResultListener { + private fun getMessageResultListener(result: Result) = object : HMSMessageResultListener { override fun onError(error: HMSException) { val args = HashMap() args["event_name"] = "on_error" args["data"] = HMSExceptionExtension.toDictionary(error) - if (args["data"] != null) + if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { result.success(args) } + } } override fun onSuccess(hmsMessage: HMSMessage) { val args = HashMap() args["event_name"] = "on_success" args["message"] = HMSMessageExtension.toDictionary(hmsMessage) - if (args["message"] != null) + if (args["message"] != null) { CoroutineScope(Dispatchers.Main).launch { result.success(args) } + } } } - } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt index 1fa3ff890..04c795cf2 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt @@ -29,7 +29,7 @@ class HMSPipAction { } "is_pip_available" -> { result.success( - activity.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) + activity.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE), ) } "setup_pip" -> { diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRecordingAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRecordingAction.kt index 2ba564493..b2d806163 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRecordingAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRecordingAction.kt @@ -1,24 +1,19 @@ package live.hms.hmssdk_flutter -import live.hms.video.sdk.HMSSDK import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel.Result -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import live.hms.video.error.HMSException import live.hms.video.media.settings.HMSRtmpVideoResolution -import live.hms.video.sdk.HMSActionResultListener +import live.hms.video.sdk.HMSSDK import live.hms.video.sdk.models.HMSRecordingConfig class HMSRecordingAction { - companion object{ - fun recordingActions(call: MethodCall, result: Result,hmssdk:HMSSDK){ + companion object { + fun recordingActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { when (call.method) { "start_rtmp_or_recording" -> { - startRtmpOrRecording(call, result,hmssdk) + startRtmpOrRecording(call, result, hmssdk) } "stop_rtmp_and_recording" -> { - stopRtmpAndRecording(result,hmssdk) + stopRtmpAndRecording(result, hmssdk) } else -> { result.notImplemented() @@ -26,29 +21,28 @@ class HMSRecordingAction { } } - private fun startRtmpOrRecording(call: MethodCall, result: Result,hmssdk:HMSSDK) { + private fun startRtmpOrRecording(call: MethodCall, result: Result, hmssdk: HMSSDK) { val meetingUrl = call.argument("meeting_url") val toRecord = call.argument("to_record") val listOfRtmpUrls: List = call.argument>("rtmp_urls") ?: listOf() - val resolutionMap = call.argument>("resolution") - val hmsRecordingConfig = if(resolutionMap!=null) { + val resolutionMap = call.argument>("resolution") + val hmsRecordingConfig = if (resolutionMap != null) { val resolution = HMSRtmpVideoResolution( width = resolutionMap["width"]!!, - height = resolutionMap["height"]!! + height = resolutionMap["height"]!!, ) - HMSRecordingConfig(meetingUrl!!, listOfRtmpUrls, toRecord!!,resolution) - }else{ + HMSRecordingConfig(meetingUrl!!, listOfRtmpUrls, toRecord!!, resolution) + } else { HMSRecordingConfig(meetingUrl!!, listOfRtmpUrls, toRecord!!) } hmssdk.startRtmpOrRecording( hmsRecordingConfig, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } - private fun stopRtmpAndRecording(result: Result,hmssdk:HMSSDK) { + private fun stopRtmpAndRecording(result: Result, hmssdk: HMSSDK) { hmssdk.stopRtmpAndRecording(hmsActionResultListener = HMSCommonAction.getActionListener(result)) } - } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRoomAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRoomAction.kt index e6e107e03..b06b664e8 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRoomAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRoomAction.kt @@ -1,39 +1,39 @@ package live.hms.hmssdk_flutter import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel.Result -import live.hms.video.sdk.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import live.hms.video.sdk.* class HMSRoomAction { companion object { fun roomActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { when (call.method) { "get_room" -> { - getRoom(result,hmssdk) + getRoom(result, hmssdk) } "get_local_peer" -> { - localPeer(result,hmssdk) + localPeer(result, hmssdk) } "get_remote_peers" -> { - getRemotePeers(result,hmssdk) + getRemotePeers(result, hmssdk) } "get_peers" -> { - getPeers(result,hmssdk) + getPeers(result, hmssdk) } else -> { result.notImplemented() } } } - private fun getRoom(result: Result,hmssdk: HMSSDK) { + private fun getRoom(result: Result, hmssdk: HMSSDK) { result.success(HMSRoomExtension.toDictionary(hmssdk?.getRoom())) } - private fun localPeer(result: Result,hmssdk: HMSSDK) { + private fun localPeer(result: Result, hmssdk: HMSSDK) { result.success(HMSPeerExtension.toDictionary(HMSCommonAction.getLocalPeer(hmssdk))) } - private fun getRemotePeers(result: Result,hmssdk: HMSSDK) { + private fun getRemotePeers(result: Result, hmssdk: HMSSDK) { val peersList = hmssdk.getRemotePeers() val peersMapList = ArrayList?>() peersList.forEach { @@ -45,7 +45,7 @@ class HMSRoomAction { } // TODO: check behaviour when room is not joined - private fun getPeers(result: Result,hmssdk: HMSSDK) { + private fun getPeers(result: Result, hmssdk: HMSSDK) { val peersList = hmssdk.getPeers() val peersMapList = ArrayList?>() peersList.forEach { @@ -56,4 +56,4 @@ class HMSRoomAction { } } } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt index 63f1500fb..6b9cc1f5e 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt @@ -7,7 +7,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import live.hms.hmssdk_flutter.HMSCommonAction import live.hms.hmssdk_flutter.HMSErrorLogger -import live.hms.hmssdk_flutter.HMSExceptionExtension import live.hms.hmssdk_flutter.HMSSessionMetadataExtension import live.hms.video.error.HMSException import live.hms.video.sdk.HMSSDK @@ -38,7 +37,7 @@ class HMSSessionMetadataAction { hmssdk.setSessionMetaData(metadata, HMSCommonAction.getActionListener(result)) } - private fun getSessionMetadataResultListener(result: MethodChannel.Result) = object: + private fun getSessionMetadataResultListener(result: MethodChannel.Result) = object : HMSSessionMetadataListener { override fun onError(error: HMSException) { result.success(null) @@ -49,17 +48,16 @@ class HMSSessionMetadataAction { args["event_name"] = "session_metadata" if (sessionMetadata is String?) { args["data"] = HMSSessionMetadataExtension.toDictionary(sessionMetadata) - } - else { - HMSErrorLogger.logError("getSessionMetadata","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + } else { + HMSErrorLogger.logError("getSessionMetadata", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") args["data"] = null } - if (args["data"] != null) + if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { result.success(args) } + } } } - } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt index 04d72340f..496366bae 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt @@ -12,15 +12,15 @@ import live.hms.video.sessionstore.HmsSessionStore class HMSSessionStoreAction { - companion object{ + companion object { - fun sessionStoreActions(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?){ - when(call.method){ + fun sessionStoreActions(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { + when (call.method) { "get_session_metadata_for_key" -> { - getSessionMetadataForKey(call,result,hmsSessionStore) + getSessionMetadataForKey(call, result, hmsSessionStore) } "set_session_metadata_for_key" -> { - setSessionMetadataForKey(call,result,hmsSessionStore) + setSessionMetadataForKey(call, result, hmsSessionStore) } } } @@ -33,26 +33,29 @@ class HMSSessionStoreAction { * * This method returns [sessionMetadata] is the session metadata is available for corresponding key */ - private fun getSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ + private fun getSessionMetadataForKey(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { val key = call.argument("key") ?: run { HMSErrorLogger.returnArgumentsError("key is null") } - key?.let { key as String - hmsSessionStore?.get(key,object:HMSSessionMetadataListener{ - override fun onError(error: HMSException) { - result.success(HMSResultExtension.toDictionary(false, HMSExceptionExtension.toDictionary(error))) - } - - override fun onSuccess(sessionMetadata: Any?) { - if (sessionMetadata is String?) { - result.success(HMSResultExtension.toDictionary(true, sessionMetadata)) + key?.let { + key as String + hmsSessionStore?.get( + key, + object : HMSSessionMetadataListener { + override fun onError(error: HMSException) { + result.success(HMSResultExtension.toDictionary(false, HMSExceptionExtension.toDictionary(error))) } - else{ - HMSErrorLogger.returnHMSException("getSessionMetadataForKey","Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) + + override fun onSuccess(sessionMetadata: Any?) { + if (sessionMetadata is String?) { + result.success(HMSResultExtension.toDictionary(true, sessionMetadata)) + } else { + HMSErrorLogger.returnHMSException("getSessionMetadataForKey", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) + } } - } - }) + }, + ) } } @@ -65,17 +68,17 @@ class HMSSessionStoreAction { * This method sets the [data] provided during the method call * The completion of this method is marked by actionResultListener's [onSuccess] or [onError] callback */ - private fun setSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ + private fun setSessionMetadataForKey(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { val key = call.argument("key") ?: run { HMSErrorLogger.returnArgumentsError("key is null") } val data = call.argument("data") - key?.let { key as String - hmsSessionStore?.set(data,key,HMSCommonAction.getActionListener(result)) + key?.let { + key as String + hmsSessionStore?.set(data, key, HMSCommonAction.getActionListener(result)) } } - } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoView.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoView.kt index 4f027aef5..fea4f86c3 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoView.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoView.kt @@ -23,7 +23,7 @@ class HMSVideoView( private val scaleType: Int? = RendererCommon.ScalingType.SCALE_ASPECT_FIT.ordinal, private val track: HMSVideoTrack?, private val disableAutoSimulcastLayerSelect: Boolean, - private val hmssdkFlutterPlugin: HmssdkFlutterPlugin? + private val hmssdkFlutterPlugin: HmssdkFlutterPlugin?, ) : FrameLayout(context, null) { private var hmsVideoView: HMSVideoView? = null diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoViewFactory.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoViewFactory.kt index e9c402ed1..f3a4c0aba 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoViewFactory.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoViewFactory.kt @@ -22,7 +22,7 @@ class HMSVideoViewWidget( scaleType: Int?, private val matchParent: Boolean? = true, disableAutoSimulcastLayerSelect: Boolean, - hmssdkFlutterPlugin: HmssdkFlutterPlugin? + hmssdkFlutterPlugin: HmssdkFlutterPlugin?, ) : PlatformView { private var hmsVideoView: HMSVideoView? = null @@ -41,12 +41,12 @@ class HMSVideoViewWidget( super.onFlutterViewAttached(flutterView) var frameLayoutParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, - FrameLayout.LayoutParams.MATCH_PARENT + FrameLayout.LayoutParams.MATCH_PARENT, ) if (matchParent == false) { frameLayoutParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, - FrameLayout.LayoutParams.WRAP_CONTENT + FrameLayout.LayoutParams.WRAP_CONTENT, ) } if (view != null) { @@ -90,7 +90,7 @@ class HMSVideoViewFactory(private val plugin: HmssdkFlutterPlugin) : code = 6004, description = "There is no track corresponding to the given trackId", message = "Video track is null for corresponding trackId", - name = "HMSVideoView Error" + name = "HMSVideoView Error", ) args["data"] = HMSExceptionExtension.toDictionary(hmsException) plugin.onVideoViewError(args) diff --git a/example/android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt b/example/android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt index a4b34c4a8..83a6af844 100644 --- a/example/android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt +++ b/example/android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt @@ -27,7 +27,7 @@ class MainActivity : FlutterActivity() { override fun onPictureInPictureModeChanged( isInPictureInPictureMode: Boolean, - newConfig: Configuration? + newConfig: Configuration?, ) { if (isInPictureInPictureMode) { if (HMSPipAction.pipResult != null) { diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index 49304354f..3ee1f227c 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -28,7 +28,7 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) return } @@ -36,24 +36,23 @@ class HMSSessionStoreAction { let key = arguments["key"] as? String else { HMSErrorLogger.returnArgumentsError("key is null") - HMSErrorLogger.returnHMSException(#function,"Key to be fetched from Session Store is null.","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Key to be fetched from Session Store is null.", "NULL ERROR", result) return } store.object(forKey: key) { value, error in if let error = error { - HMSErrorLogger.returnHMSException(#function,"Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)","Key Fetching error",result) + HMSErrorLogger.returnHMSException(#function, "Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)", "Key Fetching error", result) return } - if(value is String? || value is NSNull){ + if value is String? || value is NSNull { result(HMSResultExtension.toDictionary(true, value)) + } else { + HMSErrorLogger.returnHMSException(#function, "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) } - else{ - HMSErrorLogger.returnHMSException(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error",result) - } - + } } @@ -62,23 +61,23 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - HMSErrorLogger.returnHMSException(#function,"Session Store is null.", "NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Session Store is null.", "NULL ERROR", result) return } guard let arguments = call.arguments as? [AnyHashable: Any], let key = arguments["key"] as? String else { - HMSErrorLogger.returnHMSException(#function,"Key for the object to be set in Session Store is null.","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Key for the object to be set in Session Store is null.", "NULL ERROR", result) return } let data = arguments["data"] - store.set(data as Any, forKey: key) { value, error in + store.set(data as Any, forKey: key) { _, error in if let error = error { - HMSErrorLogger.returnHMSException(#function,"Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)","Key Error",result) + HMSErrorLogger.returnHMSException(#function, "Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)", "Key Error", result) return } result(nil) diff --git a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift index 02817a65e..edd570c38 100644 --- a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift +++ b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift @@ -11,64 +11,64 @@ import HMSSDK class HMSAudioFilePlayerNodeExtension { static func play(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { - guard let fileURL = call["file_url"] as? String else{ + guard let fileURL = call["file_url"] as? String else { HMSErrorLogger.returnArgumentsError("Invalid file") - HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) + HMSErrorLogger.returnHMSException(#function, "Error in playing the file", "File Error", result) return } - guard let url = URL(string: fileURL) else{ + guard let url = URL(string: fileURL) else { HMSErrorLogger.returnArgumentsError("File URL is invalid") - HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) + HMSErrorLogger.returnHMSException(#function, "Error in playing the file", "File Error", result) return } - do{ + do { try playerNode.play(fileUrl: url, loops: call["loops"] as? Bool ?? false, interrupts: call["interrupts"] as? Bool ?? false) - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } catch { - result(HMSResultExtension.toDictionary(false,HMSErrorExtension.toDictionary(error))) + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.toDictionary(error))) } } - static func pause( _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { + static func pause( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { playerNode.pause() - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } static func resume( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { do { try playerNode.resume() - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } catch { - result(HMSResultExtension.toDictionary(false,HMSErrorExtension.toDictionary(error))) + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.toDictionary(error))) } } - static func stop( _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { + static func stop( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { playerNode.stop() - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } - static func setVolume(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { + static func setVolume(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { playerNode.volume = Float(call["volume"] as! Double) - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } static func isPlaying(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["is_playing"] = playerNode.isPlaying - result(HMSResultExtension.toDictionary(true,dict)) + result(HMSResultExtension.toDictionary(true, dict)) } static func currentDuration(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["current_duration"] = playerNode.currentTime - result(HMSResultExtension.toDictionary(true,dict)) + result(HMSResultExtension.toDictionary(true, dict)) } static func duration(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["duration"] = playerNode.duration - result(HMSResultExtension.toDictionary(true,dict)) + result(HMSResultExtension.toDictionary(true, dict)) } } diff --git a/ios/Classes/Models/HMSTrackSettingsExtension.swift b/ios/Classes/Models/HMSTrackSettingsExtension.swift index 5060846bf..12a1ab3d0 100644 --- a/ios/Classes/Models/HMSTrackSettingsExtension.swift +++ b/ios/Classes/Models/HMSTrackSettingsExtension.swift @@ -149,9 +149,9 @@ class HMSTrackSettingsExtension { return nil } } - + static private func getStringFromAudioMode(from mode: HMSAudioMode) -> String? { - switch mode{ + switch mode { case .music: return "music" diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index d6a968a2c..d68844698 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -397,17 +397,17 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene HMSAudioFilePlayerNodeExtension.play(arguments, audioNode as! HMSAudioFilePlayerNode, result) break case "stop_audio_share": - HMSAudioFilePlayerNodeExtension.stop(audioNode as! HMSAudioFilePlayerNode,result) + HMSAudioFilePlayerNodeExtension.stop(audioNode as! HMSAudioFilePlayerNode, result) break case "pause_audio_share": - HMSAudioFilePlayerNodeExtension.pause(audioNode as! HMSAudioFilePlayerNode,result) + HMSAudioFilePlayerNodeExtension.pause(audioNode as! HMSAudioFilePlayerNode, result) break case "resume_audio_share": HMSAudioFilePlayerNodeExtension.resume(audioNode as! HMSAudioFilePlayerNode, result) break case "set_audio_share_volume": if arguments["name"] as! String != "mic_node" { - HMSAudioFilePlayerNodeExtension.setVolume(arguments, audioNode as! HMSAudioFilePlayerNode,result) + HMSAudioFilePlayerNodeExtension.setVolume(arguments, audioNode as! HMSAudioFilePlayerNode, result) } else { HMSMicNodeExtension.setVolume(arguments, audioNode as! HMSMicNode) } @@ -498,26 +498,26 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) return } guard let arguments = call.arguments as? [AnyHashable: Any] else { HMSErrorLogger.returnArgumentsError("keys is null") - HMSErrorLogger.returnHMSException(#function,"No arguments passed which can be attached to Key Change Listener on the Session Store.","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "No arguments passed which can be attached to Key Change Listener on the Session Store.", "NULL ERROR", result) return } guard let keys = arguments["keys"] as? [String] else { - HMSErrorLogger.returnHMSException(#function,"No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)", "NULL ERROR", result) return } - + guard let uid = arguments["uid"] as? String else { - HMSErrorLogger.returnHMSException(#function,"No uid passed for key change listener Available arguments: \(arguments)","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "No uid passed for key change listener Available arguments: \(arguments)", "NULL ERROR", result) return } @@ -529,14 +529,13 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene var dict: [String: Any] = ["key": key] - if(value is String? || value is NSNull){ + if value is String? || value is NSNull { dict["value"] = value - } - else{ - HMSErrorLogger.logError(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + } else { + HMSErrorLogger.logError(#function, "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") dict["value"] = nil } - + dict["uid"] = uid data["data"] = dict @@ -545,19 +544,19 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene }) { [weak self] observer, error in if let error = error { - HMSErrorLogger.returnHMSException(#function,"Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)","KEY CHANGE ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)", "KEY CHANGE ERROR", result) return } guard let observer = observer else { - HMSErrorLogger.returnHMSException(#function,"Unknown Error in observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Unknown Error in observing changes for key: \(keys) in the Session Store.", "KEY CHANGE ERROR", result) return } guard let self = self else { - HMSErrorLogger.returnHMSException(#function,"Could not find self instance while observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Could not find self instance while observing changes for key: \(keys) in the Session Store.", "KEY CHANGE ERROR", result) return } @@ -575,45 +574,44 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) return } guard let arguments = call.arguments as? [AnyHashable: Any] else { - HMSErrorLogger.returnHMSException(#function,"No arguments to identify which Key Change Listener should be removed from the Session Store.","Remove Key Error",result) + HMSErrorLogger.returnHMSException(#function, "No arguments to identify which Key Change Listener should be removed from the Session Store.", "Remove Key Error", result) return } guard let uid = arguments["uid"] as? String else { - HMSErrorLogger.returnHMSException(#function,"No identifier passed which can be used. Available arguments: \(arguments)","Unique Id Error",result) + HMSErrorLogger.returnHMSException(#function, "No identifier passed which can be used. Available arguments: \(arguments)", "Unique Id Error", result) return } guard let keyChangeListenersToBeRemovedIndex = sessionStoreChangeObservers.firstIndex(where: { $0.uid == uid }) - else{ - HMSErrorLogger.returnHMSException(#function,"No listener found to remove","Listener Error",result) + else { + HMSErrorLogger.returnHMSException(#function, "No listener found to remove", "Listener Error", result) return } - store.removeObserver(sessionStoreChangeObservers[keyChangeListenersToBeRemovedIndex].observer) sessionStoreChangeObservers.remove(at: keyChangeListenersToBeRemovedIndex) result(nil) } - + /** This takes care of removing all the key change listeners attached during the session This is used while cleaning the room state i.e after calling leave room, onRemovedFromRoom or endRoom */ - private func removeAllKeyChangeListener(){ - sessionStoreChangeObservers.forEach{ + private func removeAllKeyChangeListener() { + sessionStoreChangeObservers.forEach { hmsSessionStoreObserver in sessionStore?.removeObserver(hmsSessionStoreObserver.observer) } diff --git a/sample apps/bloc/android/app/src/main/kotlin/com/example/demo_app_with_100ms_and_bloc/MainActivity.kt b/sample apps/bloc/android/app/src/main/kotlin/com/example/demo_app_with_100ms_and_bloc/MainActivity.kt index 4521925f8..c189b717c 100644 --- a/sample apps/bloc/android/app/src/main/kotlin/com/example/demo_app_with_100ms_and_bloc/MainActivity.kt +++ b/sample apps/bloc/android/app/src/main/kotlin/com/example/demo_app_with_100ms_and_bloc/MainActivity.kt @@ -1,18 +1,17 @@ package com.example.demo_app_with_100ms_and_bloc -import io.flutter.embedding.android.FlutterActivity -import live.hms.hmssdk_flutter.HmssdkFlutterPlugin import android.app.Activity import android.content.Intent +import io.flutter.embedding.android.FlutterActivity import live.hms.hmssdk_flutter.Constants +import live.hms.hmssdk_flutter.HmssdkFlutterPlugin -class MainActivity: FlutterActivity() { +class MainActivity : FlutterActivity() { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { -super.onActivityResult(requestCode, resultCode, data) + super.onActivityResult(requestCode, resultCode, data) - if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK){ - HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) + if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) { + HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) + } } - -} } diff --git a/sample apps/flutter-audio-room-quickstart/android/app/src/main/kotlin/com/example/flutter_audio_room_quickstart/MainActivity.kt b/sample apps/flutter-audio-room-quickstart/android/app/src/main/kotlin/com/example/flutter_audio_room_quickstart/MainActivity.kt index 9aa257d65..d35527b20 100644 --- a/sample apps/flutter-audio-room-quickstart/android/app/src/main/kotlin/com/example/flutter_audio_room_quickstart/MainActivity.kt +++ b/sample apps/flutter-audio-room-quickstart/android/app/src/main/kotlin/com/example/flutter_audio_room_quickstart/MainActivity.kt @@ -2,5 +2,4 @@ package com.example.flutter_audio_room_quickstart import io.flutter.embedding.android.FlutterActivity -class MainActivity: FlutterActivity() { -} +class MainActivity : FlutterActivity() diff --git a/sample apps/flutter-hls-quickstart/android/app/src/main/kotlin/com/example/flutter_hls_quickstart/MainActivity.kt b/sample apps/flutter-hls-quickstart/android/app/src/main/kotlin/com/example/flutter_hls_quickstart/MainActivity.kt index f8dc93a30..69fd8a679 100644 --- a/sample apps/flutter-hls-quickstart/android/app/src/main/kotlin/com/example/flutter_hls_quickstart/MainActivity.kt +++ b/sample apps/flutter-hls-quickstart/android/app/src/main/kotlin/com/example/flutter_hls_quickstart/MainActivity.kt @@ -2,5 +2,4 @@ package com.example.flutter_hls_quickstart import io.flutter.embedding.android.FlutterActivity -class MainActivity: FlutterActivity() { -} +class MainActivity : FlutterActivity() diff --git a/sample apps/flutter-quickstart-app/android/app/src/main/kotlin/com/example/flutter_integration_guide/MainActivity.kt b/sample apps/flutter-quickstart-app/android/app/src/main/kotlin/com/example/flutter_integration_guide/MainActivity.kt index c5e536eb2..c6a8a7608 100644 --- a/sample apps/flutter-quickstart-app/android/app/src/main/kotlin/com/example/flutter_integration_guide/MainActivity.kt +++ b/sample apps/flutter-quickstart-app/android/app/src/main/kotlin/com/example/flutter_integration_guide/MainActivity.kt @@ -2,5 +2,4 @@ package com.example.flutter_integration_guide import io.flutter.embedding.android.FlutterActivity -class MainActivity: FlutterActivity() { -} +class MainActivity : FlutterActivity() diff --git a/sample apps/getx/android/app/src/main/kotlin/com/example/demo_with_getx_and_100ms/MainActivity.kt b/sample apps/getx/android/app/src/main/kotlin/com/example/demo_with_getx_and_100ms/MainActivity.kt index 289782076..d38cacb32 100644 --- a/sample apps/getx/android/app/src/main/kotlin/com/example/demo_with_getx_and_100ms/MainActivity.kt +++ b/sample apps/getx/android/app/src/main/kotlin/com/example/demo_with_getx_and_100ms/MainActivity.kt @@ -1,19 +1,17 @@ package com.example.demo_with_getx_and_100ms -import io.flutter.embedding.android.FlutterActivity -import live.hms.hmssdk_flutter.HmssdkFlutterPlugin import android.app.Activity import android.content.Intent +import io.flutter.embedding.android.FlutterActivity import live.hms.hmssdk_flutter.Constants +import live.hms.hmssdk_flutter.HmssdkFlutterPlugin - -class MainActivity: FlutterActivity() { +class MainActivity : FlutterActivity() { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { -super.onActivityResult(requestCode, resultCode, data) + super.onActivityResult(requestCode, resultCode, data) - if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK){ - HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) + if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) { + HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) + } } - -} } diff --git a/sample apps/mobx/android/app/src/main/kotlin/com/example/zoom/MainActivity.kt b/sample apps/mobx/android/app/src/main/kotlin/com/example/zoom/MainActivity.kt index 0c724ab6a..eaf224435 100644 --- a/sample apps/mobx/android/app/src/main/kotlin/com/example/zoom/MainActivity.kt +++ b/sample apps/mobx/android/app/src/main/kotlin/com/example/zoom/MainActivity.kt @@ -1,18 +1,17 @@ package com.example.mobx -import io.flutter.embedding.android.FlutterActivity -import live.hms.hmssdk_flutter.HmssdkFlutterPlugin import android.app.Activity import android.content.Intent +import io.flutter.embedding.android.FlutterActivity import live.hms.hmssdk_flutter.Constants +import live.hms.hmssdk_flutter.HmssdkFlutterPlugin -class MainActivity: FlutterActivity() { +class MainActivity : FlutterActivity() { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { -super.onActivityResult(requestCode, resultCode, data) + super.onActivityResult(requestCode, resultCode, data) - if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK){ - HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) + if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) { + HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) + } } - -} } diff --git a/sample apps/riverpod/android/app/src/main/kotlin/com/example/example_riverpod/MainActivity.kt b/sample apps/riverpod/android/app/src/main/kotlin/com/example/example_riverpod/MainActivity.kt index 207363b1f..f739c71c0 100644 --- a/sample apps/riverpod/android/app/src/main/kotlin/com/example/example_riverpod/MainActivity.kt +++ b/sample apps/riverpod/android/app/src/main/kotlin/com/example/example_riverpod/MainActivity.kt @@ -1,18 +1,17 @@ package com.example.example_riverpod -import io.flutter.embedding.android.FlutterActivity -import live.hms.hmssdk_flutter.HmssdkFlutterPlugin import android.app.Activity import android.content.Intent +import io.flutter.embedding.android.FlutterActivity import live.hms.hmssdk_flutter.Constants +import live.hms.hmssdk_flutter.HmssdkFlutterPlugin -class MainActivity: FlutterActivity() { - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { -super.onActivityResult(requestCode, resultCode, data) +class MainActivity : FlutterActivity() { + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) - if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK){ - HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) + if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) { + HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) + } } - -} } From 962d7e7b8fcbb3e75dd1d63fb2969be0b76442d2 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 2 May 2023 23:31:40 +0530 Subject: [PATCH 60/88] Revert "fixed Kotlin lint warnings" This reverts commit 74a12f1690a160452b314140fcb1280b3f6bb54d. --- android/build.gradle | 4 +- .../HMSAudioTrackSettingsExtension.kt | 12 +- .../HMSChangeTrackStateRequestExtension.kt | 22 ++-- .../hmssdk_flutter/HMSHLSVariantExtension.kt | 16 +-- .../hmssdk_flutter/HMSKeyChangeObserver.kt | 2 +- .../live/hms/hmssdk_flutter/HMSLogSettings.kt | 12 +- .../hms/hmssdk_flutter/HMSLogsExtension.kt | 33 ++--- .../hms/hmssdk_flutter/HMSMessageExtension.kt | 17 ++- .../HMSMessageRecipientExtension.kt | 31 ++--- .../HMSNetworkQualityExtension.kt | 4 +- .../hmssdk_flutter/HMSPeerUpdateExtension.kt | 11 +- .../hms/hmssdk_flutter/HMSPreviewExtension.kt | 13 +- .../HMSRemovedFromRoomExtension.kt | 20 +-- .../hmssdk_flutter/HMSRoleChangedExtension.kt | 18 +-- .../hms/hmssdk_flutter/HMSRoleExtension.kt | 22 ++-- .../hmssdk_flutter/HMSRoomUpdateExtension.kt | 9 +- .../hmssdk_flutter/HMSRtmpStreamingState.kt | 58 +++++---- .../HMSSessionMetadataExtension.kt | 9 +- .../hms/hmssdk_flutter/HMSSpeakerExtension.kt | 18 +-- .../HMSTrackInitStateExtension.kt | 20 +-- .../HMSTrackSettingsExtension.kt | 43 ++++--- .../hmssdk_flutter/HMSTrackUpdateExtension.kt | 15 +-- .../HMSVideoResolutionExtension.kt | 17 +-- .../HMSVideoTrackSettingsExtension.kt | 28 +++-- .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 116 +++++++++--------- .../AudioParamsExtension.kt | 26 ++-- .../PermissionParamsExtension.kt | 10 +- .../VideoParamsExtension.kt | 41 ++++--- .../methods/HMSAudioDeviceAction.kt | 34 ++--- .../hmssdk_flutter/methods/HMSHLSAction.kt | 61 ++++----- .../methods/HMSMessageAction.kt | 32 ++--- .../hmssdk_flutter/methods/HMSPipAction.kt | 2 +- .../methods/HMSRecordingAction.kt | 34 ++--- .../hmssdk_flutter/methods/HMSRoomAction.kt | 20 +-- .../methods/HMSSessionMetadataAction.kt | 14 ++- .../methods/HMSSessionStoreAction.kt | 51 ++++---- .../hms/hmssdk_flutter/views/HMSVideoView.kt | 2 +- .../views/HMSVideoViewFactory.kt | 8 +- .../kotlin/live/hms/flutter/MainActivity.kt | 2 +- .../Actions/HMSSessionStoreAction.swift | 23 ++-- .../HMSAudioFilePlayerNodeExtension.swift | 36 +++--- .../Models/HMSTrackSettingsExtension.swift | 4 +- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 48 ++++---- .../MainActivity.kt | 15 +-- .../MainActivity.kt | 3 +- .../flutter_hls_quickstart/MainActivity.kt | 3 +- .../flutter_integration_guide/MainActivity.kt | 3 +- .../demo_with_getx_and_100ms/MainActivity.kt | 16 +-- .../kotlin/com/example/zoom/MainActivity.kt | 15 +-- .../example/example_riverpod/MainActivity.kt | 17 +-- 50 files changed, 573 insertions(+), 517 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 68a1da0c5..2ddaabebb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -39,9 +39,9 @@ android { minSdkVersion 21 } } - +def hmsVersion = "an719-SNAPSHOT" dependencies { - implementation "live.100ms:android-sdk:${sdkVersions['android']}" + implementation "com.github.100mslive.android-sdk:lib:$hmsVersion" implementation "live.100ms:video-view:${sdkVersions['android']}" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0' diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSAudioTrackSettingsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSAudioTrackSettingsExtension.kt index 7ee2a0654..5a089be4e 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSAudioTrackSettingsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSAudioTrackSettingsExtension.kt @@ -1,14 +1,18 @@ package live.hms.hmssdk_flutter +import live.hms.hmssdk_flutter.hms_role_components.AudioParamsExtension +import live.hms.video.media.tracks.HMSTrack +import live.hms.video.media.tracks.HMSAudioTrack +import live.hms.video.utils.HMSLogger import live.hms.video.media.settings.HMSAudioTrackSettings class HMSAudioTrackSettingsExtension { - companion object { - fun toDictionary(hmsAudioTrackSettings: HMSAudioTrackSettings?): HashMap? { - val map = HashMap() + companion object{ + fun toDictionary(hmsAudioTrackSettings: HMSAudioTrackSettings?):HashMap? { + val map = HashMap() map["user_hardware_acoustic_echo_canceler"] = hmsAudioTrackSettings?.useHardwareAcousticEchoCanceler!! map["track_initial_state"] = HMSTrackInitStateExtension.getValueFromHMSTrackInitState(hmsAudioTrackSettings.initialState) return map } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSChangeTrackStateRequestExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSChangeTrackStateRequestExtension.kt index 96a157f8e..63e6c793d 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSChangeTrackStateRequestExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSChangeTrackStateRequestExtension.kt @@ -4,18 +4,18 @@ import live.hms.video.sdk.models.trackchangerequest.HMSChangeTrackStateRequest class HMSChangeTrackStateRequestExtension { - companion object { - fun toDictionary(hmsChangeTrackStateRequest: HMSChangeTrackStateRequest?): HashMap? { - val hashMap = HashMap() - if (hmsChangeTrackStateRequest == null)return null - hashMap.put("mute", hmsChangeTrackStateRequest.mute) - hashMap.put("requested_by", HMSPeerExtension.toDictionary(hmsChangeTrackStateRequest.requestedBy)) - hashMap.put("track", HMSTrackExtension.toDictionary(hmsChangeTrackStateRequest.track)) + companion object{ + fun toDictionary(hmsChangeTrackStateRequest: HMSChangeTrackStateRequest?):HashMap?{ + val hashMap = HashMap() + if(hmsChangeTrackStateRequest==null)return null + hashMap.put("mute",hmsChangeTrackStateRequest.mute) + hashMap.put("requested_by",HMSPeerExtension.toDictionary(hmsChangeTrackStateRequest.requestedBy)) + hashMap.put("track",HMSTrackExtension.toDictionary(hmsChangeTrackStateRequest.track)) - val args = HashMap() - args.put("track_change_request", hashMap) + val args=HashMap() + args.put("track_change_request",hashMap) - return args + return args } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSHLSVariantExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSHLSVariantExtension.kt index ecd84e17c..3b0cbfd77 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSHLSVariantExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSHLSVariantExtension.kt @@ -1,19 +1,21 @@ package live.hms.hmssdk_flutter +import live.hms.video.error.HMSException import live.hms.video.sdk.models.HMSHLSVariant import java.text.SimpleDateFormat class HMSHLSVariantExtension { - companion object { - fun toDictionary(hmshlsVariant: HMSHLSVariant?): HashMap? { - val args = HashMap() + companion object{ + fun toDictionary(hmshlsVariant: HMSHLSVariant?):HashMap?{ + val args=HashMap() if (hmshlsVariant == null)return null - args["hls_stream_url"] = hmshlsVariant.hlsStreamUrl ?: "" - args["meeting_url"] = hmshlsVariant.meetingUrl ?: "" - args["metadata"] = hmshlsVariant.metadata ?: "" + args["hls_stream_url"] = hmshlsVariant.hlsStreamUrl?:"" + args["meeting_url"] = hmshlsVariant.meetingUrl?:"" + args["metadata"] = hmshlsVariant.metadata?:"" args["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmshlsVariant.startedAt).toString() return args } } -} + +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt index 0f0b62e16..3759e3d59 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt @@ -2,4 +2,4 @@ package live.hms.hmssdk_flutter import live.hms.video.sessionstore.HMSKeyChangeListener -class HMSKeyChangeObserver(val uid: String, val keyChangeListener: HMSKeyChangeListener) +class HMSKeyChangeObserver(val uid: String,val keyChangeListener: HMSKeyChangeListener) {} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogSettings.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogSettings.kt index 24564a13a..851317c60 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogSettings.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogSettings.kt @@ -5,14 +5,14 @@ import live.hms.video.utils.HMSLogger class HMSLogSettings { - companion object { + companion object{ - fun setLogSettings(maxDirSizeInBytes: Double, logStorageEnabled: Boolean, logLevel: String): HMSLogSettings { - return HMSLogSettings(maxDirSizeInBytes = maxDirSizeInBytes.toLong(), isLogStorageEnabled = logStorageEnabled, level = getLogLevel(logLevel)) + fun setLogSettings(maxDirSizeInBytes: Double,logStorageEnabled: Boolean,logLevel: String): HMSLogSettings { + return HMSLogSettings(maxDirSizeInBytes = maxDirSizeInBytes.toLong(), isLogStorageEnabled = logStorageEnabled, level = getLogLevel(logLevel)) } - private fun getLogLevel(logLevel: String?): HMSLogger.LogLevel { - return when (logLevel) { + private fun getLogLevel(logLevel:String?): HMSLogger.LogLevel { + return when(logLevel){ "error" -> HMSLogger.LogLevel.ERROR "off" -> HMSLogger.LogLevel.OFF "verbose" -> HMSLogger.LogLevel.VERBOSE @@ -21,4 +21,4 @@ class HMSLogSettings { } } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogsExtension.kt index 32e53508a..3620e6e0a 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSLogsExtension.kt @@ -1,17 +1,18 @@ package live.hms.hmssdk_flutter +import live.hms.video.sdk.models.enums.HMSPeerUpdate import live.hms.video.utils.HMSLogger class HMSLogsExtension { - companion object { + companion object{ fun toDictionary( level: HMSLogger.LogLevel, tag: String, message: String, - isWebRtCLog: Boolean, - ): HashMap { - val map = HashMap() - map["level"] = getValueOfHMSLog(level)!! + isWebRtCLog: Boolean + ) : HashMap{ + val map = HashMap() + map["level"]= getValueOfHMSLog(level)!! map["tag"] = tag map["message"] = message map["is_web_rtc_log"] = isWebRtCLog @@ -19,18 +20,18 @@ class HMSLogsExtension { return map } - fun getValueOfHMSLog(level: HMSLogger.LogLevel?): String? { - if (level == null)return null + fun getValueOfHMSLog(level: HMSLogger.LogLevel?):String?{ + if(level==null)return null - return when (level) { - HMSLogger.LogLevel.DEBUG -> "debug" - HMSLogger.LogLevel.ERROR -> "error" - HMSLogger.LogLevel.INFO -> "info" - HMSLogger.LogLevel.OFF -> "off" - HMSLogger.LogLevel.VERBOSE -> "verbose" - HMSLogger.LogLevel.WARN -> "warn" - else -> "defaultUpdate" + return when(level){ + HMSLogger.LogLevel.DEBUG-> "debug" + HMSLogger.LogLevel.ERROR-> "error" + HMSLogger.LogLevel.INFO-> "info" + HMSLogger.LogLevel.OFF-> "off" + HMSLogger.LogLevel.VERBOSE->"verbose" + HMSLogger.LogLevel.WARN->"warn" + else-> "defaultUpdate" } } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageExtension.kt index 427dbaf05..c1af27ff8 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageExtension.kt @@ -4,21 +4,20 @@ import live.hms.video.sdk.models.HMSMessage import java.text.SimpleDateFormat class HMSMessageExtension { - companion object { - fun toDictionary(message: HMSMessage?): HashMap? { - val args = HashMap() - if (message == null)return null + companion object{ + fun toDictionary(message:HMSMessage?):HashMap?{ + val args=HashMap() + if(message==null)return null args["message"] = message.message args["time"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(message.serverReceiveTime).toString() args["type"] = message.type - if (message.sender != null) { + if(message.sender != null) args["sender"] = HMSPeerExtension.toDictionary(message.sender)!! - } args["hms_message_recipient"] = HMSMessageRecipientExtension.toDictionary(message.recipient)!! - val messageArgs = HashMap() + val messageArgs=HashMap() messageArgs["message"] = args return messageArgs } - } -} + } +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageRecipientExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageRecipientExtension.kt index 47f58af95..3406c1a66 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageRecipientExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSMessageRecipientExtension.kt @@ -1,35 +1,36 @@ package live.hms.hmssdk_flutter +import io.flutter.Log import live.hms.video.sdk.models.HMSMessageRecipient import live.hms.video.sdk.models.enums.HMSMessageRecipientType class HMSMessageRecipientExtension { - companion object { - fun toDictionary(hmsMessageRecipient: HMSMessageRecipient?): HashMap? { - val hashMap = HashMap() - if (hmsMessageRecipient == null)return null + companion object{ + fun toDictionary(hmsMessageRecipient: HMSMessageRecipient?):HashMap?{ + val hashMap = HashMap() + if(hmsMessageRecipient==null)return null hashMap["recipient_peer"] = HMSPeerExtension.toDictionary(hmsMessageRecipient.recipientPeer) - val recipientRoles = ArrayList?>() + val recipientRoles = ArrayList?>() hmsMessageRecipient.recipientRoles.forEach { recipientRoles.add(HMSRoleExtension.toDictionary(it)) } - hashMap["recipient_roles"] = if (recipientRoles.size != 0)recipientRoles else null + hashMap["recipient_roles"] = if(recipientRoles.size!=0)recipientRoles else null - hashMap["recipient_type"] = getValueOfHMSMessageRecipient(hmsMessageRecipient.recipientType) + hashMap["recipient_type"] = getValueOfHMSMessageRecipient(hmsMessageRecipient.recipientType) return hashMap } - private fun getValueOfHMSMessageRecipient(hmsMessageRecipientType: HMSMessageRecipientType?): String? { - if (hmsMessageRecipientType == null)return null - return when (hmsMessageRecipientType) { - HMSMessageRecipientType.BROADCAST -> "broadCast" - HMSMessageRecipientType.PEER -> "peer" - HMSMessageRecipientType.ROLES -> "roles" - else -> "defaultRecipient" + private fun getValueOfHMSMessageRecipient(hmsMessageRecipientType: HMSMessageRecipientType?):String?{ + if(hmsMessageRecipientType==null)return null + return when(hmsMessageRecipientType){ + HMSMessageRecipientType.BROADCAST-> "broadCast" + HMSMessageRecipientType.PEER-> "peer" + HMSMessageRecipientType.ROLES-> "roles" + else-> "defaultRecipient" } } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSNetworkQualityExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSNetworkQualityExtension.kt index a814152d9..3bb247bf0 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSNetworkQualityExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSNetworkQualityExtension.kt @@ -1,6 +1,8 @@ package live.hms.hmssdk_flutter import live.hms.video.connection.stats.quality.HMSNetworkQuality +import live.hms.video.sdk.models.HMSPeer +import live.hms.video.sdk.models.enums.HMSPeerUpdate class HMSNetworkQualityExtension { @@ -12,4 +14,4 @@ class HMSNetworkQualityExtension { return args } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerUpdateExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerUpdateExtension.kt index fce6649d4..800620e73 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerUpdateExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerUpdateExtension.kt @@ -1,17 +1,18 @@ package live.hms.hmssdk_flutter +import io.flutter.Log import live.hms.video.sdk.models.HMSPeer import live.hms.video.sdk.models.enums.HMSPeerUpdate class HMSPeerUpdateExtension { - companion object { - fun toDictionary(peer: HMSPeer?, update: HMSPeerUpdate?): HashMap? { - val args = HashMap() - if (peer == null || update == null)return null + companion object{ + fun toDictionary(peer:HMSPeer?,update: HMSPeerUpdate?):HashMap?{ + val args=HashMap() + if(peer==null || update==null)return null args.put("peer", HMSPeerExtension.toDictionary(peer)!!) args.put("update", HMSPeerExtension.getValueofHMSPeerUpdate(update)!!) return args } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPreviewExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPreviewExtension.kt index d6b7989c3..987ecfe86 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPreviewExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPreviewExtension.kt @@ -1,15 +1,16 @@ package live.hms.hmssdk_flutter import live.hms.video.media.tracks.HMSTrack +import live.hms.video.sdk.models.HMSPeer import live.hms.video.sdk.models.HMSRoom class HMSPreviewExtension { - companion object { - fun toDictionary(room: HMSRoom?, allTracks: Array?): HashMap? { - val args = HashMap() - if (room == null || allTracks == null)return null + companion object{ + fun toDictionary(room: HMSRoom?,allTracks:Array?):HashMap?{ + val args=HashMap() + if(room==null || allTracks==null)return null args["room"] = HMSRoomExtension.toDictionary(room)!! - val tracks = ArrayList() + val tracks=ArrayList() for (eachTrack in allTracks) { tracks.add(HMSTrackExtension.toDictionary(eachTrack)!!) @@ -18,4 +19,4 @@ class HMSPreviewExtension { return args } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRemovedFromRoomExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRemovedFromRoomExtension.kt index 0187c4f6e..01dd696c2 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRemovedFromRoomExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRemovedFromRoomExtension.kt @@ -3,18 +3,18 @@ package live.hms.hmssdk_flutter import live.hms.video.sdk.models.HMSRemovedFromRoom class HMSRemovedFromRoomExtension { - companion object { - fun toDictionary(notification: HMSRemovedFromRoom?): HashMap? { - val hashMap = HashMap() + companion object{ + fun toDictionary(notification:HMSRemovedFromRoom?): HashMap? { + val hashMap = HashMap() - if (notification == null)return null - hashMap.put("peer_who_removed", HMSPeerExtension.toDictionary(notification.peerWhoRemoved)) - hashMap.put("reason", notification.reason) - hashMap.put("room_was_ended", notification.roomWasEnded) + if(notification==null)return null + hashMap.put("peer_who_removed",HMSPeerExtension.toDictionary(notification.peerWhoRemoved)) + hashMap.put("reason",notification.reason) + hashMap.put("room_was_ended",notification.roomWasEnded) - val roomMap = HashMap() - roomMap.put("removed_from_room", hashMap) + val roomMap = HashMap() + roomMap.put("removed_from_room",hashMap) return roomMap } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleChangedExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleChangedExtension.kt index 3c3d1b17d..b46105bae 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleChangedExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleChangedExtension.kt @@ -3,15 +3,15 @@ package live.hms.hmssdk_flutter import live.hms.video.sdk.models.HMSRoleChangeRequest class HMSRoleChangedExtension { - companion object { - fun toDictionary(role: HMSRoleChangeRequest?): HashMap? { - val args = HashMap() - if (role == null)return null - args.put("requested_by", HMSPeerExtension.toDictionary(role.requestedBy)) - args.put("suggested_role", HMSRoleExtension.toDictionary(role.suggestedRole)) - val roleChanged = HashMap() - roleChanged.put("role_change_request", args) + companion object{ + fun toDictionary(role:HMSRoleChangeRequest?):HashMap?{ + val args=HashMap() + if(role==null)return null + args.put("requested_by",HMSPeerExtension.toDictionary(role.requestedBy)) + args.put("suggested_role",HMSRoleExtension.toDictionary(role.suggestedRole)) + val roleChanged=HashMap() + roleChanged.put("role_change_request",args) return roleChanged } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleExtension.kt index dffe96e1e..c89aad09f 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoleExtension.kt @@ -1,25 +1,29 @@ package live.hms.hmssdk_flutter import android.annotation.SuppressLint +import android.util.Log import live.hms.hmssdk_flutter.hms_role_components.PermissionParamsExtension import live.hms.hmssdk_flutter.hms_role_components.PublishParamsExtension import live.hms.hmssdk_flutter.hms_role_components.SubscribeSettings import live.hms.video.sdk.models.role.HMSRole +import live.hms.video.sdk.models.role.PermissionsParams +import kotlin.jvm.internal.Intrinsics class HMSRoleExtension { - companion object { + companion object{ @SuppressLint("LongLogTag") - fun toDictionary(role: HMSRole?): HashMap? { - val hashMap = HashMap() - if (role == null)return null + fun toDictionary(role:HMSRole?):HashMap?{ - hashMap["name"] = role?.name ?: "unknown" - hashMap["publish_settings"] = PublishParamsExtension.toDictionary(role?.publishParams ?: null) - hashMap["subscribe_settings"] = SubscribeSettings.toDictionary(role?.subscribeParams ?: null) + val hashMap=HashMap() + if(role==null)return null + + hashMap["name"] = role?.name?:"unknown" + hashMap["publish_settings"] = PublishParamsExtension.toDictionary(role?.publishParams?:null) + hashMap["subscribe_settings"] = SubscribeSettings.toDictionary(role?.subscribeParams?:null) hashMap["priority"] = role?.priority!! - hashMap["permissions"] = PermissionParamsExtension.toDictionary(role.permission ?: null) + hashMap["permissions"] = PermissionParamsExtension.toDictionary(role.permission?:null) return hashMap } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoomUpdateExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoomUpdateExtension.kt index 27d06984f..16a9a0578 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoomUpdateExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRoomUpdateExtension.kt @@ -1,14 +1,15 @@ package live.hms.hmssdk_flutter +import android.util.Log import live.hms.video.sdk.models.HMSRoom import live.hms.video.sdk.models.enums.HMSRoomUpdate class HMSRoomUpdateExtension { - companion object { - fun toDictionary(room: HMSRoom?, update: HMSRoomUpdate?): HashMap? { - val args = HashMap() + companion object{ + fun toDictionary(room:HMSRoom?,update: HMSRoomUpdate?):HashMap?{ + val args=HashMap() - if (room == null)return null + if (room==null)return null args.put("room", HMSRoomExtension.toDictionary(room)!!) args.put("update", HMSRoomExtension.getValueofHMSRoomUpdate(update)!!) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRtmpStreamingState.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRtmpStreamingState.kt index 6dae4fa4d..aa4a0d9f9 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRtmpStreamingState.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSRtmpStreamingState.kt @@ -5,60 +5,58 @@ import live.hms.video.sdk.models.* import java.text.SimpleDateFormat class HMSStreamingState { - companion object { - fun toDictionary(hmsRtmpStreamingState: HMSRtmpStreamingState?): HashMap? { - val map = HashMap() - if (hmsRtmpStreamingState == null)return null + companion object{ + fun toDictionary(hmsRtmpStreamingState: HMSRtmpStreamingState?):HashMap?{ + val map = HashMap() + if(hmsRtmpStreamingState == null)return null map["running"] = hmsRtmpStreamingState.running map["error"] = HMSExceptionExtension.toDictionary(hmsRtmpStreamingState.error) - if (hmsRtmpStreamingState.running) { - map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsRtmpStreamingState.startedAt).toString() - } + if(hmsRtmpStreamingState.running) + map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsRtmpStreamingState.startedAt).toString() return map } - fun toDictionary(hmsServerRecordingState: HMSServerRecordingState?): HashMap? { - val map = HashMap() - if (hmsServerRecordingState == null)return null + fun toDictionary(hmsServerRecordingState: HMSServerRecordingState?):HashMap?{ + val map = HashMap() + if(hmsServerRecordingState == null)return null map["running"] = hmsServerRecordingState.running map["error"] = HMSExceptionExtension.toDictionary(hmsServerRecordingState.error) - if (hmsServerRecordingState.running) { - map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsServerRecordingState.startedAt).toString() - } + if(hmsServerRecordingState.running) + map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsServerRecordingState.startedAt).toString() return map } - fun toDictionary(hmsBrowserRecordingState: HMSBrowserRecordingState?): HashMap? { - val map = HashMap() - if (hmsBrowserRecordingState == null)return null + fun toDictionary(hmsBrowserRecordingState: HMSBrowserRecordingState?):HashMap?{ + val map = HashMap() + if(hmsBrowserRecordingState == null)return null map["running"] = hmsBrowserRecordingState.running map["error"] = HMSExceptionExtension.toDictionary(hmsBrowserRecordingState.error) - if (hmsBrowserRecordingState.running) { - map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsBrowserRecordingState.startedAt).toString() - } + if(hmsBrowserRecordingState.running) + map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsBrowserRecordingState.startedAt).toString() return map } - fun toDictionary(hmsHlsStreamingState: HMSHLSStreamingState?): HashMap? { - val map = HashMap() - if (hmsHlsStreamingState == null)return null + fun toDictionary(hmsHlsStreamingState: HMSHLSStreamingState?):HashMap?{ + val map = HashMap() + if(hmsHlsStreamingState == null)return null map["running"] = hmsHlsStreamingState.running - val args = ArrayList() + val args=ArrayList() hmsHlsStreamingState.variants?.forEach { args.add(HMSHLSVariantExtension.toDictionary(it)!!) } - map["variants"] = args + map["variants"]=args return map } - fun toDictionary(hmsHlsRecordingState: HmsHlsRecordingState?): HashMap? { - val map = HashMap() - if (hmsHlsRecordingState == null)return null + fun toDictionary(hmsHlsRecordingState: HmsHlsRecordingState?):HashMap?{ + val map = HashMap() + if(hmsHlsRecordingState == null)return null map["running"] = hmsHlsRecordingState.running - if (hmsHlsRecordingState.running == true) { - map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsHlsRecordingState.startedAt).toString() - } + if(hmsHlsRecordingState.running == true) + map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsHlsRecordingState.startedAt).toString() return map } + } + } diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSessionMetadataExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSessionMetadataExtension.kt index 4a8c8faf6..25c7bfccb 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSessionMetadataExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSessionMetadataExtension.kt @@ -1,13 +1,14 @@ package live.hms.hmssdk_flutter class HMSSessionMetadataExtension { - companion object { - fun toDictionary(metadata: String?): HashMap? { - val hashMap = HashMap() + companion object{ + fun toDictionary(metadata: String?):HashMap?{ + + val hashMap=HashMap() hashMap["metadata"] = metadata return hashMap } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSpeakerExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSpeakerExtension.kt index eb48daa83..f8f5c4242 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSpeakerExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSSpeakerExtension.kt @@ -3,19 +3,19 @@ package live.hms.hmssdk_flutter import live.hms.video.sdk.models.HMSSpeaker class HMSSpeakerExtension { - companion object { - fun toDictionary(speaker: HMSSpeaker?): HashMap? { - val hashMap = HashMap() - if (speaker == null)return null - hashMap.put("audioLevel", speaker.level) + companion object{ + fun toDictionary(speaker:HMSSpeaker?):HashMap?{ + val hashMap = HashMap() + if(speaker==null)return null + hashMap.put("audioLevel",speaker.level) val hmsTrackMap = HMSTrackExtension.toDictionary(speaker.hmsTrack) val hmsPeerMap = HMSPeerExtension.toDictionary(speaker.peer) - if ((hmsTrackMap == null) || (hmsPeerMap == null)) { + if((hmsTrackMap == null) || (hmsPeerMap == null)){ return null } - hashMap.put("track", hmsTrackMap) - hashMap.put("peer", hmsPeerMap) + hashMap.put("track",hmsTrackMap) + hashMap.put("peer",hmsPeerMap) return hashMap } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackInitStateExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackInitStateExtension.kt index 360c689bc..a2a28a3c3 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackInitStateExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackInitStateExtension.kt @@ -3,21 +3,21 @@ package live.hms.hmssdk_flutter import live.hms.video.media.settings.HMSTrackSettings class HMSTrackInitStateExtension { - companion object { - fun getHMSTrackInitStatefromValue(value: String): HMSTrackSettings.InitState { - return when (value) { + companion object{ + fun getHMSTrackInitStatefromValue(value:String):HMSTrackSettings.InitState{ + return when(value){ "MUTED" -> HMSTrackSettings.InitState.MUTED "UNMUTED" -> HMSTrackSettings.InitState.UNMUTED - else -> HMSTrackSettings.InitState.MUTED + else->HMSTrackSettings.InitState.MUTED } } - fun getValueFromHMSTrackInitState(hmsTrackInitState: HMSTrackSettings.InitState): String { - return when (hmsTrackInitState) { - HMSTrackSettings.InitState.UNMUTED -> "UNMUTED" - HMSTrackSettings.InitState.MUTED -> "MUTED" - else -> "MUTED" + fun getValueFromHMSTrackInitState(hmsTrackInitState:HMSTrackSettings.InitState):String{ + return when(hmsTrackInitState){ + HMSTrackSettings.InitState.UNMUTED-> "UNMUTED" + HMSTrackSettings.InitState.MUTED-> "MUTED" + else->"MUTED" } } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt index 82668bf52..76887b108 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt @@ -1,5 +1,9 @@ package live.hms.hmssdk_flutter +import live.hms.hmssdk_flutter.hms_role_components.AudioParamsExtension +import live.hms.hmssdk_flutter.hms_role_components.VideoParamsExtension +import live.hms.video.media.codec.HMSAudioCodec +import live.hms.video.media.codec.HMSVideoCodec import live.hms.video.media.settings.HMSAudioTrackSettings import live.hms.video.media.settings.HMSTrackSettings import live.hms.video.media.settings.HMSVideoTrackSettings @@ -7,23 +11,25 @@ import live.hms.video.sdk.HMSSDK class HMSTrackSettingsExtension { - companion object { - fun toDictionary(hmssdk: HMSSDK): HashMap? { - val map = HashMap() - val hmsTrackSettings: HMSTrackSettings = hmssdk.hmsSettings + companion object{ + fun toDictionary(hmssdk: HMSSDK):HashMap?{ - if (hmsTrackSettings.videoSettings != null) { + val map = HashMap(); + val hmsTrackSettings:HMSTrackSettings = hmssdk.hmsSettings; + + if(hmsTrackSettings.videoSettings != null){ map["video_track_setting"] = HMSVideoTrackSettingsExtension.toDictionary(hmsTrackSettings.videoSettings)!! } - if (hmsTrackSettings.audioSettings != null) { + if(hmsTrackSettings.audioSettings != null){ map["audio_track_setting"] = HMSAudioTrackSettingsExtension.toDictionary(hmsTrackSettings.audioSettings)!! } return map } - fun setTrackSettings(hmsAudioTrackHashMap: HashMap?, hmsVideoTrackHashMap: HashMap?): HMSTrackSettings { + fun setTrackSettings(hmsAudioTrackHashMap:HashMap?,hmsVideoTrackHashMap: HashMap?):HMSTrackSettings{ + var hmsAudioTrackSettings = HMSAudioTrackSettings.Builder() if (hmsAudioTrackHashMap != null) { val useHardwareAcousticEchoCanceler = @@ -33,32 +39,33 @@ class HMSTrackSettingsExtension { if (useHardwareAcousticEchoCanceler != null) { hmsAudioTrackSettings = hmsAudioTrackSettings.setUseHardwareAcousticEchoCanceler( - useHardwareAcousticEchoCanceler, + useHardwareAcousticEchoCanceler ) } - if (initialState != null) { + if(initialState != null){ hmsAudioTrackSettings = hmsAudioTrackSettings.initialState(initialState) } } var hmsVideoTrackSettings = HMSVideoTrackSettings.Builder() if (hmsVideoTrackHashMap != null) { - val cameraFacing = getHMSCameraFacingFromValue(hmsVideoTrackHashMap["camera_facing"] as String?) + + val cameraFacing = getHMSCameraFacingFromValue(hmsVideoTrackHashMap["camera_facing"] as String?) val disableAutoResize = hmsVideoTrackHashMap["disable_auto_resize"] as Boolean val initialState = HMSTrackInitStateExtension.getHMSTrackInitStatefromValue(hmsVideoTrackHashMap["track_initial_state"] as String) val forceSoftwareDecoder = hmsVideoTrackHashMap["force_software_decoder"] as Boolean - if (cameraFacing != null) { + if(cameraFacing != null){ hmsVideoTrackSettings = hmsVideoTrackSettings.cameraFacing(cameraFacing) } - if (disableAutoResize != null) { - hmsVideoTrackSettings = hmsVideoTrackSettings.disableAutoResize(disableAutoResize) + if(disableAutoResize != null){ + hmsVideoTrackSettings = hmsVideoTrackSettings.disableAutoResize(disableAutoResize); } - if (initialState != null) { + if(initialState != null){ hmsVideoTrackSettings = hmsVideoTrackSettings.initialState(initialState) } - if (forceSoftwareDecoder != null) { + if(forceSoftwareDecoder != null){ hmsVideoTrackSettings = hmsVideoTrackSettings.forceSoftwareDecoder(forceSoftwareDecoder) } } @@ -66,12 +73,12 @@ class HMSTrackSettingsExtension { return HMSTrackSettings.Builder().audio(hmsAudioTrackSettings.build()).video(hmsVideoTrackSettings.build()).build() } - private fun getHMSCameraFacingFromValue(cameraFacing: String?): HMSVideoTrackSettings.CameraFacing { - return when (cameraFacing) { + private fun getHMSCameraFacingFromValue(cameraFacing:String?):HMSVideoTrackSettings.CameraFacing{ + return when(cameraFacing){ "back" -> HMSVideoTrackSettings.CameraFacing.BACK "front" -> HMSVideoTrackSettings.CameraFacing.FRONT else -> HMSVideoTrackSettings.CameraFacing.FRONT } } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackUpdateExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackUpdateExtension.kt index eb86f2321..707c3f11a 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackUpdateExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackUpdateExtension.kt @@ -1,20 +1,21 @@ package live.hms.hmssdk_flutter +import android.util.Log import live.hms.video.media.tracks.HMSTrack import live.hms.video.sdk.models.HMSPeer import live.hms.video.sdk.models.enums.HMSTrackUpdate class HMSTrackUpdateExtension { - companion object { - fun toDictionary(peer: HMSPeer?, track: HMSTrack?, update: HMSTrackUpdate?): HashMap? { - val hashMap = HashMap() + companion object{ + fun toDictionary(peer:HMSPeer?,track:HMSTrack?,update: HMSTrackUpdate?):HashMap?{ + val hashMap=HashMap() - if (peer == null || track == null || update == null)return null + if(peer==null || track==null || update==null)return null - hashMap["peer"] = HMSPeerExtension.toDictionary(peer)!! - hashMap["track"] = HMSTrackExtension.toDictionary(track)!! + hashMap["peer"] = HMSPeerExtension.toDictionary(peer)!! + hashMap["track"] = HMSTrackExtension.toDictionary(track)!! hashMap["update"] = HMSTrackExtension.getTrackUpdateInString(update)!! return hashMap } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoResolutionExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoResolutionExtension.kt index 0a1de7e9b..69e5720a8 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoResolutionExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoResolutionExtension.kt @@ -4,15 +4,16 @@ import live.hms.video.media.settings.HMSVideoResolution class HMSVideoResolutionExtension { - companion object { + companion object{ - fun toDictionary(hmsVideoResolution: HMSVideoResolution?): HashMap? { - val args = HashMap() - if (hmsVideoResolution == null) return null - args["height"] = hmsVideoResolution.height / 1.0 - args["width"] = hmsVideoResolution.width / 1.0 + fun toDictionary(hmsVideoResolution: HMSVideoResolution?):HashMap?{ - return args + val args=HashMap() + if(hmsVideoResolution == null) return null + args["height"] = hmsVideoResolution.height/1.0 + args["width"] = hmsVideoResolution.width/1.0 + + return args; } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoTrackSettingsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoTrackSettingsExtension.kt index a9369731c..1826aa7ed 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoTrackSettingsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSVideoTrackSettingsExtension.kt @@ -1,26 +1,32 @@ package live.hms.hmssdk_flutter +import live.hms.video.media.codec.HMSVideoCodec import live.hms.video.media.settings.HMSVideoTrackSettings +import live.hms.video.media.tracks.HMSTrack +import live.hms.video.media.tracks.HMSVideoTrack +import live.hms.video.utils.HMSLogger class HMSVideoTrackSettingsExtension { - companion object { - fun toDictionary(hmsVideoTrackSettings: HMSVideoTrackSettings?): HashMap? { - val map = HashMap() + companion object{ + fun toDictionary(hmsVideoTrackSettings: HMSVideoTrackSettings?):HashMap?{ + val map = HashMap() map["camera_facing"] = getValueOfHMSCameraFacing(hmsVideoTrackSettings?.cameraFacing)!! map["disable_auto_resize"] = hmsVideoTrackSettings?.disableAutoResize!! map["track_initial_state"] = HMSTrackInitStateExtension.getValueFromHMSTrackInitState(hmsVideoTrackSettings.initialState) map["force_software_decoder"] = hmsVideoTrackSettings.forceSoftwareDecoder - return map + return map } - private fun getValueOfHMSCameraFacing(cameraFacing: HMSVideoTrackSettings.CameraFacing?): String? { - if (cameraFacing == null)return null - return when (cameraFacing) { - HMSVideoTrackSettings.CameraFacing.BACK -> "back" - HMSVideoTrackSettings.CameraFacing.FRONT -> "front" - else -> "default" + private fun getValueOfHMSCameraFacing(cameraFacing: HMSVideoTrackSettings.CameraFacing?):String?{ + if(cameraFacing==null)return null + + return when(cameraFacing){ + HMSVideoTrackSettings.CameraFacing.BACK-> "back" + HMSVideoTrackSettings.CameraFacing.FRONT->"front" + else-> "default" } } + } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index 277691bbe..a4034f7a5 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -55,7 +55,7 @@ class HmssdkFlutterPlugin : private var previewChannel: EventChannel? = null private var logsEventChannel: EventChannel? = null private var rtcStatsChannel: EventChannel? = null - private var sessionStoreChannel: EventChannel? = null + private var sessionStoreChannel : EventChannel? = null private var eventSink: EventChannel.EventSink? = null private var previewSink: EventChannel.EventSink? = null private var logsSink: EventChannel.EventSink? = null @@ -67,7 +67,7 @@ class HmssdkFlutterPlugin : private var requestChange: HMSRoleChangeRequest? = null var hmssdkFlutterPlugin: HmssdkFlutterPlugin? = null private var hmsSessionStore: HmsSessionStore? = null - private var hmsKeyChangeObserverList = ArrayList() + private var hmsKeyChangeObserverList = ArrayList() override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { if (hmssdkFlutterPlugin == null) { @@ -84,19 +84,19 @@ class HmssdkFlutterPlugin : EventChannel(flutterPluginBinding.binaryMessenger, "rtc_event_channel") this.sessionStoreChannel = - EventChannel(flutterPluginBinding.binaryMessenger, "session_event_channel") + EventChannel(flutterPluginBinding.binaryMessenger,"session_event_channel") this.meetingEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Meeting event channel not found") this.channel?.setMethodCallHandler(this) ?: Log.e("Channel Error", "Event channel not found") this.previewChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Preview channel not found") this.logsEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Logs event channel not found") this.rtcStatsChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "RTC Stats channel not found") - this.sessionStoreChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Session Store channel not found") + this.sessionStoreChannel?.setStreamHandler(this) ?: Log.e("Channel Error","Session Store channel not found") this.hmsVideoFactory = HMSVideoViewFactory(this) flutterPluginBinding.platformViewRegistry.registerViewFactory( "HMSVideoView", - hmsVideoFactory, + hmsVideoFactory ) hmssdkFlutterPlugin = this } else { @@ -203,10 +203,10 @@ class HmssdkFlutterPlugin : HMSCameraControlsAction.cameraControlsAction(call, result, hmssdk!!, activity.applicationContext) } "get_session_metadata_for_key", "set_session_metadata_for_key" -> { - HMSSessionStoreAction.sessionStoreActions(call, result, hmsSessionStore) + HMSSessionStoreAction.sessionStoreActions(call,result,hmsSessionStore) } - "add_key_change_listener" -> { - addKeyChangeListener(call, result) + "add_key_change_listener"-> { + addKeyChangeListener(call,result) } "remove_key_change_listener" -> { removeKeyChangeListener(call) @@ -384,7 +384,7 @@ class HmssdkFlutterPlugin : previewChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Preview channel not found") logsEventChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Logs event channel not found") rtcStatsChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "RTC Stats channel not found") - sessionStoreChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Session Store channel not found") + sessionStoreChannel?.setStreamHandler(null)?:Log.e("Channel Error","Session Store channel not found") eventSink = null previewSink = null rtcSink = null @@ -419,7 +419,7 @@ class HmssdkFlutterPlugin : } private fun getConfig( - call: MethodCall, + call: MethodCall ): HMSConfig { val userName = call.argument("user_name") val authToken = call.argument("auth_token") @@ -433,7 +433,7 @@ class HmssdkFlutterPlugin : authtoken = authToken!!, metadata = metaData, initEndpoint = endPoint.trim(), - captureNetworkQualityInPreview = captureNetworkQualityInPreview, + captureNetworkQualityInPreview = captureNetworkQualityInPreview ) } @@ -441,7 +441,7 @@ class HmssdkFlutterPlugin : userName = userName!!, authtoken = authToken!!, metadata = metaData, - captureNetworkQualityInPreview = captureNetworkQualityInPreview, + captureNetworkQualityInPreview = captureNetworkQualityInPreview ) } @@ -490,7 +490,7 @@ class HmssdkFlutterPlugin : this.logsSink = events } else if (nameOfEventSink == "rtc_stats") { this.rtcSink = events - } else if (nameOfEventSink == "session_store") { + } else if(nameOfEventSink == "session_store") { this.sessionStoreSink = events } } @@ -537,7 +537,7 @@ class HmssdkFlutterPlugin : code = 6004, description = "Room code is null", message = "Room code is null", - name = "Room code null error", + name = "Room code null error" ) val args = HMSExceptionExtension.toDictionary(hmsException) result.success(HMSResultExtension.toDictionary(false, args)) @@ -561,7 +561,7 @@ class HmssdkFlutterPlugin : peer, roleToChangeTo, forceChange ?: false, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) } @@ -578,7 +578,7 @@ class HmssdkFlutterPlugin : peer, roleToChangeTo, forceChange ?: false, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) } @@ -597,7 +597,7 @@ class HmssdkFlutterPlugin : if (requestChange != null) { hmssdk!!.acceptChangeRole( this.requestChange!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) requestChange = null } else { @@ -606,7 +606,7 @@ class HmssdkFlutterPlugin : code = 6004, description = "Role Change Request is Expired.", message = "Role Change Request is Expired.", - name = "Role Change Request Error", + name = "Role Change Request Error" ) val args = HMSExceptionExtension.toDictionary(hmsException) result.success(args) @@ -619,7 +619,7 @@ class HmssdkFlutterPlugin : HMSLogger.i( "onAudioLevelUpdateHMSLogger", - HMSLogger.level.toString(), + HMSLogger.level.toString() ) if (speakers.isNotEmpty()) { @@ -656,7 +656,7 @@ class HmssdkFlutterPlugin : hmssdk!!.changeTrackState( track, mute!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) } @@ -670,7 +670,7 @@ class HmssdkFlutterPlugin : hmssdk!!.removePeerRequest( peer = peer, hmsActionResultListener = HMSCommonAction.getActionListener(result), - reason = reason, + reason = reason ) } @@ -686,7 +686,7 @@ class HmssdkFlutterPlugin : hmssdk!!.endRoom( lock = lock!!, reason = reason, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) disposePIP() removeAllKeyChangeListener() @@ -712,7 +712,7 @@ class HmssdkFlutterPlugin : type = HMSTrackExtension.getKindFromString(type), source = source, roles = hmsRoles, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) } @@ -766,7 +766,7 @@ class HmssdkFlutterPlugin : hmssdk!!.changeMetadata( metadata!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) } @@ -919,6 +919,7 @@ class HmssdkFlutterPlugin : eventSink?.success(args) } } + } private val hmsPreviewListener = object : HMSPreviewListener { @@ -996,7 +997,7 @@ class HmssdkFlutterPlugin : level: HMSLogger.LogLevel, tag: String, message: String, - isWebRtCLog: Boolean, + isWebRtCLog: Boolean ) { /*** * Here we filter the logs based on the level we have set @@ -1031,7 +1032,7 @@ class HmssdkFlutterPlugin : val name = call.argument("name") hmssdk!!.changeName( name = name!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) } @@ -1048,11 +1049,11 @@ class HmssdkFlutterPlugin : androidScreenshareResult = result activity.applicationContext?.registerReceiver(activityBroadcastReceiver, IntentFilter("ACTIVITY_RECEIVER")) val mediaProjectionManager: MediaProjectionManager = activity.getSystemService( - Context.MEDIA_PROJECTION_SERVICE, + Context.MEDIA_PROJECTION_SERVICE ) as MediaProjectionManager activity.startActivityForResult( mediaProjectionManager.createScreenCaptureIntent(), - Constants.SCREEN_SHARE_INTENT_REQUEST_CODE, + Constants.SCREEN_SHARE_INTENT_REQUEST_CODE ) } @@ -1088,7 +1089,7 @@ class HmssdkFlutterPlugin : } } }, - data, + data ) activity.applicationContext?.unregisterReceiver(activityBroadcastReceiver) } @@ -1104,11 +1105,11 @@ class HmssdkFlutterPlugin : mode = call.argument("audio_mixing_mode") activity.applicationContext?.registerReceiver(activityBroadcastReceiver, IntentFilter("ACTIVITY_RECEIVER")) val mediaProjectionManager: MediaProjectionManager? = activity.getSystemService( - Context.MEDIA_PROJECTION_SERVICE, + Context.MEDIA_PROJECTION_SERVICE ) as MediaProjectionManager activity.startActivityForResult( mediaProjectionManager?.createScreenCaptureIntent(), - Constants.AUDIO_SHARE_INTENT_REQUEST_CODE, + Constants.AUDIO_SHARE_INTENT_REQUEST_CODE ) } @@ -1130,7 +1131,7 @@ class HmssdkFlutterPlugin : } }, data, - audioMixingMode = AudioMixingMode.valueOf(mode!!), + audioMixingMode = AudioMixingMode.valueOf(mode!!) ) activity.applicationContext?.unregisterReceiver(activityBroadcastReceiver) } @@ -1224,12 +1225,13 @@ class HmssdkFlutterPlugin : * - keyChangeListener: Instance of HMSKeyChangeListener to listen to the metadata changes for corresponding keys * - hmsActionResultListener: Instance of HMSActionResultListener to notify success or failure of the method call */ - private fun addKeyChangeListener(call: MethodCall, result: Result) { + private fun addKeyChangeListener(call: MethodCall,result: Result){ + val keys = call.argument>("keys") ?: run { HMSErrorLogger.returnArgumentsError("keys parameter is null") } - val uid = call.argument("uid") ?: run { + val uid = call.argument("uid")?: run { HMSErrorLogger.returnArgumentsError("uid is null") } @@ -1238,12 +1240,13 @@ class HmssdkFlutterPlugin : override fun onKeyChanged(key: String, value: String?) { val args = HashMap() args["event_name"] = "on_key_changed" - val newData = HashMap() + val newData = HashMap() newData["key"] = key if (value is String?) { newData["value"] = value - } else { - HMSErrorLogger.logError("onKeyChanged", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") + } + else{ + HMSErrorLogger.logError("onKeyChanged","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") newData["value"] = null } newData["uid"] = uid as String @@ -1253,10 +1256,9 @@ class HmssdkFlutterPlugin : } } } - hmsKeyChangeObserverList.add(HMSKeyChangeObserver(uid as String, keyChangeListener)) - keys.let { - keys as List - hmsSessionStore?.addKeyChangeListener(keys, keyChangeListener, HMSCommonAction.getActionListener(result)) + hmsKeyChangeObserverList.add(HMSKeyChangeObserver(uid as String,keyChangeListener)) + keys.let { keys as List + hmsSessionStore?.addKeyChangeListener(keys,keyChangeListener,HMSCommonAction.getActionListener(result)) } } } @@ -1265,15 +1267,16 @@ class HmssdkFlutterPlugin : * This method is used to remove the attached key change listeners * attached using [addKeyChangeListener] method */ - private fun removeKeyChangeListener(call: MethodCall) { - val uid = call.argument("uid") ?: run { + private fun removeKeyChangeListener(call: MethodCall){ + + val uid = call.argument("uid")?: run { HMSErrorLogger.returnArgumentsError("uid is null") } uid?.let { - hmsKeyChangeObserverList.forEach { + hmsKeyChangeObserverList.forEach{ hmsKeyChangeObserver -> - if (hmsKeyChangeObserver.uid == uid) { + if(hmsKeyChangeObserver.uid == uid){ hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) hmsKeyChangeObserverList.remove(hmsKeyChangeObserver) return @@ -1287,10 +1290,9 @@ class HmssdkFlutterPlugin : * This is used while cleaning the room state i.e after calling leave room, * onRemovedFromRoom or endRoom */ - private fun removeAllKeyChangeListener() { - hmsKeyChangeObserverList.forEach { - hmsKeyChangeObserver -> - hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) + private fun removeAllKeyChangeListener(){ + hmsKeyChangeObserverList.forEach{ + hmsKeyChangeObserver -> hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) } hmsKeyChangeObserverList.clear() } @@ -1300,7 +1302,7 @@ class HmssdkFlutterPlugin : override fun onRemoteVideoStats( videoStats: HMSRemoteVideoStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer?, + hmsPeer: HMSPeer? ) { if (hmsPeer == null) { Log.e("RemoteVideoStats err", "Peer is null") @@ -1317,7 +1319,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsRemoteVideoStats = videoStats, peer = hmsPeer, - track = hmsTrack, + track = hmsTrack ) if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { @@ -1329,7 +1331,7 @@ class HmssdkFlutterPlugin : override fun onRemoteAudioStats( audioStats: HMSRemoteAudioStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer?, + hmsPeer: HMSPeer? ) { if (hmsPeer == null) { Log.e("RemoteAudioStats err", "Peer is null") @@ -1346,7 +1348,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsRemoteAudioStats = audioStats, peer = hmsPeer, - track = hmsTrack, + track = hmsTrack ) if (args["data"] != null) { @@ -1359,7 +1361,7 @@ class HmssdkFlutterPlugin : override fun onLocalVideoStats( videoStats: List, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer?, + hmsPeer: HMSPeer? ) { if (hmsPeer == null) { Log.e("LocalVideoStats err", "Peer is null") @@ -1376,7 +1378,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsLocalVideoStats = videoStats, peer = hmsPeer, - track = hmsTrack, + track = hmsTrack ) if (args["data"] != null) { @@ -1389,7 +1391,7 @@ class HmssdkFlutterPlugin : override fun onLocalAudioStats( audioStats: HMSLocalAudioStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer?, + hmsPeer: HMSPeer? ) { if (hmsPeer == null) { Log.e("LocalAudioStats err", "Peer is null") @@ -1406,7 +1408,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsLocalAudioStats = audioStats, peer = hmsPeer, - track = hmsTrack, + track = hmsTrack ) if (args["data"] != null) { diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/AudioParamsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/AudioParamsExtension.kt index 96ddf7e81..9ad7a10cf 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/AudioParamsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/AudioParamsExtension.kt @@ -3,32 +3,32 @@ package live.hms.hmssdk_flutter.hms_role_components import live.hms.video.media.codec.HMSAudioCodec import live.hms.video.sdk.models.role.AudioParams -class AudioParamsExtension { - companion object { - fun toDictionary(audioParams: AudioParams): HashMap? { - val args = HashMap() - if (audioParams == null || audioParams.codec == null)return null - args.put("bit_rate", audioParams.bitRate) +class AudioParamsExtension{ + companion object{ + fun toDictionary(audioParams: AudioParams):HashMap? { + val args=HashMap() + if(audioParams==null || audioParams.codec==null)return null + args.put("bit_rate",audioParams.bitRate) args.put("codec", getValueOfHMSAudioCodec(audioParams.codec)) return args } - fun getValueOfHMSAudioCodec(codec: HMSAudioCodec): String { + fun getValueOfHMSAudioCodec (codec: HMSAudioCodec):String{ return when (codec) { - HMSAudioCodec.OPUS -> + HMSAudioCodec.OPUS-> "opus" - else -> + else-> "defaultCodec" } } - fun getValueOfHMSAudioCodecFromString(codec: String?): HMSAudioCodec? { + fun getValueOfHMSAudioCodecFromString (codec:String?):HMSAudioCodec?{ return when (codec) { - "opus" -> + "opus"-> HMSAudioCodec.OPUS - else -> + else-> null } } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/PermissionParamsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/PermissionParamsExtension.kt index a7123ba96..46fc659f7 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/PermissionParamsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/PermissionParamsExtension.kt @@ -3,10 +3,10 @@ package live.hms.hmssdk_flutter.hms_role_components import live.hms.video.sdk.models.role.PermissionsParams class PermissionParamsExtension { - companion object { - fun toDictionary(permissionsParams: PermissionsParams?): HashMap? { - val args = HashMap() - if (permissionsParams == null)return null + companion object{ + fun toDictionary(permissionsParams: PermissionsParams?):HashMap?{ + val args=HashMap() + if(permissionsParams==null)return null args["browser_recording"] = permissionsParams.browserRecording args["change_role"] = permissionsParams.changeRole args["end_room"] = permissionsParams.endRoom @@ -18,4 +18,4 @@ class PermissionParamsExtension { return args } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/VideoParamsExtension.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/VideoParamsExtension.kt index fd9c7a7f7..4dbb3a725 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/VideoParamsExtension.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/hms_role_components/VideoParamsExtension.kt @@ -1,46 +1,47 @@ package live.hms.hmssdk_flutter.hms_role_components +import live.hms.video.media.codec.HMSAudioCodec import live.hms.video.media.codec.HMSVideoCodec import live.hms.video.sdk.models.role.VideoParams -class VideoParamsExtension { +class VideoParamsExtension{ - companion object { - fun toDictionary(videoParams: VideoParams): HashMap? { - val args = HashMap() - if (videoParams == null || videoParams.codec == null)return null - args.put("bit_rate", videoParams.bitRate) - args.put("frame_rate", videoParams.frameRate) - args.put("width", videoParams.width) - args.put("height", videoParams.height) + companion object{ + fun toDictionary(videoParams: VideoParams):HashMap?{ + val args=HashMap() + if (videoParams==null || videoParams.codec==null)return null + args.put("bit_rate",videoParams.bitRate) + args.put("frame_rate",videoParams.frameRate) + args.put("width",videoParams.width) + args.put("height",videoParams.height) args.put("codec", getValueOfHMSAudioCodec(videoParams.codec)) return args } - fun getValueOfHMSAudioCodec(codec: HMSVideoCodec): String { + fun getValueOfHMSAudioCodec (codec: HMSVideoCodec):String{ return when (codec) { - HMSVideoCodec.H264 -> + HMSVideoCodec.H264-> "h264" - HMSVideoCodec.VP8 -> + HMSVideoCodec.VP8-> "vp8" - HMSVideoCodec.VP9 -> + HMSVideoCodec.VP9-> "vp9" - else -> + else-> "defaultCodec" } } - fun getValueOfHMSAudioCodecFromString(codec: String?): HMSVideoCodec? { + fun getValueOfHMSAudioCodecFromString(codec: String?):HMSVideoCodec?{ return when (codec) { - "h264" -> HMSVideoCodec.H264 + "h264"->HMSVideoCodec.H264 - "vp8" -> HMSVideoCodec.VP8 + "vp8"->HMSVideoCodec.VP8 - "vp9" -> HMSVideoCodec.VP9 + "vp9"->HMSVideoCodec.VP9 - else -> + else-> null } } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSAudioDeviceAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSAudioDeviceAction.kt index 59ff6c3f4..559035eb7 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSAudioDeviceAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSAudioDeviceAction.kt @@ -1,4 +1,5 @@ package live.hms.hmssdk_flutter +import android.util.Log import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel.Result import kotlinx.coroutines.CoroutineScope @@ -9,18 +10,20 @@ import live.hms.video.media.tracks.* import live.hms.video.sdk.* import live.hms.video.sdk.models.* + + class HMSAudioDeviceAction { companion object { - fun audioDeviceActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { + fun audioDeviceActions(call: MethodCall, result: Result,hmssdk:HMSSDK) { when (call.method) { "get_audio_devices_list" -> { - getAudioDevicesList(call, result, hmssdk) + getAudioDevicesList(call, result,hmssdk) } - "get_current_audio_device" -> { - getCurrentDevice(call, result, hmssdk) + "get_current_audio_device"-> { + getCurrentDevice(call,result,hmssdk) } "switch_audio_output" -> { - switchAudioOutput(call, result, hmssdk) + switchAudioOutput(call,result,hmssdk) } else -> { result.notImplemented() @@ -28,28 +31,29 @@ class HMSAudioDeviceAction { } } - private fun getAudioDevicesList(call: MethodCall, result: Result, hmssdk: HMSSDK) { - val audioDevicesList = ArrayList() - for (device in hmssdk.getAudioDevicesList()) { - audioDevicesList.add(device.name) + private fun getAudioDevicesList(call: MethodCall, result: Result,hmssdk:HMSSDK){ + val audioDevicesList = ArrayList(); + for (device in hmssdk.getAudioDevicesList()){ + audioDevicesList.add(device.name); } CoroutineScope(Dispatchers.Main).launch { result.success(audioDevicesList) } } - private fun getCurrentDevice(call: MethodCall, result: Result, hmssdk: HMSSDK) { + private fun getCurrentDevice(call: MethodCall, result: Result,hmssdk:HMSSDK){ CoroutineScope(Dispatchers.Main).launch { result.success(hmssdk.getAudioOutputRouteType().name) } } - private fun switchAudioOutput(call: MethodCall, result: Result, hmssdk: HMSSDK) { - var argument: String? = call.argument("audio_device_name") - if (argument != null) { - var audioDevice: HMSAudioManager.AudioDevice = HMSAudioManager.AudioDevice.valueOf(argument) + private fun switchAudioOutput(call: MethodCall, result: Result,hmssdk:HMSSDK){ + var argument:String? = call.argument("audio_device_name") + if(argument!=null){ + var audioDevice:HMSAudioManager.AudioDevice = HMSAudioManager.AudioDevice.valueOf(argument) hmssdk.switchAudioOutput(audioDevice) } + } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSHLSAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSHLSAction.kt index f76a85908..8bbfef6f0 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSHLSAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSHLSAction.kt @@ -1,23 +1,24 @@ package live.hms.hmssdk_flutter -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel.Result +import android.util.Log import live.hms.video.sdk.HMSSDK import live.hms.video.sdk.models.HMSHLSConfig import live.hms.video.sdk.models.HMSHLSMeetingURLVariant +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel.Result import live.hms.video.sdk.models.HMSHlsRecordingConfig class HMSHLSAction { - companion object { + companion object{ - fun hlsActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { + fun hlsActions(call: MethodCall, result: Result,hmssdk:HMSSDK){ when (call.method) { - "hls_start_streaming" -> { - hlsStreaming(call, result, hmssdk) + "hls_start_streaming"->{ + hlsStreaming(call, result,hmssdk) } - "hls_stop_streaming" -> { - stopHLSStreaming(call, result, hmssdk) + "hls_stop_streaming"->{ + stopHLSStreaming(call,result,hmssdk) } else -> { result.notImplemented() @@ -25,55 +26,57 @@ class HMSHLSAction { } } - private fun hlsStreaming(call: MethodCall, result: Result, hmssdk: HMSSDK) { - val meetingUrlVariantsList = call.argument>?>("meeting_url_variants") - val recordingConfig = call.argument?>("recording_config") - var meetingUrlVariant: ArrayList? = null + + private fun hlsStreaming(call: MethodCall, result: Result,hmssdk:HMSSDK) { + val meetingUrlVariantsList = call.argument>?>("meeting_url_variants") + val recordingConfig = call.argument?>("recording_config") + var meetingUrlVariant : ArrayList? = null var hmsHLSRecordingConfig: HMSHlsRecordingConfig? = null var hlsConfig: HMSHLSConfig? = null - if (meetingUrlVariantsList != null) { + if(meetingUrlVariantsList!=null) { meetingUrlVariant = ArrayList() meetingUrlVariantsList?.forEach { meetingUrlVariant.add( HMSHLSMeetingURLVariant( meetingUrl = it["meeting_url"]!!, - metadata = it["meta_data"]!!, - ), + metadata = it["meta_data"]!! + ) ) } } - if (recordingConfig != null) { + if(recordingConfig!=null){ hmsHLSRecordingConfig = HMSHlsRecordingConfig( singleFilePerLayer = recordingConfig?.get("single_file_per_layer")!!, - videoOnDemand = recordingConfig?.get("video_on_demand")!!, + videoOnDemand = recordingConfig?.get("video_on_demand")!! ) } - if (meetingUrlVariant != null || hmsHLSRecordingConfig != null) { + if(meetingUrlVariant!=null || hmsHLSRecordingConfig!=null) { hlsConfig = HMSHLSConfig(meetingUrlVariant, hmsHLSRecordingConfig) } hmssdk.startHLSStreaming(config = hlsConfig, hmsActionResultListener = HMSCommonAction.getActionListener(result)) } - private fun stopHLSStreaming(call: MethodCall, result: Result, hmssdk: HMSSDK) { - val meetingUrlVariantsList = call.argument>>("meeting_url_variants") - val meetingUrlVariant1: ArrayList = ArrayList() + private fun stopHLSStreaming(call: MethodCall,result: Result,hmssdk:HMSSDK) { + val meetingUrlVariantsList = call.argument>>("meeting_url_variants") + + val meetingUrlVariant1 : ArrayList = ArrayList() meetingUrlVariantsList?.forEach { meetingUrlVariant1.add( - HMSHLSMeetingURLVariant( - meetingUrl = it["meeting_url"]!!, - metadata = it["meta_data"]!!, - ), + HMSHLSMeetingURLVariant( + meetingUrl = it["meeting_url"]!!, + metadata = it["meta_data"]!! + ) ) } - var hlsConfig: HMSHLSConfig? = null - if (meetingUrlVariant1.isNotEmpty()) { + var hlsConfig : HMSHLSConfig? = null + if(meetingUrlVariant1.isNotEmpty()) hlsConfig = HMSHLSConfig(meetingUrlVariant1) - } hmssdk.stopHLSStreaming(config = hlsConfig, hmsActionResultListener = HMSCommonAction.getActionListener(result)) } + } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSMessageAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSMessageAction.kt index 4e25f31bd..0f69ba2a3 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSMessageAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSMessageAction.kt @@ -1,25 +1,25 @@ package live.hms.hmssdk_flutter import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel.Result +import live.hms.video.sdk.* +import live.hms.video.error.HMSException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import live.hms.video.error.HMSException -import live.hms.video.sdk.* import live.hms.video.sdk.models.HMSMessage class HMSMessageAction { companion object { - fun messageActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { + fun messageActions(call: MethodCall, result: Result,hmssdk:HMSSDK) { when (call.method) { "send_broadcast_message" -> { - sendBroadCastMessage(call, result, hmssdk) + sendBroadCastMessage(call, result,hmssdk) } "send_direct_message" -> { - sendDirectMessage(call, result, hmssdk) + sendDirectMessage(call, result,hmssdk) } "send_group_message" -> { - sendGroupMessage(call, result, hmssdk) + sendGroupMessage(call, result,hmssdk) } else -> { result.notImplemented() @@ -27,13 +27,14 @@ class HMSMessageAction { } } - private fun sendBroadCastMessage(call: MethodCall, result: Result, hmssdk: HMSSDK) { + + private fun sendBroadCastMessage(call: MethodCall, result: Result,hmssdk:HMSSDK) { val message = call.argument("message") val type = call.argument("type") ?: "chat" hmssdk?.sendBroadcastMessage(message!!, type, getMessageResultListener(result)) } - private fun sendGroupMessage(call: MethodCall, result: Result, hmssdk: HMSSDK) { + private fun sendGroupMessage(call: MethodCall, result: Result,hmssdk:HMSSDK) { val message = call.argument("message") val roles: List? = call.argument>("roles") val type = call.argument("type") ?: "chat" @@ -43,36 +44,35 @@ class HMSMessageAction { hmssdk?.sendGroupMessage(message!!, type, hmsRoles, getMessageResultListener(result)) } - private fun sendDirectMessage(call: MethodCall, result: Result, hmssdk: HMSSDK) { + private fun sendDirectMessage(call: MethodCall, result: Result,hmssdk:HMSSDK) { val message = call.argument("message") val peerId = call.argument("peer_id") val type = call.argument("type") ?: "chat" - val peer = HMSCommonAction.getPeerById(peerId!!, hmssdk) + val peer = HMSCommonAction.getPeerById(peerId!!,hmssdk) hmssdk?.sendDirectMessage(message!!, type, peer!!, getMessageResultListener(result)) } - private fun getMessageResultListener(result: Result) = object : HMSMessageResultListener { + private fun getMessageResultListener(result: Result) = object: HMSMessageResultListener { override fun onError(error: HMSException) { val args = HashMap() args["event_name"] = "on_error" args["data"] = HMSExceptionExtension.toDictionary(error) - if (args["data"] != null) { + if (args["data"] != null) CoroutineScope(Dispatchers.Main).launch { result.success(args) } - } } override fun onSuccess(hmsMessage: HMSMessage) { val args = HashMap() args["event_name"] = "on_success" args["message"] = HMSMessageExtension.toDictionary(hmsMessage) - if (args["message"] != null) { + if (args["message"] != null) CoroutineScope(Dispatchers.Main).launch { result.success(args) } - } } } + } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt index 04c795cf2..1fa3ff890 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt @@ -29,7 +29,7 @@ class HMSPipAction { } "is_pip_available" -> { result.success( - activity.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE), + activity.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) ) } "setup_pip" -> { diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRecordingAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRecordingAction.kt index b2d806163..2ba564493 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRecordingAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRecordingAction.kt @@ -1,19 +1,24 @@ package live.hms.hmssdk_flutter +import live.hms.video.sdk.HMSSDK import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel.Result +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import live.hms.video.error.HMSException import live.hms.video.media.settings.HMSRtmpVideoResolution -import live.hms.video.sdk.HMSSDK +import live.hms.video.sdk.HMSActionResultListener import live.hms.video.sdk.models.HMSRecordingConfig class HMSRecordingAction { - companion object { - fun recordingActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { + companion object{ + fun recordingActions(call: MethodCall, result: Result,hmssdk:HMSSDK){ when (call.method) { "start_rtmp_or_recording" -> { - startRtmpOrRecording(call, result, hmssdk) + startRtmpOrRecording(call, result,hmssdk) } "stop_rtmp_and_recording" -> { - stopRtmpAndRecording(result, hmssdk) + stopRtmpAndRecording(result,hmssdk) } else -> { result.notImplemented() @@ -21,28 +26,29 @@ class HMSRecordingAction { } } - private fun startRtmpOrRecording(call: MethodCall, result: Result, hmssdk: HMSSDK) { + private fun startRtmpOrRecording(call: MethodCall, result: Result,hmssdk:HMSSDK) { val meetingUrl = call.argument("meeting_url") val toRecord = call.argument("to_record") val listOfRtmpUrls: List = call.argument>("rtmp_urls") ?: listOf() - val resolutionMap = call.argument>("resolution") - val hmsRecordingConfig = if (resolutionMap != null) { + val resolutionMap = call.argument>("resolution") + val hmsRecordingConfig = if(resolutionMap!=null) { val resolution = HMSRtmpVideoResolution( width = resolutionMap["width"]!!, - height = resolutionMap["height"]!!, + height = resolutionMap["height"]!! ) - HMSRecordingConfig(meetingUrl!!, listOfRtmpUrls, toRecord!!, resolution) - } else { + HMSRecordingConfig(meetingUrl!!, listOfRtmpUrls, toRecord!!,resolution) + }else{ HMSRecordingConfig(meetingUrl!!, listOfRtmpUrls, toRecord!!) } hmssdk.startRtmpOrRecording( hmsRecordingConfig, - hmsActionResultListener = HMSCommonAction.getActionListener(result), + hmsActionResultListener = HMSCommonAction.getActionListener(result) ) } - private fun stopRtmpAndRecording(result: Result, hmssdk: HMSSDK) { + private fun stopRtmpAndRecording(result: Result,hmssdk:HMSSDK) { hmssdk.stopRtmpAndRecording(hmsActionResultListener = HMSCommonAction.getActionListener(result)) } + } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRoomAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRoomAction.kt index b06b664e8..e6e107e03 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRoomAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSRoomAction.kt @@ -1,39 +1,39 @@ package live.hms.hmssdk_flutter import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel.Result +import live.hms.video.sdk.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import live.hms.video.sdk.* class HMSRoomAction { companion object { fun roomActions(call: MethodCall, result: Result, hmssdk: HMSSDK) { when (call.method) { "get_room" -> { - getRoom(result, hmssdk) + getRoom(result,hmssdk) } "get_local_peer" -> { - localPeer(result, hmssdk) + localPeer(result,hmssdk) } "get_remote_peers" -> { - getRemotePeers(result, hmssdk) + getRemotePeers(result,hmssdk) } "get_peers" -> { - getPeers(result, hmssdk) + getPeers(result,hmssdk) } else -> { result.notImplemented() } } } - private fun getRoom(result: Result, hmssdk: HMSSDK) { + private fun getRoom(result: Result,hmssdk: HMSSDK) { result.success(HMSRoomExtension.toDictionary(hmssdk?.getRoom())) } - private fun localPeer(result: Result, hmssdk: HMSSDK) { + private fun localPeer(result: Result,hmssdk: HMSSDK) { result.success(HMSPeerExtension.toDictionary(HMSCommonAction.getLocalPeer(hmssdk))) } - private fun getRemotePeers(result: Result, hmssdk: HMSSDK) { + private fun getRemotePeers(result: Result,hmssdk: HMSSDK) { val peersList = hmssdk.getRemotePeers() val peersMapList = ArrayList?>() peersList.forEach { @@ -45,7 +45,7 @@ class HMSRoomAction { } // TODO: check behaviour when room is not joined - private fun getPeers(result: Result, hmssdk: HMSSDK) { + private fun getPeers(result: Result,hmssdk: HMSSDK) { val peersList = hmssdk.getPeers() val peersMapList = ArrayList?>() peersList.forEach { @@ -56,4 +56,4 @@ class HMSRoomAction { } } } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt index 6b9cc1f5e..63f1500fb 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import live.hms.hmssdk_flutter.HMSCommonAction import live.hms.hmssdk_flutter.HMSErrorLogger +import live.hms.hmssdk_flutter.HMSExceptionExtension import live.hms.hmssdk_flutter.HMSSessionMetadataExtension import live.hms.video.error.HMSException import live.hms.video.sdk.HMSSDK @@ -37,7 +38,7 @@ class HMSSessionMetadataAction { hmssdk.setSessionMetaData(metadata, HMSCommonAction.getActionListener(result)) } - private fun getSessionMetadataResultListener(result: MethodChannel.Result) = object : + private fun getSessionMetadataResultListener(result: MethodChannel.Result) = object: HMSSessionMetadataListener { override fun onError(error: HMSException) { result.success(null) @@ -48,16 +49,17 @@ class HMSSessionMetadataAction { args["event_name"] = "session_metadata" if (sessionMetadata is String?) { args["data"] = HMSSessionMetadataExtension.toDictionary(sessionMetadata) - } else { - HMSErrorLogger.logError("getSessionMetadata", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") + } + else { + HMSErrorLogger.logError("getSessionMetadata","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") args["data"] = null } - if (args["data"] != null) { + if (args["data"] != null) CoroutineScope(Dispatchers.Main).launch { result.success(args) } - } } } + } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt index 496366bae..04d72340f 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt @@ -12,15 +12,15 @@ import live.hms.video.sessionstore.HmsSessionStore class HMSSessionStoreAction { - companion object { + companion object{ - fun sessionStoreActions(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { - when (call.method) { + fun sessionStoreActions(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?){ + when(call.method){ "get_session_metadata_for_key" -> { - getSessionMetadataForKey(call, result, hmsSessionStore) + getSessionMetadataForKey(call,result,hmsSessionStore) } "set_session_metadata_for_key" -> { - setSessionMetadataForKey(call, result, hmsSessionStore) + setSessionMetadataForKey(call,result,hmsSessionStore) } } } @@ -33,29 +33,26 @@ class HMSSessionStoreAction { * * This method returns [sessionMetadata] is the session metadata is available for corresponding key */ - private fun getSessionMetadataForKey(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { + private fun getSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ val key = call.argument("key") ?: run { HMSErrorLogger.returnArgumentsError("key is null") } - key?.let { - key as String - hmsSessionStore?.get( - key, - object : HMSSessionMetadataListener { - override fun onError(error: HMSException) { - result.success(HMSResultExtension.toDictionary(false, HMSExceptionExtension.toDictionary(error))) - } + key?.let { key as String + hmsSessionStore?.get(key,object:HMSSessionMetadataListener{ + override fun onError(error: HMSException) { + result.success(HMSResultExtension.toDictionary(false, HMSExceptionExtension.toDictionary(error))) + } - override fun onSuccess(sessionMetadata: Any?) { - if (sessionMetadata is String?) { - result.success(HMSResultExtension.toDictionary(true, sessionMetadata)) - } else { - HMSErrorLogger.returnHMSException("getSessionMetadataForKey", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) - } + override fun onSuccess(sessionMetadata: Any?) { + if (sessionMetadata is String?) { + result.success(HMSResultExtension.toDictionary(true, sessionMetadata)) + } + else{ + HMSErrorLogger.returnHMSException("getSessionMetadataForKey","Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) } - }, - ) + } + }) } } @@ -68,17 +65,17 @@ class HMSSessionStoreAction { * This method sets the [data] provided during the method call * The completion of this method is marked by actionResultListener's [onSuccess] or [onError] callback */ - private fun setSessionMetadataForKey(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { + private fun setSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ val key = call.argument("key") ?: run { HMSErrorLogger.returnArgumentsError("key is null") } val data = call.argument("data") - key?.let { - key as String - hmsSessionStore?.set(data, key, HMSCommonAction.getActionListener(result)) + key?.let { key as String + hmsSessionStore?.set(data,key,HMSCommonAction.getActionListener(result)) } } + } -} +} \ No newline at end of file diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoView.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoView.kt index fea4f86c3..4f027aef5 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoView.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoView.kt @@ -23,7 +23,7 @@ class HMSVideoView( private val scaleType: Int? = RendererCommon.ScalingType.SCALE_ASPECT_FIT.ordinal, private val track: HMSVideoTrack?, private val disableAutoSimulcastLayerSelect: Boolean, - private val hmssdkFlutterPlugin: HmssdkFlutterPlugin?, + private val hmssdkFlutterPlugin: HmssdkFlutterPlugin? ) : FrameLayout(context, null) { private var hmsVideoView: HMSVideoView? = null diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoViewFactory.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoViewFactory.kt index f3a4c0aba..e9c402ed1 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoViewFactory.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/views/HMSVideoViewFactory.kt @@ -22,7 +22,7 @@ class HMSVideoViewWidget( scaleType: Int?, private val matchParent: Boolean? = true, disableAutoSimulcastLayerSelect: Boolean, - hmssdkFlutterPlugin: HmssdkFlutterPlugin?, + hmssdkFlutterPlugin: HmssdkFlutterPlugin? ) : PlatformView { private var hmsVideoView: HMSVideoView? = null @@ -41,12 +41,12 @@ class HMSVideoViewWidget( super.onFlutterViewAttached(flutterView) var frameLayoutParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, - FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT ) if (matchParent == false) { frameLayoutParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, - FrameLayout.LayoutParams.WRAP_CONTENT, + FrameLayout.LayoutParams.WRAP_CONTENT ) } if (view != null) { @@ -90,7 +90,7 @@ class HMSVideoViewFactory(private val plugin: HmssdkFlutterPlugin) : code = 6004, description = "There is no track corresponding to the given trackId", message = "Video track is null for corresponding trackId", - name = "HMSVideoView Error", + name = "HMSVideoView Error" ) args["data"] = HMSExceptionExtension.toDictionary(hmsException) plugin.onVideoViewError(args) diff --git a/example/android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt b/example/android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt index 83a6af844..a4b34c4a8 100644 --- a/example/android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt +++ b/example/android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt @@ -27,7 +27,7 @@ class MainActivity : FlutterActivity() { override fun onPictureInPictureModeChanged( isInPictureInPictureMode: Boolean, - newConfig: Configuration?, + newConfig: Configuration? ) { if (isInPictureInPictureMode) { if (HMSPipAction.pipResult != null) { diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index 3ee1f227c..49304354f 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -28,7 +28,7 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) return } @@ -36,23 +36,24 @@ class HMSSessionStoreAction { let key = arguments["key"] as? String else { HMSErrorLogger.returnArgumentsError("key is null") - HMSErrorLogger.returnHMSException(#function, "Key to be fetched from Session Store is null.", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Key to be fetched from Session Store is null.","NULL ERROR",result) return } store.object(forKey: key) { value, error in if let error = error { - HMSErrorLogger.returnHMSException(#function, "Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)", "Key Fetching error", result) + HMSErrorLogger.returnHMSException(#function,"Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)","Key Fetching error",result) return } - if value is String? || value is NSNull { + if(value is String? || value is NSNull){ result(HMSResultExtension.toDictionary(true, value)) - } else { - HMSErrorLogger.returnHMSException(#function, "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) } - + else{ + HMSErrorLogger.returnHMSException(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error",result) + } + } } @@ -61,23 +62,23 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - HMSErrorLogger.returnHMSException(#function, "Session Store is null.", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Session Store is null.", "NULL ERROR",result) return } guard let arguments = call.arguments as? [AnyHashable: Any], let key = arguments["key"] as? String else { - HMSErrorLogger.returnHMSException(#function, "Key for the object to be set in Session Store is null.", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Key for the object to be set in Session Store is null.","NULL ERROR",result) return } let data = arguments["data"] - store.set(data as Any, forKey: key) { _, error in + store.set(data as Any, forKey: key) { value, error in if let error = error { - HMSErrorLogger.returnHMSException(#function, "Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)", "Key Error", result) + HMSErrorLogger.returnHMSException(#function,"Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)","Key Error",result) return } result(nil) diff --git a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift index edd570c38..02817a65e 100644 --- a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift +++ b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift @@ -11,64 +11,64 @@ import HMSSDK class HMSAudioFilePlayerNodeExtension { static func play(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { - guard let fileURL = call["file_url"] as? String else { + guard let fileURL = call["file_url"] as? String else{ HMSErrorLogger.returnArgumentsError("Invalid file") - HMSErrorLogger.returnHMSException(#function, "Error in playing the file", "File Error", result) + HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) return } - guard let url = URL(string: fileURL) else { + guard let url = URL(string: fileURL) else{ HMSErrorLogger.returnArgumentsError("File URL is invalid") - HMSErrorLogger.returnHMSException(#function, "Error in playing the file", "File Error", result) + HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) return } - do { + do{ try playerNode.play(fileUrl: url, loops: call["loops"] as? Bool ?? false, interrupts: call["interrupts"] as? Bool ?? false) - result(HMSResultExtension.toDictionary(true, nil)) + result(HMSResultExtension.toDictionary(true,nil)) } catch { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.toDictionary(error))) + result(HMSResultExtension.toDictionary(false,HMSErrorExtension.toDictionary(error))) } } - static func pause( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { + static func pause( _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { playerNode.pause() - result(HMSResultExtension.toDictionary(true, nil)) + result(HMSResultExtension.toDictionary(true,nil)) } static func resume( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { do { try playerNode.resume() - result(HMSResultExtension.toDictionary(true, nil)) + result(HMSResultExtension.toDictionary(true,nil)) } catch { - result(HMSResultExtension.toDictionary(false, HMSErrorExtension.toDictionary(error))) + result(HMSResultExtension.toDictionary(false,HMSErrorExtension.toDictionary(error))) } } - static func stop( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { + static func stop( _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { playerNode.stop() - result(HMSResultExtension.toDictionary(true, nil)) + result(HMSResultExtension.toDictionary(true,nil)) } - static func setVolume(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { + static func setVolume(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { playerNode.volume = Float(call["volume"] as! Double) - result(HMSResultExtension.toDictionary(true, nil)) + result(HMSResultExtension.toDictionary(true,nil)) } static func isPlaying(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["is_playing"] = playerNode.isPlaying - result(HMSResultExtension.toDictionary(true, dict)) + result(HMSResultExtension.toDictionary(true,dict)) } static func currentDuration(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["current_duration"] = playerNode.currentTime - result(HMSResultExtension.toDictionary(true, dict)) + result(HMSResultExtension.toDictionary(true,dict)) } static func duration(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["duration"] = playerNode.duration - result(HMSResultExtension.toDictionary(true, dict)) + result(HMSResultExtension.toDictionary(true,dict)) } } diff --git a/ios/Classes/Models/HMSTrackSettingsExtension.swift b/ios/Classes/Models/HMSTrackSettingsExtension.swift index 12a1ab3d0..5060846bf 100644 --- a/ios/Classes/Models/HMSTrackSettingsExtension.swift +++ b/ios/Classes/Models/HMSTrackSettingsExtension.swift @@ -149,9 +149,9 @@ class HMSTrackSettingsExtension { return nil } } - + static private func getStringFromAudioMode(from mode: HMSAudioMode) -> String? { - switch mode { + switch mode{ case .music: return "music" diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index d68844698..d6a968a2c 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -397,17 +397,17 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene HMSAudioFilePlayerNodeExtension.play(arguments, audioNode as! HMSAudioFilePlayerNode, result) break case "stop_audio_share": - HMSAudioFilePlayerNodeExtension.stop(audioNode as! HMSAudioFilePlayerNode, result) + HMSAudioFilePlayerNodeExtension.stop(audioNode as! HMSAudioFilePlayerNode,result) break case "pause_audio_share": - HMSAudioFilePlayerNodeExtension.pause(audioNode as! HMSAudioFilePlayerNode, result) + HMSAudioFilePlayerNodeExtension.pause(audioNode as! HMSAudioFilePlayerNode,result) break case "resume_audio_share": HMSAudioFilePlayerNodeExtension.resume(audioNode as! HMSAudioFilePlayerNode, result) break case "set_audio_share_volume": if arguments["name"] as! String != "mic_node" { - HMSAudioFilePlayerNodeExtension.setVolume(arguments, audioNode as! HMSAudioFilePlayerNode, result) + HMSAudioFilePlayerNodeExtension.setVolume(arguments, audioNode as! HMSAudioFilePlayerNode,result) } else { HMSMicNodeExtension.setVolume(arguments, audioNode as! HMSMicNode) } @@ -498,26 +498,26 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) return } guard let arguments = call.arguments as? [AnyHashable: Any] else { HMSErrorLogger.returnArgumentsError("keys is null") - HMSErrorLogger.returnHMSException(#function, "No arguments passed which can be attached to Key Change Listener on the Session Store.", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"No arguments passed which can be attached to Key Change Listener on the Session Store.","NULL ERROR",result) return } guard let keys = arguments["keys"] as? [String] else { - HMSErrorLogger.returnHMSException(#function, "No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)","NULL ERROR",result) return } - + guard let uid = arguments["uid"] as? String else { - HMSErrorLogger.returnHMSException(#function, "No uid passed for key change listener Available arguments: \(arguments)", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"No uid passed for key change listener Available arguments: \(arguments)","NULL ERROR",result) return } @@ -529,13 +529,14 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene var dict: [String: Any] = ["key": key] - if value is String? || value is NSNull { + if(value is String? || value is NSNull){ dict["value"] = value - } else { - HMSErrorLogger.logError(#function, "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") + } + else{ + HMSErrorLogger.logError(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") dict["value"] = nil } - + dict["uid"] = uid data["data"] = dict @@ -544,19 +545,19 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene }) { [weak self] observer, error in if let error = error { - HMSErrorLogger.returnHMSException(#function, "Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)", "KEY CHANGE ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)","KEY CHANGE ERROR",result) return } guard let observer = observer else { - HMSErrorLogger.returnHMSException(#function, "Unknown Error in observing changes for key: \(keys) in the Session Store.", "KEY CHANGE ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Unknown Error in observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR",result) return } guard let self = self else { - HMSErrorLogger.returnHMSException(#function, "Could not find self instance while observing changes for key: \(keys) in the Session Store.", "KEY CHANGE ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Could not find self instance while observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR",result) return } @@ -574,44 +575,45 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) + HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) return } guard let arguments = call.arguments as? [AnyHashable: Any] else { - HMSErrorLogger.returnHMSException(#function, "No arguments to identify which Key Change Listener should be removed from the Session Store.", "Remove Key Error", result) + HMSErrorLogger.returnHMSException(#function,"No arguments to identify which Key Change Listener should be removed from the Session Store.","Remove Key Error",result) return } guard let uid = arguments["uid"] as? String else { - HMSErrorLogger.returnHMSException(#function, "No identifier passed which can be used. Available arguments: \(arguments)", "Unique Id Error", result) + HMSErrorLogger.returnHMSException(#function,"No identifier passed which can be used. Available arguments: \(arguments)","Unique Id Error",result) return } guard let keyChangeListenersToBeRemovedIndex = sessionStoreChangeObservers.firstIndex(where: { $0.uid == uid }) - else { - HMSErrorLogger.returnHMSException(#function, "No listener found to remove", "Listener Error", result) + else{ + HMSErrorLogger.returnHMSException(#function,"No listener found to remove","Listener Error",result) return } + store.removeObserver(sessionStoreChangeObservers[keyChangeListenersToBeRemovedIndex].observer) sessionStoreChangeObservers.remove(at: keyChangeListenersToBeRemovedIndex) result(nil) } - + /** This takes care of removing all the key change listeners attached during the session This is used while cleaning the room state i.e after calling leave room, onRemovedFromRoom or endRoom */ - private func removeAllKeyChangeListener() { - sessionStoreChangeObservers.forEach { + private func removeAllKeyChangeListener(){ + sessionStoreChangeObservers.forEach{ hmsSessionStoreObserver in sessionStore?.removeObserver(hmsSessionStoreObserver.observer) } diff --git a/sample apps/bloc/android/app/src/main/kotlin/com/example/demo_app_with_100ms_and_bloc/MainActivity.kt b/sample apps/bloc/android/app/src/main/kotlin/com/example/demo_app_with_100ms_and_bloc/MainActivity.kt index c189b717c..4521925f8 100644 --- a/sample apps/bloc/android/app/src/main/kotlin/com/example/demo_app_with_100ms_and_bloc/MainActivity.kt +++ b/sample apps/bloc/android/app/src/main/kotlin/com/example/demo_app_with_100ms_and_bloc/MainActivity.kt @@ -1,17 +1,18 @@ package com.example.demo_app_with_100ms_and_bloc +import io.flutter.embedding.android.FlutterActivity +import live.hms.hmssdk_flutter.HmssdkFlutterPlugin import android.app.Activity import android.content.Intent -import io.flutter.embedding.android.FlutterActivity import live.hms.hmssdk_flutter.Constants -import live.hms.hmssdk_flutter.HmssdkFlutterPlugin -class MainActivity : FlutterActivity() { +class MainActivity: FlutterActivity() { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) +super.onActivityResult(requestCode, resultCode, data) - if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) { - HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) - } + if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK){ + HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) } + +} } diff --git a/sample apps/flutter-audio-room-quickstart/android/app/src/main/kotlin/com/example/flutter_audio_room_quickstart/MainActivity.kt b/sample apps/flutter-audio-room-quickstart/android/app/src/main/kotlin/com/example/flutter_audio_room_quickstart/MainActivity.kt index d35527b20..9aa257d65 100644 --- a/sample apps/flutter-audio-room-quickstart/android/app/src/main/kotlin/com/example/flutter_audio_room_quickstart/MainActivity.kt +++ b/sample apps/flutter-audio-room-quickstart/android/app/src/main/kotlin/com/example/flutter_audio_room_quickstart/MainActivity.kt @@ -2,4 +2,5 @@ package com.example.flutter_audio_room_quickstart import io.flutter.embedding.android.FlutterActivity -class MainActivity : FlutterActivity() +class MainActivity: FlutterActivity() { +} diff --git a/sample apps/flutter-hls-quickstart/android/app/src/main/kotlin/com/example/flutter_hls_quickstart/MainActivity.kt b/sample apps/flutter-hls-quickstart/android/app/src/main/kotlin/com/example/flutter_hls_quickstart/MainActivity.kt index 69fd8a679..f8dc93a30 100644 --- a/sample apps/flutter-hls-quickstart/android/app/src/main/kotlin/com/example/flutter_hls_quickstart/MainActivity.kt +++ b/sample apps/flutter-hls-quickstart/android/app/src/main/kotlin/com/example/flutter_hls_quickstart/MainActivity.kt @@ -2,4 +2,5 @@ package com.example.flutter_hls_quickstart import io.flutter.embedding.android.FlutterActivity -class MainActivity : FlutterActivity() +class MainActivity: FlutterActivity() { +} diff --git a/sample apps/flutter-quickstart-app/android/app/src/main/kotlin/com/example/flutter_integration_guide/MainActivity.kt b/sample apps/flutter-quickstart-app/android/app/src/main/kotlin/com/example/flutter_integration_guide/MainActivity.kt index c6a8a7608..c5e536eb2 100644 --- a/sample apps/flutter-quickstart-app/android/app/src/main/kotlin/com/example/flutter_integration_guide/MainActivity.kt +++ b/sample apps/flutter-quickstart-app/android/app/src/main/kotlin/com/example/flutter_integration_guide/MainActivity.kt @@ -2,4 +2,5 @@ package com.example.flutter_integration_guide import io.flutter.embedding.android.FlutterActivity -class MainActivity : FlutterActivity() +class MainActivity: FlutterActivity() { +} diff --git a/sample apps/getx/android/app/src/main/kotlin/com/example/demo_with_getx_and_100ms/MainActivity.kt b/sample apps/getx/android/app/src/main/kotlin/com/example/demo_with_getx_and_100ms/MainActivity.kt index d38cacb32..289782076 100644 --- a/sample apps/getx/android/app/src/main/kotlin/com/example/demo_with_getx_and_100ms/MainActivity.kt +++ b/sample apps/getx/android/app/src/main/kotlin/com/example/demo_with_getx_and_100ms/MainActivity.kt @@ -1,17 +1,19 @@ package com.example.demo_with_getx_and_100ms +import io.flutter.embedding.android.FlutterActivity +import live.hms.hmssdk_flutter.HmssdkFlutterPlugin import android.app.Activity import android.content.Intent -import io.flutter.embedding.android.FlutterActivity import live.hms.hmssdk_flutter.Constants -import live.hms.hmssdk_flutter.HmssdkFlutterPlugin -class MainActivity : FlutterActivity() { + +class MainActivity: FlutterActivity() { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) +super.onActivityResult(requestCode, resultCode, data) - if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) { - HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) - } + if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK){ + HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) } + +} } diff --git a/sample apps/mobx/android/app/src/main/kotlin/com/example/zoom/MainActivity.kt b/sample apps/mobx/android/app/src/main/kotlin/com/example/zoom/MainActivity.kt index eaf224435..0c724ab6a 100644 --- a/sample apps/mobx/android/app/src/main/kotlin/com/example/zoom/MainActivity.kt +++ b/sample apps/mobx/android/app/src/main/kotlin/com/example/zoom/MainActivity.kt @@ -1,17 +1,18 @@ package com.example.mobx +import io.flutter.embedding.android.FlutterActivity +import live.hms.hmssdk_flutter.HmssdkFlutterPlugin import android.app.Activity import android.content.Intent -import io.flutter.embedding.android.FlutterActivity import live.hms.hmssdk_flutter.Constants -import live.hms.hmssdk_flutter.HmssdkFlutterPlugin -class MainActivity : FlutterActivity() { +class MainActivity: FlutterActivity() { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) +super.onActivityResult(requestCode, resultCode, data) - if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) { - HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) - } + if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK){ + HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) } + +} } diff --git a/sample apps/riverpod/android/app/src/main/kotlin/com/example/example_riverpod/MainActivity.kt b/sample apps/riverpod/android/app/src/main/kotlin/com/example/example_riverpod/MainActivity.kt index f739c71c0..207363b1f 100644 --- a/sample apps/riverpod/android/app/src/main/kotlin/com/example/example_riverpod/MainActivity.kt +++ b/sample apps/riverpod/android/app/src/main/kotlin/com/example/example_riverpod/MainActivity.kt @@ -1,17 +1,18 @@ package com.example.example_riverpod +import io.flutter.embedding.android.FlutterActivity +import live.hms.hmssdk_flutter.HmssdkFlutterPlugin import android.app.Activity import android.content.Intent -import io.flutter.embedding.android.FlutterActivity import live.hms.hmssdk_flutter.Constants -import live.hms.hmssdk_flutter.HmssdkFlutterPlugin -class MainActivity : FlutterActivity() { - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) +class MainActivity: FlutterActivity() { + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { +super.onActivityResult(requestCode, resultCode, data) - if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) { - HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) - } + if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK){ + HmssdkFlutterPlugin.hmssdkFlutterPlugin?.requestScreenShare(data) } + +} } From 5f15a1c0d54f363168d79f73ea23ce2a565d219d Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 2 May 2023 23:33:16 +0530 Subject: [PATCH 61/88] updated android gradle file --- android/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 2ddaabebb..68a1da0c5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -39,9 +39,9 @@ android { minSdkVersion 21 } } -def hmsVersion = "an719-SNAPSHOT" + dependencies { - implementation "com.github.100mslive.android-sdk:lib:$hmsVersion" + implementation "live.100ms:android-sdk:${sdkVersions['android']}" implementation "live.100ms:video-view:${sdkVersions['android']}" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0' From f4f17efc92ec3c183abca3b0319b4dc4e41257e0 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 2 May 2023 23:36:41 +0530 Subject: [PATCH 62/88] updated default Auth Token value in HLS Example app to avoid dart lint from failing --- sample apps/flutter-hls-quickstart/lib/main.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sample apps/flutter-hls-quickstart/lib/main.dart b/sample apps/flutter-hls-quickstart/lib/main.dart index f8a8eb057..5b3c09152 100644 --- a/sample apps/flutter-hls-quickstart/lib/main.dart +++ b/sample apps/flutter-hls-quickstart/lib/main.dart @@ -81,8 +81,8 @@ class _MyHomePageState extends State { context, CupertinoPageRoute( builder: (_) => MeetingPage( - authToken: - /* + authToken: "ENTER YOUR AUTH TOKEN HERE", + /* * Paste Auth Token for your Room from 100ms Dashboard here * https://dashboard.100ms.live/ */ @@ -113,8 +113,8 @@ class _MyHomePageState extends State { context, CupertinoPageRoute( builder: (_) => HLSViewerPage( - authToken: - /* + authToken: "ENTER YOUR AUTH TOKEN HERE", + /* * Paste Auth Token for your Room from 100ms Dashboard here * https://dashboard.100ms.live/ */ From aa624fda495dd3af7794f4f4303520ece8ce1b43 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Tue, 2 May 2023 23:37:55 +0530 Subject: [PATCH 63/88] corrected dart imports --- .../common/bottom_sheets/app_settings_bottom_sheet.dart | 4 ++-- example/lib/common/widgets/audio_tile.dart | 7 ------- example/lib/meeting/meeting_store.dart | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/example/lib/common/bottom_sheets/app_settings_bottom_sheet.dart b/example/lib/common/bottom_sheets/app_settings_bottom_sheet.dart index a74656a06..1ca45ae11 100644 --- a/example/lib/common/bottom_sheets/app_settings_bottom_sheet.dart +++ b/example/lib/common/bottom_sheets/app_settings_bottom_sheet.dart @@ -69,8 +69,8 @@ class _AppSettingsBottomSheetState extends State { await Utilities.getBoolData(key: 'audio-mixer-disabled') ?? true; isAutoSimulcast = await Utilities.getBoolData(key: 'is-auto-simulcast') ?? true; - int audio_mode_index = await Utilities.getIntData(key: 'audio-mode'); - currentAudioMode = await HMSAudioMode.values[audio_mode_index]; + int audioModeIndex = await Utilities.getIntData(key: 'audio-mode'); + currentAudioMode = HMSAudioMode.values[audioModeIndex]; WidgetsBinding.instance.addPostFrameCallback((_) { setState(() {}); }); diff --git a/example/lib/common/widgets/audio_tile.dart b/example/lib/common/widgets/audio_tile.dart index 925502e0d..ecd8068ed 100644 --- a/example/lib/common/widgets/audio_tile.dart +++ b/example/lib/common/widgets/audio_tile.dart @@ -1,8 +1,5 @@ // Package imports import 'package:flutter/material.dart'; -import 'package:hmssdk_flutter_example/common/app_dialogs/change_role_option_dialog.dart'; -import 'package:hmssdk_flutter_example/common/app_dialogs/change_simulcast_layer_option_dialog.dart'; -import 'package:hmssdk_flutter_example/common/app_dialogs/local_peer_tile_dialog.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/audio_level_avatar.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/audio_mute_status.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/brb_tag.dart'; @@ -12,14 +9,10 @@ import 'package:hmssdk_flutter_example/common/peer_widgets/network_icon_widget.d import 'package:hmssdk_flutter_example/common/peer_widgets/rtc_stats_view.dart'; import 'package:hmssdk_flutter_example/common/peer_widgets/tile_border.dart'; import 'package:hmssdk_flutter_example/common/util/app_color.dart'; -import 'package:hmssdk_flutter_example/common/util/utility_components.dart'; import 'package:provider/provider.dart'; // Project imports -import 'package:hmssdk_flutter/hmssdk_flutter.dart'; -import 'package:hmssdk_flutter_example/meeting/meeting_store.dart'; import 'package:hmssdk_flutter_example/model/peer_track_node.dart'; -import 'package:hmssdk_flutter_example/common/app_dialogs/remote_peer_tile_dialog.dart'; import '../peer_widgets/peer_name.dart'; diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index c63a8e947..3d2ff193d 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -4,7 +4,6 @@ import 'dart:developer'; import 'dart:io'; import 'dart:math' as Math; import 'package:firebase_analytics/firebase_analytics.dart'; -import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_foreground_task/flutter_foreground_task.dart'; From 1fd1d60fe4d150cdd164f8940959f399b3787df6 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Wed, 3 May 2023 12:21:02 +0530 Subject: [PATCH 64/88] Removed coroutine scope from result in actionResultListener (#1303) --- .../live/hms/hmssdk_flutter/methods/HMSCommonAction.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSCommonAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSCommonAction.kt index 4e2f3d7db..e6806d8cb 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSCommonAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSCommonAction.kt @@ -25,15 +25,11 @@ class HMSCommonAction { fun getActionListener(result: Result) = object : HMSActionResultListener { override fun onError(error: HMSException) { - CoroutineScope(Dispatchers.Main).launch { result.success(HMSExceptionExtension.toDictionary(error)) - } } override fun onSuccess() { - CoroutineScope(Dispatchers.Main).launch { - result.success(null) - } + result.success(null) } } From d5ef8e7f803ca39f7391c27c4706a8170c5bdd4e Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 12:35:23 +0530 Subject: [PATCH 65/88] removed TODO comments --- .../src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt index 27e41c16e..1f389ecb5 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSErrorLogger.kt @@ -24,8 +24,6 @@ class HMSErrorLogger { */ fun returnArgumentsError(errorMessage: String): Unit? { HMSLogger.e("FL_HMSSDK Args Error", errorMessage) - - // TODO: why is this return null required? return null } From 61af892bc940a8166c582873cab8808ca16d7e68 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 14:16:21 +0530 Subject: [PATCH 66/88] corrected lint warnings --- .../Actions/HMSSessionStoreAction.swift | 23 +- .../HMSAudioFilePlayerNodeExtension.swift | 36 +-- .../Models/HMSTrackSettingsExtension.swift | 4 +- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 48 ++-- sample apps/bloc/pubspec.lock | 145 ++++++---- sample apps/getx/pubspec.lock | 168 ++++++----- sample apps/mobx/pubspec.lock | 267 ++++++++++++------ 7 files changed, 432 insertions(+), 259 deletions(-) diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index 49304354f..3ee1f227c 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -28,7 +28,7 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) return } @@ -36,24 +36,23 @@ class HMSSessionStoreAction { let key = arguments["key"] as? String else { HMSErrorLogger.returnArgumentsError("key is null") - HMSErrorLogger.returnHMSException(#function,"Key to be fetched from Session Store is null.","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Key to be fetched from Session Store is null.", "NULL ERROR", result) return } store.object(forKey: key) { value, error in if let error = error { - HMSErrorLogger.returnHMSException(#function,"Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)","Key Fetching error",result) + HMSErrorLogger.returnHMSException(#function, "Error in fetching key: \(key) from Session Store. Error: \(error.localizedDescription)", "Key Fetching error", result) return } - if(value is String? || value is NSNull){ + if value is String? || value is NSNull { result(HMSResultExtension.toDictionary(true, value)) + } else { + HMSErrorLogger.returnHMSException(#function, "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) } - else{ - HMSErrorLogger.returnHMSException(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error",result) - } - + } } @@ -62,23 +61,23 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - HMSErrorLogger.returnHMSException(#function,"Session Store is null.", "NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Session Store is null.", "NULL ERROR", result) return } guard let arguments = call.arguments as? [AnyHashable: Any], let key = arguments["key"] as? String else { - HMSErrorLogger.returnHMSException(#function,"Key for the object to be set in Session Store is null.","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Key for the object to be set in Session Store is null.", "NULL ERROR", result) return } let data = arguments["data"] - store.set(data as Any, forKey: key) { value, error in + store.set(data as Any, forKey: key) { _, error in if let error = error { - HMSErrorLogger.returnHMSException(#function,"Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)","Key Error",result) + HMSErrorLogger.returnHMSException(#function, "Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)", "Key Error", result) return } result(nil) diff --git a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift index 02817a65e..edd570c38 100644 --- a/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift +++ b/ios/Classes/Models/HMSAudioFilePlayerNodeExtension.swift @@ -11,64 +11,64 @@ import HMSSDK class HMSAudioFilePlayerNodeExtension { static func play(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { - guard let fileURL = call["file_url"] as? String else{ + guard let fileURL = call["file_url"] as? String else { HMSErrorLogger.returnArgumentsError("Invalid file") - HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) + HMSErrorLogger.returnHMSException(#function, "Error in playing the file", "File Error", result) return } - guard let url = URL(string: fileURL) else{ + guard let url = URL(string: fileURL) else { HMSErrorLogger.returnArgumentsError("File URL is invalid") - HMSErrorLogger.returnHMSException(#function,"Error in playing the file", "File Error",result) + HMSErrorLogger.returnHMSException(#function, "Error in playing the file", "File Error", result) return } - do{ + do { try playerNode.play(fileUrl: url, loops: call["loops"] as? Bool ?? false, interrupts: call["interrupts"] as? Bool ?? false) - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } catch { - result(HMSResultExtension.toDictionary(false,HMSErrorExtension.toDictionary(error))) + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.toDictionary(error))) } } - static func pause( _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { + static func pause( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { playerNode.pause() - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } static func resume( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { do { try playerNode.resume() - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } catch { - result(HMSResultExtension.toDictionary(false,HMSErrorExtension.toDictionary(error))) + result(HMSResultExtension.toDictionary(false, HMSErrorExtension.toDictionary(error))) } } - static func stop( _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { + static func stop( _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { playerNode.stop() - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } - static func setVolume(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode,_ result: @escaping FlutterResult) { + static func setVolume(_ call: [AnyHashable: Any], _ playerNode: HMSAudioFilePlayerNode, _ result: @escaping FlutterResult) { playerNode.volume = Float(call["volume"] as! Double) - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } static func isPlaying(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["is_playing"] = playerNode.isPlaying - result(HMSResultExtension.toDictionary(true,dict)) + result(HMSResultExtension.toDictionary(true, dict)) } static func currentDuration(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["current_duration"] = playerNode.currentTime - result(HMSResultExtension.toDictionary(true,dict)) + result(HMSResultExtension.toDictionary(true, dict)) } static func duration(_ playerNode: HMSAudioFilePlayerNode, _ result: FlutterResult) { var dict = [String: Any]() dict["duration"] = playerNode.duration - result(HMSResultExtension.toDictionary(true,dict)) + result(HMSResultExtension.toDictionary(true, dict)) } } diff --git a/ios/Classes/Models/HMSTrackSettingsExtension.swift b/ios/Classes/Models/HMSTrackSettingsExtension.swift index 5060846bf..12a1ab3d0 100644 --- a/ios/Classes/Models/HMSTrackSettingsExtension.swift +++ b/ios/Classes/Models/HMSTrackSettingsExtension.swift @@ -149,9 +149,9 @@ class HMSTrackSettingsExtension { return nil } } - + static private func getStringFromAudioMode(from mode: HMSAudioMode) -> String? { - switch mode{ + switch mode { case .music: return "music" diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index d6a968a2c..d68844698 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -397,17 +397,17 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene HMSAudioFilePlayerNodeExtension.play(arguments, audioNode as! HMSAudioFilePlayerNode, result) break case "stop_audio_share": - HMSAudioFilePlayerNodeExtension.stop(audioNode as! HMSAudioFilePlayerNode,result) + HMSAudioFilePlayerNodeExtension.stop(audioNode as! HMSAudioFilePlayerNode, result) break case "pause_audio_share": - HMSAudioFilePlayerNodeExtension.pause(audioNode as! HMSAudioFilePlayerNode,result) + HMSAudioFilePlayerNodeExtension.pause(audioNode as! HMSAudioFilePlayerNode, result) break case "resume_audio_share": HMSAudioFilePlayerNodeExtension.resume(audioNode as! HMSAudioFilePlayerNode, result) break case "set_audio_share_volume": if arguments["name"] as! String != "mic_node" { - HMSAudioFilePlayerNodeExtension.setVolume(arguments, audioNode as! HMSAudioFilePlayerNode,result) + HMSAudioFilePlayerNodeExtension.setVolume(arguments, audioNode as! HMSAudioFilePlayerNode, result) } else { HMSMicNodeExtension.setVolume(arguments, audioNode as! HMSMicNode) } @@ -498,26 +498,26 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) return } guard let arguments = call.arguments as? [AnyHashable: Any] else { HMSErrorLogger.returnArgumentsError("keys is null") - HMSErrorLogger.returnHMSException(#function,"No arguments passed which can be attached to Key Change Listener on the Session Store.","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "No arguments passed which can be attached to Key Change Listener on the Session Store.", "NULL ERROR", result) return } guard let keys = arguments["keys"] as? [String] else { - HMSErrorLogger.returnHMSException(#function,"No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)", "NULL ERROR", result) return } - + guard let uid = arguments["uid"] as? String else { - HMSErrorLogger.returnHMSException(#function,"No uid passed for key change listener Available arguments: \(arguments)","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "No uid passed for key change listener Available arguments: \(arguments)", "NULL ERROR", result) return } @@ -529,14 +529,13 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene var dict: [String: Any] = ["key": key] - if(value is String? || value is NSNull){ + if value is String? || value is NSNull { dict["value"] = value - } - else{ - HMSErrorLogger.logError(#function,"Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + } else { + HMSErrorLogger.logError(#function, "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") dict["value"] = nil } - + dict["uid"] = uid data["data"] = dict @@ -545,19 +544,19 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene }) { [weak self] observer, error in if let error = error { - HMSErrorLogger.returnHMSException(#function,"Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)","KEY CHANGE ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)", "KEY CHANGE ERROR", result) return } guard let observer = observer else { - HMSErrorLogger.returnHMSException(#function,"Unknown Error in observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Unknown Error in observing changes for key: \(keys) in the Session Store.", "KEY CHANGE ERROR", result) return } guard let self = self else { - HMSErrorLogger.returnHMSException(#function,"Could not find self instance while observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Could not find self instance while observing changes for key: \(keys) in the Session Store.", "KEY CHANGE ERROR", result) return } @@ -575,45 +574,44 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - HMSErrorLogger.returnHMSException(#function,"Session Store is null","NULL ERROR",result) + HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) return } guard let arguments = call.arguments as? [AnyHashable: Any] else { - HMSErrorLogger.returnHMSException(#function,"No arguments to identify which Key Change Listener should be removed from the Session Store.","Remove Key Error",result) + HMSErrorLogger.returnHMSException(#function, "No arguments to identify which Key Change Listener should be removed from the Session Store.", "Remove Key Error", result) return } guard let uid = arguments["uid"] as? String else { - HMSErrorLogger.returnHMSException(#function,"No identifier passed which can be used. Available arguments: \(arguments)","Unique Id Error",result) + HMSErrorLogger.returnHMSException(#function, "No identifier passed which can be used. Available arguments: \(arguments)", "Unique Id Error", result) return } guard let keyChangeListenersToBeRemovedIndex = sessionStoreChangeObservers.firstIndex(where: { $0.uid == uid }) - else{ - HMSErrorLogger.returnHMSException(#function,"No listener found to remove","Listener Error",result) + else { + HMSErrorLogger.returnHMSException(#function, "No listener found to remove", "Listener Error", result) return } - store.removeObserver(sessionStoreChangeObservers[keyChangeListenersToBeRemovedIndex].observer) sessionStoreChangeObservers.remove(at: keyChangeListenersToBeRemovedIndex) result(nil) } - + /** This takes care of removing all the key change listeners attached during the session This is used while cleaning the room state i.e after calling leave room, onRemovedFromRoom or endRoom */ - private func removeAllKeyChangeListener(){ - sessionStoreChangeObservers.forEach{ + private func removeAllKeyChangeListener() { + sessionStoreChangeObservers.forEach { hmsSessionStoreObserver in sessionStore?.removeObserver(hmsSessionStoreObserver.observer) } diff --git a/sample apps/bloc/pubspec.lock b/sample apps/bloc/pubspec.lock index 1ec2deedf..212a31894 100644 --- a/sample apps/bloc/pubspec.lock +++ b/sample apps/bloc/pubspec.lock @@ -5,63 +5,72 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.10.0" bloc: dependency: "direct main" description: name: bloc - url: "https://pub.dartlang.org" + sha256: "318e6cc6803d93b8d2de5f580e452ca565bcaa44f724d5156c71961426b88e03" + url: "https://pub.dev" source: hosted version: "8.0.3" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.dev" source: hosted version: "1.2.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" source: hosted version: "1.0.5" equatable: dependency: "direct main" description: name: equatable - url: "https://pub.dartlang.org" + sha256: c6094fd1efad3046334a9c40bee022147e55c25401ccd89b94e373e3edadd375 + url: "https://pub.dev" source: hosted version: "2.0.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" flutter: @@ -73,14 +82,16 @@ packages: dependency: "direct main" description: name: flutter_bloc - url: "https://pub.dartlang.org" + sha256: "7b84d9777db3e30a5051c6718331be57e4cfc0c2424be82ac1771392cad7dbe8" + url: "https://pub.dev" source: hosted version: "8.0.1" flutter_lints: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + url: "https://pub.dev" source: hosted version: "1.0.4" flutter_test: @@ -92,7 +103,8 @@ packages: dependency: "direct main" description: name: focus_detector - url: "https://pub.dartlang.org" + sha256: "05e32d9dd378cd54f1a3f9ce813c05156f28eb83f8e68f5bf1a37e9cdb21af1c" + url: "https://pub.dev" source: hosted version: "2.0.1" hmssdk_flutter: @@ -101,117 +113,141 @@ packages: path: "../.." relative: true source: path - version: "0.7.6" + version: "1.6.0" http: dependency: "direct main" description: name: http - url: "https://pub.dartlang.org" + sha256: "2ed163531e071c2c6b7c659635112f24cb64ecbebf6af46b550d536c0b1aa112" + url: "https://pub.dev" source: hosted version: "0.13.4" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: db3060f22889f3d9d55f6a217565486737037eec3609f7f3eca4d0c67ee0d8a0 + url: "https://pub.dev" source: hosted version: "4.0.1" + js: + dependency: transitive + description: + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.dev" + source: hosted + version: "0.6.5" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + url: "https://pub.dev" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.13" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" source: hosted version: "1.8.0" nested: dependency: transitive description: name: nested - url: "https://pub.dartlang.org" + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" source: hosted version: "1.0.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" source: hosted version: "1.8.2" permission_handler: dependency: "direct main" description: name: permission_handler - url: "https://pub.dartlang.org" + sha256: "5749ebeb7ec0c3865ea17e3eb337174b87747be816dab582c551e1aff6f6bbf3" + url: "https://pub.dev" source: hosted version: "9.2.0" permission_handler_android: dependency: transitive description: name: permission_handler_android - url: "https://pub.dartlang.org" + sha256: a512e0fa8abcb0659d938ec2df93a70eb1df1fdea5fdc6d79a866bfd858a28fc + url: "https://pub.dev" source: hosted version: "9.0.2+1" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - url: "https://pub.dartlang.org" + sha256: "6367799be76d1fe70ffe2df7f025abfe28818b450f550621778995badbebf519" + url: "https://pub.dev" source: hosted version: "9.0.4" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - url: "https://pub.dartlang.org" + sha256: ca16451bfdc6d26693d10b37b2d81370bdf3f0318422f3eecfd6004f5bd7d21f + url: "https://pub.dev" source: hosted version: "3.7.0" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - url: "https://pub.dartlang.org" + sha256: "40ad5ab4d3c65d75c7f3a069065c77503aae19a1cf01ba246d43489e14f1b90c" + url: "https://pub.dev" source: hosted version: "0.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "075f927ebbab4262ace8d0b283929ac5410c0ac4e7fc123c76429564facfb757" + url: "https://pub.dev" source: hosted version: "2.1.2" provider: dependency: transitive description: name: provider - url: "https://pub.dartlang.org" + sha256: "8d7d4c2df46d6a6270a4e10404bfecb18a937e3e00f710c260d0a10415ce6b7b" + url: "https://pub.dev" source: hosted version: "6.0.3" rxdart: dependency: "direct main" description: name: rxdart - url: "https://pub.dartlang.org" + sha256: "933db29250b286ecfe08a552f991f0e9f245f3f8ba1e5fb37f2f55d1f82888cb" + url: "https://pub.dev" source: hosted version: "0.27.4" sky_engine: @@ -223,65 +259,74 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.4.16" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" visibility_detector: dependency: transitive description: name: visibility_detector - url: "https://pub.dartlang.org" + sha256: ec932527913f32f65aa01d3a393504240b9e9021ecc77123f017755605e48832 + url: "https://pub.dev" source: hosted version: "0.2.2" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=2.18.0 <3.0.0" flutter: ">=2.8.0" diff --git a/sample apps/getx/pubspec.lock b/sample apps/getx/pubspec.lock index bc3973dc2..e6166d449 100644 --- a/sample apps/getx/pubspec.lock +++ b/sample apps/getx/pubspec.lock @@ -5,58 +5,66 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.10.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" source: hosted version: "1.3.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.17.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.5" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -66,7 +74,8 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + url: "https://pub.dev" source: hosted version: "1.0.4" flutter_test: @@ -78,112 +87,136 @@ packages: dependency: "direct main" description: name: focus_detector - url: "https://pub.dartlang.org" + sha256: "05e32d9dd378cd54f1a3f9ce813c05156f28eb83f8e68f5bf1a37e9cdb21af1c" + url: "https://pub.dev" source: hosted version: "2.0.1" get: dependency: "direct main" description: name: get - url: "https://pub.dartlang.org" + sha256: "2ba20a47c8f1f233bed775ba2dd0d3ac97b4cf32fc17731b3dfc672b06b0e92a" + url: "https://pub.dev" source: hosted - version: "4.6.1" + version: "4.6.5" hmssdk_flutter: dependency: "direct main" description: - path: "../.." - relative: true - source: path - version: "0.7.4" + name: hmssdk_flutter + sha256: "1323678b739bb0768adea396d618eed839c3c2c15eb135166988a06a92562baa" + url: "https://pub.dev" + source: hosted + version: "1.3.2" http: dependency: "direct main" description: name: http - url: "https://pub.dartlang.org" + sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + url: "https://pub.dev" source: hosted - version: "0.13.4" + version: "0.13.5" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" + js: + dependency: transitive + description: + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.dev" + source: hosted + version: "0.6.5" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + url: "https://pub.dev" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.13" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.2" permission_handler: dependency: "direct main" description: name: permission_handler - url: "https://pub.dartlang.org" + sha256: "33c6a1253d1f95fd06fa74b65b7ba907ae9811f9d5c1d3150e51417d04b8d6a8" + url: "https://pub.dev" source: hosted - version: "9.2.0" + version: "10.2.0" permission_handler_android: dependency: transitive description: name: permission_handler_android - url: "https://pub.dartlang.org" + sha256: "8028362b40c4a45298f1cbfccd227c8dd6caf0e27088a69f2ba2ab15464159e2" + url: "https://pub.dev" source: hosted - version: "9.0.2+1" + version: "10.2.0" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - url: "https://pub.dartlang.org" + sha256: ee96ac32f5a8e6f80756e25b25b9f8e535816c8e6665a96b6d70681f8c4f7e85 + url: "https://pub.dev" source: hosted - version: "9.0.4" + version: "9.0.8" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - url: "https://pub.dartlang.org" + sha256: "68abbc472002b5e6dfce47fe9898c6b7d8328d58b5d2524f75e277c07a97eb84" + url: "https://pub.dev" source: hosted - version: "3.7.0" + version: "3.9.0" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - url: "https://pub.dartlang.org" + sha256: f67cab14b4328574938ecea2db3475dad7af7ead6afab6338772c5f88963e38b + url: "https://pub.dev" source: hosted - version: "0.1.0" + version: "0.1.2" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "075f927ebbab4262ace8d0b283929ac5410c0ac4e7fc123c76429564facfb757" + url: "https://pub.dev" source: hosted version: "2.1.2" sky_engine: @@ -195,65 +228,74 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.dev" source: hosted - version: "0.4.8" + version: "0.4.16" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.4" visibility_detector: dependency: transitive description: name: visibility_detector - url: "https://pub.dartlang.org" + sha256: ec932527913f32f65aa01d3a393504240b9e9021ecc77123f017755605e48832 + url: "https://pub.dev" source: hosted version: "0.2.2" sdks: - dart: ">=2.16.1 <3.0.0" + dart: ">=2.18.0 <3.0.0" flutter: ">=2.8.0" diff --git a/sample apps/mobx/pubspec.lock b/sample apps/mobx/pubspec.lock index c39e1b1d7..93d0a01c7 100644 --- a/sample apps/mobx/pubspec.lock +++ b/sample apps/mobx/pubspec.lock @@ -5,175 +5,200 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: "3444216bfd127af50bbe4862d8843ed44db946dd933554f0d7285e89f10e28ac" + url: "https://pub.dev" source: hosted version: "50.0.0" analyzer: dependency: transitive description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "68796c31f510c8455a06fed75fc97d8e5ad04d324a830322ab3efc9feb6201c1" + url: "https://pub.dev" source: hosted version: "5.2.0" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: b003c3098049a51720352d219b0bb5f219b60fbfb68e7a4748139a06a5676515 + url: "https://pub.dev" source: hosted version: "2.3.1" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.10.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" build: dependency: transitive description: name: build - url: "https://pub.dartlang.org" + sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + url: "https://pub.dev" source: hosted version: "2.3.1" build_config: dependency: transitive description: name: build_config - url: "https://pub.dartlang.org" + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" source: hosted version: "1.1.1" build_daemon: dependency: transitive description: name: build_daemon - url: "https://pub.dartlang.org" + sha256: "6bc5544ea6ce4428266e7ea680e945c68806c4aae2da0eb5e9ccf38df8d6acbf" + url: "https://pub.dev" source: hosted version: "3.1.0" build_resolvers: dependency: transitive description: name: build_resolvers - url: "https://pub.dartlang.org" + sha256: "7c35a3a7868626257d8aee47b51c26b9dba11eaddf3431117ed2744951416aab" + url: "https://pub.dev" source: hosted version: "2.1.0" build_runner: dependency: "direct dev" description: name: build_runner - url: "https://pub.dartlang.org" + sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727 + url: "https://pub.dev" source: hosted version: "2.3.3" build_runner_core: dependency: transitive description: name: build_runner_core - url: "https://pub.dartlang.org" + sha256: "14febe0f5bac5ae474117a36099b4de6f1dbc52df6c5e55534b3da9591bf4292" + url: "https://pub.dev" source: hosted version: "7.2.7" built_collection: dependency: transitive description: name: built_collection - url: "https://pub.dartlang.org" + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" source: hosted version: "5.1.1" built_value: dependency: transitive description: name: built_value - url: "https://pub.dartlang.org" + sha256: "59e08b0079bb75f7e27392498e26339387c1089c6bd58525a14eb8508637277b" + url: "https://pub.dev" source: hosted version: "8.4.2" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.dev" source: hosted version: "1.2.1" checked_yaml: dependency: transitive description: name: checked_yaml - url: "https://pub.dartlang.org" + sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" + url: "https://pub.dev" source: hosted version: "2.0.2" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" code_builder: dependency: transitive description: name: code_builder - url: "https://pub.dartlang.org" + sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + url: "https://pub.dev" source: hosted version: "4.4.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted version: "3.1.1" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" source: hosted version: "3.0.2" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: caac504f942f41dfadcf45229ce8c47065b93919a12739f20d6173a883c5ec73 + url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.2" dart_style: dependency: transitive description: name: dart_style - url: "https://pub.dartlang.org" + sha256: "7a03456c3490394c8e7665890333e91ae8a49be43542b616e414449ac358acd4" + url: "https://pub.dev" source: hosted version: "2.2.4" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" source: hosted version: "6.1.4" fixnum: dependency: transitive description: name: fixnum - url: "https://pub.dartlang.org" + sha256: "04be3e934c52e082558cc9ee21f42f5c1cd7a1262f4c63cd0357c08d5bba81ec" + url: "https://pub.dev" source: hosted version: "1.0.1" flutter: @@ -185,14 +210,16 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + url: "https://pub.dev" source: hosted version: "1.0.4" flutter_mobx: dependency: "direct main" description: name: flutter_mobx - url: "https://pub.dartlang.org" + sha256: "0da4add0016387a7bf309a0d0c41d36c6b3ae25ed7a176409267f166509e723e" + url: "https://pub.dev" source: hosted version: "2.0.6+5" flutter_test: @@ -200,228 +227,268 @@ packages: description: flutter source: sdk version: "0.0.0" + focus_detector: + dependency: "direct main" + description: + name: focus_detector + sha256: "05e32d9dd378cd54f1a3f9ce813c05156f28eb83f8e68f5bf1a37e9cdb21af1c" + url: "https://pub.dev" + source: hosted + version: "2.0.1" frontend_server_client: dependency: transitive description: name: frontend_server_client - url: "https://pub.dartlang.org" + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" source: hosted version: "3.2.0" glob: dependency: transitive description: name: glob - url: "https://pub.dartlang.org" + sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + url: "https://pub.dev" source: hosted version: "2.1.1" graphs: dependency: transitive description: name: graphs - url: "https://pub.dartlang.org" + sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2 + url: "https://pub.dev" source: hosted version: "2.2.0" hmssdk_flutter: dependency: "direct main" description: - path: "../.." - relative: true - source: path - version: "1.2.0" + name: hmssdk_flutter + sha256: "1323678b739bb0768adea396d618eed839c3c2c15eb135166988a06a92562baa" + url: "https://pub.dev" + source: hosted + version: "1.3.2" http: dependency: "direct main" description: name: http - url: "https://pub.dartlang.org" + sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + url: "https://pub.dev" source: hosted version: "0.13.5" http_multi_server: dependency: transitive description: name: http_multi_server - url: "https://pub.dartlang.org" + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" source: hosted version: "3.2.1" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted version: "4.0.2" intl: dependency: "direct main" description: name: intl - url: "https://pub.dartlang.org" + sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 + url: "https://pub.dev" source: hosted version: "0.18.0" io: dependency: transitive description: name: io - url: "https://pub.dartlang.org" + sha256: "0d4c73c3653ab85bf696d51a9657604c900a370549196a91f33e4c39af760852" + url: "https://pub.dev" source: hosted version: "1.0.3" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.dev" source: hosted version: "0.6.5" json_annotation: dependency: transitive description: name: json_annotation - url: "https://pub.dartlang.org" + sha256: "3520fa844009431b5d4491a5a778603520cdc399ab3406332dcc50f93547258c" + url: "https://pub.dev" source: hosted version: "4.7.0" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + url: "https://pub.dev" source: hosted version: "1.0.1" logging: dependency: transitive description: name: logging - url: "https://pub.dartlang.org" + sha256: c0bbfe94d46aedf9b8b3e695cf3bd48c8e14b35e3b2c639e0aa7755d589ba946 + url: "https://pub.dev" source: hosted version: "1.1.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.13" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" source: hosted version: "1.8.0" mime: dependency: transitive description: name: mime - url: "https://pub.dartlang.org" + sha256: "52e38f7e1143ef39daf532117d6b8f8f617bf4bcd6044ed8c29040d20d269630" + url: "https://pub.dev" source: hosted version: "1.0.3" mobx: dependency: "direct main" description: name: mobx - url: "https://pub.dartlang.org" + sha256: "6738620307a424d2c9ad8b873f4dce391c44e9135eb4e75668ac8202fec7a9b8" + url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" mobx_codegen: dependency: "direct main" description: name: mobx_codegen - url: "https://pub.dartlang.org" + sha256: "86122e410d8ea24dda0c69adb5c2a6ccadd5ce02ad46e144764e0d0184a06181" + url: "https://pub.dev" source: hosted version: "2.1.1" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" source: hosted version: "2.1.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" source: hosted version: "1.8.2" permission_handler: dependency: "direct main" description: name: permission_handler - url: "https://pub.dartlang.org" + sha256: "33c6a1253d1f95fd06fa74b65b7ba907ae9811f9d5c1d3150e51417d04b8d6a8" + url: "https://pub.dev" source: hosted version: "10.2.0" permission_handler_android: dependency: transitive description: name: permission_handler_android - url: "https://pub.dartlang.org" + sha256: "8028362b40c4a45298f1cbfccd227c8dd6caf0e27088a69f2ba2ab15464159e2" + url: "https://pub.dev" source: hosted version: "10.2.0" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - url: "https://pub.dartlang.org" + sha256: "9c370ef6a18b1c4b2f7f35944d644a56aa23576f23abee654cf73968de93f163" + url: "https://pub.dev" source: hosted version: "9.0.7" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - url: "https://pub.dartlang.org" + sha256: "68abbc472002b5e6dfce47fe9898c6b7d8328d58b5d2524f75e277c07a97eb84" + url: "https://pub.dev" source: hosted version: "3.9.0" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - url: "https://pub.dartlang.org" + sha256: f67cab14b4328574938ecea2db3475dad7af7ead6afab6338772c5f88963e38b + url: "https://pub.dev" source: hosted version: "0.1.2" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + url: "https://pub.dev" source: hosted version: "2.1.3" pool: dependency: transitive description: name: pool - url: "https://pub.dartlang.org" + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" source: hosted version: "1.5.1" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + url: "https://pub.dev" source: hosted version: "2.1.3" pubspec_parse: dependency: transitive description: name: pubspec_parse - url: "https://pub.dartlang.org" + sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a" + url: "https://pub.dev" source: hosted version: "1.2.1" shelf: dependency: transitive description: name: shelf - url: "https://pub.dartlang.org" + sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + url: "https://pub.dev" source: hosted version: "1.4.0" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - url: "https://pub.dartlang.org" + sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + url: "https://pub.dev" source: hosted version: "1.0.3" sky_engine: @@ -433,98 +500,120 @@ packages: dependency: transitive description: name: source_gen - url: "https://pub.dartlang.org" + sha256: "2d79738b6bbf38a43920e2b8d189e9a3ce6cc201f4b8fc76be5e4fe377b1c38d" + url: "https://pub.dev" source: hosted version: "1.2.6" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.4.16" timing: dependency: transitive description: name: timing - url: "https://pub.dartlang.org" + sha256: c386d07d7f5efc613479a7c4d9d64b03710b03cfaa7e8ad5f2bfb295a1f0dfad + url: "https://pub.dev" source: hosted version: "1.0.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" source: hosted version: "1.3.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + visibility_detector: + dependency: transitive + description: + name: visibility_detector + sha256: ec932527913f32f65aa01d3a393504240b9e9021ecc77123f017755605e48832 + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "0.2.2" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" source: hosted version: "1.0.2" web_socket_channel: dependency: transitive description: name: web_socket_channel - url: "https://pub.dartlang.org" + sha256: "3a969ddcc204a3e34e863d204b29c0752716f78b6f9cc8235083208d268a4ccd" + url: "https://pub.dev" source: hosted version: "2.2.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" source: hosted version: "3.1.1" sdks: From 0c368ffebbc00d1abc24ecda3ec5b4cfde5d4bd2 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 14:21:04 +0530 Subject: [PATCH 67/88] corrected kotlin lint warnings --- .trunk/config/.yamllint.yaml | 10 ++ .trunk/trunk.yaml | 11 +- .../hmssdk_flutter/HMSKeyChangeObserver.kt | 2 +- .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 116 +++++++++--------- .../hmssdk_flutter/methods/HMSCommonAction.kt | 5 +- .../methods/HMSSessionMetadataAction.kt | 14 +-- .../methods/HMSSessionStoreAction.kt | 51 ++++---- 7 files changed, 109 insertions(+), 100 deletions(-) create mode 100644 .trunk/config/.yamllint.yaml diff --git a/.trunk/config/.yamllint.yaml b/.trunk/config/.yamllint.yaml new file mode 100644 index 000000000..4d444662d --- /dev/null +++ b/.trunk/config/.yamllint.yaml @@ -0,0 +1,10 @@ +rules: + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 1ef1d7713..a6da1b099 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -4,11 +4,13 @@ cli: plugins: sources: - id: trunk - ref: v0.0.14 + ref: v0.0.16 uri: https://github.com/trunk-io/plugins lint: enabled: - - markdownlint@0.33.0 + - oxipng@8.0.0 + - yamllint@1.31.0 + - markdownlint@0.34.0 - prettier@2.8.8 - git-diff-check - shfmt@3.5.0 @@ -18,9 +20,10 @@ lint: - ktlint@0.49.0 runtimes: enabled: - - go@1.18.3 + - python@3.10.8 + - go@1.19.5 - java@11.0.13 - - node@16.14.2 + - node@18.12.1 actions: enabled: - trunk-announce diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt index 3759e3d59..0f0b62e16 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSKeyChangeObserver.kt @@ -2,4 +2,4 @@ package live.hms.hmssdk_flutter import live.hms.video.sessionstore.HMSKeyChangeListener -class HMSKeyChangeObserver(val uid: String,val keyChangeListener: HMSKeyChangeListener) {} \ No newline at end of file +class HMSKeyChangeObserver(val uid: String, val keyChangeListener: HMSKeyChangeListener) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index a4034f7a5..277691bbe 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -55,7 +55,7 @@ class HmssdkFlutterPlugin : private var previewChannel: EventChannel? = null private var logsEventChannel: EventChannel? = null private var rtcStatsChannel: EventChannel? = null - private var sessionStoreChannel : EventChannel? = null + private var sessionStoreChannel: EventChannel? = null private var eventSink: EventChannel.EventSink? = null private var previewSink: EventChannel.EventSink? = null private var logsSink: EventChannel.EventSink? = null @@ -67,7 +67,7 @@ class HmssdkFlutterPlugin : private var requestChange: HMSRoleChangeRequest? = null var hmssdkFlutterPlugin: HmssdkFlutterPlugin? = null private var hmsSessionStore: HmsSessionStore? = null - private var hmsKeyChangeObserverList = ArrayList() + private var hmsKeyChangeObserverList = ArrayList() override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { if (hmssdkFlutterPlugin == null) { @@ -84,19 +84,19 @@ class HmssdkFlutterPlugin : EventChannel(flutterPluginBinding.binaryMessenger, "rtc_event_channel") this.sessionStoreChannel = - EventChannel(flutterPluginBinding.binaryMessenger,"session_event_channel") + EventChannel(flutterPluginBinding.binaryMessenger, "session_event_channel") this.meetingEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Meeting event channel not found") this.channel?.setMethodCallHandler(this) ?: Log.e("Channel Error", "Event channel not found") this.previewChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Preview channel not found") this.logsEventChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Logs event channel not found") this.rtcStatsChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "RTC Stats channel not found") - this.sessionStoreChannel?.setStreamHandler(this) ?: Log.e("Channel Error","Session Store channel not found") + this.sessionStoreChannel?.setStreamHandler(this) ?: Log.e("Channel Error", "Session Store channel not found") this.hmsVideoFactory = HMSVideoViewFactory(this) flutterPluginBinding.platformViewRegistry.registerViewFactory( "HMSVideoView", - hmsVideoFactory + hmsVideoFactory, ) hmssdkFlutterPlugin = this } else { @@ -203,10 +203,10 @@ class HmssdkFlutterPlugin : HMSCameraControlsAction.cameraControlsAction(call, result, hmssdk!!, activity.applicationContext) } "get_session_metadata_for_key", "set_session_metadata_for_key" -> { - HMSSessionStoreAction.sessionStoreActions(call,result,hmsSessionStore) + HMSSessionStoreAction.sessionStoreActions(call, result, hmsSessionStore) } - "add_key_change_listener"-> { - addKeyChangeListener(call,result) + "add_key_change_listener" -> { + addKeyChangeListener(call, result) } "remove_key_change_listener" -> { removeKeyChangeListener(call) @@ -384,7 +384,7 @@ class HmssdkFlutterPlugin : previewChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Preview channel not found") logsEventChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Logs event channel not found") rtcStatsChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "RTC Stats channel not found") - sessionStoreChannel?.setStreamHandler(null)?:Log.e("Channel Error","Session Store channel not found") + sessionStoreChannel?.setStreamHandler(null) ?: Log.e("Channel Error", "Session Store channel not found") eventSink = null previewSink = null rtcSink = null @@ -419,7 +419,7 @@ class HmssdkFlutterPlugin : } private fun getConfig( - call: MethodCall + call: MethodCall, ): HMSConfig { val userName = call.argument("user_name") val authToken = call.argument("auth_token") @@ -433,7 +433,7 @@ class HmssdkFlutterPlugin : authtoken = authToken!!, metadata = metaData, initEndpoint = endPoint.trim(), - captureNetworkQualityInPreview = captureNetworkQualityInPreview + captureNetworkQualityInPreview = captureNetworkQualityInPreview, ) } @@ -441,7 +441,7 @@ class HmssdkFlutterPlugin : userName = userName!!, authtoken = authToken!!, metadata = metaData, - captureNetworkQualityInPreview = captureNetworkQualityInPreview + captureNetworkQualityInPreview = captureNetworkQualityInPreview, ) } @@ -490,7 +490,7 @@ class HmssdkFlutterPlugin : this.logsSink = events } else if (nameOfEventSink == "rtc_stats") { this.rtcSink = events - } else if(nameOfEventSink == "session_store") { + } else if (nameOfEventSink == "session_store") { this.sessionStoreSink = events } } @@ -537,7 +537,7 @@ class HmssdkFlutterPlugin : code = 6004, description = "Room code is null", message = "Room code is null", - name = "Room code null error" + name = "Room code null error", ) val args = HMSExceptionExtension.toDictionary(hmsException) result.success(HMSResultExtension.toDictionary(false, args)) @@ -561,7 +561,7 @@ class HmssdkFlutterPlugin : peer, roleToChangeTo, forceChange ?: false, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -578,7 +578,7 @@ class HmssdkFlutterPlugin : peer, roleToChangeTo, forceChange ?: false, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -597,7 +597,7 @@ class HmssdkFlutterPlugin : if (requestChange != null) { hmssdk!!.acceptChangeRole( this.requestChange!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) requestChange = null } else { @@ -606,7 +606,7 @@ class HmssdkFlutterPlugin : code = 6004, description = "Role Change Request is Expired.", message = "Role Change Request is Expired.", - name = "Role Change Request Error" + name = "Role Change Request Error", ) val args = HMSExceptionExtension.toDictionary(hmsException) result.success(args) @@ -619,7 +619,7 @@ class HmssdkFlutterPlugin : HMSLogger.i( "onAudioLevelUpdateHMSLogger", - HMSLogger.level.toString() + HMSLogger.level.toString(), ) if (speakers.isNotEmpty()) { @@ -656,7 +656,7 @@ class HmssdkFlutterPlugin : hmssdk!!.changeTrackState( track, mute!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -670,7 +670,7 @@ class HmssdkFlutterPlugin : hmssdk!!.removePeerRequest( peer = peer, hmsActionResultListener = HMSCommonAction.getActionListener(result), - reason = reason + reason = reason, ) } @@ -686,7 +686,7 @@ class HmssdkFlutterPlugin : hmssdk!!.endRoom( lock = lock!!, reason = reason, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) disposePIP() removeAllKeyChangeListener() @@ -712,7 +712,7 @@ class HmssdkFlutterPlugin : type = HMSTrackExtension.getKindFromString(type), source = source, roles = hmsRoles, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -766,7 +766,7 @@ class HmssdkFlutterPlugin : hmssdk!!.changeMetadata( metadata!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -919,7 +919,6 @@ class HmssdkFlutterPlugin : eventSink?.success(args) } } - } private val hmsPreviewListener = object : HMSPreviewListener { @@ -997,7 +996,7 @@ class HmssdkFlutterPlugin : level: HMSLogger.LogLevel, tag: String, message: String, - isWebRtCLog: Boolean + isWebRtCLog: Boolean, ) { /*** * Here we filter the logs based on the level we have set @@ -1032,7 +1031,7 @@ class HmssdkFlutterPlugin : val name = call.argument("name") hmssdk!!.changeName( name = name!!, - hmsActionResultListener = HMSCommonAction.getActionListener(result) + hmsActionResultListener = HMSCommonAction.getActionListener(result), ) } @@ -1049,11 +1048,11 @@ class HmssdkFlutterPlugin : androidScreenshareResult = result activity.applicationContext?.registerReceiver(activityBroadcastReceiver, IntentFilter("ACTIVITY_RECEIVER")) val mediaProjectionManager: MediaProjectionManager = activity.getSystemService( - Context.MEDIA_PROJECTION_SERVICE + Context.MEDIA_PROJECTION_SERVICE, ) as MediaProjectionManager activity.startActivityForResult( mediaProjectionManager.createScreenCaptureIntent(), - Constants.SCREEN_SHARE_INTENT_REQUEST_CODE + Constants.SCREEN_SHARE_INTENT_REQUEST_CODE, ) } @@ -1089,7 +1088,7 @@ class HmssdkFlutterPlugin : } } }, - data + data, ) activity.applicationContext?.unregisterReceiver(activityBroadcastReceiver) } @@ -1105,11 +1104,11 @@ class HmssdkFlutterPlugin : mode = call.argument("audio_mixing_mode") activity.applicationContext?.registerReceiver(activityBroadcastReceiver, IntentFilter("ACTIVITY_RECEIVER")) val mediaProjectionManager: MediaProjectionManager? = activity.getSystemService( - Context.MEDIA_PROJECTION_SERVICE + Context.MEDIA_PROJECTION_SERVICE, ) as MediaProjectionManager activity.startActivityForResult( mediaProjectionManager?.createScreenCaptureIntent(), - Constants.AUDIO_SHARE_INTENT_REQUEST_CODE + Constants.AUDIO_SHARE_INTENT_REQUEST_CODE, ) } @@ -1131,7 +1130,7 @@ class HmssdkFlutterPlugin : } }, data, - audioMixingMode = AudioMixingMode.valueOf(mode!!) + audioMixingMode = AudioMixingMode.valueOf(mode!!), ) activity.applicationContext?.unregisterReceiver(activityBroadcastReceiver) } @@ -1225,13 +1224,12 @@ class HmssdkFlutterPlugin : * - keyChangeListener: Instance of HMSKeyChangeListener to listen to the metadata changes for corresponding keys * - hmsActionResultListener: Instance of HMSActionResultListener to notify success or failure of the method call */ - private fun addKeyChangeListener(call: MethodCall,result: Result){ - + private fun addKeyChangeListener(call: MethodCall, result: Result) { val keys = call.argument>("keys") ?: run { HMSErrorLogger.returnArgumentsError("keys parameter is null") } - val uid = call.argument("uid")?: run { + val uid = call.argument("uid") ?: run { HMSErrorLogger.returnArgumentsError("uid is null") } @@ -1240,13 +1238,12 @@ class HmssdkFlutterPlugin : override fun onKeyChanged(key: String, value: String?) { val args = HashMap() args["event_name"] = "on_key_changed" - val newData = HashMap() + val newData = HashMap() newData["key"] = key if (value is String?) { newData["value"] = value - } - else{ - HMSErrorLogger.logError("onKeyChanged","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + } else { + HMSErrorLogger.logError("onKeyChanged", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") newData["value"] = null } newData["uid"] = uid as String @@ -1256,9 +1253,10 @@ class HmssdkFlutterPlugin : } } } - hmsKeyChangeObserverList.add(HMSKeyChangeObserver(uid as String,keyChangeListener)) - keys.let { keys as List - hmsSessionStore?.addKeyChangeListener(keys,keyChangeListener,HMSCommonAction.getActionListener(result)) + hmsKeyChangeObserverList.add(HMSKeyChangeObserver(uid as String, keyChangeListener)) + keys.let { + keys as List + hmsSessionStore?.addKeyChangeListener(keys, keyChangeListener, HMSCommonAction.getActionListener(result)) } } } @@ -1267,16 +1265,15 @@ class HmssdkFlutterPlugin : * This method is used to remove the attached key change listeners * attached using [addKeyChangeListener] method */ - private fun removeKeyChangeListener(call: MethodCall){ - - val uid = call.argument("uid")?: run { + private fun removeKeyChangeListener(call: MethodCall) { + val uid = call.argument("uid") ?: run { HMSErrorLogger.returnArgumentsError("uid is null") } uid?.let { - hmsKeyChangeObserverList.forEach{ + hmsKeyChangeObserverList.forEach { hmsKeyChangeObserver -> - if(hmsKeyChangeObserver.uid == uid){ + if (hmsKeyChangeObserver.uid == uid) { hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) hmsKeyChangeObserverList.remove(hmsKeyChangeObserver) return @@ -1290,9 +1287,10 @@ class HmssdkFlutterPlugin : * This is used while cleaning the room state i.e after calling leave room, * onRemovedFromRoom or endRoom */ - private fun removeAllKeyChangeListener(){ - hmsKeyChangeObserverList.forEach{ - hmsKeyChangeObserver -> hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) + private fun removeAllKeyChangeListener() { + hmsKeyChangeObserverList.forEach { + hmsKeyChangeObserver -> + hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) } hmsKeyChangeObserverList.clear() } @@ -1302,7 +1300,7 @@ class HmssdkFlutterPlugin : override fun onRemoteVideoStats( videoStats: HMSRemoteVideoStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer? + hmsPeer: HMSPeer?, ) { if (hmsPeer == null) { Log.e("RemoteVideoStats err", "Peer is null") @@ -1319,7 +1317,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsRemoteVideoStats = videoStats, peer = hmsPeer, - track = hmsTrack + track = hmsTrack, ) if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { @@ -1331,7 +1329,7 @@ class HmssdkFlutterPlugin : override fun onRemoteAudioStats( audioStats: HMSRemoteAudioStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer? + hmsPeer: HMSPeer?, ) { if (hmsPeer == null) { Log.e("RemoteAudioStats err", "Peer is null") @@ -1348,7 +1346,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsRemoteAudioStats = audioStats, peer = hmsPeer, - track = hmsTrack + track = hmsTrack, ) if (args["data"] != null) { @@ -1361,7 +1359,7 @@ class HmssdkFlutterPlugin : override fun onLocalVideoStats( videoStats: List, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer? + hmsPeer: HMSPeer?, ) { if (hmsPeer == null) { Log.e("LocalVideoStats err", "Peer is null") @@ -1378,7 +1376,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsLocalVideoStats = videoStats, peer = hmsPeer, - track = hmsTrack + track = hmsTrack, ) if (args["data"] != null) { @@ -1391,7 +1389,7 @@ class HmssdkFlutterPlugin : override fun onLocalAudioStats( audioStats: HMSLocalAudioStats, hmsTrack: HMSTrack?, - hmsPeer: HMSPeer? + hmsPeer: HMSPeer?, ) { if (hmsPeer == null) { Log.e("LocalAudioStats err", "Peer is null") @@ -1408,7 +1406,7 @@ class HmssdkFlutterPlugin : args["data"] = HMSRtcStatsExtension.toDictionary( hmsLocalAudioStats = audioStats, peer = hmsPeer, - track = hmsTrack + track = hmsTrack, ) if (args["data"] != null) { diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSCommonAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSCommonAction.kt index e6806d8cb..729e158b0 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSCommonAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSCommonAction.kt @@ -1,8 +1,5 @@ package live.hms.hmssdk_flutter import io.flutter.plugin.common.MethodChannel.Result -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import live.hms.video.error.HMSException import live.hms.video.sdk.* import live.hms.video.sdk.models.* @@ -25,7 +22,7 @@ class HMSCommonAction { fun getActionListener(result: Result) = object : HMSActionResultListener { override fun onError(error: HMSException) { - result.success(HMSExceptionExtension.toDictionary(error)) + result.success(HMSExceptionExtension.toDictionary(error)) } override fun onSuccess() { diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt index 63f1500fb..6b9cc1f5e 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionMetadataAction.kt @@ -7,7 +7,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import live.hms.hmssdk_flutter.HMSCommonAction import live.hms.hmssdk_flutter.HMSErrorLogger -import live.hms.hmssdk_flutter.HMSExceptionExtension import live.hms.hmssdk_flutter.HMSSessionMetadataExtension import live.hms.video.error.HMSException import live.hms.video.sdk.HMSSDK @@ -38,7 +37,7 @@ class HMSSessionMetadataAction { hmssdk.setSessionMetaData(metadata, HMSCommonAction.getActionListener(result)) } - private fun getSessionMetadataResultListener(result: MethodChannel.Result) = object: + private fun getSessionMetadataResultListener(result: MethodChannel.Result) = object : HMSSessionMetadataListener { override fun onError(error: HMSException) { result.success(null) @@ -49,17 +48,16 @@ class HMSSessionMetadataAction { args["event_name"] = "session_metadata" if (sessionMetadata is String?) { args["data"] = HMSSessionMetadataExtension.toDictionary(sessionMetadata) - } - else { - HMSErrorLogger.logError("getSessionMetadata","Session metadata type is not compatible, Please use String? type while setting metadata","Type Incompatibility Error") + } else { + HMSErrorLogger.logError("getSessionMetadata", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error") args["data"] = null } - if (args["data"] != null) + if (args["data"] != null) { CoroutineScope(Dispatchers.Main).launch { result.success(args) } + } } } - } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt index 04d72340f..496366bae 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSSessionStoreAction.kt @@ -12,15 +12,15 @@ import live.hms.video.sessionstore.HmsSessionStore class HMSSessionStoreAction { - companion object{ + companion object { - fun sessionStoreActions(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?){ - when(call.method){ + fun sessionStoreActions(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { + when (call.method) { "get_session_metadata_for_key" -> { - getSessionMetadataForKey(call,result,hmsSessionStore) + getSessionMetadataForKey(call, result, hmsSessionStore) } "set_session_metadata_for_key" -> { - setSessionMetadataForKey(call,result,hmsSessionStore) + setSessionMetadataForKey(call, result, hmsSessionStore) } } } @@ -33,26 +33,29 @@ class HMSSessionStoreAction { * * This method returns [sessionMetadata] is the session metadata is available for corresponding key */ - private fun getSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ + private fun getSessionMetadataForKey(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { val key = call.argument("key") ?: run { HMSErrorLogger.returnArgumentsError("key is null") } - key?.let { key as String - hmsSessionStore?.get(key,object:HMSSessionMetadataListener{ - override fun onError(error: HMSException) { - result.success(HMSResultExtension.toDictionary(false, HMSExceptionExtension.toDictionary(error))) - } - - override fun onSuccess(sessionMetadata: Any?) { - if (sessionMetadata is String?) { - result.success(HMSResultExtension.toDictionary(true, sessionMetadata)) + key?.let { + key as String + hmsSessionStore?.get( + key, + object : HMSSessionMetadataListener { + override fun onError(error: HMSException) { + result.success(HMSResultExtension.toDictionary(false, HMSExceptionExtension.toDictionary(error))) } - else{ - HMSErrorLogger.returnHMSException("getSessionMetadataForKey","Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) + + override fun onSuccess(sessionMetadata: Any?) { + if (sessionMetadata is String?) { + result.success(HMSResultExtension.toDictionary(true, sessionMetadata)) + } else { + HMSErrorLogger.returnHMSException("getSessionMetadataForKey", "Session metadata type is not compatible, Please use String? type while setting metadata", "Type Incompatibility Error", result) + } } - } - }) + }, + ) } } @@ -65,17 +68,17 @@ class HMSSessionStoreAction { * This method sets the [data] provided during the method call * The completion of this method is marked by actionResultListener's [onSuccess] or [onError] callback */ - private fun setSessionMetadataForKey(call: MethodCall,result: Result,hmsSessionStore: HmsSessionStore?){ + private fun setSessionMetadataForKey(call: MethodCall, result: Result, hmsSessionStore: HmsSessionStore?) { val key = call.argument("key") ?: run { HMSErrorLogger.returnArgumentsError("key is null") } val data = call.argument("data") - key?.let { key as String - hmsSessionStore?.set(data,key,HMSCommonAction.getActionListener(result)) + key?.let { + key as String + hmsSessionStore?.set(data, key, HMSCommonAction.getActionListener(result)) } } - } -} \ No newline at end of file +} From b7adab9ffdaa2a76b95e278d1d762d773a39de36 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 14:22:52 +0530 Subject: [PATCH 68/88] updated documentation link in pubspec --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 77d5bf2b2..76beae5ba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.6.0 homepage: https://www.100ms.live/ repository: https://github.com/100mslive/100ms-flutter issue_tracker: https://github.com/100mslive/100ms-flutter/issues -documentation: https://www.100ms.live/docs/flutter/v2/get-started/quickstart +documentation: https://www.100ms.live/docs environment: sdk: ">=2.12.0 <3.0.0" From 9297a72194758fa9e7c4d93516c7552bf2d27d52 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 14:26:24 +0530 Subject: [PATCH 69/88] updated Example app Changelog --- example/ExampleAppChangelog.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/example/ExampleAppChangelog.txt b/example/ExampleAppChangelog.txt index c4ef28a3f..272157afc 100644 --- a/example/ExampleAppChangelog.txt +++ b/example/ExampleAppChangelog.txt @@ -6,6 +6,9 @@ https://github.com/100mslive/100ms-flutter/issues/1259 - Add support for setting a Tile in Spotlight Mode using Session Store https://github.com/100mslive/100ms-flutter/issues/1252 +- Add support for Music Mode on iOS +https://github.com/100mslive/100ms-flutter/issues/1275 + - Fixed Role change request popup taking time to dismiss https://github.com/100mslive/100ms-flutter/issues/1271 @@ -17,5 +20,5 @@ https://github.com/100mslive/100ms-flutter/pull/1280 Flutter SDK: 1.6.0 -Android SDK: 2.6.1 +Android SDK: 2.6.2 iOS SDK: 0.9.3 From f11b571c6cca4137fc6f64898f2dd6e9175d8984 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 14:26:37 +0530 Subject: [PATCH 70/88] updated Example app version --- example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index e7b30247b..ba4806bec 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ description: Demonstrates how to use the hmssdk_flutter plugin. # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. publish_to: "none" # Remove this line if you wish to publish to pub.dev -version: 1.0.7+7 +version: 1.6.0 environment: sdk: ">=2.12.0 <3.0.0" From 73d0a7d98ffd9df19c7ce15d6ce7ecefbcf72475 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 14:39:29 +0530 Subject: [PATCH 71/88] updated key change listener function --- .../main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index 277691bbe..21b222b21 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -1235,7 +1235,7 @@ class HmssdkFlutterPlugin : uid.let { val keyChangeListener = object : HMSKeyChangeListener { - override fun onKeyChanged(key: String, value: String?) { + override fun onKeyChanged(key: String, value: Any?) { val args = HashMap() args["event_name"] = "on_key_changed" val newData = HashMap() From 2f407198794bcb8b995ac0803de8c8be7ed9ba70 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 15:08:58 +0530 Subject: [PATCH 72/88] =?UTF-8?q?released=20sample=20app=20version=201.4.9?= =?UTF-8?q?9=20(234)=20=F0=9F=8D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 4 ++-- example/ios/Runner/Info.plist | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 3f3d6d39c..d2b697547 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 231 - versionName "1.4.96" + versionCode 234 + versionName "1.4.99" } signingConfigs { diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index e584de8ff..61640455f 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.97 + 1.4.99 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 232 + 234 ITSAppUsesNonExemptEncryption LSApplicationCategoryType From 79898ea90fcb89037bf1a3cc169cda86b5e76bd1 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Wed, 3 May 2023 18:59:51 +0530 Subject: [PATCH 73/88] Fixed spotlight and one-to-one bug (#1308) --- example/lib/meeting/meeting_page.dart | 9 ++++---- example/lib/meeting/meeting_store.dart | 30 ++++++++++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/example/lib/meeting/meeting_page.dart b/example/lib/meeting/meeting_page.dart index 6d8b52858..5aca1f838 100644 --- a/example/lib/meeting/meeting_page.dart +++ b/example/lib/meeting/meeting_page.dart @@ -379,9 +379,7 @@ class _MeetingPageState extends State { top: 55, left: 0, right: 0, - bottom: (widget.isStreamingLink && - (modeData.item2?.role.permissions.hlsStreaming == - true)) + bottom: (widget.isStreamingLink && (modeData.item2?.role.permissions.hlsStreaming == true)) ? 108 : 68, /*** @@ -392,7 +390,7 @@ class _MeetingPageState extends State { * - Remaining as the mode from bottom sheet is selected corresponding grid layout is rendered */ child: Container( - child: (((modeData.item1 == MeetingMode.OneToOne) || data.item3 == 2) && + child: (((modeData.item1 == MeetingMode.OneToOne) || ((data.item3 == 2) && context.read().peers.length == 2)) && (modeData.item2 != null)) ? OneToOneMode( @@ -411,7 +409,8 @@ class _MeetingPageState extends State { MeetingMode .ActiveSpeaker) ? basicGridView( - peerTracks: data.item1.sublist(0, min(data.item1.length, data.item4 + 4)), + peerTracks: + data.item1.sublist(0, min(data.item1.length, data.item4 + 4)), itemCount: min(data.item3, data.item4 + 4), screenShareCount: data.item4, context: context, diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index 3d2ff193d..a851195d2 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -586,6 +586,15 @@ class MeetingStore extends ChangeNotifier notificationText: "Tap to return to the app"); } + void getSpotlightPeer() async { + String? metadata = + await _hmsSessionStore?.getSessionMetadataForKey(key: "spotlight"); + if (metadata != null) { + setPeerToSpotlight(metadata); + spotlightMetadata = metadata; + } + } + @override void onRoomUpdate({required HMSRoom room, required HMSRoomUpdate update}) { log("onRoomUpdate-> room: ${room.toString()} update: ${update.name}"); @@ -699,7 +708,6 @@ class MeetingStore extends ChangeNotifier track: track as HMSVideoTrack)); if (spotlightMetadata == track.trackId) { setPeerToSpotlight(spotlightMetadata); - spotlightMetadata = null; } notifyListeners(); return; @@ -744,8 +752,9 @@ class MeetingStore extends ChangeNotifier //To handle the active speaker mode scenario if (meetingMode == MeetingMode.ActiveSpeaker) { //Picking up the first four peers from the peerTracks list - List activeSpeakerList = - peerTracks.sublist(screenShareCount, Math.min(peerTracks.length, 4)); + List activeSpeakerList = peerTracks.sublist( + screenShareCount + (spotLightPeer != null ? 1 : 0), + Math.min(peerTracks.length, 4)); /* Here we iterate through the updateSpeakers list * and do the following: @@ -763,8 +772,11 @@ class MeetingStore extends ChangeNotifier if (peerIndex != -1) { PeerTrackNode activeSpeaker = peerTracks[peerIndex]; peerTracks.removeAt(peerIndex); - peerTracks.insert(screenShareCount, activeSpeaker); - peerTracks[screenShareCount].setOffScreenStatus(false); + peerTracks.insert( + screenShareCount + (spotLightPeer != null ? 1 : 0), + activeSpeaker); + peerTracks[screenShareCount + (spotLightPeer != null ? 1 : 0)] + .setOffScreenStatus(false); } } }); @@ -1126,6 +1138,7 @@ class MeetingStore extends ChangeNotifier case HMSPeerUpdate.roleUpdated: if (peer.isLocal) { + getSpotlightPeer(); localPeer = peer; if (hlsVideoController != null && !peer.role.name.contains("hls-")) { hlsVideoController?.dispose(forceDispose: true); @@ -1324,6 +1337,7 @@ class MeetingStore extends ChangeNotifier _hmsSessionStore?.addKeyChangeListener( keys: SessionStoreKeyValues.getSessionStoreKeys(), hmsKeyChangeListener: this); + getSpotlightPeer(); } ///We get this call everytime metadata corresponding to a key is changed @@ -1355,6 +1369,7 @@ class MeetingStore extends ChangeNotifier if (currentSpotlightPeerIndex != -1) { peerTracks[currentSpotlightPeerIndex].pinTile = false; spotLightPeer = null; + spotlightMetadata = null; } if (value != null) { int index = @@ -1363,9 +1378,10 @@ class MeetingStore extends ChangeNotifier Utilities.showToast("${peerTracks[index].peer.name} is in spotlight"); spotLightPeer = peerTracks[index]; changePinTileStatus(peerTracks[index]); - } else { - spotlightMetadata = value; } + } else { + spotlightMetadata = null; + spotLightPeer = null; } notifyListeners(); } From c198344e9f9f57e28cebcc0ae139e951de35f989 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Wed, 3 May 2023 19:37:51 +0530 Subject: [PATCH 74/88] updated Github issue Templates --- .github/ISSUE_TEMPLATE/1-bug_report.yml | 3 ++- .github/ISSUE_TEMPLATE/2-question-support.md | 12 ++++----- .github/ISSUE_TEMPLATE/3-feature-request.md | 27 +++++++++----------- .github/ISSUE_TEMPLATE/4-docs-bug.md | 21 +++++++-------- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/1-bug_report.yml b/.github/ISSUE_TEMPLATE/1-bug_report.yml index a82efb567..3b1f7755b 100644 --- a/.github/ISSUE_TEMPLATE/1-bug_report.yml +++ b/.github/ISSUE_TEMPLATE/1-bug_report.yml @@ -1,5 +1,6 @@ name: 🐛 Bug Report description: Report a reproducible bug or regression in 100ms Flutter Package +title: "🐛 " labels: ["Needs Triage 🔍"] body: - type: markdown @@ -68,7 +69,7 @@ body: ```dart ``` validations: - required: true + required: true - type: textarea attributes: label: Logs diff --git a/.github/ISSUE_TEMPLATE/2-question-support.md b/.github/ISSUE_TEMPLATE/2-question-support.md index e76649555..e2fe1d973 100644 --- a/.github/ISSUE_TEMPLATE/2-question-support.md +++ b/.github/ISSUE_TEMPLATE/2-question-support.md @@ -1,27 +1,27 @@ --- name: "❓ Question or Support Request" about: "Questions and requests for support." -title: "" +title: "❓ " labels: ["question"] -assignees: '' - +assignees: "" --- # ❓ Question or Support Request + - ## Describe your question or ask for support + -* +- ## Is your feature request related to a problem? Please describe - -* + ---- +- *** ## **Describe the solution you'd like** - -* + ---- +- *** ## **Describe alternatives you've considered** - -* + ---- +- *** ### Any Media to attach? + --- - ### **Additional context** - -* + +- ## Test Scenarios diff --git a/.github/ISSUE_TEMPLATE/4-docs-bug.md b/.github/ISSUE_TEMPLATE/4-docs-bug.md index 4ac39fca9..bd707e3c7 100644 --- a/.github/ISSUE_TEMPLATE/4-docs-bug.md +++ b/.github/ISSUE_TEMPLATE/4-docs-bug.md @@ -1,21 +1,21 @@ --- name: "📚 Documentation issue report" about: "Report an issue in the documentation." -title: "" +title: "📚 " labels: ["Needs Triage 🔍"] -assignees: '' - +assignees: "" --- + # 📚 Documentation Issue Report + ## **Describe the bug** - -* + ---- +- *** ### Steps to Reproduce @@ -36,21 +36,22 @@ assignees: '' --- ### Any Media to attach? + --- ## **Describe the solution you'd like** + -* - ---- +- *** ### **Additional context** + -* +- From 7eb2bc3e2e67bab0c685d4c40c2b76ea839a34ae Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Thu, 4 May 2023 15:54:36 +0530 Subject: [PATCH 77/88] Fixed spotlight mode (#1312) * Fixed spotlight mode * Added suggested changes --- .../lib/common/peer_widgets/more_option.dart | 16 +++++--- example/lib/meeting/meeting_store.dart | 37 +++++++++++++------ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/example/lib/common/peer_widgets/more_option.dart b/example/lib/common/peer_widgets/more_option.dart index d410c0164..bb1944fc5 100644 --- a/example/lib/common/peer_widgets/more_option.dart +++ b/example/lib/common/peer_widgets/more_option.dart @@ -71,9 +71,11 @@ class MoreOption extends StatelessWidget { metadata: null); return; } - String? metadata = (peerTrackNode.track == null) - ? peerTrackNode.audioTrack?.trackId - : peerTrackNode.track?.trackId; + ///Setting the metadata as audio trackId if it's not present + ///then setting it as video trackId + String? metadata = (peerTrackNode.audioTrack == null) + ? peerTrackNode.track?.trackId + : peerTrackNode.audioTrack?.trackId; _meetingStore.setSessionMetadata( key: SessionStoreKeyValues.getNameFromMethod( SessionStoreKey.SPOTLIGHT), @@ -278,9 +280,11 @@ class MoreOption extends StatelessWidget { metadata: null); return; } - String? metadata = (peerTrackNode.track == null) - ? peerTrackNode.audioTrack?.trackId - : peerTrackNode.track?.trackId; + ///Setting the metadata as audio trackId if it's not present + ///then setting it as video trackId + String? metadata = (peerTrackNode.audioTrack == null) + ? peerTrackNode.track?.trackId + : peerTrackNode.audioTrack?.trackId; _meetingStore.setSessionMetadata( key: SessionStoreKeyValues.getNameFromMethod( SessionStoreKey.SPOTLIGHT), diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index a851195d2..0134ba978 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -686,6 +686,7 @@ class MeetingStore extends ChangeNotifier audioTrack: track as HMSAudioTrack)); notifyListeners(); } + setSpotlightOnTrackUpdate(track); return; } @@ -706,12 +707,12 @@ class MeetingStore extends ChangeNotifier uid: peer.peerId + "mainVideo", stats: RTCStats(), track: track as HMSVideoTrack)); - if (spotlightMetadata == track.trackId) { - setPeerToSpotlight(spotlightMetadata); - } notifyListeners(); + setSpotlightOnTrackUpdate(track); return; } + + setSpotlightOnTrackUpdate(track); } peerOperationWithTrack(peer, trackUpdate, track); } @@ -770,13 +771,15 @@ class MeetingStore extends ChangeNotifier int peerIndex = peerTracks.indexWhere( (node) => node.uid == speaker.peer.peerId + "mainVideo"); if (peerIndex != -1) { - PeerTrackNode activeSpeaker = peerTracks[peerIndex]; - peerTracks.removeAt(peerIndex); - peerTracks.insert( - screenShareCount + (spotLightPeer != null ? 1 : 0), - activeSpeaker); - peerTracks[screenShareCount + (spotLightPeer != null ? 1 : 0)] - .setOffScreenStatus(false); + if (peerTracks[peerIndex].uid != spotLightPeer?.uid) { + PeerTrackNode activeSpeaker = peerTracks[peerIndex]; + peerTracks.removeAt(peerIndex); + peerTracks.insert( + screenShareCount + (spotLightPeer != null ? 1 : 0), + activeSpeaker); + peerTracks[screenShareCount + (spotLightPeer != null ? 1 : 0)] + .setOffScreenStatus(false); + } } } }); @@ -1372,8 +1375,9 @@ class MeetingStore extends ChangeNotifier spotlightMetadata = null; } if (value != null) { - int index = - peerTracks.indexWhere((node) => node.track?.trackId == (value)); + int index = peerTracks.indexWhere(((node) => + node.audioTrack?.trackId == (value) || + node.track?.trackId == (value))); if (index != -1) { Utilities.showToast("${peerTracks[index].peer.name} is in spotlight"); spotLightPeer = peerTracks[index]; @@ -1488,6 +1492,15 @@ class MeetingStore extends ChangeNotifier return false; } + void setSpotlightOnTrackUpdate(HMSTrack track) { + ///In order to avoid errors because of + ///track updates ordering for audio and video + ///adding the method call here. + if (spotlightMetadata == track.trackId) { + setPeerToSpotlight(spotlightMetadata); + } + } + HMSAudioFilePlayerNode audioFilePlayerNode = HMSAudioFilePlayerNode("audioFilePlayerNode"); HMSMicNode micNode = HMSMicNode(); From fff9a1461fc051ec78c9fc8f7ef48d84bd861e84 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Thu, 4 May 2023 16:21:36 +0530 Subject: [PATCH 78/88] Added checks while disposing PIP (#1313) * Added checks while disposing PIP * Update android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt Co-authored-by: ygit --------- Co-authored-by: ygit --- .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 12 +++--------- .../hms/hmssdk_flutter/methods/HMSPipAction.kt | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index 21b222b21..96e42f9db 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -471,7 +471,7 @@ class HmssdkFlutterPlugin : private fun leave(result: Result) { hmssdk!!.leave(hmsActionResultListener = HMSCommonAction.getActionListener(result)) - disposePIP() + HMSPipAction.disposePIP(activity) removeAllKeyChangeListener() } @@ -688,7 +688,7 @@ class HmssdkFlutterPlugin : reason = reason, hmsActionResultListener = HMSCommonAction.getActionListener(result), ) - disposePIP() + HMSPipAction.disposePIP(activity) removeAllKeyChangeListener() } @@ -872,7 +872,7 @@ class HmssdkFlutterPlugin : args.put("data", HMSRemovedFromRoomExtension.toDictionary(notification)) if (HMSPipAction.isPIPActive(activity)) { activity.moveTaskToBack(true) - disposePIP() + HMSPipAction.disposePIP(activity) removeAllKeyChangeListener() } if (args["data"] != null) { @@ -1209,12 +1209,6 @@ class HmssdkFlutterPlugin : result.success(map) } - private fun disposePIP() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - activity.setPictureInPictureParams(PictureInPictureParams.Builder().setAutoEnterEnabled(false).build()) - } - } - /** * This method is used to add key change listener for * keys passed while calling this method diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt index 1fa3ff890..72fab0c3a 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt @@ -15,6 +15,7 @@ class HMSPipAction { var pipResult: Result? = null private var pipAutoEnterEnabled = false private var pipAspectRatio = mutableListOf(16, 9) + private var isPIPEnabled = false fun pipActions(call: MethodCall, result: Result, activity: Activity) { when (call.method) { "enter_pip_mode" -> { @@ -45,6 +46,7 @@ class HMSPipAction { } private fun setupPIP(call: MethodCall, result: Result) { + isPIPEnabled = true call.argument?>("ratio")?.let { pipAspectRatio = it.toMutableList() } @@ -72,6 +74,7 @@ class HMSPipAction { @RequiresApi(Build.VERSION_CODES.O) private fun enterPipMode(call: MethodCall, result: Result, activity: Activity) { + isPIPEnabled = true call.argument>("aspect_ratio")?.let { pipAspectRatio = it.toMutableList() } @@ -90,7 +93,7 @@ class HMSPipAction { @RequiresApi(Build.VERSION_CODES.O) fun autoEnterPipMode(activity: Activity) { - if (pipAutoEnterEnabled) { + if (pipAutoEnterEnabled && isPIPEnabled) { var params = PictureInPictureParams.Builder().setAspectRatio(Rational(pipAspectRatio[0], pipAspectRatio[1])) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { @@ -99,5 +102,16 @@ class HMSPipAction { activity.enterPictureInPictureMode(params.build()) } } + + /** + * This method only needs to be called when application is using PIP mode + * [isPIPEnabled] variable keeps a track whether PIP was enabled in application or not + */ + fun disposePIP(activity: Activity) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && isPIPEnabled) { + activity.setPictureInPictureParams(PictureInPictureParams.Builder().setAutoEnterEnabled(false).build()) +isPIPEnabled = false + } + } } } From 307cf256638708513c6c48a21080caa748cca2fe Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 4 May 2023 16:24:58 +0530 Subject: [PATCH 79/88] corrected lint warnings --- .trunk/trunk.yaml | 2 +- .../kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 1 - .../kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index a6da1b099..b3af55343 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,6 +1,6 @@ version: 0.1 cli: - version: 1.8.1 + version: 1.9.1 plugins: sources: - id: trunk diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index 96e42f9db..40e2d9f29 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -1,7 +1,6 @@ package live.hms.hmssdk_flutter import android.app.Activity -import android.app.PictureInPictureParams import android.content.BroadcastReceiver import android.content.Context import android.content.Intent diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt index 72fab0c3a..de7af687e 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/methods/HMSPipAction.kt @@ -30,7 +30,7 @@ class HMSPipAction { } "is_pip_available" -> { result.success( - activity.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) + activity.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE), ) } "setup_pip" -> { @@ -110,7 +110,7 @@ class HMSPipAction { fun disposePIP(activity: Activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && isPIPEnabled) { activity.setPictureInPictureParams(PictureInPictureParams.Builder().setAutoEnterEnabled(false).build()) -isPIPEnabled = false + isPIPEnabled = false } } } From 718c89034595fcf2c309444c7ec9ea6eae2c07bf Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 4 May 2023 16:49:15 +0530 Subject: [PATCH 80/88] =?UTF-8?q?released=20sample=20app=20version=201.4.1?= =?UTF-8?q?01=20(236)=20=F0=9F=8D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 4 ++-- example/ios/Runner/Info.plist | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index dcc2b8dab..4ba072bd6 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 235 - versionName "1.4.100" + versionCode 236 + versionName "1.4.101" } signingConfigs { diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index a5d59f043..4f2965650 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.100 + 1.4.101 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 235 + 236 ITSAppUsesNonExemptEncryption LSApplicationCategoryType From b4cb849590e7fb6cd75d1d3b99eecb22c921b604 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Thu, 4 May 2023 20:55:31 +0530 Subject: [PATCH 81/88] Added fix for removeKeyChangeListener method (#1317) --- .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 13 +++++++++++-- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 14 ++++++++++---- lib/src/model/hms_session_store.dart | 6 +++--- lib/src/service/platform_service.dart | 17 ++++++++++++++--- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index 40e2d9f29..36c8361ef 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -208,7 +208,7 @@ class HmssdkFlutterPlugin : addKeyChangeListener(call, result) } "remove_key_change_listener" -> { - removeKeyChangeListener(call) + removeKeyChangeListener(call,result) } else -> { result.notImplemented() @@ -1258,10 +1258,16 @@ class HmssdkFlutterPlugin : * This method is used to remove the attached key change listeners * attached using [addKeyChangeListener] method */ - private fun removeKeyChangeListener(call: MethodCall) { + private fun removeKeyChangeListener(call: MethodCall,result: Result) { val uid = call.argument("uid") ?: run { HMSErrorLogger.returnArgumentsError("uid is null") } + //There is no need to call removeKeyChangeListener is + //there is no keyChangeListener attached + if(hmsKeyChangeObserverList.isEmpty()){ + result.success(HMSResultExtension.toDictionary(true,null)) + return + } uid?.let { hmsKeyChangeObserverList.forEach { @@ -1269,9 +1275,12 @@ class HmssdkFlutterPlugin : if (hmsKeyChangeObserver.uid == uid) { hmsSessionStore?.removeKeyChangeListener(hmsKeyChangeObserver.keyChangeListener) hmsKeyChangeObserverList.remove(hmsKeyChangeObserver) + result.success(HMSResultExtension.toDictionary(true,null)) return } } + }?: run { + result.success(HMSResultExtension.toDictionary(false,"keyChangeListener uid is null")) } } diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index d68844698..8795bcdd9 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -572,6 +572,13 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene */ private func removeKeyChangeListener(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { +// There is no need to call removeKeyChangeListener is +// there is no keyChangeListener attached + if(sessionStoreChangeObservers.isEmpty){ + result(HMSResultExtension.toDictionary(true,nil)) + return + } + guard let store = sessionStore else { HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) @@ -602,7 +609,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene sessionStoreChangeObservers.remove(at: keyChangeListenersToBeRemovedIndex) - result(nil) + result(HMSResultExtension.toDictionary(true,nil)) } /** @@ -611,9 +618,8 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene onRemovedFromRoom or endRoom */ private func removeAllKeyChangeListener() { - sessionStoreChangeObservers.forEach { - hmsSessionStoreObserver in - sessionStore?.removeObserver(hmsSessionStoreObserver.observer) + sessionStoreChangeObservers.forEach {[weak self] observer in + self?.sessionStore?.removeObserver(observer.observer) } sessionStoreCleanup() } diff --git a/lib/src/model/hms_session_store.dart b/lib/src/model/hms_session_store.dart index 240d568d5..84bac1fd4 100644 --- a/lib/src/model/hms_session_store.dart +++ b/lib/src/model/hms_session_store.dart @@ -38,9 +38,9 @@ class HMSSessionStore { /// /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] which was attaced earlier in [addKeyChangeListener] /// - void removeKeyChangeListener( - {required HMSKeyChangeListener hmsKeyChangeListener}) { - PlatformService.removeKeyChangeObserver(hmsKeyChangeListener); + Future removeKeyChangeListener( + {required HMSKeyChangeListener hmsKeyChangeListener}) async{ + return PlatformService.removeKeyChangeObserver(hmsKeyChangeListener); } ///[getSessionMetadataForKey] method is used to get metadata corresponding to the given key. diff --git a/lib/src/service/platform_service.dart b/lib/src/service/platform_service.dart index c2720115c..f7f292235 100644 --- a/lib/src/service/platform_service.dart +++ b/lib/src/service/platform_service.dart @@ -104,15 +104,26 @@ class PlatformService { keyChangeObservers.add(hmsKeyChangeObserver); } - static void removeKeyChangeObserver( + static Future removeKeyChangeObserver( HMSKeyChangeListener hmsKeyChangeListener) async { int index = keyChangeObservers.indexWhere((observer) => observer.hmsKeyChangeListener.hashCode == hmsKeyChangeListener.hashCode); if (index != -1) { - invokeMethod(PlatformMethod.removeKeyChangeListener, + var result = await invokeMethod(PlatformMethod.removeKeyChangeListener, arguments: {"uid": keyChangeObservers[index].uid}); - keyChangeObservers.removeAt(index); + if (result["success"]) { + keyChangeObservers.removeAt(index); + return null; + } else { + return HMSException.fromMap(result["data"]["error"]); + } + } else { + return HMSException( + message: "hmsKeyChangeListener not found", + description: "No listener found to remove", + action: "Listener Error", + isTerminal: true); } } From 5189796485fb405b09e08ffbe0e6cc648f8b6cab Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 4 May 2023 21:32:12 +0530 Subject: [PATCH 82/88] updated Changelog --- CHANGELOG.md | 95 +++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cf95207..add8233ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +## 1.6.0 - 2023-05-04 + +### New Features + +- Session Store + You can now use Session Store, a shared real-time key-value store accessible by everyone in the Room. This can be used to implement new features such as Pinned Messages and Spotlight Video Tiles, which brings a particular peer to the center stage for everyone in the Room. + + Learn more about Session Store in the [documentation](https://www.100ms.live/docs/flutter/v2/how-to-guides/interact-with-room/room/session-store). + +- Music Mode on iOS + The latest update adds the ability to achieve high-quality audio recordings with full, rich sound, whether you are recording music, podcasts, or any other type of audio. + + Learn more about the [Music Mode here](https://www.100ms.live/docs/flutter/v2/how-to-guides/configure-your-device/microphone/music-mode). + +### Changes + +- Android version 12+: We've made changes to Android 12+ so that adding PIP declaration in the Manifest file is now optional, except for those using the PIP Feature. + + Check out more in the [Picture-in-Picture (PIP) documentation](https://www.100ms.live/docs/flutter/v2/how-to-guides/set-up-video-conferencing/render-video/pip-mode). + +- This version includes a significant improvement in the usability of Local Audio Share APIs. By optimizing the ergonomics, we have made it more intuitive and user-friendly for you to interact with these APIs. + + Read more about [Local Audio Share here](https://www.100ms.live/docs/flutter/v2/how-to-guides/set-up-video-conferencing/local-audio-share). + +Updated to Android SDK 2.6.2 & iOS SDK 0.9.3 + +**Full Changelog**: [1.5.0...1.6.0](https://github.com/100mslive/100ms-flutter/compare/1.5.0...1.6.0) + ## 1.5.0 - 2023-04-21 ### Breaking @@ -7,6 +35,7 @@ The latest update includes changes in the implementation of Screen share and Audio share on Android. If you are using Screenshare or Local Audio Share functionalities, upgrading to this version or above will require changes to be made to the `onActivityResult` method of `MainActivity.kt`. More details are available in the Migration Guide listed below: + - [Screen Share Migration Guide](https://www.100ms.live/docs/flutter/v2/how--to-guides/set-up-video-conferencing/screen-share#migrating-from-older-hmssdk-version-to-150-or-above) - [Audio Share Migration Guide](https://www.100ms.live/docs/flutter/v2/how--to-guides/set-up-video-conferencing/local-audio-share#migrating-from-older-hmssdk-version-to-150-or-above) @@ -25,14 +54,12 @@ Read more about adding [PIP Mode here](https://www.100ms.live/docs/flutter/v2/how--to-guides/set-up-video-conferencing/render-video/pip-mode). - ### Changed - Improved logging capabilities in SDK for a more efficient and streamlined logging process. Read more about using [Logging here](https://www.100ms.live/docs/flutter/v2/how--to-guides/debugging/error-logging). - Updated to Android SDK 2.6.1 & iOS SDK 0.9.2 Full Changelog: [1.4.0...1.5.0](https://github.com/100mslive/100ms-flutter/compare/1.4.0...1.5.0) @@ -42,22 +69,21 @@ Full Changelog: [1.4.0...1.5.0](https://github.com/100mslive/100ms-flutter/compa ### Added - Join using Room Codes + - Room Codes is a streamlined and secure way to manage user authentication in Rooms. - By generating short codes via `getAuthTokenByRoomCode` API, you can easily manage user access with one code per role for each room, without the need for server infrastructure - This feature ensures a smoother login experience for users while enhancing security. - + You can read more about Room Codes [here](https://www.100ms.live/docs/concepts/v2/concepts/rooms/room-codes/room-codes). ### Changed - Improved Logging capabilities to help you diagnose and debug performance and user-reported issues more effectively - Updated to Android SDK 2.6.0 & iOS SDK 0.9.1 Full Changelog: [1.3.3...1.4.0](https://github.com/100mslive/100ms-flutter/compare/1.3.3...1.4.0) - ## 1.3.3 - 2023-03-22 ### Fixed @@ -68,27 +94,24 @@ Full Changelog: [1.3.3...1.4.0](https://github.com/100mslive/100ms-flutter/compa - Updated the 100ms Quickstart, GetX, MobX & Riverpod based [Sample apps](https://github.com/100mslive/100ms-flutter/tree/main/sample%20apps) - Updated to Android SDK 2.5.9 & iOS SDK 0.7.1 Full Changelog: [1.3.2...1.3.3](https://github.com/100mslive/100ms-flutter/compare/1.3.2...1.3.3) - ## 1.3.2 - 2023-03-09 ### Fixed - Corrected an issue with `DateTime` parsing where joining failed on iOS devices behind UTC Timezone - Updated to Android SDK 2.5.7 & iOS SDK 0.6.4 Full Changelog: [1.3.1...1.3.2](https://github.com/100mslive/100ms-flutter/compare/1.3.1...1.3.2) - ## 1.3.1 - 2023-02-27 ### Changed + - Performance improvements for PIP Mode on iOS - Improved Disconnected State detection on certain Networks - Gracefully handling of null objects @@ -111,17 +134,14 @@ Full Changelog: [1.3.0...1.3.1](https://github.com/100mslive/100ms-flutter/compa To learn more about PIP & how to implement it in your apps, refer the PIP Guide [here](https://www.100ms.live/docs/flutter/v2/how--to-guides/set-up-video-conferencing/render-video/pip-mode#ios). - - Added `HMSPIPAndroidController` to easily configure & use PIP Mode on Android PIP Mode support was available on Android since version 1.0.0. With this release we have made it more easy & simple to setup PIP on Android devices. Use the new `HMSPIPAndroidController` class to configure & start playing your Live Videos when your app is in Background. Refer the PIP Guide [here](https://www.100ms.live/docs/flutter/v2/how--to-guides/set-up-video-conferencing/render-video/pip-mode#android). - - Added Capture Snapshot API to capture a frame of the video track being rendered With the new `captureSnapshot()` method on `HMSVideoTrack` you can instantly capture a frame of any Video being rendered on screen. You can use this to capture moments of a Peer's Video, or a Screenshare happening in Room, etc. To learn more about how to use Capture Snapshot refer the Guide [here](https://www.100ms.live/docs/flutter/v2/how--to-guides/set-up-video-conferencing/render-video/capture-snapshot). - ### Deprecated - Deprecated direct passing of AppGroup & PreferredExtension while building HMSSDK for iOS Screenshare. Use the new `HMSIOSScreenshareConfig` class for starting Screenshare from iOS Devices. For more details, refer the Screnshare Guide [here](https://www.100ms.live/docs/flutter/v2/how--to-guides/set-up-video-conferencing/screen-share). @@ -133,12 +153,10 @@ Full Changelog: [1.3.0...1.3.1](https://github.com/100mslive/100ms-flutter/compa - Corrected an issue where doing multiple Role Changes stopped working - Corrected an issue where video views were getting recreated - Updated to Android SDK 2.5.7 & iOS SDK 0.6.2 Full Changelog: [1.2.0...1.3.0](https://github.com/100mslive/100ms-flutter/compare/1.2.0...1.3.0) - ## 1.2.0 - 2023-01-13 ### Breaking @@ -166,22 +184,18 @@ Full Changelog: [1.2.0...1.3.0](https://github.com/100mslive/100ms-flutter/compa To learn more about how ABR works & how it enhances your app, refer the guide [here](https://www.100ms.live/docs/flutter/v2/foundation/adaptive-bitrate). - - Using HMSVideoView on Android HMSVideoView on Android provides a better abstraction to render live video and handles edge cases like managing Release/Init states. It has in-built support to subscribe to video of the correct resolution. To learn more about Rendering Video, refer the guide [here](https://www.100ms.live/docs/flutter/v2/features/render-video). - - Added Simulcast support for RTC Stats RTC Call Stats are updated to show Simulcast layer data if available for Local Peer's Video Track. This can be used to diagnose user experience with metrics such as Audio/Video Bitrate, Round Trip Time, Packet loss, etc. To learn more about using RTC Call Stats, refer the guide [here](https://www.100ms.live/docs/flutter/v2/features/call-stats). - - ### Changed - Sending correct `joined_at` property on Android indicating the time when the peer joins the Room @@ -190,15 +204,10 @@ Full Changelog: [1.2.0...1.3.0](https://github.com/100mslive/100ms-flutter/compa - On Android, the `onJoin` updates will now be triggered before `onPeerUpdate` when a user joins the room - - Updated to Android SDK 2.5.6 & iOS SDK 0.5.5 - Full Changelog: [1.1.0...1.2.0](https://github.com/100mslive/100ms-flutter/compare/1.1.0...1.2.0) - - ## 1.1.0 - 2022-12-17 ### Added @@ -235,8 +244,8 @@ Full Changelog: [1.1.0...1.2.0](https://github.com/100mslive/100ms-flutter/compa ```dart hmsSDK.switchAudioOutput(audioDevice: HMSAudioDevice.SPEAKER_PHONE); ``` - For More Information, refer: https://www.100ms.live/docs/flutter/v2/features/audio-output-routing + For More Information, refer: https://www.100ms.live/docs/flutter/v2/features/audio-output-routing ### Deprecated @@ -244,37 +253,35 @@ Full Changelog: [1.1.0...1.2.0](https://github.com/100mslive/100ms-flutter/compa No change in functionality or method signature. - ### Fixed - Microphone not getting captured on Role Change from a non-publishing to publishing Role on iOS - Corrected an issue where on iOS a default Audio Mixer was getting created if Track Settings was passed while building the HMSSDK instance - Updated to Native Android SDK 2.5.4 & Native iOS SDK 0.5.3 Full Changelog: [1.0.0...1.1.0](https://github.com/100mslive/100ms-flutter/compare/1.0.0...1.1.0) - ## 1.0.0 - 2022-12-09 ### Added - Added support for Picture in Picture mode on Android. - PIP Mode lets the user watch the room video in a small window pinned to a corner of the screen while navigating between apps or browsing content on the main screen. + PIP Mode lets the user watch the room video in a small window pinned to a corner of the screen while navigating between apps or browsing content on the main screen. - Example implementation for checking device support & enabling PIP mode: - ```dart - // to start PIP mode invoke the `enterPipMode` function, the parameters passed to it are optional - hmsSDK.enterPipMode(aspectRatio: [16, 9], autoEnterPip: true); + Example implementation for checking device support & enabling PIP mode: - // method to check whether PIP mode is available for current device - bool isPipAvailable = await hmsSDK.isPipAvailable(); + ```dart + // to start PIP mode invoke the `enterPipMode` function, the parameters passed to it are optional + hmsSDK.enterPipMode(aspectRatio: [16, 9], autoEnterPip: true); - // method to check whether PIP mode is active currently - bool isPipActive = await hmsSDK.isPipActive(); - ``` + // method to check whether PIP mode is available for current device + bool isPipAvailable = await hmsSDK.isPipAvailable(); + + // method to check whether PIP mode is active currently + bool isPipActive = await hmsSDK.isPipActive(); + ``` - Added `roomPeerCountUpdated` type in `HMSRoomUpdate` @@ -282,14 +289,13 @@ Full Changelog: [1.0.0...1.1.0](https://github.com/100mslive/100ms-flutter/compa - Added convenience APIs to Mute / Unmute Audio or Video of the entire room locally - ### Fixed - Corrected parsing of `HMSMessage` objects sent Server-side APIs - Session Metadata can now be reset to a null value - Importing Native Android SDK dependency from Maven Central instead of Jitpack - HMSTrackSettings is now nullable while building the HMSSDK object -- Corrected usage of Native Util functions to fetch Audio & Video tracks +- Corrected usage of Native Util functions to fetch Audio & Video tracks - Corrected default local audio track settings for iOS devices - Corrected sending of peer count in `HMSRoom` instance on iOS @@ -297,8 +303,6 @@ Updated to Native Android SDK 2.5.1 & Native iOS SDK 0.4.7 Full Changelog: [0.7.8...1.0.0](https://github.com/100mslive/100ms-flutter/compare/0.7.8...1.0.0) - - ## 0.7.8 - 2022-10-31 - Added support for Joining with Muted Audio & Video on iOS devices @@ -334,7 +338,6 @@ Full Changelog: [0.7.6...0.7.7](https://github.com/100mslive/100ms-flutter/compa Full Changelog: [0.7.6...0.7.5](https://github.com/100mslive/100ms-flutter/compare/0.7.6...0.7.5) - ## 0.7.5 - 2022-08-18 - Added support on iOS for sharing audio from local files on your device & from other audio playing apps @@ -342,7 +345,7 @@ Full Changelog: [0.7.6...0.7.5](https://github.com/100mslive/100ms-flutter/compa - Added APIs to fetch local peer track settings - Fixed an issue where exiting from Preview without joining room was not releasing camera access - Added `destroy` API to cleanup Native HMSSDK instance correctly -- Disabled Hardware Scaler on Android to correct intermittent Video tile flickering +- Disabled Hardware Scaler on Android to correct intermittent Video tile flickering - Updated to Native Android SDK 2.4.8 & Native iOS SDK 0.3.3 ## 0.7.4 - 2022-07-29 @@ -350,7 +353,7 @@ Full Changelog: [0.7.6...0.7.5](https://github.com/100mslive/100ms-flutter/compa ### Added - Added APIs to stream device audio in different modes -- Added APIs to view and change the output speaker selected by the SDK to playout +- Added APIs to view and change the output speaker selected by the SDK to playout - setAudioMode API to change the Audio out mode manually between in-call volume and media volume ### Fixed @@ -367,8 +370,8 @@ Full Changelog: [0.7.6...0.7.5](https://github.com/100mslive/100ms-flutter/compa - recording permission in HMSRole is now broken into - `browserRecording` and `rtmpStreaming` - streaming permission in HMSRole is now `hlsStreaming` - ## 0.7.3 - 2022-06-23 + - Added support for iOS Screenshare - Added `HMSHLSRecordingConfig` to perform recording while HLS Streaming - Updated error callback in `HMSUpdateListener` to `onHMSError` @@ -431,7 +434,7 @@ Full Changelog: [0.7.6...0.7.5](https://github.com/100mslive/100ms-flutter/compa - Added HLS Support. Now you can Start/Stop HLS Streaming from Flutter SDK - Added support to do ScreenShare from Android device - + ### Changed - Updated callbacks for Permission based action APIs From aeda5a2df3cc77e2e80fafe7b9d784664d99cf48 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Thu, 4 May 2023 22:10:58 +0530 Subject: [PATCH 83/88] Session store docs (#1318) * Added fix for removeKeyChangeListener method * Added docs in method definition --- lib/src/model/hms_audio_track_setting.dart | 4 ++++ lib/src/model/hms_session_store.dart | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/src/model/hms_audio_track_setting.dart b/lib/src/model/hms_audio_track_setting.dart index 6b85a71d2..428c85582 100644 --- a/lib/src/model/hms_audio_track_setting.dart +++ b/lib/src/model/hms_audio_track_setting.dart @@ -12,15 +12,19 @@ class HMSAudioTrackSetting { /// The default is on if it is supported. /// Please note that on some devices the hardware wrongly reports the HW echo canceler to be present whereas it does not work /// In such as application need to set this to false, so that SW echo canceler is picked up. + /// Refer: Read more about useHardwareAcousticEchoCanceler [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/interact-with-room/track/set-track-settings#usehardwareacousticechocanceler) final bool? useHardwareAcousticEchoCanceler; ///[audioSource] only for iOS. Used for audioSharing use cases. + ///Refer: Read more about audio source [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/set-up-video-conferencing/local-audio-share#i-os-setup) HMSAudioMixerSource? audioSource; ///[trackInitialState] property to set the initial state of the audio track i.e Mute/Unmute.By default it's unmuted. + ///Refer: Read more about trackInitialState [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/set-up-video-conferencing/join#join-with-muted-audio-video) final HMSTrackInitState? trackInitialState; ///[audioMode] property to set the audio mode of audio track i.e voice or music mode + ///Refer: Read more about audio mode [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/configure-your-device/microphone/music-mode) final HMSAudioMode? audioMode; HMSAudioTrackSetting( diff --git a/lib/src/model/hms_session_store.dart b/lib/src/model/hms_session_store.dart index 84bac1fd4..e5bb1dcd1 100644 --- a/lib/src/model/hms_session_store.dart +++ b/lib/src/model/hms_session_store.dart @@ -16,6 +16,7 @@ class HMSSessionStore { /// /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] implemented in the class where changes needs to be listened /// + ///Refer: Read more about addKeyChangeListener [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/interact-with-room/room/session-store#retrieve-the-current-value-and-receive-updates) Future addKeyChangeListener( {required List keys, required HMSKeyChangeListener hmsKeyChangeListener}) async { @@ -38,6 +39,7 @@ class HMSSessionStore { /// /// **hmsKeyChangeListener** An instance of [HMSKeyChangeListener] which was attaced earlier in [addKeyChangeListener] /// + ///Refer: Read more about removeKeyChangeListener [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/interact-with-room/room/session-store#stop-listening-to-updates-for-keys) Future removeKeyChangeListener( {required HMSKeyChangeListener hmsKeyChangeListener}) async{ return PlatformService.removeKeyChangeObserver(hmsKeyChangeListener); @@ -50,6 +52,7 @@ class HMSSessionStore { /// /// **key** key for which metadata is required /// + ///Refer: Read more about getSessionMetadataForKey [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/interact-with-room/room/session-store#retrieve-the-current-value-once) Future getSessionMetadataForKey({required String key}) async { dynamic result = await PlatformService.invokeMethod( PlatformMethod.getSessionMetadataForKey, @@ -71,6 +74,7 @@ class HMSSessionStore { /// /// **hmsActionResultListener** [hmsActionResultListener] is a callback instance on which [HMSActionResultListener.onSuccess] and [HMSActionResultListener.onException] will be called. /// + ///Refer: Read more about setSessionMetadataForKey [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/interact-with-room/room/session-store#setting-a-value-for-a-specific-key) Future setSessionMetadataForKey( {required String key, required String? data, From fccdc724c5e3728a601d05705d113e5ede942cb4 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Thu, 4 May 2023 23:14:50 +0530 Subject: [PATCH 84/88] =?UTF-8?q?released=20sample=20app=20version=201.4.1?= =?UTF-8?q?02=20(237)=20=F0=9F=8D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 4 ++-- example/ios/Runner/Info.plist | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 4ba072bd6..a36d1555c 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 236 - versionName "1.4.101" + versionCode 237 + versionName "1.4.102" } signingConfigs { diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 4f2965650..ee466d8f3 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.101 + 1.4.102 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 236 + 237 ITSAppUsesNonExemptEncryption LSApplicationCategoryType From 967525927016e09bdf1d62ca0eed7102197494d6 Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Fri, 5 May 2023 13:17:02 +0530 Subject: [PATCH 85/88] corrected lint warnings --- example/lib/common/peer_widgets/more_option.dart | 6 ++++-- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 8 ++++---- lib/src/model/hms_session_store.dart | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/example/lib/common/peer_widgets/more_option.dart b/example/lib/common/peer_widgets/more_option.dart index bb1944fc5..fd753ade8 100644 --- a/example/lib/common/peer_widgets/more_option.dart +++ b/example/lib/common/peer_widgets/more_option.dart @@ -71,7 +71,8 @@ class MoreOption extends StatelessWidget { metadata: null); return; } - ///Setting the metadata as audio trackId if it's not present + + ///Setting the metadata as audio trackId if it's not present ///then setting it as video trackId String? metadata = (peerTrackNode.audioTrack == null) ? peerTrackNode.track?.trackId @@ -280,7 +281,8 @@ class MoreOption extends StatelessWidget { metadata: null); return; } - ///Setting the metadata as audio trackId if it's not present + + ///Setting the metadata as audio trackId if it's not present ///then setting it as video trackId String? metadata = (peerTrackNode.audioTrack == null) ? peerTrackNode.track?.trackId diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 8795bcdd9..1d16b948b 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -574,11 +574,11 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene // There is no need to call removeKeyChangeListener is // there is no keyChangeListener attached - if(sessionStoreChangeObservers.isEmpty){ - result(HMSResultExtension.toDictionary(true,nil)) + if sessionStoreChangeObservers.isEmpty { + result(HMSResultExtension.toDictionary(true, nil)) return } - + guard let store = sessionStore else { HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) @@ -609,7 +609,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene sessionStoreChangeObservers.remove(at: keyChangeListenersToBeRemovedIndex) - result(HMSResultExtension.toDictionary(true,nil)) + result(HMSResultExtension.toDictionary(true, nil)) } /** diff --git a/lib/src/model/hms_session_store.dart b/lib/src/model/hms_session_store.dart index e5bb1dcd1..35b7fc68c 100644 --- a/lib/src/model/hms_session_store.dart +++ b/lib/src/model/hms_session_store.dart @@ -41,7 +41,7 @@ class HMSSessionStore { /// ///Refer: Read more about removeKeyChangeListener [here](https://www.100ms.live/docs/flutter/v2/how-to-guides/interact-with-room/room/session-store#stop-listening-to-updates-for-keys) Future removeKeyChangeListener( - {required HMSKeyChangeListener hmsKeyChangeListener}) async{ + {required HMSKeyChangeListener hmsKeyChangeListener}) async { return PlatformService.removeKeyChangeObserver(hmsKeyChangeListener); } From a312a9e52a01ebff4ec0556100a6e030469e0422 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Fri, 5 May 2023 16:24:36 +0530 Subject: [PATCH 86/88] Fixed comments (#1320) * Fixed comments * fixed result * Setting sessionSink to nil * Fixed error bugs --- .../hms/hmssdk_flutter/HmssdkFlutterPlugin.kt | 4 ++-- .../Actions/HMSSessionStoreAction.swift | 9 +++++--- ios/Classes/SwiftHmssdkFlutterPlugin.swift | 22 ++++++++++++------- lib/src/model/hms_session_store.dart | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt index 36c8361ef..599f42ed5 100644 --- a/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt +++ b/android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt @@ -1226,7 +1226,7 @@ class HmssdkFlutterPlugin : HMSErrorLogger.returnArgumentsError("uid is null") } - uid.let { + uid?.let { val keyChangeListener = object : HMSKeyChangeListener { override fun onKeyChanged(key: String, value: Any?) { val args = HashMap() @@ -1262,7 +1262,7 @@ class HmssdkFlutterPlugin : val uid = call.argument("uid") ?: run { HMSErrorLogger.returnArgumentsError("uid is null") } - //There is no need to call removeKeyChangeListener is + //There is no need to call removeKeyChangeListener since //there is no keyChangeListener attached if(hmsKeyChangeObserverList.isEmpty()){ result.success(HMSResultExtension.toDictionary(true,null)) diff --git a/ios/Classes/Actions/HMSSessionStoreAction.swift b/ios/Classes/Actions/HMSSessionStoreAction.swift index 3ee1f227c..2381c5998 100644 --- a/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -61,14 +61,16 @@ class HMSSessionStoreAction { guard let store = plugin.sessionStore else { - HMSErrorLogger.returnHMSException(#function, "Session Store is null.", "NULL ERROR", result) + HMSErrorLogger.logError(#function,"Session Store is null.","NULL Error") + result(HMSErrorExtension.getError("Session Store is null.")) return } guard let arguments = call.arguments as? [AnyHashable: Any], let key = arguments["key"] as? String else { - HMSErrorLogger.returnHMSException(#function, "Key for the object to be set in Session Store is null.", "NULL ERROR", result) + HMSErrorLogger.logError(#function,"Key for the object to be set in Session Store is null.","NULL Error") + result(HMSErrorExtension.getError("Key for the object to be set in Session Store is null.")) return } @@ -77,7 +79,8 @@ class HMSSessionStoreAction { store.set(data as Any, forKey: key) { _, error in if let error = error { - HMSErrorLogger.returnHMSException(#function, "Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)", "Key Error", result) + HMSErrorLogger.logError(#function,"Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)","Key Error") + result(HMSErrorExtension.getError("Error in setting data: \(data ?? "null") for key: \(key) to the Session Store. Error: \(error.localizedDescription)")) return } result(nil) diff --git a/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 1d16b948b..ae03fe79e 100644 --- a/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -134,7 +134,7 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene } if sessionEventChannel != nil { sessionEventChannel!.setStreamHandler(nil) - sessionEventChannel = nil + sessionSink = nil } else { print(#function, "sessionEventChannel not found") } @@ -498,26 +498,29 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene guard let store = sessionStore else { - HMSErrorLogger.returnHMSException(#function, "Session Store is null", "NULL ERROR", result) + HMSErrorLogger.logError(#function,"Session Store is null","NULL ERROR") + result(HMSErrorExtension.getError("Session Store is null")) return } guard let arguments = call.arguments as? [AnyHashable: Any] else { HMSErrorLogger.returnArgumentsError("keys is null") - HMSErrorLogger.returnHMSException(#function, "No arguments passed which can be attached to Key Change Listener on the Session Store.", "NULL ERROR", result) + result(HMSErrorExtension.getError("No arguments passed which can be attached to Key Change Listener on the Session Store.")) return } guard let keys = arguments["keys"] as? [String] else { - HMSErrorLogger.returnHMSException(#function, "No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)", "NULL ERROR", result) + HMSErrorLogger.logError(#function,"No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)","NULL ERROR") + result(HMSErrorExtension.getError("No keys passed which can be attached to Key Change Listener on the Session Store. Available arguments: \(arguments)")) return } guard let uid = arguments["uid"] as? String else { - HMSErrorLogger.returnHMSException(#function, "No uid passed for key change listener Available arguments: \(arguments)", "NULL ERROR", result) + HMSErrorLogger.logError(#function,"No uid passed for key change listener Available arguments: \(arguments)", "NULL ERROR") + result(HMSErrorExtension.getError("No uid passed for key change listener Available arguments: \(arguments)")) return } @@ -544,19 +547,22 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene }) { [weak self] observer, error in if let error = error { - HMSErrorLogger.returnHMSException(#function, "Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)", "KEY CHANGE ERROR", result) + HMSErrorLogger.logError(#function,"Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)","KEY CHANGE ERROR") + result(HMSErrorExtension.getError("Error in observing changes for key: \(keys) in the Session Store. Error: \(error.localizedDescription)")) return } guard let observer = observer else { - HMSErrorLogger.returnHMSException(#function, "Unknown Error in observing changes for key: \(keys) in the Session Store.", "KEY CHANGE ERROR", result) + HMSErrorLogger.logError(#function,"Unknown Error in observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR") + result(HMSErrorExtension.getError("Unknown Error in observing changes for key: \(keys) in the Session Store.")) return } guard let self = self else { - HMSErrorLogger.returnHMSException(#function, "Could not find self instance while observing changes for key: \(keys) in the Session Store.", "KEY CHANGE ERROR", result) + HMSErrorLogger.logError(#function,"Could not find self instance while observing changes for key: \(keys) in the Session Store.","KEY CHANGE ERROR") + result(HMSErrorExtension.getError("Could not find self instance while observing changes for key: \(keys) in the Session Store.")) return } diff --git a/lib/src/model/hms_session_store.dart b/lib/src/model/hms_session_store.dart index 35b7fc68c..0c8f2f380 100644 --- a/lib/src/model/hms_session_store.dart +++ b/lib/src/model/hms_session_store.dart @@ -29,7 +29,7 @@ class HMSSessionStore { uid: uid, hmsKeyChangeListener: hmsKeyChangeListener)); return null; } else { - return HMSException.fromMap(result["data"]); + return HMSException.fromMap(result["error"]); } } From ce8590208ed1ace3360d75bc70b1376a374b2b60 Mon Sep 17 00:00:00 2001 From: Pushpam <93931528+Decoder07@users.noreply.github.com> Date: Fri, 5 May 2023 16:30:05 +0530 Subject: [PATCH 87/88] Spotlight app fix (#1321) * Fixed comments * fixed result * Setting sessionSink to nil * Fixed error bugs * Spotlight application fix --- example/lib/meeting/meeting_store.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/lib/meeting/meeting_store.dart b/example/lib/meeting/meeting_store.dart index 0134ba978..671f8e07a 100644 --- a/example/lib/meeting/meeting_store.dart +++ b/example/lib/meeting/meeting_store.dart @@ -1382,6 +1382,8 @@ class MeetingStore extends ChangeNotifier Utilities.showToast("${peerTracks[index].peer.name} is in spotlight"); spotLightPeer = peerTracks[index]; changePinTileStatus(peerTracks[index]); + } else { + spotlightMetadata = value; } } else { spotlightMetadata = null; From 25952bce8eb0183018bcf48a39acd38147af2a0d Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Fri, 5 May 2023 17:00:59 +0530 Subject: [PATCH 88/88] =?UTF-8?q?released=20sample=20app=20version=201.4.1?= =?UTF-8?q?03=20(238)=20=F0=9F=8D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 4 ++-- example/ios/Runner/Info.plist | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index a36d1555c..96ad1908f 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 237 - versionName "1.4.102" + versionCode 238 + versionName "1.4.103" } signingConfigs { diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index ee466d8f3..ac3e4c2c0 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.102 + 1.4.103 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 237 + 238 ITSAppUsesNonExemptEncryption LSApplicationCategoryType