Skip to content

Commit 2c55167

Browse files
committed
feat: add resumeVideoCapturer method to javascript
1 parent a216526 commit 2c55167

File tree

7 files changed

+52
-6
lines changed

7 files changed

+52
-6
lines changed

sample/src/direct-call/components/DirectCallVideoContentView.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { FC, useEffect, useRef } from 'react';
2-
import { Animated, Easing, StyleSheet, View, useWindowDimensions } from 'react-native';
2+
import { Animated, Easing, Platform, StyleSheet, View, useWindowDimensions } from 'react-native';
33
import { useSafeAreaInsets } from 'react-native-safe-area-context';
44

55
import { DirectCall, DirectCallVideoView } from '@sendbird/calls-react-native';
@@ -31,6 +31,14 @@ const DirectCallVideoContentView: FC<CallStatusProps> = ({ call, status }) => {
3131
}
3232
}, [status]);
3333

34+
// In Android, if you have granted permission after accepting the call,
35+
// you have to call `call.android_resumeVideoCapturer()`.
36+
useEffect(() => {
37+
if (Platform.OS === 'android') {
38+
call.android_resumeVideoCapturer();
39+
}
40+
}, []);
41+
3442
return (
3543
<View style={{ flex: 1 }}>
3644
<DirectCallVideoView

sample/src/group-call/components/GroupCallVideoStreamView.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { FC, useEffect, useState } from 'react';
2-
import { Image, StyleSheet, View } from 'react-native';
2+
import { Image, Platform, StyleSheet, View } from 'react-native';
33

44
import {
55
GroupCallVideoView,
@@ -64,6 +64,14 @@ const GroupCallVideoStreamView: FC<GroupCallVideoStreamViewProps> = ({ room, lay
6464
}
6565
}, [layoutSize.width, layoutSize.height, rowCol.row, rowCol.column]);
6666

67+
// In Android, if you have granted permission after accepting the call,
68+
// you have to call `room.localParticipant.android_resumeVideoCapturer()`.
69+
useEffect(() => {
70+
if (Platform.OS === 'android' && room.localParticipant) {
71+
room.localParticipant.android_resumeVideoCapturer();
72+
}
73+
}, [room.localParticipant]);
74+
6775
return (
6876
<View
6977
style={[

src/libs/DirectCall.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ export class DirectCall implements DirectCallProperties, DirectCallMethods {
287287
await this._binder.nativeModule.selectAudioDevice(ControllableModuleType.DIRECT_CALL, this.callId, device);
288288
};
289289

290+
/**
291+
* Connects the device camera and Sendbird Calls SDK to stream video.
292+
*
293+
* @platform Android
294+
* @since 1.1.3
295+
* */
296+
public android_resumeVideoCapturer = () => {
297+
this._binder.nativeModule.resumeVideoCapturer(ControllableModuleType.DIRECT_CALL, this.callId);
298+
};
299+
290300
/**
291301
* Mutes the audio of local user.
292302
* Will trigger {@link DirectCallListener.onRemoteAudioSettingsChanged} method of the remote user.

src/libs/Participant.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,14 @@ export class LocalParticipant extends Participant implements LocalParticipantMet
158158
public switchCamera = () => {
159159
return this._binder.nativeModule.switchCamera(ControllableModuleType.GROUP_CALL, this._roomId);
160160
};
161+
162+
/**
163+
* Connects the device camera and Sendbird Calls SDK to stream video for local participant.
164+
*
165+
* @platform Android
166+
* @since 1.1.3
167+
* */
168+
public android_resumeVideoCapturer = () => {
169+
return this._binder.nativeModule.resumeVideoCapturer(ControllableModuleType.GROUP_CALL, this._roomId);
170+
};
161171
}

src/types/Call.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,11 @@ export interface DirectCallProperties {
335335

336336
/** DirectCall */
337337
type JSDirectCallModule = AsJSDirectCall<NativeDirectCallModule>;
338-
type JSDirectCallMediaDeviceControl = AsJSInterface<JSMediaDeviceControl, 'android', 'selectAudioDevice'>;
338+
type JSDirectCallMediaDeviceControl = AsJSInterface<
339+
JSMediaDeviceControl,
340+
'android',
341+
'selectAudioDevice' | 'resumeVideoCapturer'
342+
>;
339343

340344
export interface DirectCallMethods extends JSDirectCallModule, JSDirectCallMediaDeviceControl {
341345
addListener(listener: Partial<DirectCallListener>): () => void;

src/types/NativeModule.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ export interface NativeMediaDeviceControl {
8181
selectVideoDevice(type: ControllableModuleType, identifier: string, device: VideoDevice): Promise<void>;
8282
/** @platform Android **/
8383
selectAudioDevice(type: ControllableModuleType, identifier: string, device: AudioDevice): Promise<void>;
84+
/** @platform Android **/
85+
resumeVideoCapturer(type: ControllableModuleType, identifier: string): void;
8486
}
8587

8688
export interface NativeDirectCallModule {

src/types/Participant.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { User } from './User';
2-
import { JSMediaDeviceControl } from './index';
2+
import type { AsJSInterface, JSMediaDeviceControl } from './index';
33

44
export interface ParticipantProperties {
55
participantId: string;
@@ -18,10 +18,14 @@ export interface ParticipantProperties {
1818

1919
type JSLocalParticipantMediaDeviceControl = Pick<
2020
JSMediaDeviceControl,
21-
'muteMicrophone' | 'unmuteMicrophone' | 'switchCamera' | 'startVideo' | 'stopVideo'
21+
'muteMicrophone' | 'unmuteMicrophone' | 'switchCamera' | 'startVideo' | 'stopVideo' | 'resumeVideoCapturer'
2222
>;
2323

24-
export type LocalParticipantMethods = JSLocalParticipantMediaDeviceControl;
24+
export type LocalParticipantMethods = AsJSInterface<
25+
JSLocalParticipantMediaDeviceControl,
26+
'android',
27+
'resumeVideoCapturer'
28+
>;
2529

2630
export enum ParticipantState {
2731
ENTERED = 'ENTERED',

0 commit comments

Comments
 (0)