Skip to content

Commit

Permalink
Finalize 0.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
lanreolokoba committed Feb 21, 2023
0 parents commit da5c1e9
Show file tree
Hide file tree
Showing 76 changed files with 3,847 additions and 0 deletions.
84 changes: 84 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## 0.0.10
+ Added support for realtime background removal using machine learning. [See the docs](https://docs.videokit.ai/videokit/workflows/background).
+ Added `MatteKitPredictor` for predicting a human texture from a given image.
+ Added `VideoKitCameraManager.facing` property for specifying a desired camera facing.
+ Added `VideoKitCameraManager.Facing` enumeration for specifying a desired camera facing.
+ Fixed camera preview being vertically mirrored when streaming the front camera on Android devices.
+ Refactored `VideoKitRecorder.Resolution._2K` enumeration member to `Resolution._2560xAuto`.
+ Refactored `VideoKitRecorder.Resolution._4K` enumeration member to `Resolution._3840xAuto`.
+ Refactored `VideoKitCameraManager.cameraDevice` property to `VideoKitCameraManager.device`.
+ Refactored `VideoKitAudioManager.audioDevice` property to `VideoKitAudioManager.device`.

## 0.0.9
+ Upgraded to NatML 1.1.

## 0.0.8
+ Added `VideoKitRecorder.Resolution.Custom` resolution preset for specifying custom recording resolution.
+ Added `VideoKitRecorder.customResolution` property for setting custom recording resolution.
+ Added `VideoKitCameraView.focusMode` setting for specifying how to handle camera focus gestures.
+ Added `VideoKitCameraView.exposureMode` setting for specifying how to handle camera exposure gestures.
+ Added `VideoKitCameraView.zoomMode` setting for specifying how to handle camera zoom gestures.
+ Fixed bug where VideoKit components could not be added in the Unity 2022 editor.
+ Removed `VideoKitCameraFocus` component. Use `VideoKitCameraView.focusMode` setting instead.
+ Removed `VideoKitCameraZoom` component. Use `VideoKitCameraView.zoomMode` setting instead.

## 0.0.7
+ Added `VideoKitRecorder.frameSkip` property for recording every `n` frames during recording.
+ Fixed `VideoKitRecorder.StartRecording` throwing error on Android with OpenGL ES3.
+ Fixed `VideoKitRecorder` exception when stopping recording session on WebGL.
+ Fixed `NullReferenceException` in `VideoKitRecorder` when stopping recording without `audioManager` assigned.
+ Refactored `VideoKitAudioManager.SampleRate._160000` to `SampleRate._16000`.

## 0.0.6
+ Added `VideoKitAudioManager` component for managing streaming audio from audio devices.
+ Added `VideoKitRecorder.RecordingSession` struct for receiving richer information about a completed recording session.
+ Added `VideoKitRecorder.audioManager` property for managing recording audio from audio devices.
+ Added `VideoKitRecorder.Resolution._320x240` resolution preset.
+ Added `VideoKitRecorder.Resolution._480x320` resolution preset.
+ Fixed `VideoKitRecorder` not allowing developer to select `Destination.PromptUser` destination.
+ Fixed `VideoKitRecorder` incorrect video size orientation when using `Resolution.Screen` and `Orientation.Portrait`.
+ Refactored `VideoKitRecorder.orientation` property to `VideoKitRecorder.orientationMode`.
+ Refactored `VideoKitRecorder.aspect` property to `VideoKitRecorder.aspectMode`.
+ Refactored `VideoKitRecorder.videoKeyframeInterval` property to `VideoKitRecorder.keyframeInterval`.
+ Refactored `VideoKitCameraManager.OnFrame` event to `OnCameraFrame`.
+ Removed `VideoKitRecorder.OnRecordingFailed` event. Use `OnRecordingCompleted` event instead.

## 0.0.5
+ Added `VideoKitRecorder.videoBitRate` property for specifying the video bitrate for applicable formats.
+ Added `VideoKitRecorder.videoKeyframeInterval` property for specifying the keyframe interval for applicable formats.
+ Added `VideoKitRecorder.audioBitRate` property for specifying the audio bitrate for applicable formats.

## 0.0.4
+ Added `CropTextureInput` for recording a cropped area of the recording.
+ Added `WatermarkTextureInput` for adding a watermark to recorded videos.
+ Added `VideoKitRecorder.VideoMode.CameraDevice` video mode for recording videos directly from a camera device.
+ Added `VideoKitRecorder.destinationPathPrefix` property for specifying recording directory.
+ Added `VideoKitRecorder.Resolution._2K` resolution preset for recording at 2K WQHD.
+ Added `VideoKitRecorder.Resolution._4K` resolution preset for recording at 4K UHD.
+ Added `VideoKitCameraView.OnPresent` event to be notified when the view presents the camera preview to the user.
+ Added `VideoKitCameraFocus` UI component for focusing a camera device with tap gestures.
+ Fixed `CameraFrame.feature` property returning new feature instance on every access.
+ Refactored `MicrophoneInput` class to `AudioDeviceInput`.
+ Refactored `VideoKitRecorder.AudioMode.Microphone` enumeration member to `AudioMode.AudioDevice`.

## 0.0.3
+ Fixed `NullReferenceException` when running camera with `Capabilities.MachineLearning` enabled.
+ Fixed rare crash when using running camera with `Capabilities.HumanTexture` enabled.
+ Fixed recording session not being ended when `VideoKitRecorder` component is disabled or destroyed.

## 0.0.2
+ Added `VideoKitCameraManager.Resolution.Default` resolution preset to leave camera resolution unchanged.
+ Added `VideoKitCameraManager.Capabilities.DepthTexture` enumeration member for streaming camera depth.
+ Added `MicrophoneInput` recorder input for recording audio frames from an `AudioDevice`.
+ Added implicit conversion from `CameraFrame` to `CameraImage`.
+ Fixed `CameraFrame.image` being uninitialized in `VideoKitCameraManager.OnFrame`.
+ Refactored `VideoKitCameraManager.Play` method to `StartRunning`.
+ Refactored `VideoKitCameraManager.Stop` method to `StopRunning`.
+ Removed `CameraFrame.width` property. Use `CameraFrame.image.width` instead.
+ Removed `CameraFrame.height` property. Use `CameraFrame.image.height` instead.
+ Removed `CameraFrame.pixelBuffer` property.
+ Removed `CameraFrame.timestamp` property.
+ Removed `VideoKitCameraManager.Capabilities.PixelData` enumeration member.

## 0.0.1
+ First pre-release.
7 changes: 7 additions & 0 deletions Changelog.md.meta

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

8 changes: 8 additions & 0 deletions Editor.meta

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

19 changes: 19 additions & 0 deletions Editor/NatML.VideoKit.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "NatML.VideoKit.Editor",
"references": [
"NatML.Hub",
"NatML.Hub.Editor",
"NatML.VideoKit"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Editor/NatML.VideoKit.Editor.asmdef.meta

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

27 changes: 27 additions & 0 deletions Editor/VideoKitMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* VideoKit
* Copyright © 2023 NatML Inc. All Rights Reserved.
*/

namespace NatML.VideoKit.Editor {

using UnityEditor;
using Internal;

internal static class VideoKitMenu {

private const int BasePriority = -80;

[MenuItem(@"NatML/VideoKit " + VideoKitSettings.Version, false, BasePriority)]
private static void Version () { }

[MenuItem(@"NatML/VideoKit " + VideoKitSettings.Version, true, BasePriority)]
private static bool DisableVersion () => false;

[MenuItem(@"NatML/View VideoKit Docs", false, BasePriority + 1)]
private static void OpenDocs () => Help.BrowseURL(@"https://docs.natml.ai/videokit");

[MenuItem(@"NatML/Open a VideoKit Issue", false, BasePriority + 2)]
private static void OpenIssue () => Help.BrowseURL(@"https://github.com/natmlx/VideoKit");
}
}
11 changes: 11 additions & 0 deletions Editor/VideoKitMenu.cs.meta

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

74 changes: 74 additions & 0 deletions Editor/VideoKitProjectSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* VideoKit
* Copyright © 2023 NatML Inc. All Rights Reserved.
*/

namespace NatML.VideoKit.Editor {

using System;
using System.Threading.Tasks;
using UnityEngine;
using UnityEditor;
using Hub;
using Hub.Internal;
using Hub.Requests;
using Internal;

[FilePath(@"ProjectSettings/VideoKit.asset", FilePathAttribute.Location.ProjectFolder)]
internal sealed class VideoKitProjectSettings : ScriptableSingleton<VideoKitProjectSettings> {

#region --Client API--
/// <summary>
/// VideoKit settings from the current project settings.
/// </summary>
internal static VideoKitSettings CurrentSettings {
get {
var settings = ScriptableObject.CreateInstance<VideoKitSettings>();
settings.token = SessionState.GetString(tokenKey, string.Empty);
return settings;
}
}

/// <summary>
/// Create VideoKit settings.
/// </summary>
/// <param name="platform">NatML platform identifier.</param>
/// <param name="bundle">NatML app bundle.</param>
/// <param name="accessKey">NatML access key.</param>
internal static VideoKitSettings CreateSettings (string platform, string bundle, string accessKey) {
var input = new CreateMediaSessionRequest.Input {
api = VideoKitSettings.API,
version = VideoKitSettings.Version,
platform = platform,
bundle = bundle
};
var session = Task.Run(() => NatMLHub.CreateMediaSession(input, accessKey)).Result;
var settings = ScriptableObject.CreateInstance<VideoKitSettings>();
settings.token = session.token;
return settings;
}
#endregion


#region --Operations--
private static string tokenKey => $"{VideoKitSettings.API}.token";

[InitializeOnLoadMethod]
private static void OnLoad () {
VideoKitSettings.Instance = CurrentSettings;
HubSettings.OnUpdateSettings += OnUpdateHubSettings;
}

private static void OnUpdateHubSettings (HubSettings hubSettings) {
try {
var settings = CreateSettings(NatMLHub.CurrentPlatform, NatMLHub.GetEditorBundle(), hubSettings.AccessKey);
SessionState.SetString(tokenKey, settings.token);
} catch (Exception ex) {
SessionState.EraseString(tokenKey);
Debug.LogWarning($"VideoKit Error: {ex.InnerException.Message}");
}
VideoKitSettings.Instance = CurrentSettings;
}
#endregion
}
}
11 changes: 11 additions & 0 deletions Editor/VideoKitProjectSettings.cs.meta

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

96 changes: 96 additions & 0 deletions Editor/VideoKitRecorderEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* VideoKit
* Copyright © 2023 NatML Inc. All Rights Reserved.
*/

namespace NatML.VideoKit.Editor {

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using static VideoKitRecorder;
using Resolution = VideoKitRecorder.Resolution;

[CustomEditor(typeof(VideoKitRecorder)), CanEditMultipleObjects]
internal sealed class VideoKitRecorderEditor : Editor {

private readonly Dictionary<string, SerializedProperty> properties = new();
private readonly Format[] VideoFormats = new [] { Format.MP4, Format.HEVC, Format.WEBM, Format.GIF, Format.JPEG };
private readonly Format[] AudioFormats = new [] { Format.MP4, Format.HEVC, Format.WEBM, Format.WAV };

private void OnEnable () {
var propertyNames = new [] {
@"format", @"destination", @"prepareOnAwake", @"videoMode", @"audioMode", @"resolution", @"customResolution",
@"cameras", @"texture", @"cameraManager", @"frameSkip", @"watermarkMode", @"watermark",
@"watermarkRect", @"audioManager", @"configureAudioManager", @"audioDeviceGain", @"OnRecordingCompleted",
};
foreach (var name in propertyNames) {
var property = serializedObject.FindProperty(name);
if (property == null)
throw new InvalidOperationException($"Cannot find property {name} in `VideoKitRecorder`");
properties.Add(name, property);
}
}

public override void OnInspectorGUI () {
serializedObject.Update();
// Format
EditorGUILayout.PropertyField(properties[@"format"]);
EditorGUILayout.PropertyField(properties[@"destination"]);
EditorGUILayout.PropertyField(properties[@"prepareOnAwake"]);
// Video mode
var format = (Format)Enum.GetValues(typeof(Format)).GetValue(properties[@"format"].enumValueIndex);
var videoOptions = Array.IndexOf(VideoFormats, format) > -1;
var videoMode = (VideoMode)Enum.GetValues(typeof(VideoMode)).GetValue(properties[@"videoMode"].enumValueIndex);
if (videoOptions) {
EditorGUILayout.PropertyField(properties[@"videoMode"]);
if (videoMode != VideoMode.None) {
// Video resolution
var resolution = (Resolution)Enum.GetValues(typeof(Resolution)).GetValue(properties[@"resolution"].enumValueIndex);
EditorGUILayout.PropertyField(properties[@"resolution"]);
if (resolution == Resolution.Custom)
EditorGUILayout.PropertyField(properties[@"customResolution"]);
// Video input
switch (videoMode) {
case VideoMode.Camera:
EditorGUILayout.PropertyField(properties[@"cameras"]);
break;
case VideoMode.Texture:
EditorGUILayout.PropertyField(properties[@"texture"]);
break;
case VideoMode.CameraDevice:
EditorGUILayout.PropertyField(properties[@"cameraManager"]);
break;
}
// Frame skip
EditorGUILayout.PropertyField(properties[@"frameSkip"]);
// Watermark
var watermarkMode = (WatermarkMode)Enum.GetValues(typeof(WatermarkMode)).GetValue(properties[@"watermarkMode"].enumValueIndex);
EditorGUILayout.PropertyField(properties[@"watermarkMode"]);
if (watermarkMode != WatermarkMode.None)
EditorGUILayout.PropertyField(properties[@"watermark"]);
if (watermarkMode == WatermarkMode.Custom)
EditorGUILayout.PropertyField(properties[@"watermarkRect"]);
}
}
// Audio mode
var audioOptions = Array.IndexOf(AudioFormats, format) > -1;
var audioMode = (AudioMode)properties[@"audioMode"].enumValueFlag;
if (audioOptions) {
EditorGUILayout.PropertyField(properties[@"audioMode"]);
if (audioMode.HasFlag(AudioMode.AudioDevice)) {
EditorGUILayout.PropertyField(properties[@"audioManager"]);
EditorGUILayout.PropertyField(properties[@"configureAudioManager"]);
}
if (audioMode.HasFlag(AudioMode.AudioListener) && audioMode.HasFlag(AudioMode.AudioDevice))
EditorGUILayout.PropertyField(properties[@"audioDeviceGain"]);
}
// Events
EditorGUILayout.PropertyField(properties[@"OnRecordingCompleted"]);
// Apply
serializedObject.ApplyModifiedProperties();
}
}
}
11 changes: 11 additions & 0 deletions Editor/VideoKitRecorderEditor.cs.meta

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

Loading

0 comments on commit da5c1e9

Please sign in to comment.