Skip to content

Commit

Permalink
[Android]update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfd3 committed Aug 15, 2023
1 parent 0d096e0 commit 8664133
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 221 deletions.
10 changes: 5 additions & 5 deletions Android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ _English | [中文](README.zh.md)
2. FaceUnity
Put the FaceUnity beauty resources into the corresponding path

| FaceUnity Beauty Resources | Location |
|-------------------------------------|------------------------------------------------------|
| makeup resource(e.g. naicha.bundle) | app/src/main/assets/beauty_faceunity/makeup |
| sticker resource(e.g. fashi.bundle) | app/src/main/assets/beauty_faceunity/sticker |
| authpack.java | app/src/main/java/io/agora/beauty/demo/authpack.java |
| FaceUnity Beauty Resources | Location |
|-------------------------------------|---------------------------------------------------------|
| makeup resource(e.g. naicha.bundle) | app/src/main/assets/beauty_faceunity/makeup |
| sticker resource(e.g. fashi.bundle) | app/src/main/assets/beauty_faceunity/sticker |
| authpack.java | app/src/main/java/io/agora/beautyapi/demo/authpack.java |

3. ByteDance
Unzip the ByteDance beauty resource and copy the following files/directories to the corresponding path
Expand Down
10 changes: 5 additions & 5 deletions Android/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
2. 相芯美颜
将相芯美颜资源放入对应路径下

| 美颜资源 | 项目路径 |
|----------------------|-------------------------------------------------------|
| 美妆资源(如naicha.bundle) | app/src/main/assets/beauty_faceunity/makeup |
| 贴纸资源(如fashi.bundle) | app/src/main/assets/beauty_faceunity/sticker |
| 证书authpack.java | app/src/main/java/io/agora/beauty/demo/authpack.java |
| 美颜资源 | 项目路径 |
|----------------------|---------------------------------------------------------|
| 美妆资源(如naicha.bundle) | app/src/main/assets/beauty_faceunity/makeup |
| 贴纸资源(如fashi.bundle) | app/src/main/assets/beauty_faceunity/sticker |
| 证书authpack.java | app/src/main/java/io/agora/beautyapi/demo/authpack.java |

3. 字节/火山美颜
解压字节/火山美颜资源并复制以下文件/目录到对应路径下
Expand Down
97 changes: 47 additions & 50 deletions Android/lib_bytedance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,39 @@ src/main/java/io/agora/beautyapi/bytedance
```

3. Initialization

> Before initialization, you need to copy the resources required by the ByteDanceBeauty SDK to the sdcard, and create a RenderManager instance in advance and pass it to ByteDanceBeautyAPI.
> For the initialization and destruction of renderManager, it needs to be called in the GL thread. Here, ByteDanceBeautyAPI provides two callbacks, onEffectInitialized and onEffectDestroyed.
```kotlin
private val mByteDanceApi by lazy {
createByteDanceBeautyAPI()
}
private val mEffectManager by lazy {
val resourceHelper =
AssetsResourcesHelper(this, "beauty_bytedance")
EffectManager(
this,
resourceHelper,
resourceHelper.getLicensePath(LICENSE_NAME)
)
createByteDanceBeautyAPI()
}

mByteDanceApi.initialize(
Config(
mRtcEngine,
mEffectManager,
captureMode = CaptureMode.Agora,
statsEnable = BuildConfig.BUILD,
eventCallback = EventCallback(
onBeautyStats = {stats ->
Log.d(TAG, "BeautyStats stats = $stats")
},
onEffectInitialized = {
Log.d(TAG, "onEffectInitialized")
},
onEffectDestroyed = {
Log.d(TAG, "onEffectInitialized")
}
)
))
Config(
applicationContext,
mRtcEngine,
renderManager,
captureMode = if (isCustomCaptureMode) CaptureMode.Custom else CaptureMode.Agora,
statsEnable = true,
cameraConfig = CameraConfig(),
eventCallback = EventCallback(
onBeautyStats = {stats ->
Log.d(TAG, "BeautyStats stats = $stats")
},
onEffectInitialized = {
// Callback in the GL thread, used to initialize the Bytebeauty SDK
ByteDanceBeautySDK.initEffect(applicationContext)
Log.d(TAG, "onEffectInitialized")
},
onEffectDestroyed = {
// Callback in the GL thread, used to destroy the Bytebeauty SDK
ByteDanceBeautySDK.unInitEffect()
Log.d(TAG, "onEffectInitialized")
}
)
)
)
```

4. Beauty On/Off (default off)
Expand All @@ -78,7 +79,16 @@ mByteDanceApi.setupLocalVideo(mBinding.localVideoView, Constants.RENDER_MODE_FIT
mByteDanceApi.setBeautyPreset(BeautyPreset.DEFAULT) // BeautyPreset.CUSTOM:Close Recommended Beauty
```

