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

@ -35,6 +35,11 @@ VideoEncoderWrapper::VideoEncoderWrapper(JNIEnv* jni,
: encoder_(jni, j_encoder), int_array_class_(GetClass(jni, "[I")) {
initialized_ = false;
num_resets_ = 0;
// Get bitrate thresholds in the constructor. This is a static property of the
// encoder and is expected to be available before it is initialized.
encoder_info_.resolution_bitrate_thresholds =
GetResolutionBitrateThresholds(jni);
}
VideoEncoderWrapper::~VideoEncoderWrapper() = default;
@ -214,6 +219,38 @@ VideoEncoderWrapper::GetScalingSettingsInternal(JNIEnv* jni) const {
}
}
std::vector<VideoEncoder::ResolutionBitrateThresholds>
VideoEncoderWrapper::GetResolutionBitrateThresholds(JNIEnv* jni) const {
std::vector<VideoEncoder::ResolutionBitrateThresholds>
resolution_bitrate_thresholds;
ScopedJavaLocalRef<jobjectArray> j_thresholds_array =
Java_VideoEncoder_getResolutionBitrateThresholds(jni, encoder_);
const jsize num_thresholds = jni->GetArrayLength(j_thresholds_array.obj());
for (int i = 0; i < num_thresholds; ++i) {
ScopedJavaLocalRef<jobject> j_thresholds = ScopedJavaLocalRef<jobject>(
jni, jni->GetObjectArrayElement(j_thresholds_array.obj(), i));
jint frame_size_pixels =
Java_ResolutionBitrateThresholds_getFrameSizePixels(jni, j_thresholds);
jint min_start_bitrate_bps =
Java_ResolutionBitrateThresholds_getMinStartBitrateBps(jni,
j_thresholds);
jint min_bitrate_bps =
Java_ResolutionBitrateThresholds_getMinBitrateBps(jni, j_thresholds);
jint max_bitrate_bps =
Java_ResolutionBitrateThresholds_getMaxBitrateBps(jni, j_thresholds);
resolution_bitrate_thresholds.push_back(
VideoEncoder::ResolutionBitrateThresholds(
frame_size_pixels, min_start_bitrate_bps, min_bitrate_bps,
max_bitrate_bps));
}
return resolution_bitrate_thresholds;
}
void VideoEncoderWrapper::OnEncodedFrame(
JNIEnv* jni,
const JavaRef<jobject>& j_caller,

View File

@ -79,6 +79,9 @@ class VideoEncoderWrapper : public VideoEncoder {
ScalingSettings GetScalingSettingsInternal(JNIEnv* jni) const;
std::vector<ResolutionBitrateThresholds> GetResolutionBitrateThresholds(
JNIEnv* jni) const;
const ScopedJavaGlobalRef<jobject> encoder_;
const ScopedJavaGlobalRef<jclass> int_array_class_;