简体   繁体   English

iOS在后台通过UDP连接发送视频(屏幕共享)数据包

[英]iOS send video (screen sharing) packets on UDP connection in background

I am working on an iOS application with screen sharing feature using Broadcast Upload extension. 我正在使用带有“广播上传”扩展程序的屏幕共享功能的iOS应用程序。 I am able to send video packets using UDP connection for screen share in foreground mode but when app goes to background mode no video packets are being delivered to media server. 我能够使用UDP连接在前台模式下发送视频数据包以进行屏幕共享,但是当应用程序进入后台模式时,没有视频数据包将传递到媒体服务器。 Although audio packets are getting delivered. 虽然音频数据包正在传递。 I have turned on the Audio Airplay and Voip background modes. 我已打开音频Airplay和Voip背景模式。

Also frames are being added to the capturer using below code. 同样,使用以下代码将帧添加到捕获器。

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];

//NSLog(@"videoframe %@",videoFrame.buffer.description);
[_videoSource capturer:_capturer didCaptureVideoFrame:videoFrame];

I can see the above frames being added to capturer even in background mode but not able to see anything on server. 我可以看到以上框架即使在后台模式下也已添加到捕获器,但在服务器上看不到任何内容。

Note - All the code for sending data to server is written in containing app and not in extension . 注–将数据发送到服务器的所有代码均写在包含app而不是扩展名中。

Apple's replayKit works only on foreground due to security policy apple doesn't allow in the background. 苹果的replayKit仅在前台运行,因为苹果不允许在后台使用安全策略。 in your case when the application goes background there will not generate any video buffer. 在您的情况下,当应用程序进入后台时,将不会生成任何视频缓冲区。 you can check by debugging in 您可以通过调试来检查

override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) { 覆盖func processSampleBuffer(_ sampleBuffer:CMSampleBuffer,sampleBufferType:RPSampleBufferType){

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM