好的
我根据这个swift的demo只做了 uplodaer的修改 变成OC的,然后使用屏幕共享的时候发现延迟很高,有时候画面还会变形 需要做什么处理么
(void)sendVideoBuffer:(CMSampleBufferRef)sampleBuffer{
CVPixelBufferRef _Nullable videoFrame =
CMSampleBufferGetImageBuffer(sampleBuffer);
if (videoFrame) {
}else{
return;
}
int rotain = 0;
if (@available(iOS 11.0, *)) {
CFStringRef RPVideoSampleOrientationKeyRef = (__bridge CFStringRef)RPVideoSampleOrientationKey;
NSNumber *orientation = (NSNumber *)CMGetAttachment(sampleBuffer, RPVideoSampleOrientationKeyRef,NULL);
if (orientation.integerValue == kCGImagePropertyOrientationUp || orientation.integerValue == kCGImagePropertyOrientationUpMirrored) {
rotain = 0;
}else if(orientation.integerValue == kCGImagePropertyOrientationDown || orientation.integerValue == kCGImagePropertyOrientationDownMirrored){
rotain = 180;
}else if (orientation.integerValue == kCGImagePropertyOrientationLeft || orientation.integerValue == kCGImagePropertyOrientationLeftMirrored){
rotain = 90;
}else if (orientation.integerValue == kCGImagePropertyOrientationRight ||orientation.integerValue == kCGImagePropertyOrientationRightMirrored){
rotain = 270;
}
CMTime time = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
AgoraVideoFrame *frame = [[AgoraVideoFrame alloc] init];
frame.format = 12;
frame.time = time;
frame.textureBuf = videoFrame;
frame.rotation = rotain;
[[self sharedAgoraEngine] pushExternalVideoFrame:frame];
} else {
// Fallback on earlier versions
}
}