Skip to content

Commit

Permalink
android: better sent video rotation and remember rotation when changi…
Browse files Browse the repository at this point in the history
…ng cameras
  • Loading branch information
c-g-owen committed Oct 18, 2021
1 parent 0cf9004 commit f1f555e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion android/java/com/waz/avs/VideoCapturer.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,16 @@ public int getRotation() {
if (camera == null || cameraInfo == null)
return 0;

return (360 + ui_rotation - cameraInfo.orientation) % 360;
switch (cameraInfo.facing) {
case CameraInfo.CAMERA_FACING_BACK:
return (360 + ui_rotation - cameraInfo.orientation) % 360;

case CameraInfo.CAMERA_FACING_FRONT:
return (360 - (ui_rotation + cameraInfo.orientation)) % 360;

default:
return 0;
}
}

public void setUIRotation(int rotation) {
Expand Down
5 changes: 5 additions & 0 deletions android/java/com/waz/call/FlowManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Surface;
import java.io.File;

import com.waz.avs.AVSystem;
Expand Down Expand Up @@ -113,6 +114,7 @@ public class FlowManager

private HashSet<FlowManagerListener> _listenerSet = null;

private int ui_rotation = Surface.ROTATION_0;

private HashSet<FlowManagerListener> getListenerSet ( ) {
if ( this._listenerSet == null ) {
Expand Down Expand Up @@ -371,6 +373,7 @@ public void setVideoSendState(String convId, int state) {
public native void setVideoSendStateNative(String convId, int state);

public void setUIRotation(int rotation) {
this.ui_rotation = rotation;
if (this.videoCapturer != null) {
this.videoCapturer.setUIRotation(rotation);
}
Expand Down Expand Up @@ -484,6 +487,8 @@ private void createCapturer() {
if (this.previewView != null)
this.videoCapturer.startCapture(this.previewView);

this.videoCapturer.setUIRotation(this.ui_rotation);

Log.d(TAG, "createCapturer: created");
}

Expand Down

0 comments on commit f1f555e

Please sign in to comment.