作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个 webrtc 屏幕共享应用程序。因此我正在使用objective-c webrtc 框架。
现在我在如何传递 RTCVideoEncoderSettings ( http://cocoadocs.org/docsets/GoogleWebRTC/1.1.20266/Classes/RTCVideoEncoderSettings.html ) 方面遇到问题
到编码器 (VP9)。这是我目前拥有的:
public class CustomVideoEncoderFactory : NSObject, RTCVideoEncoderFactory {
var encoder: RTCVideoEncoder?
var preferredCodec: RTCVideoCodecInfo = RTCVideoCodecInfo(name: "VP9")
public func createEncoder(_ info: RTCVideoCodecInfo) -> RTCVideoEncoder? {
let vp9Encoder = RTCVideoEncoderVP9.vp9Encoder()!
// How to pass the RTCVideoEncoderSettings into this encoder???
return vp9Encoder
}
public func supportedCodecs() -> [RTCVideoCodecInfo] {
return [RTCVideoCodecInfo(name: "VP9")]
}
public class CustomVideoEncoder: NSObject, RTCVideoEncoder { ... }
) 没有用。
最佳答案
好的,我找到了解决方案。事实证明,对于 VP9 和 VP8,缺少 Objective-c 包装。 VP9 和 Vp8 直接链接到原生实现!
因此,如果您使用的是 h264,则只能进行子类化。
要更改 VP9 和 VP8 上的设置,需要修改 C++ 代码中的设置!
自定义编码器工厂的示例:
public class CustomVideoEncoderFactory : NSObject, RTCVideoEncoderFactory {
public func createEncoder(_ info: RTCVideoCodecInfo) -> RTCVideoEncoder? {
let encoder = super.createEncoder(info) // will create the h264 encoder
let customEncoder = CustomVideoEncoder()
self.encoder = customEncoder
return encoder
}
public func supportedCodecs() -> [RTCVideoCodecInfo] {
return [RTCVideoCodecInfo(name: kRTCVideoCodecH264Name)] }}
public class CustomVideoEncoder: NSObject, RTCVideoEncoder {
public var encoder: RTCVideoEncoder? // ONLY WORKS WITH h264
public func setCallback(_ callback: @escaping RTCVideoEncoderCallback) {
return encoder!.setCallback(callback)
}
public func startEncode(with settings: RTCVideoEncoderSettings, numberOfCores: Int32) -> Int {
// Change settings here !
let res = encoder!.startEncode(with: settings, numberOfCores: numberOfCores)
}
public func release() -> Int {
return encoder!.release()
}
public func encode(_ frame: RTCVideoFrame, codecSpecificInfo info: RTCCodecSpecificInfo?, frameTypes: [NSNumber]) -> Int {
return encoder!.encode(frame, codecSpecificInfo: info, frameTypes: frameTypes)
}
public func setBitrate(_ bitrateKbit: UInt32, framerate: UInt32) -> Int32 {
return encoder!.setBitrate(bitrateKbit, framerate: framerate)
}
public func implementationName() -> String {
return encoder!.implementationName()
}
public func scalingSettings() -> RTCVideoEncoderQpThresholds? {
return encoder!.scalingSettings()
}}
关于objective-c - WebRTC:如何将 RTCVideoEncoderSettings 传递到 RTCVideoEncoder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61426109/
我正在开发一个 webrtc 屏幕共享应用程序。因此我正在使用objective-c webrtc 框架。 现在我在如何传递 RTCVideoEncoderSettings ( http://coco
我是一名优秀的程序员,十分优秀!