云信SDK会把采集数据 回调出来
NIMNetCallVideoCaptureParam *param = [[NIMNetCallVideoCaptureParamalloc]init];
param.videoHandler = ^(CMSampleBufferRef _Nonnull sampleBuffer) {
//1- 添加回调
};
[selffillVideoCaptureSetting:param];
option.videoCaptureParam = param;
//以上回调 添加以下方法
- (void)processVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer
{
CVPixelBufferRef pixelBuffer =CMSampleBufferGetImageBuffer(sampleBuffer);
size_t bufferWidth = 0;
size_t bufferHeight = 0;
if (CVPixelBufferIsPlanar(pixelBuffer)) {
bufferHeight = CVPixelBufferGetHeightOfPlane(pixelBuffer,0);
bufferWidth = CVPixelBufferGetWidthOfPlane(pixelBuffer,0);
} else {
bufferWidth = CVPixelBufferGetWidth(pixelBuffer);
bufferHeight = CVPixelBufferGetHeight(pixelBuffer);
}
//加滤镜代码 测试
CFAbsoluteTime elapsedTime, startTime =CFAbsoluteTimeGetCurrent();
CIImage *inputImage = [CIImage imageWithCVPixelBuffer:pixelBuffer];
// 创建滤镜
CIFilter *fiter = [CIFilter filterWithName:@"CIPhotoEffectInstant"];
[fiter setValue:inputImage forKey:@"inputImage"];
CIImage *outputImage = [fiter outputImage];
elapsedTime = CFAbsoluteTimeGetCurrent() - startTime;
NSLog(@"Core Image frame time: %f", elapsedTime *1000.0);
EAGLContext *openglCtx = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES2];
CIContext *ctx = [CIContext contextWithEAGLContext:openglCtx];
[ctx render:outputImage toCVPixelBuffer:pixelBuffer];
// 处理完的数据 塞回云信
[[NIMAVChatSDKsharedSDK].netCallManagersendVideoSampleBuffer:sampleBuffer];
}