Skip to content
Advertisement

How to implement video with connectionservice

I want to implement a videochat using the system app via connectionservice. https://developer.android.com/reference/android/telecom/ConnectionService.html. Unfortunately i can not find any example or tutorial how to do it. Here is what i have done:

Registering the service:

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);  

Placing the call:

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 get 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 place my videoprovider into the connection the system asks for. The phone activity appears and showing me the call with the little camera sign, so the system knows what i want to do. I now somehow expect that the videoprovider methods get called from the system to give me the surfaces for video and so on but no method get called. Does somebody know what am i doing wrong or know where to find a good example of this topic.

Advertisement

Answer

I simply forgot to add conn.setVideoState(VideoProfile.STATE_BIDIRECTIONAL); to my connection not only on placeCall. Now the VideoProvider is accessed as expected

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement