JNI wrapper for PeerConnection::SetBitrate.

BUG=webrtc:7395

Review-Url: https://codereview.webrtc.org/2868413004
Cr-Commit-Position: refs/heads/master@{#19243}
This commit is contained in:
zstein 2017-08-03 11:11:40 -07:00 committed by Commit Bot
parent 552ba37dac
commit d89b0bcc8a
3 changed files with 28 additions and 0 deletions

View File

@ -324,6 +324,10 @@ public class PeerConnection {
nativeNewGetStats(callback);
}
// Limits the bandwidth allocated for all RTP streams sent by this
// PeerConnection. Pass null to leave a value unchanged.
public native boolean setBitrate(Integer min, Integer current, Integer max);
// Starts recording an RTC event log. Ownership of the file is transfered to
// the native code. If an RTC event log is already being recorded, it will be
// stopped and a new one will start using the provided file. Logging will

View File

@ -815,6 +815,10 @@ public class PeerConnectionTest {
answeringExpectations.dataChannel.close();
offeringExpectations.dataChannel.close();
// Test SetBitrate.
assertTrue(offeringPC.setBitrate(100000, 5000000, 500000000));
assertFalse(offeringPC.setBitrate(3, 2, 1));
// Free the Java-land objects and collect them.
shutdownPC(offeringPC, offeringExpectations);
offeringPC = null;

View File

@ -286,6 +286,26 @@ JOW(void, PeerConnection_nativeNewGetStats)
ExtractNativePC(jni, j_pc)->GetStats(callback);
}
JOW(jboolean, PeerConnection_setBitrate)
(JNIEnv* jni, jobject j_pc, jobject j_min, jobject j_current, jobject j_max) {
webrtc::PeerConnectionInterface::BitrateParameters params;
jclass j_integer_class = jni->FindClass("java/lang/Integer");
jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I");
if (!IsNull(jni, j_min)) {
int min_value = jni->CallIntMethod(j_min, int_value_id);
params.min_bitrate_bps = rtc::Optional<int>(min_value);
}
if (!IsNull(jni, j_current)) {
int current_value = jni->CallIntMethod(j_current, int_value_id);
params.current_bitrate_bps = rtc::Optional<int>(current_value);
}
if (!IsNull(jni, j_max)) {
int max_value = jni->CallIntMethod(j_max, int_value_id);
params.max_bitrate_bps = rtc::Optional<int>(max_value);
}
return ExtractNativePC(jni, j_pc)->SetBitrate(params).ok();
}
JOW(bool, PeerConnection_nativeStartRtcEventLog)
(JNIEnv* jni, jobject j_pc, int file_descriptor, int max_size_bytes) {
return ExtractNativePC(jni, j_pc)->StartRtcEventLog(file_descriptor,