其他语言版本: 简体中文
This open source demo project demonstrates how to implement 1to1 video chat with [Agora] (www.agora.io) video SDK and the [Faceunity] (http://www.faceunity.com) beauty SDK.
This project adopts the video beauty pre-processing function provided by Faceunity, Uses the audio collection, encoding, transmission, decoding and rendering functions provided by Agora's, and uses the video collection function provided by Agora Module.
Faceunity beauty function please refer to. Faceunity Document
Agora function implementation please refer to Agora Document
Due to the need to use third-party capture when using beauty function, please refer to Customized Media Source API or Configuring the External Data API
This section shows you how to prepare, build, and run the sample application.
To build and run the sample application, get an App ID:
-
Create a developer account at agora.io. Once you finish the signup process, you will be redirected to the Dashboard.
-
Navigate in the Dashboard tree on the left to Projects > Project List.
-
Save the App ID from the Dashboard for later use.
-
Generate a temp Access Token (valid for 24 hours) from dashboard page with given channel name, save for later use.
-
Open
Agora iOS Tutorial Objective-C.xcodeprojand edit theAppID.mfile. Update<#Your App Id#>with your app ID, and assign the token variable with the temp Access Token generated from dashboard.NSString *const appID = @"<#Your App ID#>"; // assign token to nil if you have not enabled app certificate NSString *const token = @"<#Temp Token#>";
Please contact FaceUnity to get license file and replace the authpack.h file located in BeautifyExample/FaceUnity
- Update CocoaPods by running:
pod install
- Connect your iPhone or iPad device and run the project. Ensure a valid provisioning profile is applied or your project will not run.
- Capturer
- Camera Capturer
- Support for front and rear camera switching
- Support for dynamic resolution switching
- Support I420, NV12, BGRA pixel format output
- Support Exposure, ISO
- Support ZoomScale
- Support Torch
- Support watermark
- Audio Capturer
- Support single and double channel
- Support Mute
- Video Adapter Filter (For processing the video frame direction required by different modules)
- Support VideoOutputOrientationModeAdaptative for RTC function
- Support ...FixedLandscape and ...FixedLandscape for CDN live streaming
- Camera Capturer
- Renderer
- gles
- Support glContext Shared
- Support mirror
- Support fit、hidden zoom mode
- gles
// init process manager
self.processingManager = [[VideoProcessingManager alloc] init];
// init capturer, it will push pixelbuffer to rtc channel
AGMCapturerVideoConfig *videoConfig = [AGMCapturerVideoConfig defaultConfig];
videoConfig.sessionPreset = AVCaptureSessionPreset1280x720;
videoConfig.fps = 30;
self.capturerManager = [[CapturerManager alloc] initWithVideoConfig:videoConfig delegate:self.processingManager];
// add FaceUnity filter and add to process manager
self.videoFilter = [FUManager shareManager];
self.videoFilter.enabled = YES;
[self.processingManager addVideoFilter:self.videoFilter];
[self.capturerManager startCapture];Create a class that implements the VideoFilterDelegate protocol FUManager , Implement the processFrame: method to handle the videoframe .
#pragma mark - VideoFilterDelegate
/// process your video frame here
- (CVPixelBufferRef)processFrame:(CVPixelBufferRef)frame {
if(self.enabled) {
CVPixelBufferRef buffer = [self renderItemsToPixelBuffer:frame];
return buffer;
}
return frame;
}
decoupling module, we user Abstract API and category to do this,now , you can setupFaceUnity in viewDidLoad.
#import "FUDemoManager.h"
// FaceUnity UI
CGFloat safeAreaBottom = 0;
if (@available(iOS 11.0, *)) {
safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
}
[FUDemoManager setupFaceUnityDemoInController:self originY:CGRectGetHeight(self.view.frame) - FUBottomBarHeight - safeAreaBottom];
All Business in Abstract file folder. you do not care for detail, only need add for every module(like makeup) a provider and a viewModel. for example:
#import "FUAPIDemoBar.h"
...
//create viewModel
_makeupViewModel = [FUMakeupViewModel instanceViewModel];
//create provider for dataSource
_makeupViewModel.provider = [FUMakeupNodeModelProvider instanceProducer];
//bind to you view
_makeupView.dataList = _makeupViewModel.provider.dataSource;
_makeupView.viewModel = _makeupViewModel;
check viewDidLoad dealloc:
- Please do not use the raw data interface provided by Agora to integrate beauty features
- Videosource internal is a strong reference, you must set nil when not in use, otherwise it will cause a circular reference
- If you encounter a big head problem, please contact technical support
- XCode 8.0 +
- Real devices (iPhone or iPad)
- iOS simulator is NOT supported
- You can find full API document at Document Center
- You can file bugs about this demo at issue
The MIT License (MIT).