-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add SenseTime plugin demo (#3)
* feat: Add SenseTime plugin demo
- Loading branch information
1 parent
fb7b5bb
commit 1b575eb
Showing
51 changed files
with
4,295 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
case "${1}" in | ||
--about) | ||
echo "Runs clang-format on source files" | ||
;; | ||
*) | ||
for file in $(find . -name Constants.java); do | ||
diff=$(git diff HEAD $file) | ||
|
||
if [[ -z $diff ]]; then | ||
exit 0 | ||
else | ||
echo "diff: $diff" | ||
echo "Make sure you not commit the test AppID or test Token!" | ||
exit 1 | ||
fi | ||
done | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
**/.DS_Store | ||
**/.idea/ | ||
**/.idea/ | ||
**/.plugin_dev.properties | ||
**/.plugin_dev |
4 changes: 2 additions & 2 deletions
4
ByteDance/android/app/src/main/java/io/agora/rte/extension/bytedance/example/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package io.agora.rte.extension.bytedance.example; | ||
|
||
public interface Constants { | ||
String mAppId = <#YOUR_APP_ID#>; | ||
String mAppId = "<YOUR_APP_ID>"; | ||
String mToken = null; | ||
String mLicenseName = <#YOUR_LICENSE_NAME#>; | ||
String mLicenseName = "<YOUR_LICENSE_NAME>"; | ||
} |
2 changes: 1 addition & 1 deletion
2
FaceUnity/android/app/src/main/java/io/agora/rte/extension/faceunity/example/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package io.agora.rte.extension.faceunity.example; | ||
|
||
public interface Constants { | ||
String mAppId = <#YOUR_APP_ID#>; | ||
String mAppId = "<YOUR_APP_ID>"; | ||
String mToken = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Get started | ||
### Android | ||
1. Download the latest Android AAR from [AgoraMarketPlace release page](https://github.com/AgoraIO-Community/AgoraMarketPlace/releases?q=sensetime-effect-plugin&expanded=true), then copy the `sensetime-effect-plugin-<latest-version>.aar` to `android/app/libs` directory; | ||
|
||
2. Download the assets from SenseTime, then copy to `android/app/src/main/assets` directory; | ||
|
||
3. Download the `STMobileJNI-release.aar` from SenseTime, then copy it to `android/app/libs` directory. | ||
|
||
4. Update your `mAppId`(e.g., `ccb8b8f5a8cdxxxxxxxx`) and `mLicenseName`(e.g., `SenseME.lic`) in `android/app/src/main/java/io/agora/rte/extension/sensetime/example/Constants.java` file. | ||
|
||
5. Run the example | ||
|
||
### iOS | ||
1. Download the iOS latest framework from [AgoraMarketPlace release page](https://github.com/AgoraIO-Community/AgoraMarketPlace/releases?q=sensetime-effect-plugin&expanded=true), then copy the `AgoraSenseTimeExtension.framework` to `ios/ExtensionExample` directory; | ||
|
||
2. Download the assets from SenseTime, then copy to `ios/Resource` directory. | ||
|
||
3. Include the `st_mobile_sdk` header files by following SenseTime SDK integration guide. | ||
|
||
4. Update your `appID`(e.g., `ccb8b8f5a8cdxxxxxxxx`) and `license_name`(e.g., `SenseME.lic`) in `ios/ExtensionExample/AppID.m` file | ||
|
||
5. Go to `ios` directory and run `pod install` | ||
|
||
6. Run the example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.gradle/ | ||
.cxx/ | ||
local.properties | ||
.plugin_dev.properties | ||
app/libs/* | ||
app/src/main/assets/ | ||
build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
applicationId "io.agora.rte.extension.sensetime" | ||
minSdk 21 | ||
targetSdk 31 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
aaptOptions { | ||
ignoreAssetsPattern '!**' | ||
} | ||
packagingOptions { | ||
pickFirst '**/*.so' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'com.github.agorabuilder:agora-special-full:3.7.201' | ||
|
||
if (getLocalPluginPath(project) != null) { | ||
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"]) | ||
implementation project(':plugin') | ||
} else { | ||
// implement aar | ||
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"]) | ||
} | ||
|
||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.3.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.2' | ||
implementation 'androidx.databinding:databinding-runtime:4.1.3' | ||
implementation 'androidx.test.ext:junit-ktx:1.1.3' | ||
|
||
testImplementation 'junit:junit:4.+' | ||
|
||
implementation "androidx.core:core-ktx:+" | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
|
||
androidTestImplementation "androidx.test:core:1.4.0" | ||
androidTestImplementation "androidx.test:runner:1.4.0" | ||
androidTestImplementation "androidx.test:rules:1.4.0" | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
static String getLocalPluginPath(Project project) { | ||
def rootProject = project.rootProject | ||
def localProperties = new Properties() | ||
def localPropertiesFile = rootProject.file('.plugin_dev.properties') | ||
if (!localPropertiesFile.exists()) { | ||
return null | ||
} | ||
|
||
localPropertiesFile.withReader('UTF-8') { reader -> | ||
localProperties.load(reader) | ||
} | ||
|
||
def localPluginPath = localProperties.getProperty('local_plugin_path') | ||
if (localPluginPath == null) { | ||
throw new GradleScriptException("local_plugin_path not found. Define location with local_plugin_path in the .plugin_dev.properties file.") | ||
} | ||
|
||
return localPluginPath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
152 changes: 152 additions & 0 deletions
152
...c/androidTest/java/io/agora/rte/extension/sensetime/example/ExtensionPropertySmokeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package io.agora.rte.extension.sensetime.example | ||
|
||
import android.content.Context | ||
import androidx.test.core.app.ActivityScenario | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.sensetime.stmobile.STMobileEffectNative | ||
import com.sensetime.stmobile.STMobileHumanActionNative | ||
import com.sensetime.stmobile.params.STEffectBeautyType | ||
import io.agora.rtc2.IRtcEngineEventHandler | ||
import io.agora.rtc2.RtcEngine | ||
import io.agora.rtc2.RtcEngineConfig | ||
import io.agora.rte.extension.sensetime.ExtensionManager | ||
import junit.framework.Assert.assertEquals | ||
import org.json.JSONObject | ||
import org.junit.* | ||
import org.junit.runner.RunWith | ||
import java.io.File | ||
|
||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ExtensionPropertySmokeTest { | ||
|
||
companion object { | ||
private lateinit var rtcEngine: RtcEngine | ||
private lateinit var appContext: Context | ||
|
||
@BeforeClass | ||
@JvmStatic | ||
fun setUpAll() { | ||
ActivityScenario.launch(MainActivity::class.java) | ||
appContext = ApplicationProvider.getApplicationContext() | ||
|
||
// Ensure the makeup_lip/license/models directories been copied | ||
FileUtils.copyStickerFiles(appContext, "makeup_lip") | ||
FileUtils.copyStickerFiles(appContext, "license") | ||
FileUtils.copyFileIfNeed(appContext, "SenseME.lic", "license") | ||
FileUtils.copyModelsFiles(appContext, "models") | ||
|
||
val config = RtcEngineConfig() | ||
config.mContext = appContext | ||
config.mAppId = Constants.mAppId | ||
config.mEventHandler = object : IRtcEngineEventHandler() { | ||
override fun onWarning(warn: Int) { | ||
} | ||
|
||
override fun onError(err: Int) { | ||
} | ||
|
||
override fun onJoinChannelSuccess(channel: String, uid: Int, elapsed: Int) { | ||
|
||
} | ||
} | ||
rtcEngine = RtcEngine.create(config) | ||
|
||
ExtensionManager.getInstance(rtcEngine).initialize(appContext) | ||
rtcEngine.enableExtension("SenseTime", "Effect", true) | ||
} | ||
|
||
@AfterClass | ||
@JvmStatic | ||
fun teardownAll() { | ||
RtcEngine.destroy() | ||
} | ||
} | ||
|
||
@Test | ||
fun st_mobile_check_activecode_success() { | ||
val licensePath: File = File( | ||
appContext.getExternalFilesDir(null), | ||
"license/" + Constants.mLicenseName | ||
) | ||
val jsonObject = JSONObject() | ||
jsonObject.put("licensePath", licensePath.path) | ||
val ret = rtcEngine.setExtensionProperty("SenseTime", "Effect", "st_mobile_check_activecode", jsonObject.toString()) | ||
assertEquals(ret, 0) | ||
} | ||
|
||
@Test | ||
fun st_mobile_human_action_create_success() { | ||
val licensePath: File = File( | ||
appContext.getExternalFilesDir(null), | ||
"license/" + Constants.mLicenseName | ||
) | ||
val jsonObject = JSONObject() | ||
jsonObject.put("licensePath", licensePath.path) | ||
rtcEngine.setExtensionProperty("SenseTime", "Effect", "st_mobile_check_activecode", jsonObject.toString()) | ||
|
||
val modelsPath: File = File( | ||
appContext.getExternalFilesDir(null), | ||
"models/M_SenseME_Face_Extra_Advanced_6.0.13.model" | ||
) | ||
val humanActionCreateJson = JSONObject() | ||
humanActionCreateJson.put("model_path", modelsPath.path) | ||
humanActionCreateJson.put( | ||
"config", | ||
STMobileHumanActionNative.ST_MOBILE_HUMAN_ACTION_DEFAULT_CONFIG_IMAGE | ||
) | ||
val ret = rtcEngine.setExtensionProperty("SenseTime", "Effect", "st_mobile_human_action_create", humanActionCreateJson.toString()) | ||
assertEquals(ret, 0) | ||
} | ||
|
||
@Test | ||
fun st_mobile_effect_create_handle_success() { | ||
val licensePath: File = File( | ||
appContext.getExternalFilesDir(null), | ||
"license/" + Constants.mLicenseName | ||
) | ||
val jsonObject = JSONObject() | ||
jsonObject.put("licensePath", licensePath.path) | ||
rtcEngine.setExtensionProperty("SenseTime", "Effect", "st_mobile_check_activecode", jsonObject.toString()) | ||
|
||
val modelsPath: File = File( | ||
appContext.getExternalFilesDir(null), | ||
"models/M_SenseME_Face_Extra_Advanced_6.0.13.model" | ||
) | ||
val humanActionCreateJson = JSONObject() | ||
humanActionCreateJson.put("model_path", modelsPath.path) | ||
humanActionCreateJson.put( | ||
"config", | ||
STMobileHumanActionNative.ST_MOBILE_HUMAN_ACTION_DEFAULT_CONFIG_IMAGE | ||
) | ||
rtcEngine.setExtensionProperty("SenseTime", "Effect", "st_mobile_human_action_create", humanActionCreateJson.toString()) | ||
|
||
val effectCreateHandleJson = JSONObject() | ||
effectCreateHandleJson.put("config", STMobileEffectNative.EFFECT_CONFIG_IMAGE_MODE) | ||
val ret = rtcEngine.setExtensionProperty("SenseTime", "Effect", "st_mobile_effect_create_handle", humanActionCreateJson.toString()) | ||
assertEquals(ret, 0) | ||
} | ||
|
||
@Test | ||
fun st_mobile_effect_set_beauty_strength_success() { | ||
val jsonObject = JSONObject() | ||
jsonObject.put("param", STEffectBeautyType.EFFECT_BEAUTY_PLASTIC_SHRINK_GODDESS_FACE) | ||
jsonObject.put("val", java.lang.Double.valueOf(0.8).toDouble()) | ||
val ret = rtcEngine.setExtensionProperty("SenseTime", "Effect", "st_mobile_effect_set_beauty_strength", jsonObject.toString()) | ||
assertEquals(ret, 0) | ||
} | ||
|
||
@Test | ||
fun st_mobile_effect_set_beauty_success() { | ||
val makeupLipPath: File = File( | ||
appContext.getExternalFilesDir(null), | ||
"makeup_lip/12自然.zip" | ||
) | ||
val jsonObject = JSONObject() | ||
jsonObject.put("param", STEffectBeautyType.EFFECT_BEAUTY_MAKEUP_LIP) | ||
jsonObject.put("path", makeupLipPath.path) | ||
val ret = rtcEngine.setExtensionProperty("SenseTime", "Effect", "st_mobile_effect_set_beauty", jsonObject.toString()) | ||
assertEquals(ret, 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="io.agora.rte.extension.sensetime.example"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:configChanges="orientation|keyboardHidden|screenSize" | ||
android:screenOrientation="portrait" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
7 changes: 7 additions & 0 deletions
7
SenseTime/android/app/src/main/java/io/agora/rte/extension/sensetime/example/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.agora.rte.extension.sensetime.example; | ||
|
||
public interface Constants { | ||
String mAppId = "<YOUR_APP_ID>"; | ||
String mToken = null; | ||
String mLicenseName = "<YOUR_LICENSE_NAME>"; | ||
} |
Oops, something went wrong.