diff --git a/Packages/StreamVideo/Runtime/Core/LowLevelClient/RtcSession.cs b/Packages/StreamVideo/Runtime/Core/LowLevelClient/RtcSession.cs index 185c64f4..76d66580 100644 --- a/Packages/StreamVideo/Runtime/Core/LowLevelClient/RtcSession.cs +++ b/Packages/StreamVideo/Runtime/Core/LowLevelClient/RtcSession.cs @@ -1421,7 +1421,7 @@ private void OnSfuConnectionQualityChanged(ConnectionQualityChanged connectionQu private void OnSfuAudioLevelChanged(AudioLevelChanged audioLevelChanged) { - _sfuTracer?.Trace("audioLevelChanged", audioLevelChanged); + // StreamTODO: Implement OnSfuAudioLevelChanged } diff --git a/Packages/StreamVideo/Runtime/Libs/AppInfo/UnityApplicationInfo.cs b/Packages/StreamVideo/Runtime/Libs/AppInfo/UnityApplicationInfo.cs index 8b294e7f..0e8b4d81 100644 --- a/Packages/StreamVideo/Runtime/Libs/AppInfo/UnityApplicationInfo.cs +++ b/Packages/StreamVideo/Runtime/Libs/AppInfo/UnityApplicationInfo.cs @@ -5,23 +5,58 @@ namespace StreamVideo.Libs.AppInfo public class UnityApplicationInfo : IApplicationInfo { public string Engine => "Unity"; - + public string EngineVersion => Application.unityVersion; - + public string Platform => Application.platform.ToString(); - + public string OperatingSystem => SystemInfo.operatingSystem; - public string OperatingSystemFamily => SystemInfo.operatingSystemFamily.ToString(); + + public string OperatingSystemFamily => GetOsFamily(); + public string CpuArchitecture => SystemInfo.processorType; public int MemorySize => SystemInfo.systemMemorySize; - + public int GraphicsMemorySize => SystemInfo.graphicsMemorySize; public string ScreenSize => Screen.width + "x" + Screen.height; - + //StreamTodo: solve this, the deviceName is just a local name so perhaps not something we want - public string DeviceName => SystemInfo.deviceName; + public string DeviceName => SystemInfo.deviceName; + public string DeviceModel => SystemInfo.deviceModel; + + private static string GetOsFamily() + { + switch (Application.platform) + { + case RuntimePlatform.Android: + return "Android"; + + case RuntimePlatform.IPhonePlayer: + return "iOS"; + + case RuntimePlatform.tvOS: + return "tvOS"; + + case RuntimePlatform.OSXPlayer: + case RuntimePlatform.OSXEditor: + return "macOS"; + + case RuntimePlatform.WindowsPlayer: + case RuntimePlatform.WindowsEditor: + return "Windows"; + + case RuntimePlatform.LinuxPlayer: + case RuntimePlatform.LinuxServer: + case RuntimePlatform.LinuxEditor: + return "Linux"; + + default: + var family = SystemInfo.operatingSystemFamily; + return family != UnityEngine.OperatingSystemFamily.Other ? family.ToString() : "Unknown"; + } + } } -} \ No newline at end of file +} diff --git a/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Plugins/Android/libwebrtc.aar b/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Plugins/Android/libwebrtc.aar index 9153880b..1b3a9a72 100644 Binary files a/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Plugins/Android/libwebrtc.aar and b/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Plugins/Android/libwebrtc.aar differ diff --git a/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/Context.cs b/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/Context.cs index a06b9204..ea3ec37b 100644 --- a/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/Context.cs +++ b/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/Context.cs @@ -411,6 +411,11 @@ public void StopAudioPlayback() { NativeMethods.StopAudioPlayback(self); } + + public void SetAndroidAudioUsageMode(int usage) + { + NativeMethods.SetAndroidAudioUsageMode(self, usage); + } #endif internal void BatchUpdate(IntPtr batchData) diff --git a/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/WebRTC.cs b/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/WebRTC.cs index fb9bbf4c..9472218c 100644 --- a/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/WebRTC.cs +++ b/Packages/StreamVideo/Runtime/Libs/io.stream.unity.webrtc/Runtime/Scripts/WebRTC.cs @@ -715,6 +715,26 @@ public enum NativeLoggingSeverity None, }; +#if UNITY_ANDROID && !UNITY_EDITOR + /// + /// Android audio usage modes for Oboe audio streams. + /// + public enum AndroidAudioUsageMode + { + /// + /// Media usage mode - suitable for media playback (e.g., music, video). + /// Use this for viewers/consumers in livestream scenarios. + /// + Media = 1, + + /// + /// Voice communication usage mode - optimized for voice calls. + /// Use this for broadcasters/hosts in livestream scenarios. + /// + VoiceCommunication = 2 + } +#endif + /// /// Provides utilities and management functions for integrating WebRTC functionality. /// @@ -1133,6 +1153,20 @@ public static void StopAudioPlayback() Context.StopAudioPlayback(); } + /// + /// Sets the Android audio usage mode for audio playback. + /// Changing the usage mode during an active call will restart the audio stream. + /// + /// The audio usage mode to set (Media or VoiceCommunication) + /// + /// - Use VoiceCommunication for broadcasters/hosts in livestream scenarios + /// - Use Media for viewers/consumers in livestream scenarios + /// + public static void SetAndroidAudioUsageMode(AndroidAudioUsageMode usage) + { + Context.SetAndroidAudioUsageMode((int)usage); + } + #endif class CallbackObject { @@ -1837,6 +1871,9 @@ public static extern IntPtr CreateVideoRenderer( [DllImport(WebRTC.Lib)] public static extern void GetAudioProcessingModuleConfig(IntPtr context, out bool enabled, out bool echoCancellationEnabled, out bool autoGainEnabled, out bool noiseSuppressionEnabled, out int noiseSuppressionLevel); + + [DllImport(WebRTC.Lib)] + public static extern void SetAndroidAudioUsageMode(IntPtr context, int usage); #endif } diff --git a/Packages/StreamVideo/Tests/Runtime/CallsTests.cs b/Packages/StreamVideo/Tests/Runtime/CallsTests.cs index 75f37825..fd59e6d5 100644 --- a/Packages/StreamVideo/Tests/Runtime/CallsTests.cs +++ b/Packages/StreamVideo/Tests/Runtime/CallsTests.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using NUnit.Framework; +using StreamVideo.Core; using StreamVideo.Core.StatefulModels.Tracks; using StreamVideo.Tests.Shared; using UnityEngine; @@ -35,27 +36,32 @@ public IEnumerator When_client_joins_call_with_video_expect_receiving_video_trac private async Task When_client_joins_call_with_video_expect_receiving_video_track_Async( ITestClient clientA, ITestClient clientB) { - var streamCall = await clientA.JoinRandomCallAsync(); + var clientACall = await clientA.JoinRandomCallAsync(); var cameraDevice = await TestUtils.TryGetFirstWorkingCameraDeviceAsync(clientA.Client); Debug.Log("Selected camera device: " + cameraDevice); clientA.Client.VideoDeviceManager.SelectDevice(cameraDevice, enable: true); - var call = await clientB.Client.JoinCallAsync(streamCall.Type, streamCall.Id, create: false, + var clientBCall = await clientB.Client.JoinCallAsync(clientACall.Type, clientACall.Id, create: false, ring: false, notify: false); - var otherParticipant = call.Participants.First(p => !p.IsLocalParticipant); + // Wait for client B to get client A participant + await WaitForConditionAsync(() + => clientBCall.Participants.Any(p => p.SessionId == clientACall.GetLocalParticipant().SessionId)); + + var clientAParticipant = clientBCall.Participants.First(p => p.SessionId == clientACall.GetLocalParticipant().SessionId); + clientAParticipant.UpdateRequestedVideoResolution(VideoResolution.Res_720p); StreamVideoTrack streamTrack = null; - if (otherParticipant.VideoTrack != null) + if (clientAParticipant.VideoTrack != null) { - streamTrack = (StreamVideoTrack)otherParticipant.VideoTrack; + streamTrack = (StreamVideoTrack)clientAParticipant.VideoTrack; } else { - otherParticipant.TrackAdded += (_, track) => { streamTrack = (StreamVideoTrack)track; }; + clientAParticipant.TrackAdded += (_, track) => { streamTrack = (StreamVideoTrack)track; }; await WaitForConditionAsync(() => streamTrack != null); } diff --git a/Packages/StreamVideo/Tests/Shared/TestClient.cs b/Packages/StreamVideo/Tests/Shared/TestClient.cs index 2bb37c5e..9816146d 100644 --- a/Packages/StreamVideo/Tests/Shared/TestClient.cs +++ b/Packages/StreamVideo/Tests/Shared/TestClient.cs @@ -23,6 +23,11 @@ public TestClient(IStreamVideoClient client) public async Task JoinRandomCallAsync() { + if (Client.ActiveCall != null) + { + await Client.ActiveCall.LeaveAsync(); + } + var callId = Guid.NewGuid().ToString(); return await Client.JoinCallAsync(StreamCallType.Default, callId, create: true, ring: false, notify: false);