Unfortunately, you cannot directly stream the camera feed using both ARFoundation and Agora. A workaround for this is to save the camera output into a `RenderTexture` inside Unity and use that. You can then feed this into Agora. Just make sure to disable the camera capture of Agora if that is active, and call this method in your `Update()` function:
Texture2D frameTexture;
void CaptureFrame()
{
RenderTexture rt = new RenderTexture(Screen.width, Screen.height, 24);
ScreenCapture.CaptureScreenshotIntoRenderTexture(rt);
RenderTexture.active = rt;
frameTexture = new Texture2D(rt.width, rt.height, TextureFormat.RGBA32, false);
frameTexture.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
frameTexture.Apply();
RenderTexture.active = null;
rt.Release();
}
Here is the documentation from Agora's side on how to achieve this:
- Agora's Github for Unity: https://github.com/AgoraIO-Extensions/Agora-Unity-Quickstart
- Custom Video Source Docs ( using Agora's native SDK ) : https://docs.agora.io/en/video-calling/overview/product-overview