7. Destroy BeautyAPI
7. Update Camera Config
```kotlin
val cameraConfig = CameraConfig(
frontMirror = MirrorMode.MIRROR_LOCAL_REMOTE,
backMirror = MirrorMode.MIRROR_NONE
)
mByteDanceApi.updateCameraConfig(cameraConfig)
```

8. Destroy BeautyAPI
```kotlin
mRtcEngine.leaveChannel()
// Must release beauty api after leaveChannel
Expand All @@ -97,6 +107,7 @@ mByteDanceApi.initialize(
mEffectManager,
captureMode = CaptureMode.Custom,
statsEnable = BuildConfig.BUILD,
cameraConfig = CameraConfig(),
eventCallback = EventCallback(
onBeautyStats = {stats ->
Log.d(TAG, "BeautyStats stats = $stats")
Expand All @@ -113,28 +124,14 @@ mByteDanceApi.initialize(
2. Pass external video frame to BeautyAPI by onFrame interface.
```kotlin
override fun onCaptureVideoFrame(
sourceType: Int,
videoFrame: VideoFrame?
) : Boolean {
when(mByteDanceApi.onFrame(videoFrame!!)){
ErrorCode.ERROR_OK.value -> {
shouldMirror = false
return true
}
ErrorCode.ERROR_FRAME_SKIPPED.value ->{
shouldMirror = false
return false
}
else -> {
val mirror = videoFrame.sourceType == VideoFrame.SourceType.kFrontCamera
if(shouldMirror != mirror){
shouldMirror = mirror
return false
}
return true
}
}
sourceType: Int,
videoFrame: VideoFrame?
) = when (mByteDanceApi.onFrame(videoFrame!!)) {
ErrorCode.ERROR_FRAME_SKIPPED.value -> false
else -> true
}

override fun getMirrorApplied() = mByteDanceApi.getMirrorApplied()
```

## Feedback
Expand Down
64 changes: 30 additions & 34 deletions Android/lib_bytedance/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,39 @@ src/main/java/io/agora/beautyapi/bytedance
```

3. 初始化

> 初始化前需要先复制字节美颜SDK所需的资源到sdcard上,并提前创建好RenderManager实例传给ByteDanceBeautyAPI。
> 对于renderManager的初始化和销毁,需要放在GL线程里去调用,这里ByteDanceBeautyAPI分别提供了两个回调onEffectInitialized和onEffectDestroyed。
```kotlin
private val mByteDanceApi by lazy {
createByteDanceBeautyAPI()
}
private val mEffectManager by lazy {
val resourceHelper =
AssetsResourcesHelper(this, "beauty_bytedance")
EffectManager(
this,
resourceHelper,
resourceHelper.getLicensePath(LICENSE_NAME)
)
}

mByteDanceApi.initialize(
Config(
applicationContext,
mRtcEngine,
mEffectManager,
captureMode = CaptureMode.Agora,
statsEnable = BuildConfig.BUILD,
renderManager,
captureMode = if (isCustomCaptureMode) CaptureMode.Custom else CaptureMode.Agora,
statsEnable = true,
cameraConfig = CameraConfig(),
eventCallback = EventCallback(
onBeautyStats = {stats ->
Log.d(TAG, "BeautyStats stats = $stats")
},
onEffectInitialized = {
// 在GL线程里回调,用于初始化字节美颜SDK
ByteDanceBeautySDK.initEffect(applicationContext)
Log.d(TAG, "onEffectInitialized")
},
onEffectDestroyed = {
// 在GL线程里回调,用于销毁字节美颜SDK
ByteDanceBeautySDK.unInitEffect()
Log.d(TAG, "onEffectInitialized")
}
)
))
)
)
```

