From 1b233d3498e685039b709fa89820e536b231688b Mon Sep 17 00:00:00 2001 From: bodamnam Date: Fri, 3 Feb 2023 09:02:51 +0000 Subject: Implementation of video downgrade opreration API Add APIs to downgrade the video triggered by bitrate monitoring Bug: 224903790 Test: atest ImsMediaNativeTests, ImsMediaJavaUnitTests, verified with loopback mode using ImsMediaTestingApp, Video Call downgrade test with L_IR94_312601. Change-Id: I407e5b864bf8258ebb22bb47a1aba1eec871bc2c --- .../imsmedia/IImsVideoSessionCallback.aidl | 2 +- .../telephony/imsmedia/MediaQualityThreshold.java | 26 ++++++++++++++++++++-- .../telephony/imsmedia/VideoSessionCallback.java | 11 +++++---- 3 files changed, 30 insertions(+), 9 deletions(-) (limited to 'framework/src') diff --git a/framework/src/android/telephony/imsmedia/IImsVideoSessionCallback.aidl b/framework/src/android/telephony/imsmedia/IImsVideoSessionCallback.aidl index 8de33a39..b48e560d 100644 --- a/framework/src/android/telephony/imsmedia/IImsVideoSessionCallback.aidl +++ b/framework/src/android/telephony/imsmedia/IImsVideoSessionCallback.aidl @@ -35,6 +35,6 @@ oneway interface IImsVideoSessionCallback { void onPeerDimensionChanged(in int width, in int height); void onHeaderExtensionReceived(in List extensions); void notifyMediaInactivity(int packetType); - void notifyPacketLoss(int packetLossPercentage); + void notifyBitrate(int bitate); void notifyVideoDataUsage(long bytes); } diff --git a/framework/src/android/telephony/imsmedia/MediaQualityThreshold.java b/framework/src/android/telephony/imsmedia/MediaQualityThreshold.java index 3f38e89a..42024a87 100644 --- a/framework/src/android/telephony/imsmedia/MediaQualityThreshold.java +++ b/framework/src/android/telephony/imsmedia/MediaQualityThreshold.java @@ -38,6 +38,7 @@ public final class MediaQualityThreshold implements Parcelable { private final int[] mRtpPacketLossRate; private final int[] mRtpJitterMillis; private final boolean mNotifyCurrentStatus; + private final int mVideoBitrateBps; /** @hide **/ public MediaQualityThreshold(Parcel in) { @@ -60,6 +61,7 @@ public final class MediaQualityThreshold implements Parcelable { mRtpJitterMillis[i] = in.readInt(); } mNotifyCurrentStatus = in.readBoolean(); + mVideoBitrateBps = in.readInt(); } /** @hide **/ @@ -74,6 +76,7 @@ public final class MediaQualityThreshold implements Parcelable { mRtpJitterMillis = Arrays.copyOf(builder.mRtpJitterMillis, builder.mRtpJitterMillis.length); mNotifyCurrentStatus = builder.mNotifyCurrentStatus; + mVideoBitrateBps = builder.mVideoBitrateBps; } /** @hide **/ @@ -111,6 +114,10 @@ public final class MediaQualityThreshold implements Parcelable { return mNotifyCurrentStatus; } + public int getVideoBitrateBps() { + return mVideoBitrateBps; + } + @NonNull @Override public String toString() { @@ -122,6 +129,7 @@ public final class MediaQualityThreshold implements Parcelable { + ", mRtpPacketLossRate=" + Arrays.toString(mRtpPacketLossRate) + ", mRtpJitterMillis=" + Arrays.toString(mRtpJitterMillis) + ", mNotifyCurrentStatus=" + mNotifyCurrentStatus + + ", mVideoBitrateBps=" + mVideoBitrateBps + " }"; } @@ -130,7 +138,7 @@ public final class MediaQualityThreshold implements Parcelable { return Objects.hash(Arrays.hashCode(mRtpInactivityTimerMillis), mRtcpInactivityTimerMillis, mRtpHysteresisTimeInMillis, mRtpPacketLossDurationMillis, Arrays.hashCode(mRtpPacketLossRate), Arrays.hashCode(mRtpJitterMillis), - mNotifyCurrentStatus); + mNotifyCurrentStatus, mVideoBitrateBps); } @Override @@ -151,7 +159,8 @@ public final class MediaQualityThreshold implements Parcelable { && mRtpPacketLossDurationMillis == s.mRtpPacketLossDurationMillis && Arrays.equals(mRtpPacketLossRate, s.mRtpPacketLossRate) && Arrays.equals(mRtpJitterMillis, s.mRtpJitterMillis) - && mNotifyCurrentStatus == s.mNotifyCurrentStatus); + && mNotifyCurrentStatus == s.mNotifyCurrentStatus + && mVideoBitrateBps == s.mVideoBitrateBps); } /** @@ -172,6 +181,7 @@ public final class MediaQualityThreshold implements Parcelable { dest.writeIntArray(mRtpPacketLossRate); dest.writeIntArray(mRtpJitterMillis); dest.writeBoolean(mNotifyCurrentStatus); + dest.writeInt(mVideoBitrateBps); } public static final @NonNull Parcelable.Creator @@ -198,6 +208,7 @@ public final class MediaQualityThreshold implements Parcelable { private int[] mRtpPacketLossRate; private int[] mRtpJitterMillis; private boolean mNotifyCurrentStatus; + private int mVideoBitrateBps; /** * Default constructor for Builder. @@ -209,6 +220,7 @@ public final class MediaQualityThreshold implements Parcelable { mRtpPacketLossDurationMillis = 0; mRtpPacketLossRate = new int[0]; mRtpJitterMillis = new int[0]; + mVideoBitrateBps = 0; } /** @@ -302,6 +314,16 @@ public final class MediaQualityThreshold implements Parcelable { return this; } + /** + * The receiving bitrate threshold in bps for video call. If it is not zero, bitrate + * notification event is triggered when the receiving frame bitrate is less than the + * threshold. + */ + public @NonNull Builder setVideoBitrateBps(final int bitrate) { + this.mVideoBitrateBps = bitrate; + return this; + } + /** * Build the MediaQualityThreshold. * diff --git a/framework/src/android/telephony/imsmedia/VideoSessionCallback.java b/framework/src/android/telephony/imsmedia/VideoSessionCallback.java index cf66ee56..17748bbb 100644 --- a/framework/src/android/telephony/imsmedia/VideoSessionCallback.java +++ b/framework/src/android/telephony/imsmedia/VideoSessionCallback.java @@ -151,12 +151,12 @@ public class VideoSessionCallback extends ImsMediaManager.SessionCallback { } @Override - public void notifyPacketLoss(final int packetLossPercentage) { + public void notifyBitrate(final int bitrate) { if (mLocalCallback == null) return; final long callingIdentity = Binder.clearCallingIdentity(); try { - mExecutor.execute(() -> mLocalCallback.notifyPacketLoss(packetLossPercentage)); + mExecutor.execute(() -> mLocalCallback.notifyBitrate(bitrate)); } finally { restoreCallingIdentity(callingIdentity); } @@ -234,13 +234,12 @@ public class VideoSessionCallback extends ImsMediaManager.SessionCallback { } /** - * Notifies RTP packet loss observed as per thresholds set by + * Notifies when the video bitrate decreased below the threshold set by * setMediaQualityThreshold() API * - * @param packetLossPercentage percentage of packet loss calculated - * over the duration + * @param bitrate The bitrate of sending video packets in bps unit */ - public void notifyPacketLoss(final int packetLossPercentage) { + public void notifyBitrate(final int bitrate) { // Base Implementation } -- cgit v1.2.3