/// <summary> /// Start the image conversion using this class to interact with the asynchronous conversion and results. /// </summary> /// <param name="cameraSubsystem">The camera subsystem performing the image conversion.</param> /// <param name="nativeHandle">The native handle for the camera image.</param> /// <param name="conversionParams">The parameters for image conversion.</param> internal XRAsyncCameraImageConversion(XRCameraSubsystem cameraSubsystem, int nativeHandle, XRCameraImageConversionParams conversionParams) { m_CameraSubsystem = cameraSubsystem; m_RequestId = m_CameraSubsystem.ConvertAsync(nativeHandle, conversionParams); this.conversionParams = conversionParams; #if ENABLE_UNITY_COLLECTIONS_CHECKS m_SafetyHandle = AtomicSafetyHandle.Create(); #endif }
/// <summary> /// <para>Convert the <c>XRCameraImage</c> to one of the supported formats using the specified /// <paramref name="conversionParams"/>. The conversion is performed asynchronously, and /// <paramref name="onComplete"/> is invoked when the conversion is complete, whether successful or not.</para> /// <para>The <c>NativeArray</c> provided in the <paramref name="onComplete"/> delegate is only valid during /// the invocation and is disposed immediately upon return.</para> /// </summary> /// <param name="conversionParams">The parameters to use for the conversion.</param> /// <param name="onComplete">A delegate to invoke when the conversion operation completes. The delegate is /// always invoked.</param> /// <seealso cref="FormatSupported"/> public void ConvertAsync( XRCameraImageConversionParams conversionParams, Action <AsyncCameraImageConversionStatus, XRCameraImageConversionParams, NativeArray <byte> > onComplete) { ValidateNativeHandleAndThrow(); ValidateConversionParamsAndThrow(conversionParams); var handle = GCHandle.Alloc(onComplete); var context = GCHandle.ToIntPtr(handle); m_CameraSubsystem.ConvertAsync(m_NativeHandle, conversionParams, s_OnAsyncConversionComplete, context); }