in BasicBroadcast/ViewControllers/CustomSourcesViewController.swift [137:152]
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
if output == videoOutput {
// This keeps the images coming in with the correct orientation.
connection.videoOrientation = orientation
// A host application can do further processing of this sample by applying a CIFilter, custom Metal shader, or
// by using a more complex pipeline that provides services like a beauty filter.
// It is important that the processing finishes before the next frame arrives, otherwise frames will start to backup.
// If a new video sample does not arrive to the SDK in time, the previous sample will be repeated in the broadcast
// until a new frame arrives.
customImageSource?.onSampleBuffer(sampleBuffer)
} else if output == audioOutput {
// A host application can do further processing of this sample here. It is required for processing to happen before
// the next sample arrives, otherwise audio may be dropped (it will be replaced with silence).
customAudioSource?.onSampleBuffer(sampleBuffer)
}
}