Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a04bb8b0 authored by allenwtsu's avatar allenwtsu
Browse files

Pipe audio codec bitrate and bandwidth

Bug: 172304392
Test: atest
Change-Id: Ic00ca711f6da2fd285b50ea0ffaa0aec26610f6f
parent 960fe339
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -190,6 +190,8 @@ public abstract class Connection {

    public static final int AUDIO_QUALITY_STANDARD = 1;
    public static final int AUDIO_QUALITY_HIGH_DEFINITION = 2;
    // the threshold used to compare mAudioCodecBitrateKbps and mAudioCodecBandwidth.
    public static final float THRESHOLD = 0.01f;

    /**
     * The telecom internal call ID associated with this connection.  Only to be used for debugging
@@ -247,6 +249,10 @@ public abstract class Connection {

    // Store the current audio code
    protected int mAudioCodec;
    // audio codec bitrate in kbps
    protected float mAudioCodecBitrateKbps;
    // audio codec bandwidth in kHz
    protected float mAudioCodecBandwidthKhz;

    @UnsupportedAppUsage
    private static String LOG_TAG = "Connection";
@@ -1430,6 +1436,20 @@ public abstract class Connection {
        return mAudioCodec;
    }

    /**
     * @return the audio codec bitrate in kbps.
     */
    public float getAudioCodecBitrateKbps() {
        return mAudioCodecBitrateKbps;
    }

    /**
     * @return the audio codec bandwidth in kHz.
     */
    public float getAudioCodecBandwidthKhz() {
        return mAudioCodecBandwidthKhz;
    }

    /**
     * @return The number verification status; only applicable for IMS calls.
     */
+19 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.ims.AudioCodecAttributes;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsStreamMediaProfile;
import android.text.TextUtils;
@@ -1069,6 +1070,24 @@ public class ImsPhoneConnection extends Connection implements
                mOwner.getPhone().getVoiceCallSessionStats().onAudioCodecChanged(this, mAudioCodec);
            }

            if (localCallProfile != null
                    && localCallProfile.mMediaProfile.getAudioCodecAttributes() != null) {
                AudioCodecAttributes audioCodecAttributes =
                        localCallProfile.mMediaProfile.getAudioCodecAttributes();

                if (Math.abs(mAudioCodecBitrateKbps
                        - audioCodecAttributes.getBitrateRangeKbps().getUpper()) > THRESHOLD) {
                    mAudioCodecBitrateKbps = audioCodecAttributes.getBitrateRangeKbps().getUpper();
                    changed = true;
                }
                if (Math.abs(mAudioCodecBandwidthKhz
                        - audioCodecAttributes.getBandwidthRangeKhz().getUpper()) > THRESHOLD) {
                    mAudioCodecBandwidthKhz =
                            audioCodecAttributes.getBandwidthRangeKhz().getUpper();
                    changed = true;
                }
            }

            int newAudioQuality =
                    getAudioQualityFromCallProfile(localCallProfile, remoteCallProfile);
            if (getAudioQuality() != newAudioQuality) {