MHBeautyManager 参数要始终保持一致,也就是传入MHMeiyanMenusView和Zego的滤镜类的参数是一样的。
需要在下面的类中作如下修改。黑框中的部分为新加的,可以与即构的demo对比参考。(MHBeautyManager parameters should always be consistent, that is, the parameters of the filter class passed into MHMeiyanMenusView and Zego are the same.The following modifications need to be made in the following classes. The part in the black box is newly added, which can be compared with the instant demo for reference.)
- ZGVideoFilterAsyncDemo.h
```
@property (nonatomic, strong) MHBeautyManager *beautyManager;
```
- ZGVideoFilterAsyncDemo.m
```
\- (void)queueInputBuffer:(CVPixelBufferRef)pixel\_buffer timestamp:(unsigned long long)timestamp\_100n {
// \* 采集到的图像数据通过这个传进来,这个点需要异步处理
dispatch\_async(queue\_, ^ {
int imageWidth = (int)CVPixelBufferGetWidth(pixel\_buffer);
int imageHeight = (int)CVPixelBufferGetHeight(pixel\_buffer);
int imageStride = (int)CVPixelBufferGetBytesPerRowOfPlane(pixel\_buffer, 0);
CVPixelBufferRef dst = \[self->buffer\_pool\_ dequeueInputBuffer:imageWidth height:imageHeight stride:imageStride\];
if (dst) {
if(self.beautyManager){
\[self.beautyManager processZGWithPixelBuffer:pixel\_buffer\];
}
CVPixelBufferRef output = pixel\_buffer;
if (\[ZGImageUtils copyPixelBufferFrom:output to:dst\]) {
// \* 把从 buffer pool 中得到的 CVPixelBuffer 实例传进来
\[self->buffer\_pool\_ queueInputBuffer:dst timestamp:timestamp\_100n\];
}
}
self.pendingCount = self.pendingCount - 1;
CVPixelBufferRelease(pixel\_buffer);
});
}
- ZGVideoFilterAsyncDemo.h
@property (nonatomic, strong) MHBeautyManager \*beautyManager;
- ZGVideoFilterFactoryDemo.m
// 创建外部滤镜实例
- (id<ZegoVideoFilter>)zego_create {
if (g_filter_ == nil) {
// 此处的 bufferType 对应四种滤镜类型,以创建不同的外部滤镜实例
switch (self.bufferType) {
case ZegoVideoBufferTypeAsyncPixelBuffer:
{
g_filter_ = [[ZGVideoFilterAsyncDemo alloc] init];
ZGVideoFilterAsyncDemo* g_filter = (ZGVideoFilterAsyncDemo*)g_filter_;
[g_filter setMHBeautyManager:self.beautyManager];
}
break;
case ZegoVideoBufferTypeSyncPixelBuffer:
g_filter_ = [[ZGVideoFilterSyncDemo alloc] init];
break;
case ZegoVideoBufferTypeAsyncI420PixelBuffer:
g_filter_ = [[ZGVideoFilterI420Demo alloc] init];
break;
case ZegoVideoBufferTypeAsyncNV12PixelBuffer:
g_filter_ = [[ZGVideoFilterNV12Demo alloc] init];
break;
default:
break;
}
}
return g_filter_;
}
```
- ZGExternalVideoFilterDemo.h add method:
```
- (void)initFilterFactoryType:(ZegoVideoBufferType)type beautyManager:(MHBeautyManager*)beautyManager;
```
- ZGExternalVideoFilterDemo.m :
```
- (void)initFilterFactoryType:(ZegoVideoBufferType)type beautyManager:(MHBeautyManager*)beautyManager{
if (self.g_filterFactory == nil) {
self.g_filterFactory = [[ZGVideoFilterFactoryDemo alloc] init];
self.g_filterFactory.bufferType = type;
self.g_filterFactory.beautyManager = beautyManager;
}
[ZGApiManager releaseApi];
[ZegoExternalVideoFilter setVideoFilterFactory:self.g_filterFactory channelIndex:ZEGOAPI_CHN_MAIN];
}
```
- ZGVideoTalkLoginViewController
- ViewDidLoad (Initial method) ZGExternalVideoFilterDemo:
```
self.demo = [[ZGExternalVideoFilterDemo alloc] init];
self.demo.delegate = self;
[self.demo initFilterFactoryType:ZegoVideoBufferTypeAsyncPixelBuffer beautyManager:self.beautyManager];
```
- ZGVideoTalkViewController是实现视频通话的功能,将ZGVideoTalkLoginViewControlle初始化的beautyManager作为参数传入(ZGVideoTalkViewController is to realize the function of video call. Pass in the initialized beautyManager in the previous step as a parameter)。
```
ZGVideoTalkViewController *vc = [sb instantiateViewControllerWithIdentifier:NSStringFromClass([ZGVideoTalkViewController class])];
vc.roomID = roomID;
vc.videoTalkDemo = self.videoTalkDemo;
vc.beautyManager = self.beautyManager;
```
ZGVideoTalkViewController.h
```
@property (nonatomic, strong) MHBeautyManager *beautyManager;
```
ZGVideoTalkViewController .m ,并将传入的beautyManager传入MHMeiyanMenusView (And pass in the beautyManager to MHMeiyanMenusView)
```
- (MHMeiyanMenusView *)menusView {
if (!_menusView) {
_menusView = [[MHMeiyanMenusView alloc] initWithFrame:CGRectMake(0, window_height - MHMeiyanMenuHeight - BottomIndicatorHeight, window_width, MHMeiyanMenuHeight) superView:self.view beautyManager:self.beautyManager ];
}
return _menusView;
}
```
- 美狐SDK接入文档
- Meihu SDK Access Document
- (Untitled)
- 一、基础描述(Basic description)
- 1. 最新特性 (Latest features)
- 2. 支持平台 (Support platform)
- 二、集成步骤 (Integration steps)
- 3. 配置工程(Configuration Engineering)
- 4. 使用 MHUI (Use MHUI)
- 5. 腾讯直播 SDK/短视频SDK (Tencent live SDK / short video SDK)
- 6. 金山直播SDK (Jinshan)
- 7. 七牛直播SDK (Qiniu Live)
- 8. 七牛短视频SDK (Qiniu ShortVideo)
- 9. Movieous短视频 (Movieous short Video)
- 10. 即构直播SDK (Zego live)
- 11. 即构实时音视频SDK(Zego Real time audio and video)
- 12. 新版Zego(即构)实时音视频(New Zego Real time audio and video)
- 13. 网易直播 (NetEase live)
- 14. 腾讯互动直播 (Tencent interactive live broadcast)
- 15. 腾讯实时音视频(Tencent real-time audio and video)
- 16. 融云实时音视频 (SealRTC)
- 17. 声网视频通话 (Agora video call)
- 18. 声网直播 (Agora Live)
- 19. 阿里直播 (Ali Live)
- 20. 阿里音视频 SDK美颜
- 三、对接说明 (Docking instructions)
- 四、常见问题(common problem)
- 2. 美颜无效果(Beauty has no effect)
- 3. 贴纸下载失败(Sticker download failed)
- 4. 点击无法出现美颜菜单页(The beauty menu page cannot appear after clicking)
- 5. 英文版显示中文(The beauty menu page cannot appear after clicking)
- 6. 语言切换功能(Language switching function)