Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ private void getDisplayMedia(final Result result, final MediaStream mediaStream,
VideoCapturer videoCapturer = null;
videoCapturer =
new OrientationAwareScreenCapturer(
applicationContext,
mediaProjectionData,
new MediaProjection.Callback() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
import android.os.Looper;
import android.os.Handler;
import android.os.Build;
import android.os.Bundle;
import android.view.Display;
import android.util.Log;
import android.content.Context;
import android.content.res.Configuration;

/**
* An copy of ScreenCapturerAndroid to capture the screen content while being aware of device orientation
Expand All @@ -46,6 +50,7 @@ public class OrientationAwareScreenCapturer implements VideoCapturer, VideoSink
private MediaProjectionManager mediaProjectionManager;
private WindowManager windowManager;
private boolean isPortrait;
private Context context;

/**
* Constructs a new Screen Capturer.
Expand All @@ -56,10 +61,12 @@ public class OrientationAwareScreenCapturer implements VideoCapturer, VideoSink
* @param mediaProjectionCallback MediaProjection callback to implement application specific
* logic in events such as when the user revokes a previously granted capture permission.
**/
public OrientationAwareScreenCapturer(Intent mediaProjectionPermissionResultData,
public OrientationAwareScreenCapturer(Context context,
Intent mediaProjectionPermissionResultData,
MediaProjection.Callback mediaProjectionCallback) {
this.mediaProjectionPermissionResultData = mediaProjectionPermissionResultData;
this.mediaProjectionCallback = mediaProjectionCallback;
this.context = context;
}

public void onFrame(VideoFrame frame) {
Expand All @@ -76,9 +83,7 @@ public void onFrame(VideoFrame frame) {
}

private boolean isDeviceOrientationPortrait() {
final int surfaceRotation = windowManager.getDefaultDisplay().getRotation();

return surfaceRotation != Surface.ROTATION_90 && surfaceRotation != Surface.ROTATION_270;
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
}


Expand Down