From da9433a6133890c172ef8ffae916683b6312adfc Mon Sep 17 00:00:00 2001 From: kanat Date: Tue, 8 Oct 2024 17:14:22 -0400 Subject: [PATCH] add docs --- .../video/android/ui/call/CallScreen.kt | 4 + .../android/ui/lobby/CallLobbyViewModel.kt | 8 +- .../video/android/ui/menu/MenuDefinitions.kt | 19 ++- .../video/android/ui/menu/SettingsMenu.kt | 2 + .../Android/02-tutorials/03-livestream.mdx | 6 +- .../03-guides/05-noise-cancellation.mdx | 146 ++++++++++++++++++ .../{05-call-types.mdx => 06-call-types.mdx} | 0 ...live.mdx => 07-keeping-the-call-alive.mdx} | 0 ...erying-calls.mdx => 08-querying-calls.mdx} | 0 ....mdx => 09-permissions-and-moderation.mdx} | 4 +- ...mdx => 10-reactions-and-custom-events.mdx} | 0 .../04-call/02-audio-call-content.mdx | 2 +- docusaurus/shared | 1 + .../api/stream-video-android-core.api | 9 ++ .../io/getstream/video/android/core/Call.kt | 4 + .../video/android/core/StreamVideoImpl.kt | 4 + .../connection/StreamPeerConnectionFactory.kt | 7 + .../core/utils/NoiseCancellationUtils.kt | 44 ++++++ 18 files changed, 244 insertions(+), 16 deletions(-) create mode 100644 docusaurus/docs/Android/03-guides/05-noise-cancellation.mdx rename docusaurus/docs/Android/03-guides/{05-call-types.mdx => 06-call-types.mdx} (100%) rename docusaurus/docs/Android/03-guides/{06-keeping-the-call-alive.mdx => 07-keeping-the-call-alive.mdx} (100%) rename docusaurus/docs/Android/03-guides/{07-querying-calls.mdx => 08-querying-calls.mdx} (100%) rename docusaurus/docs/Android/03-guides/{08-permissions-and-moderation.mdx => 09-permissions-and-moderation.mdx} (96%) rename docusaurus/docs/Android/03-guides/{09-reactions-and-custom-events.mdx => 10-reactions-and-custom-events.mdx} (100%) create mode 120000 docusaurus/shared create mode 100644 stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/utils/NoiseCancellationUtils.kt diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt index 043729ca42..106566e118 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt @@ -94,6 +94,7 @@ import io.getstream.video.android.compose.ui.components.call.renderer.copy import io.getstream.video.android.core.Call import io.getstream.video.android.core.RealtimeConnection import io.getstream.video.android.core.call.state.ChooseLayout +import io.getstream.video.android.core.utils.isEnabled import io.getstream.video.android.filters.video.BlurredBackgroundVideoFilter import io.getstream.video.android.filters.video.VirtualBackgroundVideoFilter import io.getstream.video.android.mock.StreamPreviewDataUtils @@ -461,10 +462,13 @@ fun CallScreen( var isNoiseCancellationEnabled by remember { mutableStateOf(call.isAudioProcessingEnabled()) } + val settings by call.state.settings.collectAsStateWithLifecycle() + val noiseCancellationFeatureEnabled = settings?.audio?.noiseCancellation?.isEnabled == true SettingsMenu( call = call, selectedVideoFilter = selectedVideoFilter, showDebugOptions = showDebugOptions, + noiseCancellationFeatureEnabled = noiseCancellationFeatureEnabled, noiseCancellationEnabled = isNoiseCancellationEnabled, onDismissed = { isShowingSettingMenu = false }, onSelectVideoFilter = { filterIndex -> diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/lobby/CallLobbyViewModel.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/lobby/CallLobbyViewModel.kt index cd2b5ecdee..f900c98ddd 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/lobby/CallLobbyViewModel.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/lobby/CallLobbyViewModel.kt @@ -26,6 +26,7 @@ import io.getstream.chat.android.client.ChatClient import io.getstream.video.android.core.Call import io.getstream.video.android.core.DeviceStatus import io.getstream.video.android.core.StreamVideo +import io.getstream.video.android.core.utils.isAutoOn import io.getstream.video.android.datastore.delegate.StreamUserDataStore import io.getstream.video.android.model.StreamCallId import io.getstream.video.android.model.User @@ -116,7 +117,7 @@ class CallLobbyViewModel @Inject constructor( // based on it val settings = call.state.settings.first { it != null } - val enabled = when (call.camera.status.first()) { + val isCameraEnabled = when (call.camera.status.first()) { is DeviceStatus.NotSelected -> { settings?.video?.cameraDefaultOn ?: false } @@ -131,7 +132,10 @@ class CallLobbyViewModel @Inject constructor( } // enable/disable camera capture (no preview would be visible otherwise) - call.camera.setEnabled(enabled) + call.camera.setEnabled(isCameraEnabled) + + val isNoiseCancellationEnabled = settings?.audio?.noiseCancellation?.isAutoOn ?: false + call.setAudioProcessingEnabled(isNoiseCancellationEnabled) } } diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/MenuDefinitions.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/MenuDefinitions.kt index 35121bcf20..826e9673eb 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/MenuDefinitions.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/MenuDefinitions.kt @@ -47,6 +47,7 @@ import io.getstream.video.android.ui.menu.base.SubMenuItem */ fun defaultStreamMenu( showDebugOptions: Boolean = false, + noiseCancellationFeatureEnabled: Boolean = false, noiseCancellationEnabled: Boolean = false, codecList: List, onCodecSelected: (MediaCodecInfo) -> Unit, @@ -111,14 +112,16 @@ fun defaultStreamMenu( action = onToggleScreenShare, ), ) - add( - ActionMenuItem( - title = "Noise cancellation", - icon = Icons.Default.SpatialAudioOff, - highlight = noiseCancellationEnabled, - action = onNoiseCancellation, - ), - ) + if (noiseCancellationFeatureEnabled) { + add( + ActionMenuItem( + title = "Noise cancellation", + icon = Icons.Default.SpatialAudioOff, + highlight = noiseCancellationEnabled, + action = onNoiseCancellation, + ), + ) + } if (showDebugOptions) { add( SubMenuItem( diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt index fada752c1c..9c4d544de9 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt @@ -68,6 +68,7 @@ internal fun SettingsMenu( call: Call, selectedVideoFilter: Int, showDebugOptions: Boolean, + noiseCancellationFeatureEnabled: Boolean, noiseCancellationEnabled: Boolean, onDismissed: () -> Unit, onSelectVideoFilter: (Int) -> Unit, @@ -208,6 +209,7 @@ internal fun SettingsMenu( }, items = defaultStreamMenu( showDebugOptions = showDebugOptions, + noiseCancellationFeatureEnabled = noiseCancellationFeatureEnabled, noiseCancellationEnabled = noiseCancellationEnabled, codecList = codecInfos, availableDevices = availableDevices, diff --git a/docusaurus/docs/Android/02-tutorials/03-livestream.mdx b/docusaurus/docs/Android/02-tutorials/03-livestream.mdx index 3799426f33..879f44d8ce 100644 --- a/docusaurus/docs/Android/02-tutorials/03-livestream.mdx +++ b/docusaurus/docs/Android/02-tutorials/03-livestream.mdx @@ -363,10 +363,10 @@ It also went into more details about HLS & RTMP-in. There are several advanced features that can improve the livestreaming experience: * ** [Co-hosts](../03-guides/02-joining-creating-calls.mdx) ** You can add members to your livestream with elevated permissions. So you can have co-hosts, moderators etc. -* ** [Custom events](../03-guides/09-reactions-and-custom-events.mdx) ** You can use custom events on the call to share any additional data. Think about showing the score for a game, or any other realtime use case. -* ** [Reactions & Chat](../03-guides/09-reactions-and-custom-events.mdx) ** Users can react to the livestream, and you can add chat. This makes for a more engaging experience. +* ** [Custom events](../03-guides/10-reactions-and-custom-events.mdx) ** You can use custom events on the call to share any additional data. Think about showing the score for a game, or any other realtime use case. +* ** [Reactions & Chat](../03-guides/10-reactions-and-custom-events.mdx) ** Users can react to the livestream, and you can add chat. This makes for a more engaging experience. * ** [Notifications](../06-advanced/01-ringing.mdx) ** You can notify users via push notifications when the livestream starts -* ** [Recording](../06-advanced/06-recording.mdx) ** The call recording functionality allows you to record the call with various options and layouts +* ** [Recording](../06-advanced/09-recording.mdx) ** The call recording functionality allows you to record the call with various options and layouts ### Recap diff --git a/docusaurus/docs/Android/03-guides/05-noise-cancellation.mdx b/docusaurus/docs/Android/03-guides/05-noise-cancellation.mdx new file mode 100644 index 0000000000..7f96c23f39 --- /dev/null +++ b/docusaurus/docs/Android/03-guides/05-noise-cancellation.mdx @@ -0,0 +1,146 @@ +--- +title: Noise Cancellation +description: How to implement noise cancellation in Stream Video Android SDK +--- + +Noise Cancellation capabilities of our Android Video SDK can be enabled by installing our NoiseCancellation package. Under the hood, this package uses the technology developed by krisp.ai. + +## Installation + +### Add the SDK to your project + +To add the Stream Video Noise Cancellation SDK, open your app's `build.gradle.kts` file and add the following dependency: +```kotlin +dependencies { + implementation(libs.stream.video.android.noise.cancellation) +} +``` + +Make sure you have the correct version specified in your `libs.versions.toml` file: + +```toml +[versions] +streamNoiseCancellation = "1.0.1" + +[libraries] +stream-video-android-noise-cancellation = { module = "io.getstream:stream-video-android-noise-cancellation", version.ref = "streamNoiseCancellation" } +``` + +## Integration + +Our Android SDK provides a utility component that makes the integration smoother. You'll need to create a `NoiseCancellation` instance and pass it to the `StreamVideoBuilder` when initializing the SDK. +```kotlin +import io.getstream.video.android.core.StreamVideoBuilder +import io.getstream.video.android.noise.cancellation.NoiseCancellation + +// ... + +val noiseCancellation = NoiseCancellation(context) +val streamVideo = StreamVideoBuilder( + context = context, + apiKey = apiKey, + user = user, + token = token, + // ... other configuration options + audioProcessing = noiseCancellation +).build() + +// ... +``` + +## Feature availability + +The availability of noise cancellation is controlled by the call settings. You can check the availability and status of noise cancellation through the `Call` object: + +```kotlin +val call: Call = // ... obtain your call object +val noiseCancellationMode = call.state.settings.value?.audio?.noiseCancellation?.mode +``` + +There are three possible modes for noise cancellation: + +### Available + +```kotlin +if (noiseCancellationMode == NoiseCancellationSettings.Mode.Available) { + // The feature is enabled on the dashboard and available for the call + // You can present noise cancellation toggle UI in your application +} +``` + +The feature has been enabled on the dashboard and it's available for the call. In this case, you are free to present any noise cancellation toggle UI in your application. + +:::info +Even though the feature may be enabled for your call, you should note that NoiseCancellation is a very performance-heavy process. For that reason, it's recommended to only allow the feature on devices with sufficient processing power. + +While there isn't a definitive way to determine if a device can handle noise cancellation efficiently, you can use the following method to check for advanced audio processing capabilities: + +```kotlin +import android.content.pm.PackageManager + +val context: Context = // ... obtain your context +val hasAdvancedAudioProcessing = context.packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_PRO) +``` + +This can serve as an indicator of whether the device might be capable of handling noise cancellation efficiently. Devices with this feature are more likely to have the necessary hardware to support performance-intensive audio processing tasks. + +For the most accurate assessment of noise cancellation performance, you may want to consider implementing your own benchmarking or testing mechanism on different device models. +::: + +For more info, you can refer to our UI docs about Noise Cancellation. + +### Disabled + +````kotlin +if (noiseCancellationMode == NoiseCancellationSettings.Mode.Disabled) { + // The feature is not enabled on the dashboard or not available for the call + // You should hide any noise cancellation toggle UI in your application +} +```` + +The feature hasn't been enabled on the dashboard or the feature isn't available for the call. In this case, you should hide any noise cancellation toggle UI in your application. + +### AutoOn + +````kotlin +if (noiseCancellationMode == NoiseCancellationSettings.Mode.AutoOn) { + // Noise cancellation is automatically enabled +} +```` + +Similar to `Available` with the difference that if possible, the StreamVideo SDK will enable the filter automatically, when the user joins the call. + +:::note +The requirements for `AutoOn` to work properly are: + +1. A `NoiseCancellation` instance provided when you initialize StreamVideo: + ```kotlin + val noiseCancellation = NoiseCancellation(context) + val streamVideo = StreamVideoBuilder( + // ... other parameters + audioProcessing = noiseCancellation + ).build() + ``` +2. Device has sufficient processing power (you can use the `FEATURE_AUDIO_PRO` check as an indicator) +::: + + +## Activate/Deactivate the filter + +To toggle noise cancellation during a call, you can use the `toggleAudioProcessing()` method on the `StreamVideo` instance: + +```kotlin +val streamVideo: StreamVideo = // ... obtain your StreamVideo instance + +// Check if audio processing (noise cancellation) is enabled +val isAudioProcessingEnabled = streamVideo.isAudioProcessingEnabled() + +// Toggle noise cancellation +val isEnabled = streamVideo.toggleAudioProcessing() + +// Or using the setAudioProcessingEnabled method +streamVideo.setAudioProcessingEnabled(!isAudioProcessingEnabled) +``` + +Note that toggling noise cancellation affects all ongoing and future calls for the current `StreamVideo` instance. + diff --git a/docusaurus/docs/Android/03-guides/05-call-types.mdx b/docusaurus/docs/Android/03-guides/06-call-types.mdx similarity index 100% rename from docusaurus/docs/Android/03-guides/05-call-types.mdx rename to docusaurus/docs/Android/03-guides/06-call-types.mdx diff --git a/docusaurus/docs/Android/03-guides/06-keeping-the-call-alive.mdx b/docusaurus/docs/Android/03-guides/07-keeping-the-call-alive.mdx similarity index 100% rename from docusaurus/docs/Android/03-guides/06-keeping-the-call-alive.mdx rename to docusaurus/docs/Android/03-guides/07-keeping-the-call-alive.mdx diff --git a/docusaurus/docs/Android/03-guides/07-querying-calls.mdx b/docusaurus/docs/Android/03-guides/08-querying-calls.mdx similarity index 100% rename from docusaurus/docs/Android/03-guides/07-querying-calls.mdx rename to docusaurus/docs/Android/03-guides/08-querying-calls.mdx diff --git a/docusaurus/docs/Android/03-guides/08-permissions-and-moderation.mdx b/docusaurus/docs/Android/03-guides/09-permissions-and-moderation.mdx similarity index 96% rename from docusaurus/docs/Android/03-guides/08-permissions-and-moderation.mdx rename to docusaurus/docs/Android/03-guides/09-permissions-and-moderation.mdx index 5b4fb08077..667ea8f8de 100644 --- a/docusaurus/docs/Android/03-guides/08-permissions-and-moderation.mdx +++ b/docusaurus/docs/Android/03-guides/09-permissions-and-moderation.mdx @@ -72,12 +72,12 @@ The permissions are required and any usage of the `Call` object without them may ::: In order to notify an inconsistency the SDK will log a warning when `Call.join()` is being called without the required permissions. -This is completely ok, if you have a [call type](./05-call-types.mdx) which does not require streaming audio or video from the users device (e.g. `audio_room` or live broadcast where the user is only a guest and listens in to the stream). +This is completely ok, if you have a [call type](./06-call-types.mdx) which does not require streaming audio or video from the users device (e.g. `audio_room` or live broadcast where the user is only a guest and listens in to the stream). The SDK by default will check for runtime permissions based on call capabilities, so if your call requires audio to be sent, the SDK will expect that the `android.Manifest.permission.RECORD_AUDIO` is granted. :::warning -If you are not overriding the `runForegroundServiceForCalls` flag to `false` in the `StreamVideoBuilder` the resulting foreground service that starts for [keeping the call alive](./06-keeping-the-call-alive.mdx) can not run without the permissions and will crash with a detailed message. +If you are not overriding the `runForegroundServiceForCalls` flag to `false` in the `StreamVideoBuilder` the resulting foreground service that starts for [keeping the call alive](./07-keeping-the-call-alive.mdx) can not run without the permissions and will crash with a detailed message. ::: If you wish to override the behavior on which permissions are required for your calls you can provide a new implementation of `StreamPermissionCheck` to the `StreamVideoBuilder`. diff --git a/docusaurus/docs/Android/03-guides/09-reactions-and-custom-events.mdx b/docusaurus/docs/Android/03-guides/10-reactions-and-custom-events.mdx similarity index 100% rename from docusaurus/docs/Android/03-guides/09-reactions-and-custom-events.mdx rename to docusaurus/docs/Android/03-guides/10-reactions-and-custom-events.mdx diff --git a/docusaurus/docs/Android/04-ui-components/04-call/02-audio-call-content.mdx b/docusaurus/docs/Android/04-ui-components/04-call/02-audio-call-content.mdx index d2bfae4af4..443b928721 100644 --- a/docusaurus/docs/Android/04-ui-components/04-call/02-audio-call-content.mdx +++ b/docusaurus/docs/Android/04-ui-components/04-call/02-audio-call-content.mdx @@ -5,7 +5,7 @@ The `AudioCallContent` component is an alternative to the [`CallContent`](./1-ca :::note The `AudioCallContent` by itself does not make the call audio only. In order to have true audio only call you must update the capabilities of the call type and disable video via the Stream dashboard. -The call can still stream video if this is allowed by the call configuration. See [call types](../.././03-guides/05-call-types.mdx) for more details. +The call can still stream video if this is allowed by the call configuration. See [call types](../.././03-guides/06-call-types.mdx) for more details. ::: This component renders a call UI similar to the [ringing calls](./05-ringing-call.mdx) UI and has parameters (without the `videoRenderer` etc..) similar to [`CallContent`](./01-call-content.mdx) component. diff --git a/docusaurus/shared b/docusaurus/shared new file mode 120000 index 0000000000..61347b5d2d --- /dev/null +++ b/docusaurus/shared @@ -0,0 +1 @@ +/Users/kanat/.nvm/versions/node/v20.10.0/bin/../lib/node_modules/stream-chat-docusaurus-cli/shared \ No newline at end of file diff --git a/stream-video-android-core/api/stream-video-android-core.api b/stream-video-android-core/api/stream-video-android-core.api index cbb1fc5246..52f4160475 100644 --- a/stream-video-android-core/api/stream-video-android-core.api +++ b/stream-video-android-core/api/stream-video-android-core.api @@ -62,6 +62,7 @@ public final class io/getstream/video/android/core/Call { public final fun sendReaction (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun sendReaction$default (Lio/getstream/video/android/core/Call;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun setAudioFilter (Lio/getstream/video/android/core/call/audio/InputAudioFilter;)V + public final fun setAudioProcessingEnabled (Z)V public final fun setVideoFilter (Lio/getstream/video/android/core/call/video/VideoFilter;)V public final fun setVisibility (Ljava/lang/String;Lstream/video/sfu/models/TrackType;Z)V public final fun startHLS (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -1042,6 +1043,7 @@ public final class io/getstream/video/android/core/call/connection/StreamPeerCon public final fun makePeerConnection (Lkotlinx/coroutines/CoroutineScope;Lorg/webrtc/PeerConnection$RTCConfiguration;Lio/getstream/video/android/core/model/StreamPeerType;Lorg/webrtc/MediaConstraints;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;I)Lio/getstream/video/android/core/call/connection/StreamPeerConnection; public static synthetic fun makePeerConnection$default (Lio/getstream/video/android/core/call/connection/StreamPeerConnectionFactory;Lkotlinx/coroutines/CoroutineScope;Lorg/webrtc/PeerConnection$RTCConfiguration;Lio/getstream/video/android/core/model/StreamPeerType;Lorg/webrtc/MediaConstraints;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;IILjava/lang/Object;)Lio/getstream/video/android/core/call/connection/StreamPeerConnection; public final fun makeVideoTrack (Lorg/webrtc/VideoSource;Ljava/lang/String;)Lorg/webrtc/VideoTrack; + public final fun setAudioProcessingEnabled (Z)V public final fun setAudioRecordDataCallback (Lkotlin/jvm/functions/Function4;)V public final fun setAudioSampleCallback (Lkotlin/jvm/functions/Function1;)V public final fun toggleAudioProcessing ()Z @@ -4574,6 +4576,13 @@ public final class io/getstream/video/android/core/utils/MinimalSdpParser { public final fun setSdp (Ljava/lang/String;)V } +public final class io/getstream/video/android/core/utils/NoiseCancellationUtilsKt { + public static final fun isAutoOn (Lorg/openapitools/client/models/NoiseCancellationSettings;)Z + public static final fun isAvailable (Lorg/openapitools/client/models/NoiseCancellationSettings;)Z + public static final fun isDisabled (Lorg/openapitools/client/models/NoiseCancellationSettings;)Z + public static final fun isEnabled (Lorg/openapitools/client/models/NoiseCancellationSettings;)Z +} + public final class io/getstream/video/android/core/utils/RtpMapAttribute { public fun (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V public final fun component1 ()I diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/Call.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/Call.kt index ffc5abe47b..a0b0874866 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/Call.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/Call.kt @@ -1072,6 +1072,10 @@ public class Call( return clientImpl.isAudioProcessingEnabled() } + fun setAudioProcessingEnabled(enabled: Boolean) { + return clientImpl.setAudioProcessingEnabled(enabled) + } + fun toggleAudioProcessing(): Boolean { return clientImpl.toggleAudioProcessing() } diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoImpl.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoImpl.kt index 75a44283a7..ddbadd449a 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoImpl.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoImpl.kt @@ -1115,6 +1115,10 @@ internal class StreamVideoImpl internal constructor( return peerConnectionFactory.isAudioProcessingEnabled() } + internal fun setAudioProcessingEnabled(enabled: Boolean) { + return peerConnectionFactory.setAudioProcessingEnabled(enabled) + } + internal fun toggleAudioProcessing(): Boolean { return peerConnectionFactory.toggleAudioProcessing() } diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/connection/StreamPeerConnectionFactory.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/connection/StreamPeerConnectionFactory.kt index 95fe84abea..ca3428c6e7 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/connection/StreamPeerConnectionFactory.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/connection/StreamPeerConnectionFactory.kt @@ -368,6 +368,13 @@ public class StreamPeerConnectionFactory( return audioProcessing?.isEnabled ?: false } + /** + * Sets the audio processing on or off. + */ + public fun setAudioProcessingEnabled(enabled: Boolean) { + audioProcessing?.isEnabled = enabled + } + /** * Toggles the audio processing on and off. */ diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/utils/NoiseCancellationUtils.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/utils/NoiseCancellationUtils.kt new file mode 100644 index 0000000000..452a139b4f --- /dev/null +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/utils/NoiseCancellationUtils.kt @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014-2024 Stream.io Inc. All rights reserved. + * + * Licensed under the Stream License; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://github.com/GetStream/stream-video-android/blob/main/LICENSE + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.getstream.video.android.core.utils + +import org.openapitools.client.models.NoiseCancellationSettings + +/** + * Returns true if the noise cancellation mode is "auto-on". + */ +val NoiseCancellationSettings.isAutoOn get() = mode == NoiseCancellationSettings.Mode.AutoOn + +/** + * Returns true if the noise cancellation mode is "available". + */ +val NoiseCancellationSettings.isAvailable get() = mode == NoiseCancellationSettings.Mode.Available + +/** + * Returns true if the noise cancellation mode is "disabled". + */ +val NoiseCancellationSettings.isDisabled get() = mode == NoiseCancellationSettings.Mode.Disabled + +/** + * Returns true if the noise cancellation mode is "auto-on" or "available". + */ +val NoiseCancellationSettings.isEnabled get() = when (mode) { + NoiseCancellationSettings.Mode.Available, + NoiseCancellationSettings.Mode.AutoOn, + -> true + else -> false +}