Learn how to add peer-to-peer video calls to your app.
QBRTCClientDelegate
protocol. Use the method below to subscribe. Learn more details about the event delegate configuration in the Event delegate section.
QBRTCClient
and QBRTCSession
methods below.
QBRTCConfig
).
self.session
refers to the current call session. Each particular audio/video call has a unique sessionID
. This allows you to have more than one independent audio/video conference calls. If you want to increase the call timeout, you can increase it up to 60 seconds at maximum.
setAnswerTimeInterval
value is 45 seconds.acceptCall()
method below.
rejectCall()
method below.
hangUp()
method below.
UIView
on the storyboard and then use the following code.
QBRTCRemoteVideoView
views on the storyboard and then use the following code.
QBCallSession
methods (assuming that they are existent).
session(_:acceptedByUser:userInfo:)
method of the QBRTCClientDelegate
is called when your call has been accepted by the user. This callback receives information about the call session, user ID who accepted the call and additional key-value data about the user.
QuickBlox iOS 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 QBRTCSessionEventsCallback
listener. The supported event callbacks for a call session and peer connection are listed in the table below.
Method | Invoked when |
---|---|
didReceiveNewSession(_:userInfo:) | A new call session has been received. |
session(_:acceptedByUser:userInfo:) | A call session has been accepted. |
session(_:rejectedByUser:userInfo:) | A call session has been rejected. |
session(_:hungUpByUser:userInfo:) | An accepted call has been ended by the peer by pressing the hang-up button. |
session(_:userDidNotRespond:) | A remote peer did not respond to your call within the timeout period. |
session(_:sessionDidClose:) | A call session has been closed. |
session(_:updatedStatsReport:forUserID:) | An updated stats report, which is called by timeout, has been received for the user ID. |
session(_:didChangeState:) | A call session state has been changed in real-time. View all available call session states in the Call session states section. |
session(_:receivedRemoteAudioTrack:fromUser:) | A remote audio track has been received from the peer. |
session(_: receivedRemoteVideoTrack:fromUser:) | A remote video track has been received from the peer. |
session(_:startedConnectingToUser:) | A peer connection has been initiated. |
session(_:connectedToUser:) | A peer connection has been established. |
session(_:connectionFailedForUser:) | A peer connection has failed. |
session(_:disconnectedFromUser:) | A connection was terminated. |
session(_:didChange:forUser:) | A peer connection state has been changed. View all available peer connection states in the Peer connection states section. |
session(_:connectionClosedForUser:) | A peer connection has been closed. |
session(_:didChangeRconnectionState:forUser:) | A call reconnection state has been changed in real-time. View all available call reconnection states in the Call reconnection states section. |
QBRTCSession
property.
State | Description |
---|---|
QBRTCSessionStateNew | A call session was successfully created and ready for the next step. |
QBRTCSessionStatePending | A call session is in a pending state for other actions to occur. |
QBRTCSessionStateConnecting | A call session is in the progress of establishing a connection. |
QBRTCSessionStateConnected | A call session was successfully established. |
QBRTCSessionStateClosed | A call session has been closed. |
State | Description |
---|---|
QBRTCReconnectionStateReconnecting | A connection with opponent in reconnection progress after ICE connection failed. |
QBRTCReconnectionStateReconnected | A connection with opponent was successfully established. |
QBRTCReconnectionStateFailed | A connection with opponent isn’t restored by disconnect time interval. |
QBRTCSession
.
State | Description |
---|---|
QBRTCConnectionUnknown | A connection state is unknown; this can occur when none of the other states are fit for the current situation. |
QBRTCConnectionStateNew | A peer connection has been created and hasn’t done any networking yet. |
QBRTCConnectionStatePending | A connection is in a pending state for other actions to occur. |
QBRTCConnectionStateConnecting | One or more of the ICE transports are currently in the process of establishing a connection. |
QBRTCConnectionStateChecking | 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 gathering of candidates is also still underway. |
QBRTCConnectionStateConnected | A usable pairing of local and remote candidates has been found for all components of the connection, and the connection has been established. |
QBRTCConnectionStateDisconnected | A peer has been disconnected from the call session. But the call session is still open and the peer can be reconnected to the session. |
QBRTCConnectionStateDisconnectTimeout | The peer connection was disconnected by the timeout. |
QBRTCConnectionStateClosed | 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. |
QBRTCConnectionStateCount | The ICE connection reached max numbers. |
QBRTCConnectionStateNoAnswer | The connection did not receive an answer from the remote peer. |
QBRTCConnectionStateRejected | The connection was rejected by the remote peer. |
QBRTCConnectionStateHangUp | The connection was hung up by the remote peer. |
QBRTCConnectionStateFailed | 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. |