4. 美颜开关(默认关)
Expand All @@ -78,7 +79,16 @@ mByteDanceApi.setupLocalVideo(mBinding.localVideoView, Constants.RENDER_MODE_FIT
mByteDanceApi.setBeautyPreset(BeautyPreset.DEFAULT) // BeautyPreset.CUSTOM:关闭推荐美颜参数
```

7. 销毁美颜
7. 更新镜像配置
```kotlin
val cameraConfig = CameraConfig(
frontMirror = MirrorMode.MIRROR_LOCAL_REMOTE,
backMirror = MirrorMode.MIRROR_NONE
)
mByteDanceApi.updateCameraConfig(cameraConfig)
```

8. 销毁美颜
```kotlin
mRtcEngine.leaveChannel()
// 必须在leaveChannel后销毁
Expand Down Expand Up @@ -115,26 +125,12 @@ mByteDanceApi.initialize(
override fun onCaptureVideoFrame(
sourceType: Int,
videoFrame: VideoFrame?
) : Boolean {
when(mByteDanceApi.onFrame(videoFrame!!)){
ErrorCode.ERROR_OK.value -> {
shouldMirror = false
return true
}
ErrorCode.ERROR_FRAME_SKIPPED.value ->{
shouldMirror = false
return false
}
else -> {
val mirror = videoFrame.sourceType == VideoFrame.SourceType.kFrontCamera
if(shouldMirror != mirror){
shouldMirror = mirror
return false
}
return true
}
}
) = when (mByteDanceApi.onFrame(videoFrame!!)) {
ErrorCode.ERROR_FRAME_SKIPPED.value -> false
else -> true
}

override fun getMirrorApplied() = mByteDanceApi.getMirrorApplied()
```

## 联系我们
Expand Down
79 changes: 40 additions & 39 deletions Android/lib_faceunity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,40 @@ dependencies {


2. Copy the following BeautyAPI interface and implementation into the project

> Please keep the package name so that we can upgrade the code.
```xml
src/main/java/io/agora/beautyapi/faceunity
├── FaceUnityBeautyAPI.kt
├── FaceUnityBeautyAPIImpl
└── utils
```

3. Initialization

> Before initialization, you need to initialize the FaceUnity beauty sdk and get the FURenderKit instance.
3. Initialization
```kotlin
private val mFaceUnityApi by lazy {
createFaceUnityBeautyAPI()
}
private val mFuRenderKit by lazy {
FURenderer.getInstance().setup(this, authpack.A())
FURenderKit.getInstance()
createFaceUnityBeautyAPI()
}

mFaceUnityApi.initialize(
Config(
mRtcEngine,
mFuRenderKit,
captureMode = CaptureMode.Agora,
statsEnable = true,
eventCallback = object: IEventCallback{
override fun onBeautyStats(stats: BeautyStats) {
Log.d(TAG, "BeautyStats stats = $stats")
}
}
))
Config(
applicationContext,
mRtcEngine,
fuRenderKit,
captureMode = CaptureMode.Agora,
cameraConfig = CameraConfig(),
statsEnable = BuildConfig.DEBUG,
eventCallback = object: IEventCallback{
override fun onBeautyStats(stats: BeautyStats) {
Log.d(TAG, "BeautyStats stats = $stats")
}
}
)
)
```

4. Beauty On/Off (default off)
Expand All @@ -84,7 +86,20 @@ mFaceUnityApi.setupLocalVideo(mBinding.localVideoView, Constants.RENDER_MODE_FIT
mFaceUnityApi.setBeautyPreset(BeautyPreset.DEFAULT) // BeautyPreset.CUSTOM:Close Recommended Beauty
```

7. Destroy BeautyAPI
7. Update Camera Config
```kotlin
val cameraConfig = CameraConfig(
frontMirror = MirrorMode.MIRROR_LOCAL_REMOTE,
backMirror = MirrorMode.MIRROR_NONE
)
mFuRenderKit.updateCameraConfig(cameraConfig)
```


8. Destroy BeautyAPI

> The calling time must be after leaveChannel/stopPreview and before RtcEngine.destroy!
```kotlin
mRtcEngine.leaveChannel()
// Must release beauty api after leaveChannel
Expand Down Expand Up @@ -114,28 +129,14 @@ mFaceUnityApi.initialize(
2. Pass external video frame to BeautyAPI by onFrame interface.
```kotlin
override fun onCaptureVideoFrame(
sourceType: Int,
videoFrame: VideoFrame?
) : Boolean{
when(mFaceUnityApi.onFrame(videoFrame!!)){
ErrorCode.ERROR_OK.value -> {
shouldMirror = false
return true
}
ErrorCode.ERROR_FRAME_SKIPPED.value ->{
shouldMirror = false
return false
}
else -> {
val mirror = videoFrame.sourceType == VideoFrame.SourceType.kFrontCamera
if(shouldMirror != mirror){
shouldMirror = mirror
return false
}
return true
}
}
sourceType: Int,
videoFrame: VideoFrame?
) = when (mFaceUnityApi.onFrame(videoFrame!!)) {
ErrorCode.ERROR_FRAME_SKIPPED.value -> false
else -> true
}

override fun getMirrorApplied() = mFaceUnityApi.getMirrorApplied()
```

## Feedback
Expand Down
Loading

0 comments on commit 8664133

Please sign in to comment.