ThibaultBee / StreamPack

SRT/RTMP/RTMPS live streaming libraries for Android
https://thibaultbee.github.io/StreamPack/index.html
Apache License 2.0
196 stars 70 forks source link

Mirroring in landscape mode cause the sink side to be stretched #65

Closed lcksk closed 1 year ago

lcksk commented 1 year ago

screenrecorder 1:

If the initial state of the demo is portrait mode, sink display is normal. v_screen_source Then the display on the sink side is normal. then, if the mobile phone is switched between horizontal and vertical ,it just work well. v_sink

screenrecorder 2:

If the initial state of the phone is horizontal, the display screen is stretched. Before clicking the "record screen" button, keep the phone in landscape mode, and then click "record screen" land_source

The screen displayed on the sink is stretched, and later, if the mobile phone switches between horizontal and vertical mode, the picture is also distorted

land_sink

lcksk commented 1 year ago

I've tried a few more phones and each has this problem -(

ThibaultBee commented 1 year ago

Hi,

I will have a look when I have time.

lcksk commented 1 year ago

I will have a look when I have time.

Thanks for your attention. Just now, I took a moment to debug a bit and found that if the first parameter of setMVPMatrixAndViewPort() is forced to 90 degrees, the behavior is normal. Since I don't know much about gles, I can't submit a valid PR, so if you have time, you can see if there is a perfect solution.

private fun initOrUpdateSurfaceTexture(surface: Surface) {
            eglSurface = ensureGlContext(EGlSurface(surface)) {
                val width = it.getWidth()
                val height = it.getHeight()
                fullFrameRect = FullFrameRect(Texture2DProgram()).apply {
                    textureId = createTextureObject()
                    setMVPMatrixAndViewPort(
                        90fps,
                        Size(width, height)
                    )
                }
ThibaultBee commented 1 year ago

Hi, Thanks for the hint :) Somehow, the screen recorder frame is always oriented in portrait. I have made a fix in the main branch. Could you test it?

lcksk commented 1 year ago

Yes, using main branch to confirm the issures is gone.