Banuba SDK iOS
The entry point to Banuba SDK is BanubaSdkManager
class. This class provides the following functionality:
- Rendering layer configuration --
setRenderTarget
(RenderTarget
on the diagramm). - Start/stop Effect Player --
startEffectPlayer
,stopEffectPlayer
. - Continuous photo rendering (i.e. the dynamic effect applied to the frozen image) --
startEditingImage
,captureEditedImage
,stopEditingImage
. - Take a photo with the camera and apply the current effect --
makeCameraPhoto
. - Apply the effect to an in-memory photo (e.g. images created from files) --
processImageData
. - Apply the watermark while rendering --
configureWatermark
,removeWatermark
. - Apply the effect to the sequence of frames in memory (e.g. video file) --
startVideoProcessing
,stopVideoProcessing
,processVideoFrame
. - Push a frame from the camera --
push
. - Take snapshots --
output?.takeSnapshot
. - Record a screen video with effects applied --
output?.startRecordingWithURL
,output?.pauseRecording
,output?.resumeRecording
,output?.stopRecording
(OutputService
andVideoRecorder
on the diagramm). - Send frames to other destinations (e.g. via WebRTC) --
output?.startForwardingFrames
,output?.stopForwardingFrames
. - Camera and audio input control --
input
(instanse ofInputService
, see the diagramm). - Capturing the frames rendered (in binary form, used for debugging) --
setFrameDataRecord
.
The Effect component makes up an essential part of the SDK usage. The effect is represented as a folder with scripts and resources. Please, refer to the iOS demo app section for more details about effects.
Configuring watermark
If you wan't to apply watermark to your photos, you should use output?.takeSnapshot
method instead of makeCameraPhoto
. Watermark can be used only with snapshots made with takeSnapshot
.
guard let watermark = UIImage(named: "YOUR_WATERMARK_IMAGE") else { return }
let offset = CGPoint(x: 20.0, y: 10.0)
let watermarkInfo = WatermarkInfo(image: watermark,
corner: .bottomLeft, offset: offset, targetNormalizedWidth: 0.7)
sdkManager.configureWatermark(watermarkInfo)
let config = OutputConfiguration(applyWatermark: true, adjustDeviceOrientation: true,
mirrorFrontCamera: false)
sdkManager.output?.takeSnapshot(configuration: config) {}
Configuring AVAudioSession
In Banuba SDK, the AVAudioSession is set to category .ambient
by default. You can change it to another category using the InputService.swift
file, the startCamera()
method.
public func startCamera() {
configureAudioSessionWithCategory(.ambient)
cameraSessionQueue.async { [weak self] in
guard let self = self, let session = self.cameraCaptureSession else { return }
session.startRunning()
}
}
You can modify AVAudioSession mode and the options that will be appropriate for your app’s behaviour using the configureAudioSessionWithCategory
method.
private func configureAudioSessionWithCategory(_ category: AVAudioSession.Category) {
let audioSharedSession = AVAudioSession.sharedInstance()
do {
try audioSharedSession.setCategory(category, mode: .default, options: .mixWithOthers)
try audioSharedSession.setActive(true)
} catch {
print(Defaults.configureAudioSessionFailedMessage)
}
}
Visit our FAQ or contact our support.