Develop
Develop
Select your platform

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.

OVRMRCLib

To add OVRMrcLib to your native Android project:
  1. Amend AndroidManifest.xml by adding the following inside the <application> section:
    <uses-native-library
        android:name="libOVRMrcLib.oculus.so"
        android:required="true" />
    
  2. Include Shim/OVR_Mrc_Shim.h and Shim/OVR_Mrc_Shim.cpp in your project
  3. Call ovrm_LoadSharedLibrary(nullptr) to initiate the service
  4. Call ovrm_GetAPIs().Func() to access low-level functions
  5. Call ovrm_UnloadSharedLibrary() to terminate the service

Initialize MRC Service

To initialize the service:
  1. Initialize the Oculus Mobile SDK
  2. Call ovrm_Initialize()
  3. Configure your graphics API
  4. ovrm_ConfigureGLES() // if GLES
  5. ovrm_ConfigureVulkan() and ovrm_SetAvailableQueueIndexVulkan() // if Vulkan
  6. Call ovrm_SetMrcActivationMode()
  7. Call ovrm_SetMrcInputVideoBufferType() and ovrm_SetMrcAudioSampleRate()

In Loop / Capture

To run the service in your game loop:
  1. Call ovrm_Update()
  2. Call ovrm_GetMrcActivationMode()
  3. If MRC mode is activated:
  4. Call ovrm_GetExternalCameraCount(), ovrm_GetExternalCameraIntrinsics(), and ovrm_GetExternalCameraExtrinsics()
  5. Construct or update your virtual camera(s)
  6. Render to your virtual camera(s). You may interleave the foreground and background images for performance.
  7. 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.

Terminate the Service

To terminate the service:
  1. Call ovrm_Shutdown()

OVRMRCLib Reference

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.
Did you find this page helpful?