Expose bitrate_priority and network_priority in Android API.

BUG=webrtc:5658

Change-Id: Ie4fcad0a379bed17c41efffde044fa51f51a14b1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168360
Commit-Queue: Taylor <deadbeef@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30861}
This commit is contained in:
Taylor Brandstetter 2020-03-23 23:16:58 +00:00 committed by Commit Bot
parent ea6ae4a323
commit e3a294c2d6
5 changed files with 51 additions and 6 deletions

View file

@ -322,6 +322,12 @@ rtc_library("rtp_parameters") {
]
}
if (is_android) {
java_cpp_enum("rtp_parameters_enums") {
sources = [ "rtp_parameters.h" ]
}
}
rtc_source_set("audio_quality_analyzer_api") {
visibility = [ "*" ]
testonly = true

View file

@ -93,6 +93,7 @@ enum class DegradationPreference {
RTC_EXPORT extern const double kDefaultBitratePriority;
// GENERATED_JAVA_ENUM_PACKAGE: org.webrtc
enum class Priority {
kVeryLow,
kLow,
@ -399,6 +400,11 @@ struct RTC_EXPORT RtpEncodingParameters {
// The relative bitrate priority of this encoding. Currently this is
// implemented for the entire rtp sender by using the value of the first
// encoding parameter.
// See: https://w3c.github.io/webrtc-priority/#enumdef-rtcprioritytype
// "very-low" = 0.5
// "low" = 1.0
// "medium" = 2.0
// "high" = 4.0
// TODO(webrtc.bugs.org/8630): Implement this per encoding parameter.
// Currently there is logic for how bitrate is distributed per simulcast layer
// in the VideoBitrateAllocator. This must be updated to incorporate relative
@ -407,9 +413,7 @@ struct RTC_EXPORT RtpEncodingParameters {
// The relative DiffServ Code Point priority for this encoding, allowing
// packets to be marked relatively higher or lower without affecting
// bandwidth allocations. See https://w3c.github.io/webrtc-dscp-exp/ . NB
// we follow chromium's translation of the allowed string enum values for
// this field to 1.0, 0.5, et cetera, similar to bitrate_priority above.
// bandwidth allocations. See https://w3c.github.io/webrtc-dscp-exp/ .
// TODO(http://crbug.com/webrtc/8630): Implement this per encoding parameter.
// TODO(http://crbug.com/webrtc/11379): TCP connections should use a single
// DSCP value even if shared by multiple senders; this is not implemented.

View file

@ -327,7 +327,10 @@ if (is_android) {
"//rtc_base:base_java",
"//third_party/android_deps:com_android_support_support_annotations_java",
]
srcjar_deps = [ "//api/video:video_frame_enums" ]
srcjar_deps = [
"//api:rtp_parameters_enums",
"//api/video:video_frame_enums",
]
}
# Modules, in alphabetical order.

View file

@ -50,6 +50,19 @@ public class RtpParameters {
// Set to true to cause this encoding to be sent, and false for it not to
// be sent.
public boolean active = true;
// The relative bitrate priority of this encoding. Currently this is
// implemented for the entire RTP sender by using the value of the first
// encoding parameter.
// See: https://w3c.github.io/webrtc-priority/#enumdef-rtcprioritytype
// "very-low" = 0.5
// "low" = 1.0
// "medium" = 2.0
// "high" = 4.0
public double bitratePriority = 1.0;
// The relative DiffServ Code Point priority for this encoding, allowing
// packets to be marked relatively higher or lower without affecting
// bandwidth allocations.
@Priority public int networkPriority = Priority.LOW;
// If non-null, this represents the Transport Independent Application
// Specific maximum bandwidth defined in RFC3890. If null, there is no
// maximum bitrate.
@ -75,10 +88,13 @@ public class RtpParameters {
}
@CalledByNative("Encoding")
Encoding(String rid, boolean active, Integer maxBitrateBps, Integer minBitrateBps,
Integer maxFramerate, Integer numTemporalLayers, Double scaleResolutionDownBy, Long ssrc) {
Encoding(String rid, boolean active, double bitratePriority, @Priority int networkPriority,
Integer maxBitrateBps, Integer minBitrateBps, Integer maxFramerate,
Integer numTemporalLayers, Double scaleResolutionDownBy, Long ssrc) {
this.rid = rid;
this.active = active;
this.bitratePriority = bitratePriority;
this.networkPriority = networkPriority;
this.maxBitrateBps = maxBitrateBps;
this.minBitrateBps = minBitrateBps;
this.maxFramerate = maxFramerate;
@ -98,6 +114,17 @@ public class RtpParameters {
return active;
}
@CalledByNative("Encoding")
double getBitratePriority() {
return bitratePriority;
}
@CalledByNative("Encoding")
@Priority
int getNetworkPriority() {
return networkPriority;
}
@Nullable
@CalledByNative("Encoding")
Integer getMaxBitrateBps() {

View file

@ -47,6 +47,7 @@ ScopedJavaLocalRef<jobject> NativeToJavaRtpEncodingParameter(
const RtpEncodingParameters& encoding) {
return Java_Encoding_Constructor(
env, NativeToJavaString(env, encoding.rid), encoding.active,
encoding.bitrate_priority, static_cast<int>(encoding.network_priority),
NativeToJavaInteger(env, encoding.max_bitrate_bps),
NativeToJavaInteger(env, encoding.min_bitrate_bps),
NativeToJavaInteger(env, encoding.max_framerate),
@ -95,6 +96,10 @@ RtpEncodingParameters JavaToNativeRtpEncodingParameters(
encoding.active = Java_Encoding_getActive(jni, j_encoding_parameters);
ScopedJavaLocalRef<jobject> j_max_bitrate =
Java_Encoding_getMaxBitrateBps(jni, j_encoding_parameters);
encoding.bitrate_priority =
Java_Encoding_getBitratePriority(jni, j_encoding_parameters);
encoding.network_priority = static_cast<webrtc::Priority>(
Java_Encoding_getNetworkPriority(jni, j_encoding_parameters));
encoding.max_bitrate_bps = JavaToNativeOptionalInt(jni, j_max_bitrate);
ScopedJavaLocalRef<jobject> j_min_bitrate =
Java_Encoding_getMinBitrateBps(jni, j_encoding_parameters);