I use Replaykit and webrtc to share my iOS screen to a Chrome web browser.but video is stuck

226 views
Skip to first unread message

王收拾收拾

unread,
Jun 2, 2019, 2:29:56 AM6/2/19
to discuss-webrtc
Replaykit capture screen api:- (void)startCaptureWithHandler:(nullable void(^)(CMSampleBufferRef sampleBuffer, RPSampleBufferType bufferType, NSError * _Nullable error))captureHandler completionHandler:(nullable void(^)(NSError * _Nullable error))completionHandler

transfer CMSampleBufferRef to webrtc to send to Chrome web browser:

- (void)didCaptureVideoBuffer:(CMSampleBufferRef)sampleBuffer {

    if (CMSampleBufferGetNumSamples(sampleBuffer) != 1 || !CMSampleBufferIsValid(sampleBuffer) ||

        !CMSampleBufferDataIsReady(sampleBuffer)) {

        return;

    }

    

    CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

    if (pixelBuffer == nil) {

        return;

    }

    size_t  width = CVPixelBufferGetWidth(pixelBuffer);

    RTCCVPixelBuffer *rtcPixelBuffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:pixelBuffer];

    int64_t timeStampNs =

    CMTimeGetSeconds(CMSampleBufferGetPresentationTimeStamp(sampleBuffer)) * NSEC_PER_SEC;

    RTCVideoFrame *videoFrame = [[RTCVideoFrame alloc] initWithBuffer:rtcPixelBuffer

                                                             rotation:RTCVideoRotation_0

                                                          timeStampNs:timeStampNs];

    [self.delegate capturer:self didCaptureVideoFrame:videoFrame];

}



server is created with nodejs,current problem is that the browser's video is always stuck and stop playing, i checked the iOS end and found it send no data any longer, but the audio is still normal, anyone can help me ,thanks

Krishna Sunkara

unread,
Aug 1, 2019, 5:21:22 AM8/1/19
to discuss-webrtc
We also got the same issue, how to resolve this 

devil 2010

unread,
Oct 8, 2021, 6:22:20 AM (12 days ago) Oct 8
to discuss-webrtc
did someone solved this?

Vào lúc 16:21:22 UTC+7 ngày Thứ Năm, 1 tháng 8, 2019, stv.k...@gmail.com đã viết:
Reply all
Reply to author
Forward
0 new messages