Mohammad Elsayed
Mohammad Elsayed

Reputation: 2064

Forcing camera to landscape android

I am developing a video chat application. everything is working just fine. The application is intended to keep the video taken by the camera in the landscape, and I am already OK with this, I could eventually make the video chat continues when the application goes to the background by the action of clicking the Home button, but since the phone Home Screen is portrait, the camera flips the video taken by it to portrait mode and this can be seen by the other peer. Is there a way to make the camera keeps recording video in landscape mode when the application goes to the background.

Upvotes: 1

Views: 2032

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57203

In WebRTC, the piece of code that keeps track of 'phone orientation' is a static CameraSession.getDeviceOrientation(Context context) method. Both Camera1Session and Camera2Session use this function, but you want to have same fixed return value, probably 90.

If your code is not so far from this WebRtcActivity.java, you should create your private copy of CameraEnumerator which will override createCapturer() which will return a capturer that overrides createCameraSession() and return your modified overload of CameraSession.

Unfortunately, you cannot simply inherit from Camera1Session, because it has the call to CameraSession.getDeviceOrientation() deep in a private method.

Upvotes: 1

Related Questions