8000 Fixed frame rotation for Android. · PushoN/flutter-webrtc@d83ced5 · GitHub
[go: up one dir, main page]

Skip to content

Commit d83ced5

Browse files
committed
Fixed frame rotation for Android.
1 parent 23b5487 commit d83ced5

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

android/src/main/java/com/cloudwebrtc/webrtc/FlutterRTCVideoRenderer.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,15 @@ public void onFrameResolutionChanged(
5252
ConstraintsMap params = new ConstraintsMap();
5353
params.putString("event", "didTextureChangeVideoSize");
5454
params.putInt("id", id);
55-
params.putDouble("width", (double) videoWidth);
56-
params.putDouble("height", (double) videoHeight);
55+
56+
if(rotation == 90 || rotation == 270){
57+
params.putDouble("width", (double) videoHeight);
58+
params.putDouble("height", (double) videoWidth);
59+
}else {
60+
params.putDouble("width", (double) videoWidth);
61+
params.putDouble("height", (double) videoHeight);
62+
}
63+
5764
eventSink.success(params.toMap());
5865

5966
ConstraintsMap params2 = new ConstraintsMap();

android/src/main/java/com/cloudwebrtc/webrtc/SurfaceTextureRenderer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,13 @@ private void updateFrameDimensionsAndReportEvents(VideoRenderer.I420Frame frame)
564564
frameWidth = frame.width;
565565
frameHeight = frame.height;
566566
frameRotation = frame.rotationDegree;
567-
texture.setDefaultBufferSize(frameWidth, frameHeight);
568-
surfaceChanged(frameWidth, frameHeight);
567+
if(frameRotation == 90 || frameRotation == 270) {
568+
texture.setDefaultBufferSize(frameHeight, frameWidth);
569+
surfaceChanged(frameHeight, frameWidth);
570+
}else {
571+
texture.setDefaultBufferSize(frameWidth, frameHeight);
572+
surfaceChanged(frameWidth, frameHeight);
573+
}
569574
}
570575
}
571576
}

0 commit comments

Comments
 (0)
0