Class SurfaceTextureCaptureSession
- Namespace
- Uralstech.UXR.QuestCamera.SurfaceTextureCapture
This experimental capture session uses a native OpenGL texture to capture images for better performance.
public class SurfaceTextureCaptureSession : AndroidJavaProxy
- Inheritance
-
objectSurfaceTextureCaptureSession
- Derived
Remarks
Requires OpenGL ES 3.0 as the project's graphics API. Works with single and multi-threaded rendering.
Constructors
SurfaceTextureCaptureSession(Resolution)
public SurfaceTextureCaptureSession(Resolution resolution)
Parameters
resolutionResolution
Fields
Texture
The texture being rendered to.
public readonly Texture2D Texture
Field Value
- Texture2D
_captureSession
The native capture session object.
protected AndroidJavaObject? _captureSession
Field Value
- AndroidJavaObject?
_commandBuffer
CommandBuffer for invoking native renderer events.
protected readonly CommandBuffer _commandBuffer
Field Value
- CommandBuffer
_nativeTextureId
The native texture which captures YUV 4:2:0 data.
protected uint? _nativeTextureId
Field Value
- uint?
Properties
CaptureTimestamp
The timestamp the last frame processed was captured at in nanoseconds.
public long CaptureTimestamp { get; protected set; }
Property Value
- long
CurrentState
The current assumed state of the native CaptureSession wrapper.
public NativeWrapperState CurrentState { get; }
Property Value
Disposed
protected bool Disposed { get; }
Property Value
- bool
Methods
DisposeAsync()
Closes and releases the capture session..
public ValueTask DisposeAsync()
Returns
- ValueTask
~SurfaceTextureCaptureSession()
protected ~SurfaceTextureCaptureSession()
InitializeNative(long)
Initializes the native renderer.
protected virtual void InitializeNative(long timestamp)
Parameters
timestamplongThe timestamp corresponding to the native capture session wrapper.
Invoke(string, nint)
public override nint Invoke(string methodName, nint javaArgs)
Parameters
methodNamestringjavaArgsnint
Returns
- nint
OnFrameReadyInvk(Texture2D, long)
Invokes OnFrameReady for child classes.
protected void OnFrameReadyInvk(Texture2D texture, long timestamp)
Parameters
textureTexture2Dtimestamplong
SendNativeUpdate(NativeEventId, NativeUpdateCallbackWithTimestampType?, long)
Sends an update event to the native renderer.
protected virtual Task SendNativeUpdate(STCaptureSessionNative.NativeEventId eventId, STCaptureSessionNative.NativeUpdateCallbackWithTimestampType? callback, long timestamp = 0)
Parameters
eventIdSTCaptureSessionNative.NativeEventIdThe type of the event.
callbackSTCaptureSessionNative.NativeUpdateCallbackWithTimestampTypeAn optional callback for the event's completion.
timestamplongAn optional timestamp to be tracked in C# code, to be forwarded to
timestamp.
Returns
- Task
WaitForInitialization()
Waits until the CaptureSession is open or erred out.
public WaitUntil WaitForInitialization()
Returns
- WaitUntil
WaitForInitialization(TimeSpan, Action, WaitTimeoutMode)
Waits until the CaptureSession opens or errs out.
public WaitUntil WaitForInitialization(TimeSpan timeout, Action onTimeout, WaitTimeoutMode timeoutMode = null)
Parameters
timeoutTimeSpanonTimeoutActiontimeoutModeWaitTimeoutMode
Returns
- WaitUntil
WaitForInitializationAsync(CancellationToken)
Waits until the CaptureSession opens or errs out.
public Task<bool> WaitForInitializationAsync(CancellationToken token = default)
Parameters
tokenCancellationToken
Returns
Events
OnDisposeCompleted
Called when the native Kotlin wrapper has been completely disposed.
protected event Action? OnDisposeCompleted
Event Type
- Action
OnFrameReady
Called when a frame is ready, with its capture timestamp in nanoseconds.
public event Action<Texture2D, long>? OnFrameReady
Event Type
- Action<Texture2D, long>
Remarks
This callback may not be called from the main thread.
OnSessionActive
Called when the session has started actively processing capture requests.
public event Action? OnSessionActive
Event Type
- Action
OnSessionClosed
Called when the session is closed.
public event Action? OnSessionClosed
Event Type
- Action
OnSessionConfigurationFailed
Called when the session could not be configured, and a boolean value indicating if the failure was caused due to a camera access/security exception.
public event Action<bool>? OnSessionConfigurationFailed
Event Type
- Action<bool>
OnSessionConfigured
Called when the session has been configured.
public event Action? OnSessionConfigured
Event Type
- Action
OnSessionRegistrationFailed
Called when the session could not be registered with the native renderer.
public event Action? OnSessionRegistrationFailed
Event Type
- Action
OnSessionRequestFailed
Called when the session request could not be set.
public event Action? OnSessionRequestFailed
Event Type
- Action
OnSessionRequestSet
Called when the session request has been set.
public event Action? OnSessionRequestSet
Event Type
- Action