Skip to content

Commit b927bf6

Browse files
authored
feat: chime sdk api rewrite (#14)
## Key Changes by Category 1. API Architecture (Core Refactoring) - Before: Global functions (joinMeeting(), leaveMeeting(), etc.) + singleton pattern with global variables - After: Instance-based `ChimeSDK` class with: - `ChimeSDK.createSession()` — static factory to initialize - `joinMeeting()` — instance method to connect - All platform-specific logic encapsulated within the instance 2. Common API Changes (ChimeSDK.kt) - Converted from `expect fun` declarations to expect class `ChimeSDK` - `joinMeeting()` signature simplified: removed many optional parameters, consolidated callbacks - New `ChimeMessage` data class added (replaces `TextMessage`) ## Migration Impact (for library consumers) This is a breaking change. Code using the old API must update: Before: ```Kotlin joinMeeting(meetingId, ..., onLocalVideoTileAdded = { tileId -> ... }) ``` After: ```Kotlin val chimeSDK = ChimeSDK.createSession(meetingId, ...) chimeSDK.joinMeeting(realTimeListener, onLocalVideoTileAdded = { tileId -> ... }) ```
1 parent 4e9efc5 commit b927bf6

25 files changed

Lines changed: 1299 additions & 1371 deletions

chime-sdk/build.gradle.kts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
}
1313

1414
group = "com.wannaverse"
15-
version = "0.3.1"
15+
version = "0.4.0"
1616

1717
kotlin {
1818
androidTarget {
@@ -39,19 +39,6 @@ kotlin {
3939
val simSlice = "ios-arm64_x86_64-simulator"
4040
val devSlice = "ios-arm64"
4141

42-
iosX64 {
43-
compilations["main"].cinterops {
44-
val AmazonChimeSDK by creating {
45-
defFile(project.file("src/nativeInterop/cinterop/AmazonChimeSDK.def"))
46-
packageName("cocoapods.AmazonChimeSDK")
47-
compilerOpts(
48-
"-fmodules",
49-
"-F", "$podsDir/AmazonChimeSDK/AmazonChimeSDK.xcframework/$simSlice",
50-
"-F", "$podsDir/AmazonChimeSDKMedia/AmazonChimeSDKMedia.xcframework/$simSlice"
51-
)
52-
}
53-
}
54-
}
5542
iosArm64 {
5643
compilations["main"].cinterops {
5744
val AmazonChimeSDK by creating {

chime-sdk/chime_sdk.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'chime_sdk'
3-
spec.version = '0.3.1'
3+
spec.version = '0.4.0'
44
spec.homepage = 'https://github.com/WannaverseOfficial/kmp-chime-sdk'
55
spec.source = { :http=> ''}
66
spec.authors = ''

chime-sdk/src/androidMain/kotlin/com/wannaverse/chimesdk/MeetingActiveSpeakerObserver.kt renamed to chime-sdk/src/androidMain/kotlin/com/wannaverse/chimesdk/ActiveSpeakerObserverImpl.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@ package com.wannaverse.chimesdk
33
import com.amazonaws.services.chime.sdk.meetings.audiovideo.AttendeeInfo
44
import com.amazonaws.services.chime.sdk.meetings.audiovideo.audio.activespeakerdetector.ActiveSpeakerObserver
55

6-
object MeetingActiveSpeakerObserver : ActiveSpeakerObserver {
7-
private const val SPEAKING_THRESHOLD = 0.05
8-
var onActiveSpeakersChanged: ((Set<String>) -> Unit)? = null
6+
private const val SPEAKING_THRESHOLD = 0.05
97

8+
class ActiveSpeakerObserverImpl(val onActiveSpeakersChanged: (Set<String>) -> Unit) : ActiveSpeakerObserver {
109
override val scoreCallbackIntervalMs: Int = 500
1110

1211
override fun onActiveSpeakerDetected(attendeeInfo: Array<AttendeeInfo>) {}
1312

14-
override fun onActiveSpeakerScoreChanged(scores: Map<AttendeeInfo, Double>) {
15-
if (scores.isEmpty()) return
16-
val activeSpeakers = scores
13+
override fun onActiveSpeakerScoreChanged(scores: Map<AttendeeInfo, Double>) =
14+
scores.mapKeys { (attendee) -> attendee.externalUserId }
1715
.filter { (_, score) -> score > SPEAKING_THRESHOLD }
18-
.map { (attendee, _) -> attendee.externalUserId }
19-
.toSet()
20-
onActiveSpeakersChanged?.invoke(activeSpeakers)
21-
}
16+
.keys
17+
.let(onActiveSpeakersChanged)
2218
}

chime-sdk/src/androidMain/kotlin/com/wannaverse/chimesdk/AudioVideoObserverImpl.kt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ package com.wannaverse.chimesdk
22

33
import com.amazonaws.services.chime.sdk.meetings.audiovideo.AudioVideoObserver
44
import com.amazonaws.services.chime.sdk.meetings.audiovideo.video.RemoteVideoSource
5+
import com.amazonaws.services.chime.sdk.meetings.session.MeetingSession
56
import com.amazonaws.services.chime.sdk.meetings.session.MeetingSessionStatus
67
import com.amazonaws.services.chime.sdk.meetings.session.MeetingSessionStatusCode
78

89
class AudioVideoObserverImpl(
10+
private val meetingSession: MeetingSession,
911
private val onConnectionStatusChanged: (ConnectionStatus) -> Unit,
1012
private val onRemoteVideoAvailable: (isAvailable: Boolean, sourceCount: Int) -> Unit,
1113
private val onCameraSendAvailable: (available: Boolean) -> Unit,
1214
private val onSessionError: (message: String, isRecoverable: Boolean) -> Unit,
1315
private val onVideoNeedsRestart: () -> Unit,
1416
private val isJoiningOnMute: Boolean
1517
) : AudioVideoObserver {
16-
1718
private var isVideoSessionActive = false
18-
private var hasReportedPoorConnection = false
1919
private var shouldRestartVideoAfterReconnect = false
2020

2121
override fun onAudioSessionStartedConnecting(reconnecting: Boolean) {
@@ -30,9 +30,7 @@ class AudioVideoObserverImpl(
3030
override fun onAudioSessionStarted(reconnecting: Boolean) {
3131
onConnectionStatusChanged(ConnectionStatus.CONNECTED)
3232

33-
if (!reconnecting && isJoiningOnMute) {
34-
meetingSession?.audioVideo?.realtimeLocalMute()
35-
}
33+
if (!reconnecting && isJoiningOnMute) meetingSession.audioVideo.realtimeLocalMute()
3634

3735
if (reconnecting && shouldRestartVideoAfterReconnect && !isVideoSessionActive) {
3836
onVideoNeedsRestart()
@@ -67,15 +65,11 @@ class AudioVideoObserverImpl(
6765
}
6866

6967
override fun onConnectionBecamePoor() {
70-
hasReportedPoorConnection = true
7168
onConnectionStatusChanged(ConnectionStatus.POOR_CONNECTION)
7269
}
7370

7471
override fun onConnectionRecovered() {
75-
if (hasReportedPoorConnection) {
76-
hasReportedPoorConnection = false
77-
onConnectionStatusChanged(ConnectionStatus.CONNECTED)
78-
}
72+
onConnectionStatusChanged(ConnectionStatus.CONNECTED)
7973
}
8074

8175
override fun onVideoSessionStartedConnecting() {}

chime-sdk/src/androidMain/kotlin/com/wannaverse/chimesdk/ChimeLogger.kt

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)