Skip to content

Commit

Permalink
Merge pull request #162 from videokit-ai/camera-view
Browse files Browse the repository at this point in the history
Support multi-camera streaming
  • Loading branch information
olokobayusuf authored Dec 30, 2024
2 parents f119f31 + 6bb33a5 commit 5510b0a
Show file tree
Hide file tree
Showing 58 changed files with 1,386 additions and 853 deletions.
24 changes: 8 additions & 16 deletions Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp/bin/Debug/</OutputPath>
<DefineConstants>UNITY_6000_0_28;UNITY_6000_0;UNITY_6000;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_3_OR_NEWER;UNITY_2018_4_OR_NEWER;UNITY_2019_1_OR_NEWER;UNITY_2019_2_OR_NEWER;UNITY_2019_3_OR_NEWER;UNITY_2019_4_OR_NEWER;UNITY_2020_1_OR_NEWER;UNITY_2020_2_OR_NEWER;UNITY_2020_3_OR_NEWER;UNITY_2021_1_OR_NEWER;UNITY_2021_2_OR_NEWER;UNITY_2021_3_OR_NEWER;UNITY_2022_1_OR_NEWER;UNITY_2022_2_OR_NEWER;UNITY_2022_3_OR_NEWER;UNITY_2023_1_OR_NEWER;UNITY_2023_2_OR_NEWER;UNITY_2023_3_OR_NEWER;UNITY_6000_0_OR_NEWER;UNITY_INCLUDE_TESTS;ENABLE_AR;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_EVENT_QUEUE;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_TEXTURE_STREAMING;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_UNITYWEBREQUEST;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_NATIVE_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_EDITOR_GAME_SERVICES;ENABLE_UNITY_GAME_SERVICES_ANALYTICS_SUPPORT;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_GENERATE_NATIVE_PLUGINS_FOR_ASSEMBLIES_API;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_AUDIO_JOBS;ENABLE_ENGINE_CODE_STRIPPING;ENABLE_ONSCREEN_KEYBOARD;ENABLE_MANAGED_UNITYTLS;INCLUDE_DYNAMIC_GI;ENABLE_SCRIPTING_GC_WBARRIERS;PLATFORM_SUPPORTS_MONO;ENABLE_MARSHALLING_TESTS;ENABLE_VIDEO;ENABLE_NAVIGATION_OFFMESHLINK_TO_NAVMESHLINK;ENABLE_ACCELERATOR_CLIENT_DEBUGGING;ENABLE_ACCESSIBILITY;TEXTCORE_1_0_OR_NEWER;EDITOR_ONLY_NAVMESH_BUILDER_DEPRECATED;PLATFORM_ANDROID;UNITY_ANDROID;UNITY_ANDROID_API;ENABLE_EGL;ENABLE_NETWORK;ENABLE_RUNTIME_GI;ENABLE_CRUNCH_TEXTURE_COMPRESSION;UNITY_CAN_SHOW_SPLASH_SCREEN;UNITY_HAS_GOOGLEVR;UNITY_HAS_TANGO;ENABLE_SPATIALTRACKING;ENABLE_ETC_COMPRESSION;PLATFORM_EXTENDS_VULKAN_DEVICE;PLATFORM_HAS_MULTIPLE_SWAPCHAINS;UNITY_ANDROID_SUPPORTS_SHADOWFILES;PLATFORM_UPDATES_TIME_OUTSIDE_OF_PLAYER_LOOP;PLATFORM_EXTENDS_VULKAN_PIPELINE_CACHE;PLATFORM_SUPPORTS_SPLIT_GRAPHICS_JOBS;PLATFORM_HAS_ADDITIONAL_API_CHECKS;ENABLE_UNITYADS_RUNTIME;UNITY_UNITYADS_API;ENABLE_MONO;NET_STANDARD_2_0;NET_STANDARD;NET_STANDARD_2_1;NETSTANDARD;NETSTANDARD2_1;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_LOCALIZATION;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_LEGACY_INPUT_MANAGER;TEXTCORE_FONT_ENGINE_1_5_OR_NEWER;TEXTCORE_TEXT_ENGINE_1_5_OR_NEWER;CSHARP_7_OR_LATER;CSHARP_7_3_OR_NEWER</DefineConstants>
<DefineConstants>UNITY_6000_0_28;UNITY_6000_0;UNITY_6000;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_3_OR_NEWER;UNITY_2018_4_OR_NEWER;UNITY_2019_1_OR_NEWER;UNITY_2019_2_OR_NEWER;UNITY_2019_3_OR_NEWER;UNITY_2019_4_OR_NEWER;UNITY_2020_1_OR_NEWER;UNITY_2020_2_OR_NEWER;UNITY_2020_3_OR_NEWER;UNITY_2021_1_OR_NEWER;UNITY_2021_2_OR_NEWER;UNITY_2021_3_OR_NEWER;UNITY_2022_1_OR_NEWER;UNITY_2022_2_OR_NEWER;UNITY_2022_3_OR_NEWER;UNITY_2023_1_OR_NEWER;UNITY_2023_2_OR_NEWER;UNITY_2023_3_OR_NEWER;UNITY_6000_0_OR_NEWER;UNITY_INCLUDE_TESTS;ENABLE_AUDIO;ENABLE_CLOTH;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_TEXTURE_STREAMING;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_UNITYWEBREQUEST;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_EDITOR_GAME_SERVICES;ENABLE_UNITY_GAME_SERVICES_ANALYTICS_SUPPORT;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_GENERATE_NATIVE_PLUGINS_FOR_ASSEMBLIES_API;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_AUDIO_JOBS;ENABLE_ENGINE_CODE_STRIPPING;ENABLE_ONSCREEN_KEYBOARD;ENABLE_MANAGED_UNITYTLS;RENDER_SOFTWARE_CURSOR;ENABLE_MARSHALLING_TESTS;ENABLE_VIDEO;ENABLE_NAVIGATION_OFFMESHLINK_TO_NAVMESHLINK;ENABLE_ACCELERATOR_CLIENT_DEBUGGING;TEXTCORE_1_0_OR_NEWER;EDITOR_ONLY_NAVMESH_BUILDER_DEPRECATED;PLATFORM_WEBGL;UNITY_WEBGL;UNITY_WEBGL_API;UNITY_DISABLE_WEB_VERIFICATION;UNITY_GFX_USE_PLATFORM_VSYNC;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_SPATIALTRACKING;ENABLE_MONO;NET_STANDARD_2_0;NET_STANDARD;NET_STANDARD_2_1;NETSTANDARD;NETSTANDARD2_1;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_LOCALIZATION;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_LEGACY_INPUT_MANAGER;TEXTCORE_FONT_ENGINE_1_5_OR_NEWER;TEXTCORE_TEXT_ENGINE_1_5_OR_NEWER;CSHARP_7_OR_LATER;CSHARP_7_3_OR_NEWER</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169;USG0001</NoWarn>
Expand All @@ -55,7 +55,7 @@
<UnityProjectGeneratorVersion>2.0.22</UnityProjectGeneratorVersion>
<UnityProjectGeneratorStyle>SDK</UnityProjectGeneratorStyle>
<UnityProjectType>Game:1</UnityProjectType>
<UnityBuildTarget>Android:13</UnityBuildTarget>
<UnityBuildTarget>WebGL:20</UnityBuildTarget>
<UnityVersion>6000.0.28f1</UnityVersion>
</PropertyGroup>
<ItemGroup>
Expand All @@ -72,10 +72,6 @@
<HintPath>/Applications/Unity/Hub/Editor/6000.0.28f1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.ARModule">
<HintPath>/Applications/Unity/Hub/Editor/6000.0.28f1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.ARModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.AccessibilityModule">
<HintPath>/Applications/Unity/Hub/Editor/6000.0.28f1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.AccessibilityModule.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -272,6 +268,10 @@
<HintPath>/Applications/Unity/Hub/Editor/6000.0.28f1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.VideoModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.WebGLModule">
<HintPath>/Applications/Unity/Hub/Editor/6000.0.28f1/PlaybackEngines/WebGLSupport/Managed/UnityEngine.WebGLModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEditor">
<HintPath>/Applications/Unity/Hub/Editor/6000.0.28f1/Unity.app/Contents/Managed/UnityEngine/UnityEditor.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -988,10 +988,6 @@
<HintPath>Library/ScriptAssemblies/Unity.TestTools.CodeCoverage.Editor.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Unity.Multiplayer.Center.Editor">
<HintPath>Library/ScriptAssemblies/Unity.Multiplayer.Center.Editor.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEditor.UI">
<HintPath>Library/ScriptAssemblies/UnityEditor.UI.dll</HintPath>
<Private>False</Private>
Expand All @@ -1012,18 +1008,14 @@
<HintPath>Library/ScriptAssemblies/Unity.Sysroot.Linux_x86_64.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Unity.Multiplayer.Center.Common">
<HintPath>Library/ScriptAssemblies/Unity.Multiplayer.Center.Common.dll</HintPath>
<Reference Include="Function.Unity">
<HintPath>Library/ScriptAssemblies/Function.Unity.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Unity.TextMeshPro.Editor">
<HintPath>Library/ScriptAssemblies/Unity.TextMeshPro.Editor.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Function.Unity">
<HintPath>Library/ScriptAssemblies/Function.Unity.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Unity.TestTools.CodeCoverage.Editor.OpenCover.Mono.Reflection">
<HintPath>Library/ScriptAssemblies/Unity.TestTools.CodeCoverage.Editor.OpenCover.Mono.Reflection.dll</HintPath>
<Private>False</Private>
Expand Down
62 changes: 31 additions & 31 deletions Assets/Tests/Runtime/CameraDeviceEnumerateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,44 @@ private async void Start () {
foreach (var device in cameraDevices)
Debug.Log(JsonConvert.SerializeObject(new Dictionary<string, object> {
// Media device
["uniqueID"] = device.uniqueId,
["name"] = device.name,
["location"] = device.location,
["defaultForMediaType"] = device.defaultForMediaType,
[@"uniqueID"] = device.uniqueId,
[@"name"] = device.name,
[@"location"] = device.location,
[@"defaultForMediaType"] = device.defaultForMediaType,
// Streaming
["previewResolution"] = device.previewResolution,
["photoResolution"] = device.photoResolution,
["frameRate"] = device.frameRate,
["running"] = device.running,
[@"previewResolution"] = device.previewResolution,
[@"photoResolution"] = device.photoResolution,
[@"frameRate"] = device.frameRate,
[@"running"] = device.running,
// Properties
["frontFacing"] = device.frontFacing,
["torchSupported"] = device.torchSupported,
["fieldOfView"] = device.fieldOfView,
["zoomRange"] = device.zoomRange,
[@"frontFacing"] = device.frontFacing,
[@"torchSupported"] = device.torchSupported,
[@"fieldOfView"] = device.fieldOfView,
[@"zoomRange"] = device.zoomRange,
// Flash
["flashSupported"] = device.flashSupported,
["flashMode"] = device.flashMode,
[@"flashSupported"] = device.flashSupported,
[@"flashMode"] = device.flashMode,
// Exposure
["exposureMode"] = device.exposureMode,
["exposureContinuousSupported"] = device.IsExposureModeSupported(CameraDevice.ExposureMode.Continuous),
["exposureLockSupported"] = device.IsExposureModeSupported(CameraDevice.ExposureMode.Locked),
["exposureManualSupported"] = device.IsExposureModeSupported(CameraDevice.ExposureMode.Manual),
["exposurePointSupported"] = device.exposurePointSupported,
["exposureBiasRange"] = device.exposureBiasRange,
["exposureDurationRange"] = device.exposureDurationRange,
["ISORange"] = device.ISORange,
[@"exposureMode"] = device.exposureMode,
[@"exposureContinuousSupported"] = device.IsExposureModeSupported(CameraDevice.ExposureMode.Continuous),
[@"exposureLockSupported"] = device.IsExposureModeSupported(CameraDevice.ExposureMode.Locked),
[@"exposureManualSupported"] = device.IsExposureModeSupported(CameraDevice.ExposureMode.Manual),
[@"exposurePointSupported"] = device.exposurePointSupported,
[@"exposureBiasRange"] = device.exposureBiasRange,
[@"exposureDurationRange"] = device.exposureDurationRange,
[@"ISORange"] = device.ISORange,
// Focus
["focusMode"] = device.focusMode,
["focusContinuousSupported"] = device.IsFocusModeSupported(CameraDevice.FocusMode.Continuous),
["focusLockSupported"] = device.IsFocusModeSupported(CameraDevice.FocusMode.Locked),
["focusPointSupported"] = device.focusPointSupported,
[@"focusMode"] = device.focusMode,
[@"focusContinuousSupported"] = device.IsFocusModeSupported(CameraDevice.FocusMode.Continuous),
[@"focusLockSupported"] = device.IsFocusModeSupported(CameraDevice.FocusMode.Locked),
[@"focusPointSupported"] = device.focusPointSupported,
// White balance
["whiteBalanceMode"] = device.whiteBalanceMode,
["whiteBalanceContinuousSupported"] = device.IsWhiteBalanceModeSupported(CameraDevice.WhiteBalanceMode.Continuous),
["whiteBalanceLockSupported"] = device.IsWhiteBalanceModeSupported(CameraDevice.WhiteBalanceMode.Locked),
[@"whiteBalanceMode"] = device.whiteBalanceMode,
[@"whiteBalanceContinuousSupported"] = device.IsWhiteBalanceModeSupported(CameraDevice.WhiteBalanceMode.Continuous),
[@"whiteBalanceLockSupported"] = device.IsWhiteBalanceModeSupported(CameraDevice.WhiteBalanceMode.Locked),
// Video stabilization
["videoStabilizationMode"] = device.videoStabilizationMode,
["videoStabilizationStandardSupported"] = device.IsVideoStabilizationModeSupported(CameraDevice.VideoStabilizationMode.Standard),
[@"videoStabilizationMode"] = device.videoStabilizationMode,
[@"videoStabilizationStandardSupported"] = device.IsVideoStabilizationModeSupported(CameraDevice.VideoStabilizationMode.Standard),
}, Formatting.Indented));
}
}
Expand Down
5 changes: 3 additions & 2 deletions Assets/Tests/Runtime/HumanTextureTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ namespace VideoKit.Tests {
using Function;
using Function.Types;
using Newtonsoft.Json;
using UI;
using Stopwatch = System.Diagnostics.Stopwatch;

internal sealed class HumanTextureTest : MonoBehaviour {

[SerializeField] private VideoKitCameraManager cameraManager;
[SerializeField] private VideoKitCameraView cameraView;
[SerializeField] UnityEngine.UI.RawImage rawImage;
private Texture2D humanTexture;
private Function fxn;
Expand All @@ -27,7 +28,7 @@ private async void Start () {

private void Update () {
// Check
var previewTexture = cameraManager.texture;
var previewTexture = cameraView.texture;
if (previewTexture == null)
return;
// Check
Expand Down
29 changes: 29 additions & 0 deletions Assets/Tests/Runtime/MultiCameraDeviceEnumeratTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* VideoKit
* Copyright © 2024 Yusuf Olokoba. All Rights Reserved.
*/

namespace VideoKit.Tests {

using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;

internal sealed class MultiCameraDeviceEnumerateTest : MonoBehaviour {

private async void Start () {
await MultiCameraDevice.CheckPermissions();
var multiCameraDevices = await MultiCameraDevice.Discover();
foreach (var device in multiCameraDevices)
Debug.Log(JsonConvert.SerializeObject(new Dictionary<string, object> {
// Identifiers
[@"uniqueID"] = device.uniqueId,
[@"name"] = device.name,
[@"location"] = device.location,
[@"defaultForMediaType"] = device.defaultForMediaType,
// Streaming
[@"running"] = device.running,
}, Formatting.Indented));
}
}
}
2 changes: 2 additions & 0 deletions Assets/Tests/Runtime/MultiCameraDeviceEnumeratTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5510b0a

Please sign in to comment.