50 lines
1.6 KiB
Swift
50 lines
1.6 KiB
Swift
//
|
|
// SampleHandler.swift
|
|
// BroadcastUpload
|
|
//
|
|
// Created by Tiago Daniel Jacobs on 12/02/22.
|
|
//
|
|
|
|
import ReplayKit
|
|
|
|
class SampleHandler: RPBroadcastSampleHandler {
|
|
|
|
override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?) {
|
|
// User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.
|
|
print("replayKit2 event :: broadcastStarted")
|
|
}
|
|
|
|
override func broadcastPaused() {
|
|
// User has requested to pause the broadcast. Samples will stop being delivered.
|
|
print("replayKit2 event :: broadcastPaused")
|
|
}
|
|
|
|
override func broadcastResumed() {
|
|
// User has requested to resume the broadcast. Samples delivery will resume.
|
|
print("replayKit2 event :: broadcastResumed")
|
|
}
|
|
|
|
override func broadcastFinished() {
|
|
// User has requested to finish the broadcast.
|
|
print("replayKit2 event :: broadcastFinished")
|
|
}
|
|
|
|
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
|
|
switch sampleBufferType {
|
|
case RPSampleBufferType.video:
|
|
// Handle video sample buffer
|
|
print("we got video")
|
|
break
|
|
case RPSampleBufferType.audioApp:
|
|
// Handle audio sample buffer for app audio
|
|
break
|
|
case RPSampleBufferType.audioMic:
|
|
// Handle audio sample buffer for mic audio
|
|
break
|
|
@unknown default:
|
|
// Handle other sample buffer types
|
|
fatalError("Unknown type of sample buffer")
|
|
}
|
|
}
|
|
}
|