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,9 +123,9 @@ class RTC_EXPORT VideoEncoder {
ScalingSettings(); ScalingSettings();
}; };
// Bitrate thresholds for resolution. // Bitrate limits for resolution.
struct ResolutionBitrateThresholds { struct ResolutionBitrateLimits {
ResolutionBitrateThresholds(int frame_size_pixels, ResolutionBitrateLimits(int frame_size_pixels,
int min_start_bitrate_bps, int min_start_bitrate_bps,
int min_bitrate_bps, int min_bitrate_bps,
int max_bitrate_bps) int max_bitrate_bps)
@ -214,8 +214,8 @@ class RTC_EXPORT VideoEncoder {
absl::InlinedVector<uint8_t, kMaxTemporalStreams> absl::InlinedVector<uint8_t, kMaxTemporalStreams>
fps_allocation[kMaxSpatialLayers]; fps_allocation[kMaxSpatialLayers];
// Recommended bitrate thresholds for different resolutions. // Recommended bitrate limits for different resolutions.
std::vector<ResolutionBitrateThresholds> resolution_bitrate_thresholds; std::vector<ResolutionBitrateLimits> resolution_bitrate_limits;
}; };
struct RateControlParameters { 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; public final int frameSizePixels;
@ -207,7 +207,7 @@ public interface VideoEncoder {
*/ */
public final int maxBitrateBps; public final int maxBitrateBps;
public ResolutionBitrateThresholds( public ResolutionBitrateLimits(
int frameSizePixels, int minStartBitrateBps, int minBitrateBps, int maxBitrateBps) { int frameSizePixels, int minStartBitrateBps, int minBitrateBps, int maxBitrateBps) {
this.frameSizePixels = frameSizePixels; this.frameSizePixels = frameSizePixels;
this.minStartBitrateBps = minStartBitrateBps; this.minStartBitrateBps = minStartBitrateBps;
@ -215,22 +215,22 @@ public interface VideoEncoder {
this.maxBitrateBps = maxBitrateBps; this.maxBitrateBps = maxBitrateBps;
} }
@CalledByNative("ResolutionBitrateThresholds") @CalledByNative("ResolutionBitrateLimits")
public int getFrameSizePixels() { public int getFrameSizePixels() {
return frameSizePixels; return frameSizePixels;
} }
@CalledByNative("ResolutionBitrateThresholds") @CalledByNative("ResolutionBitrateLimits")
public int getMinStartBitrateBps() { public int getMinStartBitrateBps() {
return minStartBitrateBps; return minStartBitrateBps;
} }
@CalledByNative("ResolutionBitrateThresholds") @CalledByNative("ResolutionBitrateLimits")
public int getMinBitrateBps() { public int getMinBitrateBps() {
return minBitrateBps; return minBitrateBps;
} }
@CalledByNative("ResolutionBitrateThresholds") @CalledByNative("ResolutionBitrateLimits")
public int getMaxBitrateBps() { public int getMaxBitrateBps() {
return maxBitrateBps; return maxBitrateBps;
} }
@ -295,12 +295,12 @@ public interface VideoEncoder {
/** Any encoder that wants to use WebRTC provided quality scaler must implement this method. */ /** Any encoder that wants to use WebRTC provided quality scaler must implement this method. */
@CalledByNative ScalingSettings getScalingSettings(); @CalledByNative ScalingSettings getScalingSettings();
/** Returns the list of resolution bitrate thresholds. */ /** Returns the list of bitrate limits. */
@CalledByNative @CalledByNative
default ResolutionBitrateThresholds[] getResolutionBitrateThresholds() { default ResolutionBitrateLimits[] getResolutionBitrateLimits() {
// TODO(ssilkin): Update downstream projects and remove default implementation. // TODO(ssilkin): Update downstream projects and remove default implementation.
ResolutionBitrateThresholds thresholds[] = {}; ResolutionBitrateLimits bitrate_limits[] = {};
return thresholds; return bitrate_limits;
} }
/** /**

View File

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

View File

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

View File

@ -36,10 +36,9 @@ VideoEncoderWrapper::VideoEncoderWrapper(JNIEnv* jni,
initialized_ = false; initialized_ = false;
num_resets_ = 0; 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 and is expected to be available before it is initialized.
encoder_info_.resolution_bitrate_thresholds = encoder_info_.resolution_bitrate_limits = GetResolutionBitrateLimits(jni);
GetResolutionBitrateThresholds(jni);
} }
VideoEncoderWrapper::~VideoEncoderWrapper() = default; VideoEncoderWrapper::~VideoEncoderWrapper() = default;
@ -219,36 +218,35 @@ VideoEncoderWrapper::GetScalingSettingsInternal(JNIEnv* jni) const {
} }
} }
std::vector<VideoEncoder::ResolutionBitrateThresholds> std::vector<VideoEncoder::ResolutionBitrateLimits>
VideoEncoderWrapper::GetResolutionBitrateThresholds(JNIEnv* jni) const { VideoEncoderWrapper::GetResolutionBitrateLimits(JNIEnv* jni) const {
std::vector<VideoEncoder::ResolutionBitrateThresholds> std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits;
resolution_bitrate_thresholds;
ScopedJavaLocalRef<jobjectArray> j_thresholds_array = ScopedJavaLocalRef<jobjectArray> j_bitrate_limits_array =
Java_VideoEncoder_getResolutionBitrateThresholds(jni, encoder_); 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) { for (int i = 0; i < num_thresholds; ++i) {
ScopedJavaLocalRef<jobject> j_thresholds = ScopedJavaLocalRef<jobject>( ScopedJavaLocalRef<jobject> j_bitrate_limits = ScopedJavaLocalRef<jobject>(
jni, jni->GetObjectArrayElement(j_thresholds_array.obj(), i)); jni, jni->GetObjectArrayElement(j_bitrate_limits_array.obj(), i));
jint frame_size_pixels = jint frame_size_pixels =
Java_ResolutionBitrateThresholds_getFrameSizePixels(jni, j_thresholds); Java_ResolutionBitrateLimits_getFrameSizePixels(jni, j_bitrate_limits);
jint min_start_bitrate_bps = jint min_start_bitrate_bps =
Java_ResolutionBitrateThresholds_getMinStartBitrateBps(jni, Java_ResolutionBitrateLimits_getMinStartBitrateBps(jni,
j_thresholds); j_bitrate_limits);
jint min_bitrate_bps = jint min_bitrate_bps =
Java_ResolutionBitrateThresholds_getMinBitrateBps(jni, j_thresholds); Java_ResolutionBitrateLimits_getMinBitrateBps(jni, j_bitrate_limits);
jint max_bitrate_bps = jint max_bitrate_bps =
Java_ResolutionBitrateThresholds_getMaxBitrateBps(jni, j_thresholds); Java_ResolutionBitrateLimits_getMaxBitrateBps(jni, j_bitrate_limits);
resolution_bitrate_thresholds.push_back( resolution_bitrate_limits.push_back(VideoEncoder::ResolutionBitrateLimits(
VideoEncoder::ResolutionBitrateThresholds(
frame_size_pixels, min_start_bitrate_bps, min_bitrate_bps, frame_size_pixels, min_start_bitrate_bps, min_bitrate_bps,
max_bitrate_bps)); max_bitrate_bps));
} }
return resolution_bitrate_thresholds; return resolution_bitrate_limits;
} }
void VideoEncoderWrapper::OnEncodedFrame( void VideoEncoderWrapper::OnEncodedFrame(

View File

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