0

i have implemented the screen sharing with webrtc streaming. i have used RPKit for screen sharing. screen sharing is working in iPhone11 mobile but same code not working in iPhone6s mobile. both mobiles had same iOS Version(iOS 13.4). i want to show this in every iOS Device. Please help me on this. please refer the below code:

 func startScreenShare() {
    let screenSharefactory = self.connectionFactory
    let screenShare_Stream = screenSharefactory.mediaStream(withStreamId :  "videostream")
    let videoCapturer = RTCVideoCapturer()
    let videoSource :  RTCVideoSource = screenSharefactory.videoSource()
    self.captureController?.stopCapture()
    self.peerConnection?.remove(stream)


    RPScreenRecorder.shared().startCapture(handler: { (cmSampleBuffer, rpSampleType, error) in



        switch rpSampleType {



        case RPSampleBufferType.video:

            // create the CVPixelBuffer

            guard let pixelBuffer: CVImageBuffer = CMSampleBufferGetImageBuffer(cmSampleBuffer) else {

                break

            }



            let rtcpixelBuffer = RTCCVPixelBuffer(pixelBuffer: pixelBuffer)



            let timeStampNs: Int64 = Int64(CMTimeGetSeconds(CMSampleBufferGetPresentationTimeStamp(cmSampleBuffer)) * 1000000000)



            let videoFrame =  RTCVideoFrame(buffer: rtcpixelBuffer, rotation: RTCVideoRotation._0, timeStampNs: timeStampNs)

            videoSource.capturer(videoCapturer, didCapture: videoFrame)



            let screenShare_VideoTrack = screenSharefactory.videoTrack(with :  videoSource, trackId :  "videotrack")

            screenShare_VideoTrack.isEnabled = true

            screenShare_Stream.addVideoTrack(screenShare_VideoTrack)



        case RPSampleBufferType.audioApp:

            break

        case RPSampleBufferType.audioMic:

            //                let audioTrack = screenSharefactory.audioTrack(withTrackId :  String.random())

            //                audioTrack.isEnabled = true

            //                screenShare_Stream.addAudioTrack(audioTrack)

            break

        default:

            print("sample has no matching type")

        }



        if self.peerConnection != nil

        {

            self.peerConnection?.add(screenShare_Stream)

        }



    })

}

0 Answers0