Skip to content

Commit b2c4b5a

Browse files
committed
Expose setting audio usage mode via the client
1 parent 1876bc6 commit b2c4b5a

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

Packages/StreamVideo/Runtime/Core/IStreamVideoClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,11 @@ Task<IStreamCall> GetCallAsync(StreamCallType callType, string callId,
139139
/// Call this resume audio playback if it was previously paused using <see cref="PauseAndroidAudioPlayback"/>.
140140
/// </summary>
141141
void ResumeAndroidAudioPlayback();
142+
143+
/// <summary>
144+
/// Set Android Audio usage mode
145+
/// </summary>
146+
/// <param name="usageMode"></param>
147+
void SetAndroidAudioUsageMode(AndroidAudioUsageMode usageMode);
142148
}
143149
}

Packages/StreamVideo/Runtime/Core/StreamVideoClient.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
using Unity.WebRTC;
3434
using UnityEngine;
3535
using Cache = StreamVideo.Core.State.Caches.Cache;
36+
using AndroidAudioUsageMode = StreamVideo.Core.AndroidAudioUsageMode;
3637

3738
namespace StreamVideo.Core
3839
{
@@ -50,6 +51,24 @@ public enum DisconnectReason
5051

5152
VideoServerDisconnected,
5253
}
54+
55+
/// <summary>
56+
/// Android audio usage modes for Oboe audio streams.
57+
/// </summary>
58+
public enum AndroidAudioUsageMode
59+
{
60+
/// <summary>
61+
/// Media usage mode - suitable for media playback (e.g., music, video).
62+
/// Use this for viewers/consumers in livestream scenarios.
63+
/// </summary>
64+
Media = 1,
65+
66+
/// <summary>
67+
/// Voice communication usage mode - optimized for voice calls.
68+
/// Use this for broadcasters/hosts in livestream scenarios.
69+
/// </summary>
70+
VoiceCommunication = 2
71+
}
5372

5473
public delegate void CallHandler(IStreamCall call);
5574

@@ -335,6 +354,17 @@ public void SetAudioProcessingModule(bool enabled, bool echoCancellationEnabled,
335354

336355
public void ResumeAndroidAudioPlayback() => InternalLowLevelClient.RtcSession.ResumeAndroidAudioPlayback();
337356

357+
public void SetAndroidAudioUsageMode(AndroidAudioUsageMode usageMode)
358+
{
359+
#if STREAM_NATIVE_AUDIO
360+
WebRTC.SetAndroidAudioUsageMode((Unity.WebRTC.AndroidAudioUsageMode)usageMode);
361+
_logs.Warning("Audio Playback is paused. This stops all audio coming from StreamVideo SDK on Android platform.");
362+
#else
363+
throw new NotSupportedException(
364+
$"{nameof(SetAndroidAudioUsageMode)} is only supported on Android platform.");
365+
#endif
366+
}
367+
338368
#region IStreamVideoClientEventsListener
339369

340370
event Action IStreamVideoClientEventsListener.Destroyed

Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/WebRTC.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,6 @@ public enum NativeLoggingSeverity
715715
None,
716716
};
717717

718-
#if UNITY_ANDROID && !UNITY_EDITOR
719718
/// <summary>
720719
/// Android audio usage modes for Oboe audio streams.
721720
/// </summary>
@@ -733,7 +732,6 @@ public enum AndroidAudioUsageMode
733732
/// </summary>
734733
VoiceCommunication = 2
735734
}
736-
#endif
737735

738736
/// <summary>
739737
/// Provides utilities and management functions for integrating WebRTC functionality.

0 commit comments

Comments
 (0)