Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
codematrixer opened this issue Dec 2, 2022 · 4 comments
Open

Comments

@codematrixer
Copy link

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

@rom1v
Copy link
Collaborator

rom1v commented Dec 2, 2022

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.

@codematrixer
Copy link
Author

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?

@rom1v
Copy link
Collaborator

rom1v commented Dec 2, 2022

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.

@sbfkcel
Copy link

sbfkcel commented Dec 26, 2024

It is recommended to call the getCurrentRotation method to obtain the device's orientation when the device is rotated. The orientation information can be sent along with the video in the header of the key frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants