Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RN-330: Virtual background support #1396

Merged
merged 42 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d734f38
initial `react-native-video-plugin` changes
stanwolverine May 20, 2024
381a58d
renamed `100mslive` dir to `hms` dir
stanwolverine May 20, 2024
b2d2deb
added gradle wrapper
stanwolverine May 20, 2024
4fb4c32
added react-native-hms as peerDependencies in react-native-video-plugin
stanwolverine May 20, 2024
c479cfc
configured video-plugin lib into room-kit example app
stanwolverine May 21, 2024
08e3eb0
initial video background effect changes
stanwolverine May 22, 2024
f1e49a0
completed virtual background changes
stanwolverine May 28, 2024
65fced1
Merge branch 'develop' into RN-330
stanwolverine May 28, 2024
9732f1a
updated change log file
stanwolverine May 28, 2024
a991249
added loading indicator while applying VB
ygit May 28, 2024
4c137e9
updated example app changelog
ygit May 28, 2024
e9dd74d
Merge branch 'RN-330' of https://github.com/100mslive/react-native-hm…
stanwolverine May 29, 2024
ea9c9a2
released sample app version 2.4.44 (494) ⚛️
ygit May 29, 2024
3c0a4e2
updated uri path in android
ygit May 29, 2024
81d67d7
released sample app version 2.4.45 (495) ⚛️
ygit May 29, 2024
98ec21d
added support for image uri source in virtual background
stanwolverine May 30, 2024
a1a2a4c
added `react-native-image-picker` lib as optional dependency
stanwolverine May 30, 2024
c532797
Merge branch 'RN-330' of https://github.com/100mslive/react-native-hm…
stanwolverine May 30, 2024
8a7557b
hiding image picker options when `react-native-image-picker` lib is n…
stanwolverine May 30, 2024
5a75ff6
released sample app version 2.4.46 (496) ⚛️
ygit May 31, 2024
352ad98
updated ios SDK version
stanwolverine May 31, 2024
974b6eb
Merge branch 'RN-330' of https://github.com/100mslive/react-native-hm…
stanwolverine May 31, 2024
5b46381
updated trunk yaml
ygit May 31, 2024
5507506
moved react-native-video-plugin lib to separate repo
stanwolverine Jun 3, 2024
5baed22
refactor: removed local references of react-native-video-plugin lib
stanwolverine Jun 3, 2024
578e3de
upgraded android sdk version
stanwolverine Jun 3, 2024
d2f6a86
build: android - renamed local reference of react-native-hms project
stanwolverine Jun 3, 2024
63c6796
feat: conditonally using `react-native-video-plugin` lib in `react-na…
stanwolverine Jun 3, 2024
745a7b3
released sample app version 2.4.49 (499) ⚛️
ygit Jun 4, 2024
25e2c34
style(prebuilt): removed static VB images from prebuilt, Improved pre…
stanwolverine Jun 6, 2024
772865a
fix(prebuilt): app going into PIP when selecting image for virtual ba…
stanwolverine Jun 6, 2024
2de965d
Merge branch 'RN-330' of https://github.com/100mslive/react-native-hm…
stanwolverine Jun 6, 2024
25ade10
refactor: removed warning coming because of usage of deprecated apis
stanwolverine Jun 6, 2024
5c5da1e
released sample app version 2.4.50 (500) ⚛️
ygit Jun 6, 2024
bfa9f98
released sample app version 2.4.51 (501) ⚛️
ygit Jun 7, 2024
bda3938
fix(prebuilt): VB option showing for peer who can't publish video
stanwolverine Jun 7, 2024
f2293d7
released beta.0 version
ygit Jun 7, 2024
ec04289
added virtual background sample app
stanwolverine Jun 7, 2024
c351bc0
updated beta package version
ygit Jun 7, 2024
96e7be5
updated package versions
ygit Jun 10, 2024
bf23b1b
updated Example app changelog
ygit Jun 10, 2024
c2ba5ce
updated package versions
ygit Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ lint:
- osv-scanner
enabled:
- [email protected]
- [email protected].0
- [email protected].1
- [email protected]
- [email protected]
- [email protected].91
- [email protected].1
- trufflehog@3.76.0
- [email protected].114
- [email protected].4
- trufflehog@3.77.0
- [email protected]
- [email protected]
- [email protected]
Expand All @@ -25,8 +25,8 @@ lint:
- [email protected]
- [email protected]
- git-diff-check
- markdownlint@0.40.0
- [email protected].1
- markdownlint@0.41.0
- [email protected].2
runtimes:
enabled:
- [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,20 @@ class HMSManager(reactContext: ReactApplicationContext) :
}
// endregion

// region Warning on JS side
@ReactMethod
fun addListener(eventName: String) {
// Keep: Required for RN built in Event Emitter Calls.
// Fixes Warning - `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
}

