【问题标题】:How to custom WebRTC video source?如何自定义 WebRTC 视频源?
【发布时间】:2018-03-26 14:30:30
【问题描述】:

有人知道如何更改 WebRTC (https://cocoapods.org/pods/libjingle_peerconnection) 视频源吗?

我正在开发一个屏幕共享应用程序。 目前,我在 CVPixelBuffer 中实时检索渲染帧。有人知道如何将我的帧添加为视频源吗? 是否可以设置其他视频源而不是相机设备源?是的,视频必须是哪种格式以及如何做?

谢谢。

【问题讨论】:

  • 你找到解决办法了吗

标签: ios swift webrtc screensharing


【解决方案1】:
var connectionFactory :  RTCPeerConnectionFactory = RTCPeerConnectionFactory()
let videoSource :  RTCVideoSource = factory.videoSource()
videoSource.capturer(videoCapturer, didCapture: videoFrame!)

【讨论】:

  • 如果您解释了它的作用以及它解决问题的原因,这个答案会更有帮助。
  • 他暗示使用两个实例,RTCVideoSourceRTCVideoCapturer,首先你从工厂创建videoSource,然后创建捕获器RTCVideoCapturer(delegate: videoSource)。比你用videoSourcetrackId 创建videoTrack 并将其添加到peer.localStream。如果您想将自己的框架处理到 webRTC,您可以创建框架并调用 videoSource.capturer(videoCapturer, didCapture: videoFrame!)
【解决方案2】:

穆尼斯的回答是错误的。这导致什么都没有。至少在撰写本文时不是。根本没有发生任何事情。

事实上,你需要满足这个委托

- (void)capturer:(RTCVideoCapturer *)capturer didCaptureVideoFrame:(RTCVideoFrame *)frame;

(注意与 Swift 版本的区别:didCapturedidCaptureVideoFrame

由于不清楚的原因,该委托在 Swift 级别不可用(编译器说您必须使用 didCapture,因为它已使用 Swift3 从 didCaptureVideoFrame 重命名),您必须将代码放入 ObjC 类中。我确实将thisthis(这是sample project 的一部分)复制到我的项目中,使我的videoCapturer 成为ARDBroadcastSampleHandler 的实例

self.videoCapturer = ARDExternalSampleCapturer(delegate: videoSource)

在捕获回调中我正在调用它

let capturer = self.videoCapturer as? ARDExternalSampleCapturer
capturer?.didCapture(sampleBuffer)

【讨论】:

  • 很遗憾,所有链接都不起作用。
  • 对不起,这些都是外部项目,不是我的
  • 是的,我被困在这个捕获问题上。我有一个准备发送的视频帧,并应用了方法didCapture ,但没有任何运气
猜你喜欢
  • 2021-09-24
  • 2020-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-17
  • 2021-04-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多