Mute audio
Mute the audio by callinglocalMediaStream.audioTrack.enabled() method. Using this method, we can tell SDK to send/not send audio data either from a local or remote peer in the specified call session.
- Swift
- Objective-C
Mute remote audio
You can always get remote audio tracks for a specific user ID in the call using the below-specifiedQBRTCSession methods (assuming that they are existent).
- Swift
- Objective-C
- Swift
- Objective-C
Disable video
Turn off/turn on the video by callinglocalMediaStream.videoTrack.enabled(). Using this method, we can tell SDK not to send video data either from a local or remote peer in the specified call session.
- Swift
- Objective-C
Due to webrtc restrictions black frames will be placed into stream content if video is disabled.
Switch camera
You can switch the video camera during a call. (Default: front camera)- Swift
- Objective-C
Manage audio session
QuickbloxWebRTC has its own audio session management which you need to use. It’s located in theQBRTCAudioSession class. This class is represented as singleton and you can always access a shared session by calling the instance() method.
- Swift
- Objective-C
QBRTCAudioSession class header for more information.
Configure
You can configure an audio session using thesetConfiguration() method.
- Swift
- Objective-C
setConfiguration() method accepts the configuration argument of the object type with the following fields:
| Field | Required | Description |
|---|---|---|
| categoryOptions | no | Audio session category options allow to tailor the behavior of the active audio session category. Default: allowBluetooth. See Apple documentation to learn about supported values. |
| mode | no | Audio session mode allows to assign specialized behavior to an audio session category. Default: videoChat. See Apple documentation to learn about supported values. |
Activate
Activate an audio session before every call.- Swift
- Objective-C
setActive(), method accepts the following argument:
| Agrument | Required | Description |
|---|---|---|
| isActive | yes | Boolean paramater. Set the true to activate an audio session. |
setConfiguration() accepts the following arguments:
| Argument | Required | Description |
|---|---|---|
| configuration | yes | Audio session configuration object. You can set the configuration object fields. See this section to learn how to set audio session configuration. |
| isActive | yes | Boolean paramater. Set the true to activate an audio session. |
Deactivate
Deactivate an audio session after the call ends.- Swift
- Objective-C
| Argument | Required | Description |
|---|---|---|
| isActive | yes | Boolean paramater. Set the true to activate an audio session. |
Set audio output
You can output audio either from the receiver unless you set theAVAudioSessionModeVideoChat mode or speaker.
- Swift
- Objective-C
| Argument | Required | Descriotion |
|---|---|---|
| receiver/speaker | yes | State for the current audio category. |
Screen sharing
Screen sharing allows you to share information from your application to all of your opponents. It gives you the ability to promote your product, share a screen with formulas to students, distribute podcasts, share video/audio/photo moments of your life in real-time all over the world. To implement this feature in your application, we give you the ability to create custom video capture. Video capture is a base class you should inherit from in order to send frames to your opponents. There are two ways to implement this feature in your application.Due to Apple iOS restrictions, screen sharing feature works only within the app it is used in.
- Swift
- Objective-C
self.screenCapture should be a property of QBRTCVideoCapture class type.
2. iOS 10 and older.
This way is a little bit tricky and you will not be able to achieve resource-free 30 fps screen sharing. The maximum fps rate we recommend here is 5 as this a resource-heavy operation.
QBRTCVideoCapture class allows sending frames to your opponents. By inheriting this class you are able to provide custom logic to create frames, modify them, and then send to your opponents. Below you can find an example of how to implement a custom video capture and send frames to your opponents (this class is designed to share 5 screenshots per second).
- Swift
- Objective-C
WebRTC stats reporting
Stats reporting is an insanely powerful tool which can help to debug a call if there are any problems with it (for example, lags, missing audio/video etc). To enable stats report you should first set stats reporting frequency usingsetStatsReportTimeInterval() method below.
- Swift
- Objective-C
QBRTCStatsReport instance for the current period of time.
- Swift
- Objective-C
statsString(), you will receive a generic report string, which will contain the most useful data to debug a call, for example:
Logs
CNConnection info.
*VSVideo sent.VRVideo received.AvgQPAverage quantization parameter (only valid for video; it is calculated as a fraction of the current delta sum over the current delta of encoded frames; low value corresponds with good quality; the range of the value per frame is defined by the codec being used).ASAudio sent.ARAudio received.
audioReceivedOutputLevel for that.
Take a look at the QBRTCStatsReport header file to see all of the other stats properties that can be useful for you.
Calling offline users (CallKit)
Before starting you need to configure APNs and/or VoIP push certificate in your admin panel. Use this guide to add push notifications feature to your QuickBlox application.Generic push notifications
You can send a regular push notification to users you call, this will notify them about your call (if they have subscribed to push notifications in their app, see Push notifications guide).- Swift
- Objective-C
Apple CallKit using VoIP push notifications
QuickbloxWebRTC fully supports Apple CallKit. In this block, we will guide you through the most important things you need to know when integrating CallKit into your application. To learn more about this process, review the above-specified link. Project preparations In your Xcode project, make sure that your app supports Voice over IP services. For that open your Info.plist and make sure you have a specific line in Required background modes array:
QBRTCAudioSession instance for that task. See Manage audio session section for more information.
Initializing audio session
You must initialize audio session every time before you call the reportNewIncomingCall(with:update:completion:) method of CXProvider showing the incoming call screen. Before initializing the audio session, set useManualAudio property value to YES. This will not activate WebRTC audio before iOS allows it. You will need to activate audio manually later. See Manage audio session section for more information.
Managing audio session activations
CXProviderDelegate has 2 delegate methods that you must conform to:
provider(_:didActivate:)provider(_:didDeactivate:)
QBRTCAudioSessionActivationDelegate protocol of QBRTCAudioSession class, you need to notify that the session was activated outside of it. The provider(_:didActivate:) is a CXProviderDelegate where we need to activate our audio manually. Set audioEnabled property of QBRTCAudioSession class in here, to enable WebRTC audio as iOS has pushed audio session priority of our app to the top.
- Swift
- Objective-C
CXProvider deactivates it in provider(_:didDeactivate) of CXProviderDelegate. Deinitializing audio session earlier would lead to issues with the audio session.
- Swift
- Objective-C
QBRTCAudioSession somewhere else in your app, you can check and ignore it with QBRTCAudioSessionActivationDelegate audioSessionIsActivatedOutside() method. By this, you will know for sure that CallKit is in charge of your audio session. Do not forget to restore QBRTCAudioSession properties to default values in provider(_:perform:) method of CXProviderDelegate.
- Swift
- Objective-C
General settings
You can change different settings for your calls usingQBRTCConfig class. All of them are listed below.
Answer time interval
If an opponent hasn’t answered you within an answer time interval, thensession(_:userDidNotRespond:) and session(_:connectionClosedForUser:) delegate methods will be called. The answer time interval shows how much time an opponent has to answer your call. Set the answer time interval using the code snippet below.
- Swift
- Objective-C
- By default, the answer time interval is 45 seconds.
- The maximum values is 60 seconds.
- The minimum value is 10 seconds.
Dialing time interval
Dialing time interval indicates how often to notify your opponents about your call. Set the dialing time interval using the code snippet below.- Swift
- Objective-C
- By default, the dialing time interval is 5 seconds.
- The minimum value is 3 seconds.
Datagram Transport Layer Security
Datagram Transport Layer Security (DTLS) is used to provide communications privacy for datagram protocols. This fosters a secure signaling channel that cannot be tampered with. In other words, no eavesdropping or message forgery can occur on a DTLS encrypted connection.- Swift
- Objective-C
By default, DTLS is enabled.
Custom ICE servers
You can customize a list of ICE servers. By default, WebRTC module will use internal ICE servers that are usually enough, but you can always set your own. WebRTC engine will choose the TURN relay with the lowest round-trip time. Thus, setting multiple TURN servers allows your application to scale-up in terms of bandwidth and number of users. Review our Setup guide to learn how to configure custom ICE servers.Media settings
You can configure a variety of media settings such as video/audio codecs, camera resolution, etc.Video codecs
You can choose video codecs from available values:QBRTCVideoCodecVP8- VP8 video codecQBRTCVideoCodecH264Baseline- h264 baseline video codecQBRTCVideoCodecH264High- h264 high video codec
- baseline is the most suited one for video calls as it has a low cost (default value).
- high is mainly suited for broadcast to ensure you have the best picture possible. Takes more resources to encode/decode for the same resolution you set.
- Swift
- Objective-C
This will set your preferred codec as WebRTC will always choose the most suitable one for both sides in a call through negotiations.
Video quality
Video quality depends on the hardware you use. It also depends on the network you use and how many connections you have. For multi-calls, set lower video quality. For 1 to 1 calls, you can set a higher quality. You can use ourformatsWithPosition() method in order to get all supported formats for a current device.
- Swift
- Objective-C
- If some opponent user does not support h264, then automatically VP8 will be used.
- If both caller and callee have h264 support, then h264 will be used.
Camera resolution
It’s possible to set custom video resolution usingQBRTCVideoFormat.
- Swift
- Objective-C
| Parameters | Description |
|---|---|
| width | Video width. Default: 640. |
| height | Video hight. Default: 480. |
| frameRate | Video frames per second. Default: 30. |
| pixelFormat | Video pixel format. Default: QBRTCPixelFormat420f |
formats(with:). Set a needed one from the list using the snippet below,
- Swift
- Objective-C
Audio codecs
You can choose audio codecs from available values:QBRTCAudioCodecOpusQBRTCAudioCodecISACQBRTCAudioCodeciLBC
By default,
QBRTCAudioCodecOpus is set.- Swift
- Objective-C
- Supported bitrate: constant and variable, from 6 kbit/s to 510 kbit/s.
- Supported sampling rates: from 8 kHz to 48 kHz.
- Supported bitrates: adaptive and variable. From 10 kbit/s to 52 kbit/s.
- Supported sampling rates: 32 kHz.
- Supported bitrates: fixed bitrate. 15.2 kbit/s or 13.33 kbit/s
- Supported sampling rate: 8 kHz.