1

我使用 WebRtc 创建点对点连接来共享视频和音频。我想使用 replaykit 录制屏幕和麦克风。如果我在建立对等连接后开始录制,这意味着两者可以相互共享视频和音频。在这种情况下,repalykit 无法录制屏幕和麦克风,并且 previewController 是黑色的.如果我在建立连接之前开始录制 replaykit 效果很好。如果我只选择录制屏幕或不添加RTCAudioTrack,它一直有效。
那么如何在 webrtc 中使用 replaykit 呢?
可以开始用apprtc-ios进行测试

4

1 回答 1

1

通话开始后,设备扬声器、麦克风和摄像头流将添加到对等连接,并且不适用于应用程序中的其他输出。遵循 iOS 11 中引入的新 API。

/*! @abstract Starts screen and audio capture and continually calls the 
supplied handler with the current sampleBuffer and bufferType and passed it 
back to the application. Note that before recording actually starts, the 
user may be prompted with UI to confirm recording.
@result handler Called continually with sampleBuffers and the bufferType. 
Will be passed an optional NSError in the RPRecordingErrorDomain domain if 
there was an issue starting the capture.
*/

- (void)startCaptureWithHandler:(nullable void(^)(CMSampleBufferRef 
sampleBuffer, RPSampleBufferType bufferType, NSError * _Nullable 
error))captureHandler completionHandler:(nullable void(^)(NSError * 
_Nullable error))completionHandler API_AVAILABLE(ios(11.0), tvos(11.0));

此 API 用于捕获扬声器、麦克风和视频样本缓冲区,您可以使用 AVFoundation 的 AVAssetWriter 将它们写入文件。

于 2017-08-29T08:03:50.217 回答