use of com.android.ims.ImsCallProfile in project android_frameworks_opt_telephony by LineageOS.
the class ImsPhoneConnection method updateMediaCapabilities.
/**
* Check for a change in the video capabilities and audio quality for the {@link ImsCall}, and
* update the {@link ImsPhoneConnection} with this information.
*
* @param imsCall The call to check for changes in media capabilities.
* @return Whether the media capabilities have been changed.
*/
public boolean updateMediaCapabilities(ImsCall imsCall) {
if (imsCall == null) {
return false;
}
boolean changed = false;
try {
// The actual call profile (negotiated between local and peer).
ImsCallProfile negotiatedCallProfile = imsCall.getCallProfile();
if (negotiatedCallProfile != null) {
int oldVideoState = getVideoState();
int newVideoState = ImsCallProfile.getVideoStateFromImsCallProfile(negotiatedCallProfile);
if (oldVideoState != newVideoState) {
// unpaused state, we will resume passing the video states from the modem as is.
if (VideoProfile.isPaused(oldVideoState) && !VideoProfile.isPaused(newVideoState)) {
// Video entered un-paused state; recognize updates from now on; we want to
// ensure that the new un-paused state is propagated to Telecom, so change
// this now.
mShouldIgnoreVideoStateChanges = false;
}
if (!mShouldIgnoreVideoStateChanges) {
updateVideoState(newVideoState);
changed = true;
} else {
Rlog.d(LOG_TAG, "updateMediaCapabilities - ignoring video state change " + "due to paused state.");
}
if (!VideoProfile.isPaused(oldVideoState) && VideoProfile.isPaused(newVideoState)) {
// Video entered pause state; ignore updates until un-paused. We do this
// after setVideoState is called above to ensure Telecom is notified that
// the device has entered paused state.
mShouldIgnoreVideoStateChanges = true;
}
}
}
// Check for a change in the capabilities for the call and update
// {@link ImsPhoneConnection} with this information.
int capabilities = getConnectionCapabilities();
// Use carrier config to determine if downgrading directly to audio-only is supported.
if (mOwner.isCarrierDowngradeOfVtCallSupported()) {
capabilities = addCapability(capabilities, Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE | Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL);
} else {
capabilities = removeCapability(capabilities, Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE | Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL);
}
// Get the current local call capabilities which might be voice or video or both.
ImsCallProfile localCallProfile = imsCall.getLocalCallProfile();
Rlog.v(LOG_TAG, "update localCallProfile=" + localCallProfile);
if (localCallProfile != null) {
capabilities = applyLocalCallCapabilities(localCallProfile, capabilities);
}
// Get the current remote call capabilities which might be voice or video or both.
ImsCallProfile remoteCallProfile = imsCall.getRemoteCallProfile();
Rlog.v(LOG_TAG, "update remoteCallProfile=" + remoteCallProfile);
if (remoteCallProfile != null) {
capabilities = applyRemoteCallCapabilities(remoteCallProfile, capabilities);
}
if (getConnectionCapabilities() != capabilities) {
setConnectionCapabilities(capabilities);
changed = true;
}
int newAudioQuality = getAudioQualityFromCallProfile(localCallProfile, remoteCallProfile);
if (getAudioQuality() != newAudioQuality) {
setAudioQuality(newAudioQuality);
changed = true;
}
} catch (ImsException e) {
// No session in place -- no change
}
return changed;
}
Aggregations