Learn how to add peer-to-peer video calls to your app.
QBRTCClient
and add WebRTC signaling to it.
SessionCallbacksListener
to your QBRTCClient
to define session states. Learn more details about the event listener configuration in the Event listener section.
QBRTCClient
:QBRTCSessionEventsCallback
(with overriding methods) to handle session main events.
QBRTCClientSessionCallbacksImpl
to make your own Session Callback Manager.
QBRTCClient
to process calls. To be sure that your app is ready for calls processing and Activity
exists, use the following snippet in the Activity
class.
userId
for the remote camera app of the remote peer.userId
for the local camera app of the local peer.QBRTCSurfaceView
allows using several views on the screen layout and overlapping each other. This is a good feature for group video calls.
QBRTCSurfaceView
is a surface view (it extends org.webrtc.SurfaceViewRenderer
class) that renders video track. It has its own lifecycle for rendering. It uses init()
method for preparing to render and release()
to release resources when the video track does not exist anymore.
QBRTCSurfaceView
is automatically initialized after the surface is created (in surfaceCreated()
method callback). You can manually initialize QBRTCSurfaceView
using EGLContext
getting from QBRTCClient
. Use this only when Activity
is alive and GL resources exist.
init()
to reinitialize the view only after a previous init()
/release()
cycle.release()
should be called when video track is no more valid, for example, when you receive onConnectionClosedForUser()
callback from QBRTCSession
or when QBRTCSession
is going to close. But you should call release()
method before Activity
is destroyed and while EGLContext
is still valid. If you don’t call this method, the GL resources might leak.
Here are the few methods of the QBRTCSurfaceView
:
QBRTCSurfaceView
, QBRTCVideoTrack
and use:
createNewSessionWithOpponents()
method. After that, you can start calling using startCall()
method.
onReceiveNewSession()
via QBRTCClientSessionCallbacks
(read above).
onCallAcceptByUser()
callback.
onCallRejectByUser()
callback.
QBRTCConfig.setAnswerTimeInterval()
method.
QBRTCClientVideoTracksCallbacks
interface.
QBRTCClientAudioTracksCallback
interface.
hangUp()
method.
onReceiveHangUpFromUser()
callback.
QBRTCClient
. Call the destroy()
method to unregister from receiving any video chat events and close existing signaling channels.
onCallAcceptByUser
callback of QBRTCClient
is received when a call has been accepted. This callback receives information about the call session, user ID who accepted the call, and additional key-value data about the user.
QuickBlox Android SDK persistently interacts with the server via XMPP connection that works as a signaling transport for establishing a call between two or more peers. It receives the callbacks of the asynchronous events which happen with the call and peer connection. This allows you to track these events and build your own video calling features around them.
To track call session events, you should use SessionCallbacksListener
. The inherited event listeners for a call session are QBRTCClientSessionCallback
and QBRTCSessionConnectionCallbacks
.
QBRTCClientSessionCallback
The supported call session event callbacks of QBRTCClientSessionCallback
along with their parameters as well as shows how to add the listener.
Method | Invoked when |
---|---|
onReceiveNewSession() | A new call session has been received. |
onCallAcceptByUser() | A call session has been accepted. |
onCallRejectByUser() | A call session has been rejected. |
onReceiveHangUpFromUser() | An accepted call session has been ended by the peer by pressing the hang-up button. |
onUserNotAnswer() | A remote peer did not respond to your call within the timeout period. |
onUserNoActions() | A user didn’t take any actions on the received call session. |
onSessionStartClose() | A call session is going to be closed. |
onSessionClosed() | A call session has been closed. |
QBRTCSessionConnectionCallbacks
listener are listed in the table below.
Method | Invoked when |
---|---|
onStateChanged | A call session connection state has been changed in real-time. View all available call session states in the Call session states section. |
onStartConnectToUser | A connection establishment process has been started. |
onConnectedToUser | A peer connection has been established. |
onConnectionFailedWithUser | A peer connection has failed. |
onDisconnectedFromUser | A connection was terminated. |
onDisconnectedTimeoutFromUser | An opponent has been disconnected by timeout. |
onConnectionClosedForUser | A connection has been closed for the user. |
State | Description |
---|---|
QB_RTC_SESSION_NEW | A call session was successfully created and ready for the next step. |
QB_RTC_SESSION_PENDING | A call session is in a pending state for other actions to occur. |
QB_RTC_SESSION_CONNECTING | The call session is in the progress of establishing a connection. |
QB_RTC_SESSION_GOING_TO_CLOSE | A call session is going to be closed. |
QB_RTC_SESSION_CLOSED | A call session has been closed. |
State | Description |
---|---|
QB_RTC_CONNECTION_UNKNOWN | A peer connection state is unknown. This can occur when none of the other states are fit for the current situation. |
QB_RTC_CONNECTION_NEW | A peer connection has been created and has not done any networking yet. |
QB_RTC_CONNECTION_WAIT | A peer connection is in a waiting state. |
QB_RTC_CONNECTION_PENDING | A peer connection is in a pending state for other actions to occur. |
QB_RTC_CONNECTION_CONNECTING | One or more of the ICE transports are currently in the process of establishing a connection. |
QB_RTC_CONNECTION_CHECKING | The ICE agent has been given one or more remote candidates and is checking pairs of local and remote candidates against one another to try to find a compatible match, but has not yet found a pair which will allow the peer connection to be made. It is possible that the gathering of candidates is also still underway. |
QB_RTC_CONNECTION_CONNECTED | A usable pairing of local and remote candidates has been found for all components of the connection, and the connection has been established. |
QB_RTC_CONNECTION_DISCONNECTED | A peer has been disconnected from the call session. But the call session is still open and the peer can be reconnected to the call session. |
QB_RTC_CONNECTION_DISCONNECT_TIMEOUT | The peer connection was disconnected by the timeout. |
QB_RTC_CONNECTION_CLOSED | A peer connection was closed. But the call session can still be open because there can several peer connections in a single call session. The ICE agent for this peer connection has shut down and is no longer handling requests. |
QB_RTC_CONNECTION_NOT_ANSWER | No answer received from the remote peer. |
QB_RTC_CONNECTION_REJECT | An incoming call has been rejected by the remote peer without accepting the call. |
QB_RTC_CONNECTION_HANG_UP | The connection was hung up by the remote peer. |
QB_RTC_CONNECTION_FAILED | One or more of the ICE transports on the connection is in the failed state. This can occur in different circumstances, for example, bad network, etc. |
QB_RTC_CONNECTION_ERROR | A peer connection has an error. |