Adding Java and Obj-C bindings for RtpEncodingParameters.ssrc.

BUG=webrtc:6903

Review-Url: https://codereview.webrtc.org/2581913002
Cr-Commit-Position: refs/heads/master@{#15936}
This commit is contained in:
deadbeef
2017-01-06 16:53:00 -08:00
committed by Commit bot
parent 055c0a892b
commit 8014c75931
4 changed files with 33 additions and 0 deletions

View File

@ -21,6 +21,7 @@ public class RtpParameters {
public boolean active = true; public boolean active = true;
// A null value means "no maximum bitrate". // A null value means "no maximum bitrate".
public Integer maxBitrateBps; public Integer maxBitrateBps;
public Long ssrc;
} }
public static class Codec { public static class Codec {

View File

@ -2335,8 +2335,12 @@ static void JavaRtpParametersToJsepRtpParameters(
GetFieldID(jni, j_encoding_parameters_class, "active", "Z"); GetFieldID(jni, j_encoding_parameters_class, "active", "Z");
jfieldID bitrate_id = GetFieldID(jni, j_encoding_parameters_class, jfieldID bitrate_id = GetFieldID(jni, j_encoding_parameters_class,
"maxBitrateBps", "Ljava/lang/Integer;"); "maxBitrateBps", "Ljava/lang/Integer;");
jfieldID ssrc_id =
GetFieldID(jni, j_encoding_parameters_class, "ssrc", "Ljava/lang/Long;");
jclass j_integer_class = jni->FindClass("java/lang/Integer"); jclass j_integer_class = jni->FindClass("java/lang/Integer");
jclass j_long_class = jni->FindClass("java/lang/Long");
jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I"); jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I");
jmethodID long_value_id = GetMethodID(jni, j_long_class, "longValue", "()J");
for (jobject j_encoding_parameters : Iterable(jni, j_encodings)) { for (jobject j_encoding_parameters : Iterable(jni, j_encodings)) {
webrtc::RtpEncodingParameters encoding; webrtc::RtpEncodingParameters encoding;
@ -2350,6 +2354,13 @@ static void JavaRtpParametersToJsepRtpParameters(
} else { } else {
encoding.max_bitrate_bps = kBitrateUnlimited; encoding.max_bitrate_bps = kBitrateUnlimited;
} }
jobject j_ssrc =
GetNullableObjectField(jni, j_encoding_parameters, ssrc_id);
if (!IsNull(jni, j_ssrc)) {
jlong ssrc_value = jni->CallLongMethod(j_ssrc, long_value_id);
CHECK_EXCEPTION(jni) << "error during CallLongMethod";
encoding.ssrc = rtc::Optional<uint32_t>(ssrc_value);
}
parameters->encodings.push_back(encoding); parameters->encodings.push_back(encoding);
} }
@ -2394,9 +2405,13 @@ static jobject JsepRtpParametersToJavaRtpParameters(
GetFieldID(jni, encoding_class, "active", "Z"); GetFieldID(jni, encoding_class, "active", "Z");
jfieldID bitrate_id = jfieldID bitrate_id =
GetFieldID(jni, encoding_class, "maxBitrateBps", "Ljava/lang/Integer;"); GetFieldID(jni, encoding_class, "maxBitrateBps", "Ljava/lang/Integer;");
jfieldID ssrc_id =
GetFieldID(jni, encoding_class, "ssrc", "Ljava/lang/Long;");
jclass integer_class = jni->FindClass("java/lang/Integer"); jclass integer_class = jni->FindClass("java/lang/Integer");
jclass long_class = jni->FindClass("java/lang/Long");
jmethodID integer_ctor = GetMethodID(jni, integer_class, "<init>", "(I)V"); jmethodID integer_ctor = GetMethodID(jni, integer_class, "<init>", "(I)V");
jmethodID long_ctor = GetMethodID(jni, long_class, "<init>", "(J)V");
for (const webrtc::RtpEncodingParameters& encoding : parameters.encodings) { for (const webrtc::RtpEncodingParameters& encoding : parameters.encodings) {
jobject j_encoding_parameters = jobject j_encoding_parameters =
@ -2411,6 +2426,13 @@ static jobject JsepRtpParametersToJavaRtpParameters(
jni->SetObjectField(j_encoding_parameters, bitrate_id, j_bitrate_value); jni->SetObjectField(j_encoding_parameters, bitrate_id, j_bitrate_value);
CHECK_EXCEPTION(jni) << "error during SetObjectField"; CHECK_EXCEPTION(jni) << "error during SetObjectField";
} }
if (encoding.ssrc) {
jobject j_ssrc_value = jni->NewObject(long_class, long_ctor,
static_cast<jlong>(*encoding.ssrc));
CHECK_EXCEPTION(jni) << "error during NewObject";
jni->SetObjectField(j_encoding_parameters, ssrc_id, j_ssrc_value);
CHECK_EXCEPTION(jni) << "error during SetObjectField";
}
jboolean added = jni->CallBooleanMethod(j_encodings, encodings_add, jboolean added = jni->CallBooleanMethod(j_encodings, encodings_add,
j_encoding_parameters); j_encoding_parameters);
CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; CHECK_EXCEPTION(jni) << "error during CallBooleanMethod";

View File

@ -14,6 +14,7 @@
@synthesize isActive = _isActive; @synthesize isActive = _isActive;
@synthesize maxBitrateBps = _maxBitrateBps; @synthesize maxBitrateBps = _maxBitrateBps;
@synthesize ssrc = _ssrc;
static const int kBitrateUnlimited = -1; static const int kBitrateUnlimited = -1;
@ -30,6 +31,9 @@ static const int kBitrateUnlimited = -1;
_maxBitrateBps = _maxBitrateBps =
[NSNumber numberWithInt:nativeParameters.max_bitrate_bps]; [NSNumber numberWithInt:nativeParameters.max_bitrate_bps];
} }
if (nativeParameters.ssrc) {
_ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc];
}
} }
return self; return self;
} }
@ -40,6 +44,9 @@ static const int kBitrateUnlimited = -1;
if (_maxBitrateBps != nil) { if (_maxBitrateBps != nil) {
parameters.max_bitrate_bps = _maxBitrateBps.intValue; parameters.max_bitrate_bps = _maxBitrateBps.intValue;
} }
if (_ssrc != nil) {
parameters.ssrc = rtc::Optional<uint32_t>(_ssrc.unsignedLongValue);
}
return parameters; return parameters;
} }

View File

@ -25,6 +25,9 @@ RTC_EXPORT
*/ */
@property(nonatomic, copy, nullable) NSNumber *maxBitrateBps; @property(nonatomic, copy, nullable) NSNumber *maxBitrateBps;
/** The SSRC being used by this encoding. */
@property(nonatomic, readonly, nullable) NSNumber *ssrc;
- (instancetype)init NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_DESIGNATED_INITIALIZER;
@end @end