scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

How to listen on the change of the screen when the screen is rotated

Open codematrixer opened this issue 2 years ago • 3 comments

If I only use the scrcpy-server, and then use the jmuxer to decode on frontend, how will the frontend listen when the screen is rotated. Only when it listens, can the next step, such as reset jmuxer to make sure the screen display is normal

I refer to this issue, but didn't find the answer.

Looking forward to your reply. @rom1v

codematrixer avatar Dec 02 '22 10:12 codematrixer

how will the frontend listen when the screen is rotated

On the client side, scrcpy does not detect rotation per-se, but only video frame size changes. So when a new frame has a different size from the previous one, it resizes the window accordingly.

rom1v avatar Dec 02 '22 11:12 rom1v

but only video frame size changes

That is to say, my frontend needs to detect the size of each frame in real time, and reset jmuxer if it is different from the last time?

codematrixer avatar Dec 02 '22 11:12 codematrixer

my frontend needs to detect the size of each frame in real time

This is what the scrcpy client does. Alternatively, you could adapt the protocol to send a "rotation" event on the wire before sending the next frame at the new dimension.

Since when the frame is decoded, the size is available directly in the resulting AVFrame, such an event is not necessary for the scrcpy client currently.

rom1v avatar Dec 02 '22 12:12 rom1v