@ReactMethod
fun removeListeners(count: Int) {
// Keep: Required for RN built in Event Emitter Calls.
// Fixes Warning - `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
}
// endregion

// region ActivityLifecycleCallbacks

override fun onActivityCreated(
Expand Down
16 changes: 8 additions & 8 deletions packages/react-native-hms/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ PODS:
- HMSHLSPlayerSDK (0.0.2):
- HMSAnalyticsSDK (= 0.0.2)
- HMSNoiseCancellationModels (1.0.0)
- HMSSDK (1.9.0):
- HMSSDK (1.11.0):
- HMSAnalyticsSDK (= 0.0.2)
- HMSWebRTC (= 1.0.6168)
- HMSWebRTC (1.0.6168)
- HMSWebRTC (= 1.0.6169)
- HMSWebRTC (1.0.6169)
- libevent (2.1.12)
- OpenSSL-Universal (1.1.180)
- Permission-Camera (3.4.0):
Expand Down Expand Up @@ -293,11 +293,11 @@ PODS:
- React-Core
- react-native-document-picker (8.2.2):
- React-Core
- react-native-hms (1.10.5):
- react-native-hms (1.10.6):
- HMSBroadcastExtensionSDK (= 0.0.9)
- HMSHLSPlayerSDK (= 0.0.2)
- HMSNoiseCancellationModels (= 1.0.0)
- HMSSDK (= 1.9.0)
- HMSSDK (= 1.11.0)
- React-Core
- react-native-safe-area-context (3.4.1):
- React-Core
Expand Down Expand Up @@ -633,8 +633,8 @@ SPEC CHECKSUMS:
HMSBroadcastExtensionSDK: d80fe325f6c928bd8e5176290b5a4b7ae15d6fbb
HMSHLSPlayerSDK: 6a54ad4d12f3dc2270d1ecd24019d71282a4f6a3
HMSNoiseCancellationModels: a3bda1405a16015632f4bcabd46ce48f35103b02
HMSSDK: 96bdafc1c610aabfecd1155ad7e3c1bc45b3a6cb
HMSWebRTC: a302f0d6c94f7bee94f3265adb7bb1c6569e7ee5
HMSSDK: cdba5b12c080832d135af7bbc4ca6282b0e171ac
HMSWebRTC: 8f51ba33a0e505e17ebf3d7b37bcdca266751a13
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
Permission-Camera: 40f43388fa8a648dc6ced73f145ef329ab3ff3fe
Expand All @@ -653,7 +653,7 @@ SPEC CHECKSUMS:
react-native-avoid-softinput: 71a692888f0c1d426ad9045dc8325773583962cd
react-native-camera: 3eae183c1d111103963f3dd913b65d01aef8110f
react-native-document-picker: cd4d6b36a5207ad7a9e599ebb9eb0c2e84fa0b87
react-native-hms: c874b5220b21f950ca692c03815bbcf8c1522fac
react-native-hms: 75cca28d8cd59476e22f1fed4809a4aded367786
react-native-safe-area-context: 9e40fb181dac02619414ba1294d6c2a807056ab9
react-native-simple-toast: 8ee5d23f0b92b935ab7434cdb65159ce12dfb4b7
React-perflogger: 5a890ca0911669421b7611661e9b58f91c805f5c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ class SampleHandler: RPBroadcastSampleHandler {
userInfo: [NSLocalizedFailureReasonErrorKey: "You are not in a meeting."]))
}
}
break
case RPSampleBufferType.audioApp:
case RPSampleBufferType.audioApp:
_ = self.screenRenderer.process(audioSampleBuffer: sampleBuffer)
break
case RPSampleBufferType.audioMic:
// Handle audio sample buffer for mic audio
break
Expand Down
30 changes: 28 additions & 2 deletions packages/react-native-hms/ios/HMSHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class HMSHelper: NSObject {
isPrebuilt: isPrebuilt)
}

