Rename ..BitrateThresholds to ..BitrateLimits.

Bug: webrtc:10798
Change-Id: I1975206323a520b557652760d1d54c01c26a7405
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144540
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28473}
This commit is contained in:
Sergey Silkin
2019-07-03 15:09:33 +02:00
committed by Commit Bot
parent cecee9903f
commit 3d642f8442
6 changed files with 54 additions and 57 deletions

View File

@ -123,12 +123,12 @@ class RTC_EXPORT VideoEncoder {
ScalingSettings();
};
// Bitrate thresholds for resolution.
struct ResolutionBitrateThresholds {
ResolutionBitrateThresholds(int frame_size_pixels,
int min_start_bitrate_bps,
int min_bitrate_bps,
int max_bitrate_bps)
// Bitrate limits for resolution.
struct ResolutionBitrateLimits {
ResolutionBitrateLimits(int frame_size_pixels,
int min_start_bitrate_bps,
int min_bitrate_bps,
int max_bitrate_bps)
: frame_size_pixels(frame_size_pixels),
min_start_bitrate_bps(min_start_bitrate_bps),
min_bitrate_bps(min_bitrate_bps),
@ -214,8 +214,8 @@ class RTC_EXPORT VideoEncoder {
absl::InlinedVector<uint8_t, kMaxTemporalStreams>
fps_allocation[kMaxSpatialLayers];
// Recommended bitrate thresholds for different resolutions.
std::vector<ResolutionBitrateThresholds> resolution_bitrate_thresholds;
// Recommended bitrate limits for different resolutions.
std::vector<ResolutionBitrateLimits> resolution_bitrate_limits;
};
struct RateControlParameters {

View File

@ -184,11 +184,11 @@ public interface VideoEncoder {
}
/**
* Bitrate thresholds for resolution.
* Bitrate limits for resolution.
*/
public class ResolutionBitrateThresholds {
public class ResolutionBitrateLimits {
/**
* Maximum size of video frame, in pixels, the bitrate thresholds are intended for.
* Maximum size of video frame, in pixels, the bitrate limits are intended for.
*/
public final int frameSizePixels;
@ -207,7 +207,7 @@ public interface VideoEncoder {
*/
public final int maxBitrateBps;
public ResolutionBitrateThresholds(
public ResolutionBitrateLimits(
int frameSizePixels, int minStartBitrateBps, int minBitrateBps, int maxBitrateBps) {
this.frameSizePixels = frameSizePixels;
this.minStartBitrateBps = minStartBitrateBps;
@ -215,22 +215,22 @@ public interface VideoEncoder {
this.maxBitrateBps = maxBitrateBps;
}
@CalledByNative("ResolutionBitrateThresholds")
@CalledByNative("ResolutionBitrateLimits")
public int getFrameSizePixels() {
return frameSizePixels;
}
@CalledByNative("ResolutionBitrateThresholds")
@CalledByNative("ResolutionBitrateLimits")
public int getMinStartBitrateBps() {
return minStartBitrateBps;
}
@CalledByNative("ResolutionBitrateThresholds")
@CalledByNative("ResolutionBitrateLimits")
public int getMinBitrateBps() {
return minBitrateBps;
}
@CalledByNative("ResolutionBitrateThresholds")
@CalledByNative("ResolutionBitrateLimits")
public int getMaxBitrateBps() {
return maxBitrateBps;
}
@ -295,12 +295,12 @@ 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. */
/** Returns the list of bitrate limits. */
@CalledByNative
default ResolutionBitrateThresholds[] getResolutionBitrateThresholds() {
default ResolutionBitrateLimits[] getResolutionBitrateLimits() {
// TODO(ssilkin): Update downstream projects and remove default implementation.
ResolutionBitrateThresholds thresholds[] = {};
return thresholds;
ResolutionBitrateLimits bitrate_limits[] = {};
return bitrate_limits;
}
/**

View File

@ -35,7 +35,7 @@ TEST(JavaCodecsWrapperTest, JavaToNativeVideoCodecInfo) {
EXPECT_EQ(cricket::kH264ProfileLevelConstrainedBaseline, it->second);
}
TEST(JavaCodecsWrapperTest, JavaToNativeResolutionBitrateThresholds) {
TEST(JavaCodecsWrapperTest, JavaToNativeResolutionBitrateLimits) {
JNIEnv* env = AttachCurrentThreadIfNeeded();
ScopedJavaLocalRef<jobject> j_fake_encoder =
jni::Java_CodecsWrapperTestHelper_createFakeVideoEncoder(env);
@ -43,15 +43,14 @@ TEST(JavaCodecsWrapperTest, JavaToNativeResolutionBitrateThresholds) {
auto encoder = jni::JavaToNativeVideoEncoder(env, j_fake_encoder);
ASSERT_TRUE(encoder);
// Check that the resolution bitrate thresholds are correctly passed from Java
// to native.
const std::vector<VideoEncoder::ResolutionBitrateThresholds> thresholds =
encoder->GetEncoderInfo().resolution_bitrate_thresholds;
ASSERT_EQ(thresholds.size(), 1u);
EXPECT_EQ(thresholds[0].frame_size_pixels, 640 * 360);
EXPECT_EQ(thresholds[0].min_start_bitrate_bps, 300000);
EXPECT_EQ(thresholds[0].min_bitrate_bps, 200000);
EXPECT_EQ(thresholds[0].max_bitrate_bps, 1000000);
// Check that the bitrate limits correctly passed from Java to native.
const std::vector<VideoEncoder::ResolutionBitrateLimits> bitrate_limits =
encoder->GetEncoderInfo().resolution_bitrate_limits;
ASSERT_EQ(bitrate_limits.size(), 1u);
EXPECT_EQ(bitrate_limits[0].frame_size_pixels, 640 * 360);
EXPECT_EQ(bitrate_limits[0].min_start_bitrate_bps, 300000);
EXPECT_EQ(bitrate_limits[0].min_bitrate_bps, 200000);
EXPECT_EQ(bitrate_limits[0].max_bitrate_bps, 1000000);
}
} // namespace
} // namespace test

View File

@ -41,14 +41,14 @@ class FakeVideoEncoder implements VideoEncoder {
}
@Override
public ResolutionBitrateThresholds[] getResolutionBitrateThresholds() {
ResolutionBitrateThresholds resolution_bitrate_thresholds[] = {
new ResolutionBitrateThresholds(/* frameSizePixels = */ 640 * 360,
public ResolutionBitrateLimits[] getResolutionBitrateLimits() {
ResolutionBitrateLimits resolution_bitrate_limits[] = {
new ResolutionBitrateLimits(/* frameSizePixels = */ 640 * 360,
/* minStartBitrateBps = */ 300000,
/* minBitrateBps = */ 200000,
/* maxBitrateBps = */ 1000000)};
return resolution_bitrate_thresholds;
return resolution_bitrate_limits;
}
@Override

View File

@ -36,10 +36,9 @@ VideoEncoderWrapper::VideoEncoderWrapper(JNIEnv* jni,
initialized_ = false;
num_resets_ = 0;
// Get bitrate thresholds in the constructor. This is a static property of the
// Get bitrate limits 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);
encoder_info_.resolution_bitrate_limits = GetResolutionBitrateLimits(jni);
}
VideoEncoderWrapper::~VideoEncoderWrapper() = default;
@ -219,36 +218,35 @@ VideoEncoderWrapper::GetScalingSettingsInternal(JNIEnv* jni) const {
}
}
std::vector<VideoEncoder::ResolutionBitrateThresholds>
VideoEncoderWrapper::GetResolutionBitrateThresholds(JNIEnv* jni) const {
std::vector<VideoEncoder::ResolutionBitrateThresholds>
resolution_bitrate_thresholds;
std::vector<VideoEncoder::ResolutionBitrateLimits>
VideoEncoderWrapper::GetResolutionBitrateLimits(JNIEnv* jni) const {
std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits;
ScopedJavaLocalRef<jobjectArray> j_thresholds_array =
Java_VideoEncoder_getResolutionBitrateThresholds(jni, encoder_);
ScopedJavaLocalRef<jobjectArray> j_bitrate_limits_array =
Java_VideoEncoder_getResolutionBitrateLimits(jni, encoder_);
const jsize num_thresholds = jni->GetArrayLength(j_thresholds_array.obj());
const jsize num_thresholds =
jni->GetArrayLength(j_bitrate_limits_array.obj());
for (int i = 0; i < num_thresholds; ++i) {
ScopedJavaLocalRef<jobject> j_thresholds = ScopedJavaLocalRef<jobject>(
jni, jni->GetObjectArrayElement(j_thresholds_array.obj(), i));
ScopedJavaLocalRef<jobject> j_bitrate_limits = ScopedJavaLocalRef<jobject>(
jni, jni->GetObjectArrayElement(j_bitrate_limits_array.obj(), i));
jint frame_size_pixels =
Java_ResolutionBitrateThresholds_getFrameSizePixels(jni, j_thresholds);
Java_ResolutionBitrateLimits_getFrameSizePixels(jni, j_bitrate_limits);
jint min_start_bitrate_bps =
Java_ResolutionBitrateThresholds_getMinStartBitrateBps(jni,
j_thresholds);
Java_ResolutionBitrateLimits_getMinStartBitrateBps(jni,
j_bitrate_limits);
jint min_bitrate_bps =
Java_ResolutionBitrateThresholds_getMinBitrateBps(jni, j_thresholds);
Java_ResolutionBitrateLimits_getMinBitrateBps(jni, j_bitrate_limits);
jint max_bitrate_bps =
Java_ResolutionBitrateThresholds_getMaxBitrateBps(jni, j_thresholds);
Java_ResolutionBitrateLimits_getMaxBitrateBps(jni, j_bitrate_limits);
resolution_bitrate_thresholds.push_back(
VideoEncoder::ResolutionBitrateThresholds(
frame_size_pixels, min_start_bitrate_bps, min_bitrate_bps,
max_bitrate_bps));
resolution_bitrate_limits.push_back(VideoEncoder::ResolutionBitrateLimits(
frame_size_pixels, min_start_bitrate_bps, min_bitrate_bps,
max_bitrate_bps));
}
return resolution_bitrate_thresholds;
return resolution_bitrate_limits;
}
void VideoEncoderWrapper::OnEncodedFrame(

View File

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