I want to create an app which can screen mirror my phone screen. When start recording, my phone show an error with this message: "Live broadcast to smarttv stopped due to: Attemped to start an invalid broadcast session". I think the ReplayKit.framework seems to be very memory hungry when the device is processing and stop my session. This is my code in SampleHandler file :
`var httpStream : HTTPStream!
var httpService: HLSService!
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.
httpStream = HTTPStream()
httpService = HLSService(domain: "", type: "_http._tcp", name: "Cast", port: 8080)
httpService.addHTTPStream(httpStream)
httpService.startRunning()
httpStream.publish("hello")
httpStream.expectedMedias.insert(.video)
}
override func broadcastPaused() {
// User has requested to pause the broadcast. Samples will stop being delivered.
}
override func broadcastResumed() {
// User has requested to resume the broadcast. Samples delivery will resume.
}
override func broadcastFinished() {
// User has requested to finish the broadcast.
}
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
switch sampleBufferType {
case RPSampleBufferType.video:
self.httpStream.appendSampleBuffer(sampleBuffer, withType: .video)
break
case RPSampleBufferType.audioApp:
// Handle audio sample buffer for app audio
if let description = CMSampleBufferGetFormatDescription(sampleBuffer) {
let dimensions = CMVideoFormatDescriptionGetDimensions(description)
httpStream.videoSettings = VideoCodecSettings.init(videoSize: VideoSize(width: dimensions.width / 2,
height: dimensions.height / 2),
profileLevel: String(kVTProfileLevel_H264_Baseline_AutoLevel),
maxKeyFrameIntervalDuration: 2)
}
httpStream.appendSampleBuffer(sampleBuffer)
break
case RPSampleBufferType.audioMic:
// Handle audio sample buffer for mic audio
httpStream.appendSampleBuffer(sampleBuffer, withType: .audio)
break
@unknown default:
// Handle other sample buffer types
fatalError("Unknown type of sample buffer")
}
}`
To Reproduce
Start broadcast
Run and see the error
Expected behavior
The braadcast session run normally and not be stop
Describe the bug
I want to create an app which can screen mirror my phone screen. When start recording, my phone show an error with this message: "Live broadcast to smarttv stopped due to: Attemped to start an invalid broadcast session". I think the ReplayKit.framework seems to be very memory hungry when the device is processing and stop my session. This is my code in SampleHandler file : `var httpStream : HTTPStream! var httpService: HLSService!
To Reproduce
Expected behavior
The braadcast session run normally and not be stop
Version
Latest
Smartphone info.
No response
Additional context
No response
Screenshots
No response
Relevant log output
No response