Skip to content

Commit ab61771

Browse files
authored
Merge pull request #47 from sendbird/feat/resume-audio-track
feat(android): added resume audio track
2 parents 7c2a522 + 17b854e commit ab61771

File tree

11 files changed

+56
-4
lines changed

11 files changed

+56
-4
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ dependencies {
9696
// noinspection GradleDynamicVersion
9797
implementation "com.facebook.react:react-native:+"
9898
implementation "org.jetbrains.kotlin:kotlin-stdlib:${ReactNative.ext.getVersion("android", "kotlin")}"
99-
implementation("com.sendbird.sdk:sendbird-calls:1.11.10")
99+
implementation("com.sendbird.sdk:sendbird-calls:1.12.1")
100100
}
101101

102102
ReactNative.shared.applyPackageVersion()

android/src/main/java/com/sendbird/calls/reactnative/module/CallsDirectCallModule.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,13 @@ class CallsDirectCallModule(private val root: CallsModule): DirectCallModule {
191191
CallsUtils.findDirectCall(identifier, from).resumeVideoCapturer()
192192
}
193193
}
194+
195+
override fun resumeAudioTrack(type: String, identifier: String) {
196+
val from = "directCall/resumeAudioTrack"
197+
RNCallsLogger.d("[DirectCallModule] $from ($identifier)")
198+
199+
CallsUtils.safeRun {
200+
CallsUtils.findDirectCall(identifier, from).resumeAudioTrack()
201+
}
202+
}
194203
}

android/src/main/java/com/sendbird/calls/reactnative/module/CallsGroupCallModule.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,13 @@ class CallsGroupCallModule: GroupCallModule {
138138
CallsUtils.findRoom(identifier, from).localParticipant?.resumeVideoCapturer()
139139
}
140140
}
141+
142+
override fun resumeAudioTrack(type: String, identifier: String) {
143+
val from = "groupCall/resumeAudioTrack"
144+
RNCallsLogger.d("[GroupCallModule] $from ($identifier)")
145+
146+
CallsUtils.safeRun {
147+
CallsUtils.findRoom(identifier, from).localParticipant?.resumeAudioTrack()
148+
}
149+
}
141150
}

android/src/main/java/com/sendbird/calls/reactnative/module/CallsModule.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class CallsModule(val reactContext: ReactApplicationContext) : CallsModuleStruct
8686
override fun selectAudioDevice(type: String, identifier: String, device: String, promise: Promise) = getControllableModule(type).selectAudioDevice(type, identifier, device, promise)
8787
override fun selectVideoDevice(type: String, identifier: String, device: ReadableMap, promise: Promise) = getControllableModule(type).selectVideoDevice(type, identifier, device, promise)
8888
override fun resumeVideoCapturer(type: String, identifier: String) = getControllableModule(type).resumeVideoCapturer(type, identifier)
89+
override fun resumeAudioTrack(type: String, identifier: String) = getControllableModule(type).resumeAudioTrack(type, identifier)
8990

9091
/** DirectCall module interface **/
9192
override fun accept(callId: String, options: ReadableMap, holdActiveCall: Boolean, promise: Promise) = directCallModule.accept(callId, options, holdActiveCall, promise)

android/src/main/java/com/sendbird/calls/reactnative/module/CallsModuleStruct.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ interface MediaDeviceControl {
5757
fun selectAudioDevice(type: String, identifier: String, device: String, promise: Promise)
5858
fun selectVideoDevice(type: String, identifier: String, device: ReadableMap, promise: Promise)
5959
fun resumeVideoCapturer(type: String, identifier: String)
60+
fun resumeAudioTrack(type: String, identifier: String)
6061
}

android/src/oldarch/java/com/sendbird/calls/reactnative/RNSendbirdCallsModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class RNSendbirdCallsModule(private val reactContext: ReactApplicationContext) :
9393
override fun selectVideoDevice(type: String, identifier: String, device: ReadableMap, promise: Promise) = module.selectVideoDevice(type, identifier, device, promise)
9494
@ReactMethod
9595
override fun resumeVideoCapturer(type: String, identifier: String) = module.resumeVideoCapturer(type, identifier)
96+
@ReactMethod
97+
override fun resumeAudioTrack(type: String, identifier: String) = module.resumeAudioTrack(type, identifier)
9698

9799
/** DirectCall **/
98100
@ReactMethod

src/libs/DirectCall.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,17 @@ export class DirectCall implements DirectCallProperties, DirectCallMethods {
299299
this._binder.nativeModule.resumeVideoCapturer(ControllableModuleType.DIRECT_CALL, this.callId);
300300
};
301301

302+
/**
303+
* Connects the device audio and Sendbird Calls SDK to stream audio.
304+
*
305+
* @platform Android
306+
* @since 1.1.5
307+
* */
308+
public android_resumeAudioTrack = () => {
309+
if (Platform.OS !== 'android') return;
310+
this._binder.nativeModule.resumeAudioTrack(ControllableModuleType.DIRECT_CALL, this.callId);
311+
};
312+
302313
/**
303314
* Mutes the audio of local user.
304315
* Will trigger {@link DirectCallListener.onRemoteAudioSettingsChanged} method of the remote user.

src/libs/Participant.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,15 @@ export class LocalParticipant extends Participant implements LocalParticipantMet
171171
if (Platform.OS !== 'android') return;
172172
return this._binder.nativeModule.resumeVideoCapturer(ControllableModuleType.GROUP_CALL, this._roomId);
173173
};
174+
175+
/**
176+
* Connects the device audio and Sendbird Calls SDK to stream audio.
177+
*
178+
* @platform Android
179+
* @since 1.1.5
180+
* */
181+
public android_resumeAudioTrack = () => {
182+
if (Platform.OS !== 'android') return;
183+
return this._binder.nativeModule.resumeAudioTrack(ControllableModuleType.GROUP_CALL, this._roomId);
184+
};
174185
}

src/types/Call.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ type JSDirectCallModule = AsJSDirectCall<NativeDirectCallModule>;
338338
type JSDirectCallMediaDeviceControl = AsJSInterface<
339339
JSMediaDeviceControl,
340340
'android',
341-
'selectAudioDevice' | 'resumeVideoCapturer'
341+
'selectAudioDevice' | 'resumeVideoCapturer' | 'resumeAudioTrack'
342342
>;
343343

344344
export interface DirectCallMethods extends JSDirectCallModule, JSDirectCallMediaDeviceControl {

src/types/NativeModule.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export interface NativeMediaDeviceControl {
8383
selectAudioDevice(type: ControllableModuleType, identifier: string, device: AudioDevice): Promise<void>;
8484
/** @platform Android **/
8585
resumeVideoCapturer(type: ControllableModuleType, identifier: string): void;
86+
/** @platform Android **/
87+
resumeAudioTrack(type: ControllableModuleType, identifier: string): void;
8688
}
8789

8890
export interface NativeDirectCallModule {

0 commit comments

Comments
 (0)