Unable to Screencast to Apprtc using Replay Kit Over Webrtc

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-02 09:57:01

问题


Hello There, I am trying to screen broadcast with latest webrtc libraries but I keep getting following error:

iOS 13.0 & above: Live broadcast has stopped due to Attempted to start invalid broadcast session.

less than iOS13 but greater than iOS 12.0: Live broadcast has stopped due to:(null)

I would really appreciate if anyone can answer my question. Thanks

 var peerConnectionFactory: RTCPeerConnectionFactory?
            var localVideoSource: RTCVideoSource?
            var videoCapturer: RTCVideoCapturer?
            func setupVideoCapturer(){
                    // localVideoSource and videoCapturer will use 
                    localVideoSource = self.peerConnectionFactory!.videoSource() 
                    videoCapturer = RTCVideoCapturer()
                    localVideoSource.capturer(videoCapturer, didCapture: videoFrame!)

                    let videoTrack : RTCVideoTrack =   self.peerConnectionFactory!.videoTrack(with: localVideoSource, trackId: "100”)

                    let mediaStream: RTCMediaStream = (self.peerConnectionFactory?.mediaStream(withStreamId: “1"))!
                    mediaStream.addVideoTrack(videoTrack)
                    self.newPeerConnection!.add(mediaStream)
                }


         override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
             switch sampleBufferType {
                       case RPSampleBufferType.video:

                    // create the CVPixelBuffer
                    let pixelBuffer:CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)!;

                    // create the RTCVideoFrame
                    var videoFrame:RTCVideoFrame?;
                    let timestamp = NSDate().timeIntervalSince1970 * 1000
                    videoFrame = RTCVideoFrame(pixelBuffer: pixelBuffer, rotation: RTCVideoRotation._0, timeStampNs: Int64(timestamp))
                    // connect the video frames to the WebRTC
                    localVideoSource.capturer(videoCapturer, didCapture: videoFrame!)

                    break
                }
            } 

来源:https://stackoverflow.com/questions/61190672/unable-to-screencast-to-apprtc-using-replay-kit-over-webrtc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!