Learn how to add peer-to-peer video calls to your app.
init()
method.
init()
method, a Promise.reject(error)
is returned: The call service is not connected
.sessionId
). You can get the sessionId
from the session
value returned from call()
, accept()
, reject()
, hangUp()
methods or from any event emitted by QB.webrtc
module. See a full list of events here.call()
method.
call()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
opponentsIds | yes | IDs of the opponents. |
type | yes | Call type: QB.webrtc.RTC_SESSION_TYPE.VIDEO, QB.webrtc.RTC_SESSION_TYPE.AUDIO. |
QB.webrtc.EVENT_TYPE.CALL
event.accept()
method and pass sessionId
to tell SDK which call session to accept.
accept()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
sessionId | yes | Call session identifier. |
userInfo | no | Custom user data. |
reject()
method and pass sessionId
parameter to tell SDK which call session to reject.
reject()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
sessionId | yes | Call session identifier. |
userInfo | no | Custom user data. |
hangUp()
method and pass sessionId
parameter to tell SDK which call session to end.
hangUp()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
sessionId | yes | Call session identifier. |
userInfo | no | Custom user data. |
QB.webrtc
module. Call release()
method that allows to unregister QB.webrtc
module from receiving any video chat events and closes existing signaling channels.
release()
method should be called when a video track is no more valid. If you do not call this method, you will get a memory leak.userId
for the remote camera app of the remote peer.userId
for the local camera app of the local peer.WebRTCView
subscribes to QB.webrtc.EVENT_TYPE.RECEIVED_VIDEO_TRACK
event under the hood so you do not need to subscribe to it manually. Thus, once the SDK receives data that a remote video track was received, it creates the event of RECEIVED_VIDEO_TRACK
type with userId
and sessionId
properties. If userId
matches with the one in properties, the video starts playing.
Parameters | Description |
---|---|
sessionId | Call session identifier. |
style | View styles. |
userId | User identifier. |
WebRTCView
is mounted, it is ready to play the video. Thus:
QB.webrtc.EVENT_TYPE.RECEIVED_VIDEO_TRACK
and then add WebRTCViews.
orRECEIVED_VIDEO_TRACK
to come in and trigger playback.accept()
method is called when you accept an incoming call from the opponent. This method receives information about the call session and additional key-value data about the user.
QuickBlox React Native 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.
Event type | Description |
---|---|
QB.webrtc.EVENT_TYPE.CALL | An incoming call event has been received by the peer after the call session has been initiated. |
QB.webrtc.EVENT_TYPE.AССEPT | An incoming call has been accepted by the peer. |
QB.webrtc.EVENT_TYPE.REJECT | An incoming call has been rejected by the remote peer without accepting the call. |
QB.webrtc.EVENT_TYPE.HANG_UP | An accepted call has been ended by the peer by pressing the hang-up button. |
QB.webrtc.EVENT_TYPE.RECEIVED_VIDEO_TRACK | A remote video track has been received by the remote peer. |
QB.webrtc.EVENT_TYPE.PEER_CONNECTION_STATE_CHANGED | A peer connection state has been changed. View all available peer connection states in the Peer connection states section. |
QB.webrtc.EVENT_TYPE.NOT_ANSWER | No answer received from the remote peer within the timer expiration period. |
QB.webrtc.EVENT_TYPE.CALL_END | An accepted call has been ended. A call session was closed. |
Field | Description |
---|---|
type | The name of the event you have subscribed to (for example, QB.webrtc.EVENT_TYPE.CALL, QB.webrtc.EVENT_TYPE.REJECT, etc). |
payload | Available if the event transmits the data. Almost all events contain the session (to identify in which session this event occurred) and userId (to indicate initiator of the event) properties. |
QB.webrtc.EVENT\_TYPE.PEER\_CONNECTION\_STATE\_CHANGED
event type.
Connection state | Description |
---|---|
QB.webrtc.RTC_PEER_CONNECTION_STATE.NEW | Gathering information to establish connection. |
QB.webrtc.RTC_PEER_CONNECTION_STATE.CONNECTED | A peer is connected to a call session. |
QB.webrtc.RTC_PEER_CONNECTION_STATE.FAILED | A peer failed to join a call session. |
QB.webrtc.RTC_PEER_CONNECTION_STATE.DISCONNECTED | A peer is disconnected from a call session. |
QB.webrtc.RTC_PEER_CONNECTION_STATE.CLOSED | A call session is closed by the peer. |