Skip to content

Commit

Permalink
Merge pull request #47 from sendbird/feat/resume-audio-track
Browse files Browse the repository at this point in the history
feat(android): added resume audio track
  • Loading branch information
bang9 authored Dec 12, 2024
2 parents 7c2a522 + 17b854e commit ab61771
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 4 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ dependencies {
// noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${ReactNative.ext.getVersion("android", "kotlin")}"
implementation("com.sendbird.sdk:sendbird-calls:1.11.10")
implementation("com.sendbird.sdk:sendbird-calls:1.12.1")
}

ReactNative.shared.applyPackageVersion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,13 @@ class CallsDirectCallModule(private val root: CallsModule): DirectCallModule {
CallsUtils.findDirectCall(identifier, from).resumeVideoCapturer()
}
}

override fun resumeAudioTrack(type: String, identifier: String) {
val from = "directCall/resumeAudioTrack"
RNCallsLogger.d("[DirectCallModule] $from ($identifier)")

CallsUtils.safeRun {
CallsUtils.findDirectCall(identifier, from).resumeAudioTrack()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,13 @@ class CallsGroupCallModule: GroupCallModule {
CallsUtils.findRoom(identifier, from).localParticipant?.resumeVideoCapturer()
}
}

override fun resumeAudioTrack(type: String, identifier: String) {
val from = "groupCall/resumeAudioTrack"
RNCallsLogger.d("[GroupCallModule] $from ($identifier)")

CallsUtils.safeRun {
CallsUtils.findRoom(identifier, from).localParticipant?.resumeAudioTrack()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class CallsModule(val reactContext: ReactApplicationContext) : CallsModuleStruct
override fun selectAudioDevice(type: String, identifier: String, device: String, promise: Promise) = getControllableModule(type).selectAudioDevice(type, identifier, device, promise)
override fun selectVideoDevice(type: String, identifier: String, device: ReadableMap, promise: Promise) = getControllableModule(type).selectVideoDevice(type, identifier, device, promise)
override fun resumeVideoCapturer(type: String, identifier: String) = getControllableModule(type).resumeVideoCapturer(type, identifier)
override fun resumeAudioTrack(type: String, identifier: String) = getControllableModule(type).resumeAudioTrack(type, identifier)

/** DirectCall module interface **/
override fun accept(callId: String, options: ReadableMap, holdActiveCall: Boolean, promise: Promise) = directCallModule.accept(callId, options, holdActiveCall, promise)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ interface MediaDeviceControl {
fun selectAudioDevice(type: String, identifier: String, device: String, promise: Promise)
fun selectVideoDevice(type: String, identifier: String, device: ReadableMap, promise: Promise)
fun resumeVideoCapturer(type: String, identifier: String)
fun resumeAudioTrack(type: String, identifier: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class RNSendbirdCallsModule(private val reactContext: ReactApplicationContext) :
override fun selectVideoDevice(type: String, identifier: String, device: ReadableMap, promise: Promise) = module.selectVideoDevice(type, identifier, device, promise)
@ReactMethod
override fun resumeVideoCapturer(type: String, identifier: String) = module.resumeVideoCapturer(type, identifier)
@ReactMethod
override fun resumeAudioTrack(type: String, identifier: String) = module.resumeAudioTrack(type, identifier)

/** DirectCall **/
@ReactMethod
Expand Down
11 changes: 11 additions & 0 deletions src/libs/DirectCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,17 @@ export class DirectCall implements DirectCallProperties, DirectCallMethods {
this._binder.nativeModule.resumeVideoCapturer(ControllableModuleType.DIRECT_CALL, this.callId);
};

/**
* Connects the device audio and Sendbird Calls SDK to stream audio.
*
* @platform Android
* @since 1.1.5
* */
public android_resumeAudioTrack = () => {
if (Platform.OS !== 'android') return;
this._binder.nativeModule.resumeAudioTrack(ControllableModuleType.DIRECT_CALL, this.callId);
};

/**
* Mutes the audio of local user.
* Will trigger {@link DirectCallListener.onRemoteAudioSettingsChanged} method of the remote user.
Expand Down
11 changes: 11 additions & 0 deletions src/libs/Participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,15 @@ export class LocalParticipant extends Participant implements LocalParticipantMet
if (Platform.OS !== 'android') return;
return this._binder.nativeModule.resumeVideoCapturer(ControllableModuleType.GROUP_CALL, this._roomId);
};

/**
* Connects the device audio and Sendbird Calls SDK to stream audio.
*
* @platform Android
* @since 1.1.5
* */
public android_resumeAudioTrack = () => {
if (Platform.OS !== 'android') return;
return this._binder.nativeModule.resumeAudioTrack(ControllableModuleType.GROUP_CALL, this._roomId);
};
}
2 changes: 1 addition & 1 deletion src/types/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ type JSDirectCallModule = AsJSDirectCall<NativeDirectCallModule>;
type JSDirectCallMediaDeviceControl = AsJSInterface<
JSMediaDeviceControl,
'android',
'selectAudioDevice' | 'resumeVideoCapturer'
'selectAudioDevice' | 'resumeVideoCapturer' | 'resumeAudioTrack'
>;

export interface DirectCallMethods extends JSDirectCallModule, JSDirectCallMediaDeviceControl {
Expand Down
2 changes: 2 additions & 0 deletions src/types/NativeModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export interface NativeMediaDeviceControl {
selectAudioDevice(type: ControllableModuleType, identifier: string, device: AudioDevice): Promise<void>;
/** @platform Android **/
resumeVideoCapturer(type: ControllableModuleType, identifier: string): void;
/** @platform Android **/
resumeAudioTrack(type: ControllableModuleType, identifier: string): void;
}

export interface NativeDirectCallModule {
Expand Down
10 changes: 8 additions & 2 deletions src/types/Participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ export interface ParticipantProperties {

type JSLocalParticipantMediaDeviceControl = Pick<
JSMediaDeviceControl,
'muteMicrophone' | 'unmuteMicrophone' | 'switchCamera' | 'startVideo' | 'stopVideo' | 'resumeVideoCapturer'
| 'muteMicrophone'
| 'unmuteMicrophone'
| 'switchCamera'
| 'startVideo'
| 'stopVideo'
| 'resumeVideoCapturer'
| 'resumeAudioTrack'
>;

export type LocalParticipantMethods = AsJSInterface<
JSLocalParticipantMediaDeviceControl,
'android',
'resumeVideoCapturer'
'resumeVideoCapturer' | 'resumeAudioTrack'
>;

export enum ParticipantState {
Expand Down

0 comments on commit ab61771

Please sign in to comment.