Add resolution bitrate thresholds to EncoderInfo.

When provided, these thresholds will be used instead of WebRTC default
limits specified in DropDueToSize() and GetMaxDefaultVideoBitrateKbps().

Bug: none
Change-Id: Ida45ea832041963b8b8475d69114b5c60a172fb7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/142170
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Alex Glaznev <glaznev@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28390}
This commit is contained in:
Sergey Silkin
2019-06-26 14:11:03 +02:00
committed by Commit Bot
parent 2644a703cc
commit be0adee768
8 changed files with 214 additions and 1 deletions

View File

@ -11,6 +11,8 @@
package org.webrtc;
import android.support.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import org.webrtc.EncodedImage;
/**
@ -181,6 +183,59 @@ public interface VideoEncoder {
}
}
/**
* Bitrate thresholds for resolution.
*/
public class ResolutionBitrateThresholds {
/**
* Maximum size of video frame, in pixels, the bitrate thresholds are intended for.
*/
public final int frameSizePixels;
/**
* Recommended minimum bitrate to start encoding.
*/
public final int minStartBitrateBps;
/**
* Recommended minimum bitrate.
*/
public final int minBitrateBps;
/**
* Recommended maximum bitrate.
*/
public final int maxBitrateBps;
public ResolutionBitrateThresholds(
int frameSizePixels, int minStartBitrateBps, int minBitrateBps, int maxBitrateBps) {
this.frameSizePixels = frameSizePixels;
this.minStartBitrateBps = minStartBitrateBps;
this.minBitrateBps = minBitrateBps;
this.maxBitrateBps = maxBitrateBps;
}
@CalledByNative("ResolutionBitrateThresholds")
public int getFrameSizePixels() {
return frameSizePixels;
}
@CalledByNative("ResolutionBitrateThresholds")
public int getMinStartBitrateBps() {
return minStartBitrateBps;
}
@CalledByNative("ResolutionBitrateThresholds")
public int getMinBitrateBps() {
return minBitrateBps;
}
@CalledByNative("ResolutionBitrateThresholds")
public int getMaxBitrateBps() {
return maxBitrateBps;
}
}
public interface Callback {
/**
* Call to return an encoded frame. It is safe to assume the byte buffer held by |frame| is not
@ -240,6 +295,14 @@ public interface VideoEncoder {
/** Any encoder that wants to use WebRTC provided quality scaler must implement this method. */
@CalledByNative ScalingSettings getScalingSettings();
/** Returns the list of resolution bitrate thresholds. */
@CalledByNative
default ResolutionBitrateThresholds[] getResolutionBitrateThresholds() {
// TODO(ssilkin): Update downstream projects and remove default implementation.
ResolutionBitrateThresholds thresholds[] = {};
return thresholds;
}
/**
* Should return a descriptive name for the implementation. Gets called once and cached. May be
* called from arbitrary thread.