Use loger instead of print for debugging

This commit is contained in:
Tiago Jacobs 2022-02-13 12:14:59 -03:00
parent 41aae6b89a
commit 0088b12fd4

View File

@ -6,44 +6,49 @@
// //
import ReplayKit import ReplayKit
import os
class SampleHandler: RPBroadcastSampleHandler { class SampleHandler: RPBroadcastSampleHandler {
override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?) { private var logger = os.Logger(subsystem: "SampleHandler", category: "broadcast")
// User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.
print("replayKit2 event :: broadcastStarted") 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.
logger.info("replayKit2 event :: broadcastStarted")
override func broadcastPaused() { }
// User has requested to pause the broadcast. Samples will stop being delivered.
print("replayKit2 event :: broadcastPaused") override func broadcastPaused() {
} // User has requested to pause the broadcast. Samples will stop being delivered.
logger.info("replayKit2 event :: broadcastPaused")
override func broadcastResumed() { }
// User has requested to resume the broadcast. Samples delivery will resume.
print("replayKit2 event :: broadcastResumed") override func broadcastResumed() {
} // User has requested to resume the broadcast. Samples delivery will resume.
logger.info("replayKit2 event :: broadcastResumed")
override func broadcastFinished() { }
// User has requested to finish the broadcast.
print("replayKit2 event :: broadcastFinished") override func broadcastFinished() {
} // User has requested to finish the broadcast.
logger.info("replayKit2 event :: broadcastFinished")
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) { }
switch sampleBufferType {
case RPSampleBufferType.video: override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
// Handle video sample buffer switch sampleBufferType {
print("we got video") case RPSampleBufferType.video:
break // Handle video sample buffer
case RPSampleBufferType.audioApp: logger.trace("replayKit2 event :: processSampleBuffer (video)")
// Handle audio sample buffer for app audio break
break case RPSampleBufferType.audioApp:
case RPSampleBufferType.audioMic: // Handle audio sample buffer for app audio
// Handle audio sample buffer for mic audio logger.trace("replayKit2 event :: processSampleBuffer (system audio)")
break break
@unknown default: case RPSampleBufferType.audioMic:
// Handle other sample buffer types // Handle audio sample buffer for mic audio
fatalError("Unknown type of sample buffer") logger.trace("replayKit2 event :: processSampleBuffer (microphone video)")
} break
@unknown default:
// Handle other sample buffer types
fatalError("Unknown type of sample buffer")
} }
}
} }