Android: Expose setting custom visible fraction values for video layout

Bug: webrtc:10778
Change-Id: Ie189b0980b20031e985935da55aa59ea3ee8b816
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144052
Reviewed-by: Benjamin Wright <benwright@webrtc.org>
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28592}
This commit is contained in:
Magnus Jedvert
2019-06-28 13:34:21 +02:00
committed by Commit Bot
parent b04e2561be
commit fcf3a87ced

View File

@ -64,18 +64,28 @@ public class RendererCommon {
// The scaling type determines how the video will fill the allowed layout area in measure(). It
// can be specified separately for the case when video has matched orientation with layout size
// and when there is an orientation mismatch.
private ScalingType scalingTypeMatchOrientation = ScalingType.SCALE_ASPECT_BALANCED;
private ScalingType scalingTypeMismatchOrientation = ScalingType.SCALE_ASPECT_BALANCED;
private float visibleFractionMatchOrientation =
convertScalingTypeToVisibleFraction(ScalingType.SCALE_ASPECT_BALANCED);
private float visibleFractionMismatchOrientation =
convertScalingTypeToVisibleFraction(ScalingType.SCALE_ASPECT_BALANCED);
public void setScalingType(ScalingType scalingType) {
this.scalingTypeMatchOrientation = scalingType;
this.scalingTypeMismatchOrientation = scalingType;
setScalingType(/* scalingTypeMatchOrientation= */ scalingType,
/* scalingTypeMismatchOrientation= */ scalingType);
}
public void setScalingType(
ScalingType scalingTypeMatchOrientation, ScalingType scalingTypeMismatchOrientation) {
this.scalingTypeMatchOrientation = scalingTypeMatchOrientation;
this.scalingTypeMismatchOrientation = scalingTypeMismatchOrientation;
this.visibleFractionMatchOrientation =
convertScalingTypeToVisibleFraction(scalingTypeMatchOrientation);
this.visibleFractionMismatchOrientation =
convertScalingTypeToVisibleFraction(scalingTypeMismatchOrientation);
}
public void setVisibleFraction(
float visibleFractionMatchOrientation, float visibleFractionMismatchOrientation) {
this.visibleFractionMatchOrientation = visibleFractionMatchOrientation;
this.visibleFractionMismatchOrientation = visibleFractionMismatchOrientation;
}
public Point measure(int widthSpec, int heightSpec, int frameWidth, int frameHeight) {
@ -89,10 +99,10 @@ public class RendererCommon {
// and maximum layout size.
final float frameAspect = frameWidth / (float) frameHeight;
final float displayAspect = maxWidth / (float) maxHeight;
final ScalingType scalingType = (frameAspect > 1.0f) == (displayAspect > 1.0f)
? scalingTypeMatchOrientation
: scalingTypeMismatchOrientation;
final Point layoutSize = getDisplaySize(scalingType, frameAspect, maxWidth, maxHeight);
final float visibleFraction = (frameAspect > 1.0f) == (displayAspect > 1.0f)
? visibleFractionMatchOrientation
: visibleFractionMismatchOrientation;
final Point layoutSize = getDisplaySize(visibleFraction, frameAspect, maxWidth, maxHeight);
// If the measure specification is forcing a specific size - yield.
if (View.MeasureSpec.getMode(widthSpec) == View.MeasureSpec.EXACTLY) {