Skip to content

Android Video Chat

Example of video chat client for Android

This example can be used to participate in video chat for two users on Web Call Server and allows to publish WebRTC stream.

On the screenshot below the participant is connected, publishing a stream and playing stream from the other participant.
The interface of he application is the same as in the example Video Conference, except that two not three videos are played

  • left - video from the camera of this participant
  • right - video from the other participant (Bob)

Analyzing the example code

To analyze the code, let's take classVideoChatActivity.java of the video-chat example, which can be downloaded with corresponding build 1.0.1.38

Functions of initialization, joining a conference, publishing and playing streams work the same as described in the example Video Conference, but maximum number of participants is limited to two

code

@Override
public void onState(final Room room) {
    ...
    if (room.getParticipants().size() >= 2) {
        room.leave(null);
        runOnUiThread(
                new Runnable() {
                    @Override
                    public void run() {
                        mJoinStatus.setText("Room is full");
                        mJoinButton.setEnabled(true);
                    }
                }
        );
        return;
    }
    ...
}