Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ private void OnSfuConnectionQualityChanged(ConnectionQualityChanged connectionQu

private void OnSfuAudioLevelChanged(AudioLevelChanged audioLevelChanged)
{
_sfuTracer?.Trace("audioLevelChanged", audioLevelChanged);

// StreamTODO: Implement OnSfuAudioLevelChanged
}

Expand Down
51 changes: 43 additions & 8 deletions Packages/StreamVideo/Runtime/Libs/AppInfo/UnityApplicationInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,26 @@ public enum NativeLoggingSeverity
None,
};

#if UNITY_ANDROID && !UNITY_EDITOR
/// <summary>
/// Android audio usage modes for Oboe audio streams.
/// </summary>
public enum AndroidAudioUsageMode
{
/// <summary>
/// Media usage mode - suitable for media playback (e.g., music, video).
/// Use this for viewers/consumers in livestream scenarios.
/// </summary>
Media = 1,

/// <summary>
/// Voice communication usage mode - optimized for voice calls.
/// Use this for broadcasters/hosts in livestream scenarios.
/// </summary>
VoiceCommunication = 2
}
#endif

/// <summary>
/// Provides utilities and management functions for integrating WebRTC functionality.
/// </summary>
Expand Down Expand Up @@ -1133,6 +1153,20 @@ public static void StopAudioPlayback()
Context.StopAudioPlayback();
}

/// <summary>
/// Sets the Android audio usage mode for audio playback.
/// Changing the usage mode during an active call will restart the audio stream.
/// </summary>
/// <param name="usage">The audio usage mode to set (Media or VoiceCommunication)</param>
/// <remarks>
/// - Use VoiceCommunication for broadcasters/hosts in livestream scenarios
/// - Use Media for viewers/consumers in livestream scenarios
/// </remarks>
public static void SetAndroidAudioUsageMode(AndroidAudioUsageMode usage)
{
Context.SetAndroidAudioUsageMode((int)usage);
}

#endif
class CallbackObject
{
Expand Down Expand Up @@ -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

}
Expand Down
18 changes: 12 additions & 6 deletions Packages/StreamVideo/Tests/Runtime/CallsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions Packages/StreamVideo/Tests/Shared/TestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public TestClient(IStreamVideoClient client)

public async Task<IStreamCall> 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);
Expand Down
Loading