BelledonneCommunications / linphone-android

Linphone.org mirror for linphone-android (https://gitlab.linphone.org/BC/public/linphone-android)
https://linphone.org
GNU General Public License v3.0
1.13k stars 691 forks source link

Is it possible to separate the collection window from the preview window? #1880

Closed wmailn closed 1 year ago

wmailn commented 1 year ago

Hi,

In my use, I found that when resetting the preview window, the camera would stop and then reopen, which resulted in a bit of a lag in the preview window.
May I ask if it is possible to set different Windows for preview and collection respectively, so that when switching the preview window, there is no need to restart camera collection.
Thank you
  1. Describe the bug (mandatory) The camera is turned on and off repeatedly.

  2. To Reproduce (mandatory) Repeatedly destroy and reconfigure the preview window to appear.

  3. Expected behavior (mandatory) I hope the camera doesn't have to start working again when I switch the preview window.

  4. Please complete the following information (mandatory)

    • Device: [Private device]
    • OS: [Android 13]
    • Version of the App [NULL,Immediate use linphone-sdk]
    • Version of the SDK [5.2.30]
    • Where you did got it from (local build)
    • My Android is The original Android
  5. SDK logs (mandatory) HIDE

  6. Adb logcat logs (mandatory if native crash) The APP runs normally and does not crash.

wmailn commented 1 year ago

I have both nativeWindow and captureWindow Windows in the android-camera2-capture.cpp file, Does this mean that separate capture and preview Windows are considered and supported?

Viish commented 1 year ago

Hi,

I didn't took a look at your logs because they are pasted as plain text and it's impossible to read them like that, but to answer your question:

I have both nativeWindow and captureWindow Windows in the android-camera2-capture.cpp file, Does this mean that separate capture and preview Windows are considered and supported?

Yes, there is already a separation between the local preview and the remote video display, see our tutorial for exemple: https://gitlab.linphone.org/BC/public/tutorials/-/blob/master/android/kotlin/4-OutgoingCall/app/src/main/java/org/linphone/outgoingcall/OutgoingCallActivity.kt#L127

wmailn commented 1 year ago
Thank you very much for your reply.
I carefully read what you said about OutgoingCallActivity.kt file and its implementation, I guess I didn't make myself clear.
What I want to say is whether the local capture video to the camera window and the window used to display the local video can be divided into two Windows. Instead of displaying the local video and displaying the remote video two Windows.
wmailn commented 1 year ago

For example, code like the following

int oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES); SurfaceTexture surfaceTexture = new SurfaceTexture(oesTextureId); camera.startCamera(surfaceTexture ,cameraId);

When the camera started, it was a TEXTURE created internally instead of the actual preview window, and then passed the camera data to the actual preview window to avoid the camera opening and closing as the preview window was repeatedly created.

Is there any way to support this approach that I have described?

Viish commented 1 year ago

No, I don't think so. On Android you have to use and display the preview texture created by the Android API, it's a security created to prevent a malicious app from capturing the video without the user knowing he is being filmed.

wmailn commented 1 year ago

No, I don't think so. On Android you have to use and display the preview texture created by the Android API, it's a security created to prevent a malicious app from capturing the video without the user knowing he is being filmed.

I found that camera1 had this limitation, but camera2 doesn't have this limitation anymore, can use ImageReader to get the raw video data.

wmailn commented 1 year ago

Alternatively, use code like the following so that you can separate the actual preview window from the one you need to capture the camera, so that you don't have to open or close the camera repeatedly while creating the preview window.

   int[] textureIds = new int[1];

GLES20.glGenTextures(1, textureIds, 0); cameraRenderTextureId = textureIds[0]; GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraRenderTextureId); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);

   surfaceTexture = new SurfaceTexture(cameraRenderTextureId);
   surfaceTexture.setOnFrameAvailableListener(this);

   if (onSurfaceListener != null) {
       onSurfaceListener.onSurfaceCreate(surfaceTexture);
   }

   GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);

   camera.setPreviewTexture(surfaceTexture);

The code comes from: https://github.com/ChinaZeng/OpenGLESCameraDemo

Viish commented 1 year ago

Sorry but we won't do that.

wmailn commented 1 year ago

Sorry but we won't do that.

I understand. Thank you very much.