static func getLocalVideoSettings(_ settings: NSDictionary?) -> HMSVideoTrackSettings? {
static func getLocalVideoSettings(_ settings: NSDictionary?, _ videoPlugin: HMSVideoPlugin?) -> HMSVideoTrackSettings? {
if settings === nil {
return nil
}
Expand All @@ -180,6 +180,7 @@ class HMSHelper: NSObject {
let cameraFacingEncoded = HMSHelper.getCameraFacing(cameraFacing)
let initialState = settings?.value(forKey: "initialState") as? String
let initialStateEncoded = HMSHelper.getHMSTrackSettingsInitState(initialState)
let videoPlugins: [HMSVideoPlugin]? = if let videoPlugin = videoPlugin { [videoPlugin] } else { nil }
let hmsTrackSettings = HMSVideoTrackSettings(codec: codec,
resolution: resolution,
maxBitrate: maxBitrate,
Expand All @@ -188,7 +189,7 @@ class HMSHelper: NSObject {
simulcastSettings: nil,
trackDescription: trackDescription,
initialMuteState: initialStateEncoded,
videoPlugins: nil)
videoPlugins: videoPlugins)
return hmsTrackSettings
}

Expand Down Expand Up @@ -291,6 +292,31 @@ class HMSHelper: NSObject {
return nil
}

static func getHMSVideoPlugin(_ videoPluginData: NSDictionary?) -> HMSVideoPlugin? {
guard let videoPluginDict = videoPluginData else {
print(#function, "No Video Plugin data passed!")
return nil
}
guard let videoPluginType = videoPluginDict.value(forKey: "type") as? String else {
print(#function, "No HMSVideoPlugin `type` passed!")
return nil
}
switch videoPluginType {
case "HMSVirtualBackgroundPlugin":
if #available(iOS 15.0, *) {
return HMSVirtualBackgroundPlugin(backgroundImage: nil, blurRadius: 100)
} else {
print(#function, "HMSVirtualBackgroundPlugin is not available below iOS 15.0")
return nil
}
case "HMSVideoFilterPlugin":
return HMSVideoFilterPlugin()
default:
print(#function, "Unknown HMSVideoPlugin `type` passed!")
return nil
}
}

static func getAudioMixerSourceMap() -> [String: HMSAudioNode]? {
return self.audioMixerSourceHashMap
}
Expand Down
22 changes: 22 additions & 0 deletions packages/react-native-hms/ios/HMSManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,28 @@ @interface RCT_EXTERN_MODULE (HMSManager, RCTEventEmitter)
: (RCTPromiseResolveBlock)resolve
: (RCTPromiseRejectBlock)reject)

#pragma mark - Noise Cancellation Plugin

RCT_EXTERN_METHOD(enableVideoPlugin
: (NSDictionary)data
: (RCTPromiseResolveBlock)resolve
: (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(disableVideoPlugin
: (NSDictionary)data
: (RCTPromiseResolveBlock)resolve
: (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(changeVirtualBackground
: (NSDictionary)data
: (RCTPromiseResolveBlock)resolve
: (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(setVideoFilterParameter
: (NSDictionary)data
: (RCTPromiseResolveBlock)resolve
: (RCTPromiseRejectBlock)reject)

#pragma mark - Interactivity Center - Whiteboard

RCT_EXTERN_METHOD(startWhiteboard
Expand Down
46 changes: 46 additions & 0 deletions packages/react-native-hms/ios/HMSManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,52 @@ class HMSManager: RCTEventEmitter {
rnsdk.isNoiseCancellationPluginAvailable(data, resolve, reject)
}

// MARK: - Video Plugin Functions

@objc
func enableVideoPlugin( _ data: NSDictionary,
_ resolve: RCTPromiseResolveBlock?,
_ reject: RCTPromiseRejectBlock?) {
guard let rnsdk = HMSHelper.getHms(data, hmsCollection) else {
reject?("6004", "HMSRNSDK instance not found!", nil)
return
}
rnsdk.enableVideoPlugin(data, resolve, reject)
}

@objc
func disableVideoPlugin(_ data: NSDictionary,
_ resolve: RCTPromiseResolveBlock?,
_ reject: RCTPromiseRejectBlock?) {
guard let rnsdk = HMSHelper.getHms(data, hmsCollection) else {
reject?("6004", "HMSRNSDK instance not found!", nil)
return
}
rnsdk.disableVideoPlugin(data, resolve, reject)
}

@objc
func changeVirtualBackground(_ data: NSDictionary,
_ resolve: RCTPromiseResolveBlock?,
_ reject: RCTPromiseRejectBlock?) {
guard let rnsdk = HMSHelper.getHms(data, hmsCollection) else {
reject?("6004", "HMSRNSDK instance not found!", nil)
return
}
rnsdk.changeVirtualBackground(data, resolve, reject)
}

@objc
func setVideoFilterParameter(_ data: NSDictionary,
_ resolve: RCTPromiseResolveBlock?,
_ reject: RCTPromiseRejectBlock?) {
guard let rnsdk = HMSHelper.getHms(data, hmsCollection) else {
reject?("6004", "HMSRNSDK instance not found!", nil)
return
}
rnsdk.setVideoFilterParameter(data, resolve, reject)
}

// MARK: - Interactivity Center - Whiteboard
@objc
func startWhiteboard(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
Expand Down
Loading
Loading