Add support for DegradationPreference in Android SDK

This wires the current degradation preference in the SDK, it will later
be nullable in a follow up change once the native API supports it.

Bug: webrtc:11164
Change-Id: I8324e6e0af996dfddfa07e3aff4ba242d9533388
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161321
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30170}
diff --git a/sdk/android/api/org/webrtc/RtpParameters.java b/sdk/android/api/org/webrtc/RtpParameters.java
index 183faca..4293ce7 100644
--- a/sdk/android/api/org/webrtc/RtpParameters.java
+++ b/sdk/android/api/org/webrtc/RtpParameters.java
@@ -27,6 +27,22 @@
  * default value".
  */
 public class RtpParameters {
+  public enum DegradationPreference {
+    /** Does not degrade resolution or framerate. */
+    DISABLED,
+    /** Degrade resolution in order to maintain framerate. */
+    MAINTAIN_FRAMERATE,
+    /** Degrade framerate in order to maintain resolution. */
+    MAINTAIN_RESOLUTION,
+    /** Degrade a balance of framerate and resolution. */
+    BALANCED;
+
+    @CalledByNative("DegradationPreference")
+    static DegradationPreference fromNativeIndex(int nativeIndex) {
+      return values()[nativeIndex];
+    }
+  }
+
   public static class Encoding {
     // If non-null, this represents the RID that identifies this encoding layer.
     // RIDs are used to identify layers in simulcast.
@@ -230,20 +246,25 @@
 
   public final String transactionId;
 
+  /**
+   * When bandwidth is constrained and the RtpSender needs to choose between degrading resolution or
+   * degrading framerate, degradationPreference indicates which is preferred.
+   */
+  @Nullable public DegradationPreference degradationPreference;
+
   private final Rtcp rtcp;
 
   private final List<HeaderExtension> headerExtensions;
 
   public final List<Encoding> encodings;
-  // Codec parameters can't currently be changed between getParameters and
-  // setParameters. Though in the future it will be possible to reorder them or
-  // remove them.
+
   public final List<Codec> codecs;
 
   @CalledByNative
-  RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions,
-      List<Encoding> encodings, List<Codec> codecs) {
+  RtpParameters(String transactionId, DegradationPreference degradationPreference, Rtcp rtcp,
+      List<HeaderExtension> headerExtensions, List<Encoding> encodings, List<Codec> codecs) {
     this.transactionId = transactionId;
+    this.degradationPreference = degradationPreference;
     this.rtcp = rtcp;
     this.headerExtensions = headerExtensions;
     this.encodings = encodings;
@@ -256,6 +277,11 @@
   }
 
   @CalledByNative
+  DegradationPreference getDegradationPreference() {
+    return degradationPreference;
+  }
+
+  @CalledByNative
   public Rtcp getRtcp() {
     return rtcp;
   }