我有一个 webrtc应用程序,但我想更好地控制视频 View 。所以我正忙于实现我自己的渲染器。我到了通过这个回调开始接收帧的地步:
renderer:(RTCVideoRenderer *)renderer didReceiveFrame:(RTCI420Frame *)frame
它传递一个 RTCI420Frame
作为参数。我需要以某种方式将 frame
中的图像数据转换为纹理。我不知道怎么办。我认为使用 GLKTextureLoader
是不可能的(直到现在我一直使用它从磁盘加载纹理)。
如何从 frame
中获取图像数据并从中创建纹理?
最佳答案
Here is my current class处理我的应用程序中与 WebRTC 相关的所有内容。
这些类是 iOS 上原生 WebRTC 的起点。只需在 BWRTCViewController 上扩展一个 View Controller 并设置一个委托(delegate)。现在您可以立即开始测试,而不必担心自己实现整个调用序列。您只需担心信号。
// your call view controller .h
#import <BWRTCViewController.h>
@interface CallViewController : BWRTCViewController <BWRTCViewControllerDelegate>
@end
// your call view controller .m
- (void)viewDidLoad {
[super viewDidLoad];
if (/*this is the caller*/) {
[super callerSequence];
// wait until callee is ready to receive your offer, then call:
[super startNegotiating];
} else {
/*callee side doesn't have to do a thing*/
}
}
// received a remote sdp
- (void)receivedSdp {
[super receivedSessionDescription:/*your sdp description*/
withType:/*your sdp type*/];
}
// received a remote ice candidate
- (void)receivedIce {
[super receivedIceCandidate:/*your ice candidate*/
sdpMid:/*your ice sdpMid*/
sdpMLineIndex:/*your ice sdpMLineIndex*/];
}
// got a local sdp
- (void) sendSessionDescription:(NSString *)sessionDescription_
withType:(NSString *)type_ {
// use your signaling interface to send the sdp to the remote peer
}
// got a local ice candidate
- (void) sendICECandidate:(NSString *)candidate_
sdpMid:(NSString *)sdpMid_
sdpMLineIndex:(NSInteger)sdpMLineIndex_ {
// use your signaling interface to send the ice to the remote peer
}
关于ios - 如何将 RTCI420Frame 对象转换为纹理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26931588/