Broadcast Upload Extension stream sampleBuffer to a server

Implementing a Broadcast Upload Extension with a SampleHandler.swift and invoking it with a BroadcastPicker works fine. However, in trying to find out how to process the samples coming in to processSampleBuffer, the trail goes cold. Does anyone know how to upload the samples to a streaming server?


In a nutshell: How does one convert sample data (CMSampleBuffer) to a standard format, for audio and video, ready to send to a server?

Apples WWDC code suggests:


// session: add frame
let imageBuffer:CVImageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)!
let pts:CMTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer) as CMTime
VTCompressionSessionEncodeFrame(session!, imageBuffer: imageBuffer, presentationTimeStamp: pts, duration: CMTime.invalid, frameProperties: nil, sourceFrameRefcon: nil, infoFlagsOut: nil)


in processSampleBuffer, but the actual uploading of video and audio sample frames is not mentioned.


override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {

    switch sampleBufferType {
    case RPSampleBufferType.video:
        // Handle video sample buffer

        // What now?

        break
    case RPSampleBufferType.audioApp:
        // Handle audio sample buffer for app audio

        // What now?

        break
    case RPSampleBufferType.audioMic:
        // Handle audio sample buffer for mic audio

        // What now?

        break
    @unknown default:
        // Handle other sample buffer types
        fatalError("Unknown type of sample buffer")
    }

}


Any help would be much appreciated.

I support the question. How did the developers at Apple intend for audio and video to be transmitted? How can I transmit video if I'm using, for example, WebRTC in the main application? Many people solve this by serializing CVPixelBuffer into data and passing it to the application... But why not allow the transmission of IOSurface? This mechanism exists, but the methods for bootstrap port or XPC are closed for iOS.

Broadcast Upload Extension stream sampleBuffer to a server
 
 
Q