How to Implement Connected Video

I want to implement a video chat using a system app via a connection service. https://developer.android.com/reference/android/telecom/ConnectionService.html . Unfortunately I cannot find any example or tutorial on how to do this. Here's what I did:

Service registration:

TelecomManager manager = (TelecomManager) getSystemService(TELECOM_SERVICE);
PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(new    ComponentName(getBaseContext().getPackageName(),    PhoneConnectionService.class.getName()), "myConnectionServiceId");
PhoneAccount.Builder builder = PhoneAccount.builder(phoneAccountHandle,   Localization.localize(R.string.IDS_APP_NAME_SHORT));
builder.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER | PhoneAccount.CAPABILITY_CONNECTION_MANAGER| PhoneAccount.CAPABILITY_VIDEO_CALLING );
PhoneAccount phoneAccount = builder.build();
manager.registerPhoneAccount(phoneAccount);  

      

Call placement:

TelecomManager manager = (TelecomManager) context.getSystemService(TELECOM_SERVICE);
PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(new ComponentName(context.getPackageName(), PhoneConnectionService.class.getName()), "estosConnectionServiceId");
Bundle test = new Bundle();
test.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,phoneAccountHandle);
test.putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.STATE_BIDIRECTIONAL);
test.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS,extras);
manager.placeCall(Uri.parse("tel:" + number),test);

      

My ConnectionService gets called and

@Override
public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {

    Connection conn = new MyAndroidCallConnection();
    conn.setAddress(request.getAddress(),PRESENTATION_ALLOWED);
    conn.setInitializing();
    conn.setVideoProvider(new MyVideoProvider());
    conn.setActive();

    return conn;
}

      

i put my video provider on the connection that the system asks for. The phone action will pop up and show me a call with a small camera sign so the system knows what I want to do. Now I somehow expect the video user methods to be called from the system to give me surfaces for the video, etc., but the method is not called. Does anyone know what I am doing wrong or know where to find a good example of this topic.

+3


source to share


1 answer


I just forgot to add conn.setVideoState(VideoProfile.STATE_BIDIRECTIONAL);

to my connection other than placeCall. The VideoProvider is now accessed as expected



0


source







All Articles