Native Android Mixed Reality Capture
This guide describes how to add and configure mixed reality capture support for your native Android application. Native mixed reality capture is supported for Meta Quest only.
The OVRMRCLib library is available for download on the
OVRMRCLib download page.
Meta provides OVRMRCLib to our native development packages that can be used to load a camera configuration file and encode / stream MRC output over Wi-Fi to OBS. Details about these processes can be found in
Mixed Reality Capture Tool.
Make sure your build process uses Gradle v7.0 or later. All Meta Quest apps now use a minimum of Android SDK version 31 which requires explicit permission for loading non-NDK libraries and requires Gradle v7.0 or later to pass Gradle validation during the packaging step.
To add OVRMrcLib to your native Android project:
Amend AndroidManifest.xml by adding the following inside the <application>
section:
<uses-native-library
android:name="libOVRMrcLib.oculus.so"
android:required="true" />
- Include Shim/OVR_Mrc_Shim.h and Shim/OVR_Mrc_Shim.cpp in your project
- Call
ovrm_LoadSharedLibrary(nullptr)
to initiate the service - Call
ovrm_GetAPIs().Func()
to access low-level functions - Call
ovrm_UnloadSharedLibrary()
to terminate the service
To initialize the service:
- Initialize the Oculus Mobile SDK
- Call
ovrm_Initialize()
- Configure your graphics API
ovrm_ConfigureGLES()
// if GLESovrm_ConfigureVulkan()
and ovrm_SetAvailableQueueIndexVulkan()
// if Vulkan- Call
ovrm_SetMrcActivationMode()
- Call
ovrm_SetMrcInputVideoBufferType()
and ovrm_SetMrcAudioSampleRate()
To run the service in your game loop:
- Call
ovrm_Update()
- Call
ovrm_GetMrcActivationMode()
- If MRC mode is activated:
- Call
ovrm_GetExternalCameraCount()
, ovrm_GetExternalCameraIntrinsics()
, and ovrm_GetExternalCameraExtrinsics()
- Construct or update your virtual camera(s)
- Render to your virtual camera(s). You may interleave the foreground and background images for performance.
- Then, every other frame:
1. Call
ovrm_SyncMrcFrame()
with the syncId from the last ovrm_EncodeXXX()
2. Call ovrm_EncodeMrcFrame()
or ovrm_EncodeMrcFrameWithDualTextures()
to submit the RenderTexture handle of the virtual camera.
To terminate the service:
- Call
ovrm_Shutdown()
The
OVRMRCLib download contains a local web-based reference you can use for additional information on each API. To open, navigate to OVRMRCLib / Doc / html and open
index.html
in any browser.