From d0dd90be62e8f2981a4a5dad1e34edeb221b1d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Thu, 8 Feb 2018 10:15:34 +0100 Subject: [PATCH] New java ScalingSettings constructors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deprecate old constructors. Intended to make java api consistent with the changes in https://webrtc-review.googlesource.com/c/src/+/46622. Bug: webrtc:8830 Change-Id: Iadecb5d033b5de841873905af659d8d234b75c7d Reviewed-on: https://webrtc-review.googlesource.com/49062 Reviewed-by: Sami Kalliomäki Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#21956} --- sdk/android/api/org/webrtc/VideoEncoder.java | 28 +++++++++++++++++++ .../java/org/webrtc/HardwareVideoEncoder.java | 13 ++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/sdk/android/api/org/webrtc/VideoEncoder.java b/sdk/android/api/org/webrtc/VideoEncoder.java index 01c249fa6b..f4836c96ba 100644 --- a/sdk/android/api/org/webrtc/VideoEncoder.java +++ b/sdk/android/api/org/webrtc/VideoEncoder.java @@ -96,11 +96,38 @@ public interface VideoEncoder { public final Integer low; public final Integer high; + /** + * Settings to disable quality based scaling. + */ + public static final ScalingSettings OFF = new ScalingSettings(); + + /** + * Creates settings to enable quality based scaling. + * + * @param low Average QP at which to scale up the resolution. + * @param high Average QP at which to scale down the resolution. + */ + public ScalingSettings(int low, int high) { + this.on = true; + this.low = low; + this.high = high; + } + + private ScalingSettings() { + this.on = false; + this.low = null; + this.high = null; + } + + // TODO(bugs.webrtc.org/8830): Below constructors are deprecated. + // Default thresholds are going away, so thresholds have to be set + // when scaling is on. /** * Creates quality based scaling setting. * * @param on True if quality scaling is turned on. */ + @Deprecated public ScalingSettings(boolean on) { this.on = on; this.low = null; @@ -114,6 +141,7 @@ public interface VideoEncoder { * @param low Average QP at which to scale up the resolution. * @param high Average QP at which to scale down the resolution. */ + @Deprecated public ScalingSettings(boolean on, int low, int high) { this.on = on; this.low = low; diff --git a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java index 0d18a66eff..046ffb29dc 100644 --- a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java +++ b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java @@ -415,7 +415,18 @@ class HardwareVideoEncoder implements VideoEncoder { @Override public ScalingSettings getScalingSettings() { encodeThreadChecker.checkIsOnValidThread(); - return new ScalingSettings(automaticResizeOn); + if (automaticResizeOn) { + if (codecType == VideoCodecType.VP8) { + final int kLowVp8QpThreshold = 29; + final int kHighVp8QpThreshold = 95; + return new ScalingSettings(kLowVp8QpThreshold, kHighVp8QpThreshold); + } else if (codecType == VideoCodecType.H264) { + final int kLowH264QpThreshold = 24; + final int kHighH264QpThreshold = 37; + return new ScalingSettings(kLowH264QpThreshold, kHighH264QpThreshold); + } + } + return ScalingSettings.OFF; } @Override