diff --git a/.github/ci/build/build_android.groovy b/.github/ci/build/build_android.groovy
index d9cfdc887..fc7fc2103 100644
--- a/.github/ci/build/build_android.groovy
+++ b/.github/ci/build/build_android.groovy
@@ -47,10 +47,21 @@ def doPublish(buildVariables) {
"archivePattern": "*.zip",
"serverPath": "ApiExample/${shortVersion}/${buildVariables.buildDate}/${env.platform}",
"serverRepo": "SDK_repo"
+ ],
+ [
+ "type": "ARTIFACTORY",
+ "archivePattern": "*.apk",
+ "serverPath": "ApiExample/${shortVersion}/${buildVariables.buildDate}/${env.platform}",
+ "serverRepo": "SDK_repo"
]
]
- archive.archiveFiles(archiveInfos)
- sh "rm -rf *.zip || true"
+ archiveUrls = archive.archiveFiles(archiveInfos) ?: []
+ archiveUrls = archiveUrls as Set
+ if (archiveUrls) {
+ def content = archiveUrls.join("\n")
+ writeFile(file: 'package_urls', text: content, encoding: "utf-8")
+ }
+ sh "rm -rf *.zip *.apk || true"
}
pipelineLoad(this, "ApiExample", "build", "android", "apiexample_linux")
diff --git a/.github/ci/build/build_android.sh b/.github/ci/build/build_android.sh
index 053f65542..c803dca02 100644
--- a/.github/ci/build/build_android.sh
+++ b/.github/ci/build/build_android.sh
@@ -50,8 +50,6 @@ echo short_version: $short_version
echo pwd: `pwd`
echo sdk_url: $sdk_url
-ls ~/.gradle || (mkdir -p /tmp/.gradle && ln -s /tmp/.gradle ~/.gradle && touch ~/.gradle/ln_$(date "+%y%m%d%H") && ls ~/.gradle)
-
zip_name=${sdk_url##*/}
echo zip_name: $zip_name
@@ -67,55 +65,21 @@ rm -rf ./$unzip_name/rtc/demo
rm ./$unzip_name/rtc/commits
rm ./$unzip_name/rtc/package_size_report.txt
mkdir ./$unzip_name/rtc/samples
-mkdir ./$unzip_name/rtc/samples/API-example
-
-if [ ! -z "$(echo $sdk_url | grep 'audio')" ] || [ ! -z "$(echo $sdk_url | grep 'VOICE')" ]
-then
-audio_suffix=-Audio
-else
-audio_suffix=
-fi
-echo audio_suffix: $audio_suffix
-cp -rf ./Android/APIExample${audio_suffix}/** ./$unzip_name/rtc/samples/API-example
+cp -rf ./Android/${android_direction} ./$unzip_name/rtc/samples/API-Example || exit 1
7za a -tzip result.zip -r $unzip_name > log.txt
-mv result.zip $WORKSPACE/withAPIExample_$(date "+%d%H%M")_$zip_name
+mv result.zip $WORKSPACE/withAPIExample_${BUILD_NUMBER}_$zip_name
-# install android sdk
-which java
-java --version
-source ~/.bashrc
-export ANDROID_HOME=/usr/lib/android_sdk
-echo ANDROID_HOME: $ANDROID_HOME
-# compile apk
-cd ./$unzip_name/rtc/samples/API-example
-pwd
-
-## config appId
-sed -i -e "s#YOUR APP ID#${APP_ID}#g" app/src/main/res/values/string_configs.xml
-sed -i -e "s#YOUR APP CERTIFICATE##g" app/src/main/res/values/string_configs.xml
-sed -i -e "s#YOUR ACCESS TOKEN##g" app/src/main/res/values/string_configs.xml
-rm -f app/src/main/res/values/string_configs.xml-e
-cat app/src/main/res/values/string_configs.xml
-
-## config simple filter
-sed -i -e "s#simpleFilter = false#simpleFilter = true#g" gradle.properties
-mkdir -p agora-simple-filter/src/main/agoraLibs
-cp -r ../../sdk/arm64-v8a agora-simple-filter/src/main/agoraLibs/
-cp -r ../../sdk/armeabi-v7a agora-simple-filter/src/main/agoraLibs/
-curl -o opencv4.zip https://agora-adc-artifacts.s3.cn-north-1.amazonaws.com.cn/androidLibs/opencv4.zip
-unzip opencv4.zip
-mkdir -p agora-simple-filter/src/main/libs
-mv arm64-v8a agora-simple-filter/src/main/libs
-mv armeabi-v7a agora-simple-filter/src/main/libs
-sed -i -e "s#jniLibs/#libs/#g" agora-simple-filter/src/main/cpp/CMakeLists.txt
+if [ $compile_project = true ]; then
+ # install android sdk
+ which java
+ java --version
+ source ~/.bashrc
+ export ANDROID_HOME=/usr/lib/android_sdk
+ echo ANDROID_HOME: $ANDROID_HOME
+ cd ./$unzip_name/rtc/samples/API-Example || exit 1
+ ./cloud_build.sh || exit 1
+fi
-./gradlew clean || exit 1
-./gradlew :app:assembleDebug || exit 1
-cp app/build/outputs/apk/debug/app-debug.apk ./APIExample_Android_$(date "+%y%m%d%H").apk
-7za a -tzip result.zip -r *.apk > log.txt
-mv result.zip $WORKSPACE/APIExample_Android${audio_suffix}_$(date "+%y%m%d%H%M")_apk.zip
-ls $WORKSPACE
-cd -
diff --git a/.github/ci/build/build_ios.groovy b/.github/ci/build/build_ios.groovy
index b1faf2479..b5bb5f63f 100644
--- a/.github/ci/build/build_ios.groovy
+++ b/.github/ci/build/build_ios.groovy
@@ -44,10 +44,16 @@ def doPublish(buildVariables) {
"archivePattern": "*.zip",
"serverPath": "ApiExample/${shortVersion}/${buildVariables.buildDate}/${env.platform}",
"serverRepo": "SDK_repo" // ATTENTIONS: Update the artifactoryRepo if needed.
+ ],
+ [
+ "type": "ARTIFACTORY",
+ "archivePattern": "*.ipa",
+ "serverPath": "ApiExample/${shortVersion}/${buildVariables.buildDate}/${env.platform}",
+ "serverRepo": "SDK_repo" // ATTENTIONS: Update the artifactoryRepo if needed.
]
]
archive.archiveFiles(archiveInfos)
- sh "rm -rf *.zip || true"
+ sh "rm -rf *.zip *.ipa || true"
}
pipelineLoad(this, "ApiExample", "build", "ios", "apiexample_mac")
\ No newline at end of file
diff --git a/.github/ci/build/build_ios.sh b/.github/ci/build/build_ios.sh
index e39a1f792..7a60cc7ae 100644
--- a/.github/ci/build/build_ios.sh
+++ b/.github/ci/build/build_ios.sh
@@ -39,7 +39,7 @@
# others: Rename the zip package name yourself, But need copy it to workspace dir
##################################
-echo is_generate_validate_app: $is_generate_validate_app
+echo ios_direction: $ios_direction
echo Package_Publish: $Package_Publish
echo is_tag_fetch: $is_tag_fetch
echo arch: $arch
@@ -55,75 +55,29 @@ echo sdk_url: $sdk_url
zip_name=${sdk_url##*/}
echo zip_name: $zip_name
-python3 $WORKSPACE/artifactory_utils.py --action=download_file --file=$sdk_url
-7za x ./$zip_name -y
+curl -o $zip_name $sdk_url || exit 1
+7za x ./$zip_name -y > log.txt
-unzip_name=`ls -S -d */ | grep Agora`
+unzip_name=`ls -S -d */ | grep Agora | sed 's/\///g'`
echo unzip_name: $unzip_name
rm -rf ./$unzip_name/bin
rm ./$unzip_name/commits
rm ./$unzip_name/package_size_report.txt
mkdir ./$unzip_name/samples
-mkdir ./$unzip_name/samples/API-Example
-if [ $? -eq 0 ]; then
- echo "success"
-else
- echo "failed"
- exit 1
-fi
-cp -rf ./iOS/** ./$unzip_name/samples/API-Example
+cp -rf ./iOS/${ios_direction} ./$unzip_name/samples/API-Example || exit 1
+ls -al ./$unzip_name/samples/API-Example/
+mv ./$unzip_name/samples/API-Example/sdk.podspec ./$unzip_name/ || exit 1
+python3 ./.github/ci/build/modify_podfile.py ./$unzip_name/samples/API-Example/Podfile || exit 1
+
-result=$(echo $sdk_url | grep "VOICE")
-if [ ! -z "$result" ]
-then
- echo "包含"
- rm -rf ./$unzip_name/samples/API-Example/APIExample
- rm -rf ./$unzip_name/samples/API-Example/APIExample-OC
- mv ./$unzip_name/samples/API-Example/APIExample-Audio ./$unzip_name/samples/APIExample-Audio
- mv ./$unzip_name/samples/APIExample-Audio/sdk.podspec ./$unzip_name/
- python3 ./.github/ci/build/modify_podfile.py ./$unzip_name/samples/APIExample-Audio/Podfile
- if [ $? -eq 0 ]; then
- echo "success"
- else
- echo "failed"
- exit 1
- fi
- if [ $is_generate_validate_app = true ]; then
- ./.github/ci/build/build_ios_ipa.sh ./$unzip_name/samples/APIExample-Audio
- fi
+7za a -tzip result.zip -r $unzip_name > log.txt
+mv result.zip $WORKSPACE/withAPIExample_${BUILD_NUMBER}_$zip_name
-else
- echo "不包含"
- rm -rf ./$unzip_name/samples/API-Example/APIExample-Audio
- if [ $is_objective_c = true ]; then
- rm -rf ./$unzip_name/samples/API-Example/APIExample
- mv ./$unzip_name/samples/API-Example/APIExample-OC ./$unzip_name/samples/APIExample-OC
- mv ./$unzip_name/samples/APIExample-OC/sdk.podspec ./$unzip_name/
- python3 ./.github/ci/build/modify_podfile.py ./$unzip_name/samples/APIExample-OC/Podfile
- else
- rm -rf ./$unzip_name/samples/API-Example/APIExample-OC
- mv ./$unzip_name/samples/API-Example/APIExample ./$unzip_name/samples/APIExample
- mv ./$unzip_name/samples/APIExample/sdk.podspec ./$unzip_name/
- python3 ./.github/ci/build/modify_podfile.py ./$unzip_name/samples/APIExample/Podfile
- fi
-
- if [ $? -eq 0 ]; then
- echo "success"
- else
- echo "failed"
- exit 1
- fi
- if [ $is_generate_validate_app = true ]; then
- if [ $is_objective_c = true ]; then
- ./.github/ci/build/build_ios_ipa.sh ./$unzip_name/samples/APIExample-OC
- else
- ./.github/ci/build/build_ios_ipa.sh ./$unzip_name/samples/APIExample
- fi
- fi
+if [ $compile_project = true ]; then
+ cd ./$unzip_name/samples/API-Example
+ ./cloud_build.sh || exit 1
+ cd -
fi
-rm -rf ./$unzip_name/samples/API-Example
-7za a -tzip result.zip -r $unzip_name
-cp result.zip $WORKSPACE/withAPIExample_${BUILD_NUMBER}_$zip_name
diff --git a/.github/ci/build/build_ios_ipa.sh b/.github/ci/build/build_ios_ipa.sh
index 7badd7a4d..e63a4f94f 100755
--- a/.github/ci/build/build_ios_ipa.sh
+++ b/.github/ci/build/build_ios_ipa.sh
@@ -2,6 +2,10 @@ CURRENT_PATH=$PWD
# 获取项目目录
PROJECT_PATH="$( cd "$1" && pwd )"
+IS_OBJECTIVE_C=false
+if [ "$ios_direction" = "APIExample-OC" ]; then
+ IS_OBJECTIVE_C=true
+fi
cd ${PROJECT_PATH} && pod install
@@ -13,10 +17,10 @@ else
fi
# 项目target名
-TARGET_NAME=${PROJECT_PATH##*/}
+TARGET_NAME=$ios_direction
KEYCENTER_PATH=${PROJECT_PATH}"/"${TARGET_NAME}"/Common/KeyCenter.swift"
-if [ $is_objective_c = true ]; then
+if [ $IS_OBJECTIVE_C = true ]; then
KEYCENTER_PATH=${PROJECT_PATH}"/"${TARGET_NAME}"/Common/KeyCenter.m"
fi
@@ -31,7 +35,7 @@ PBXPROJ_PATH="${PROJECT_PATH}/${TARGET_NAME}.xcodeproj/project.pbxproj"
echo PBXPROJ_PATH: $PBXPROJ_PATH
# 主项目工程配置
-if [ $is_objective_c = true ]; then
+if [ $IS_OBJECTIVE_C = true ]; then
# Debug
/usr/libexec/PlistBuddy -c "Set :objects:E70ADE062A5D0050009947CF:buildSettings:CODE_SIGN_STYLE 'Manual'" $PBXPROJ_PATH
/usr/libexec/PlistBuddy -c "Set :objects:E70ADE062A5D0050009947CF:buildSettings:DEVELOPMENT_TEAM 'GM72UGLGZW'" $PBXPROJ_PATH
diff --git a/.github/ci/build/build_mac.sh b/.github/ci/build/build_mac.sh
index 9a2e0deeb..00444a1ee 100644
--- a/.github/ci/build/build_mac.sh
+++ b/.github/ci/build/build_mac.sh
@@ -38,7 +38,7 @@
# others: Rename the zip package name yourself, But need copy it to workspace dir
##################################
-echo is_generate_validate_app:$is_generate_validate_app
+echo compile_project:$compile_project
echo Package_Publish: $Package_Publish
echo is_tag_fetch: $is_tag_fetch
echo arch: $arch
@@ -54,8 +54,8 @@ echo sdk_url: $sdk_url
zip_name=${sdk_url##*/}
echo zip_name: $zip_name
-python3 $WORKSPACE/artifactory_utils.py --action=download_file --file=$sdk_url
-7za x ./$zip_name -y
+curl -o $zip_name $sdk_url || exit 1
+7za x ./$zip_name -y > log.txt
unzip_name=`ls -S -d */ | grep Agora`
echo unzip_name: $unzip_name
@@ -64,21 +64,20 @@ rm -rf ./$unzip_name/bin
rm ./$unzip_name/commits
rm ./$unzip_name/package_size_report.txt
mkdir ./$unzip_name/samples
-mkdir ./$unzip_name/samples/APIExample
-if [ $? -eq 0 ]; then
- echo "success"
-else
- echo "failed"
- exit 1
-fi
-cp -a ./macOS/** ./$unzip_name/samples/APIExample
+
+
+cp -rf ./macOS ./$unzip_name/samples/APIExample || exit 1
+ls -al ./$unzip_name/samples/API-Example/
mv ./$unzip_name/samples/APIExample/sdk.podspec ./$unzip_name/
python3 ./.github/ci/build/modify_podfile.py ./$unzip_name/samples/APIExample/Podfile
+7za a -tzip result.zip -r $unzip_name
+cp result.zip $WORKSPACE/withAPIExample_${BUILD_NUMBER}_$zip_name
-if [ $is_generate_validate_app = true ]; then
- ./.github/ci/build/build_mac_ipa.sh ./$unzip_name/samples/APIExample
+if [ $compile_project = true ]; then
+ cd ./$unzip_name/samples/APIExample
+ ./cloud_build.sh || exit 1
+ cd -
fi
-7za a -tzip result.zip -r $unzip_name
-cp result.zip $WORKSPACE/withAPIExample_${BUILD_NUMBER}_$zip_name
+
diff --git a/.github/ci/build/build_windows.bat b/.github/ci/build/build_windows.bat
index 4c83f4263..0f02ea60c 100644
--- a/.github/ci/build/build_windows.bat
+++ b/.github/ci/build/build_windows.bat
@@ -38,6 +38,7 @@ REM pr: output test.zip to workspace dir
REM others: Rename the zip package name yourself, But need copy it to workspace dir
REM ##################################
+echo compile_project: %compile_project%
echo Package_Publish: %Package_Publish%
echo is_tag_fetch: %is_tag_fetch%
echo arch: %arch%
@@ -84,15 +85,11 @@ xcopy /Y /E windows\README.zh.md Agora_Native_SDK_for_Windows_FULL\samples\API-e
rmdir /S /Q Agora_Native_SDK_for_Windows_FULL\samples\API-example\APIExample\APIExample
dir Agora_Native_SDK_for_Windows_FULL\samples\API-example\APIExample
7z a -tzip result.zip -r Agora_Native_SDK_for_Windows_FULL
-copy result.zip %WORKSPACE%\\withAPIExample_%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%_%zip_name%
+copy result.zip %WORKSPACE%\\withAPIExample_%BUILD_NUMBER%_%zip_name%
del /F result.zip
del /F %WORKSPACE%\\%zip_name%
+if %compile_project% EQU false goto FINAL
cd Agora_Native_SDK_for_Windows_FULL\samples\API-example
-echo "compile start..."
-call installThirdParty.bat
-"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" "APIExample.sln" /p:platform="Win32" /p:configuration="Release"
-7z a -tzip result.zip -r Release
-copy result.zip %WORKSPACE%\\APIExample_windows_%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%_Release_exe.zip
-del /F result.zip
-echo "compile done."
+call cloud_build.bat
+:FINAL
diff --git a/.gitignore b/.gitignore
index 2785a6808..b27e7ef9b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
xcuserdata
.DS_Store
AgoraRtcKit.framework
+*/libs
diff --git a/Android/APIExample-Audio/README.md b/Android/APIExample-Audio/README.md
index 23f880c8a..6cbdf868a 100644
--- a/Android/APIExample-Audio/README.md
+++ b/Android/APIExample-Audio/README.md
@@ -31,6 +31,7 @@ To build and run the sample application, get an App Id:
// assign token and certificate to null if you have not enabled app certificate
YOUR APP CERTIFICATE
// assign token and certificate to null if you have not enabled app certificate or you have set the certificate above.
+ // PS:It is unsafe to place the App Certificate on the client side, it is recommended to place it on the server side to ensure that the App Certificate is not leaked.
YOUR ACCESS TOKEN
```
diff --git a/Android/APIExample-Audio/README.zh.md b/Android/APIExample-Audio/README.zh.md
index 84cc668ee..6828cc087 100644
--- a/Android/APIExample-Audio/README.zh.md
+++ b/Android/APIExample-Audio/README.zh.md
@@ -31,6 +31,7 @@
// 如果你没有打开Token功能,certificate可以直接不填
YOUR APP CERTIFICATE
// 如果你没有打开Token功能或者已经配置了certificate,token可以直接不填
+ // 注意:App证书放在客户端不安全,推荐放在服务端以确保 App 证书不会泄露。
YOUR ACCESS TOKEN
```
diff --git a/Android/APIExample-Audio/app/build.gradle b/Android/APIExample-Audio/app/build.gradle
index 73679fdca..d4d1a595a 100644
--- a/Android/APIExample-Audio/app/build.gradle
+++ b/Android/APIExample-Audio/app/build.gradle
@@ -1,6 +1,7 @@
apply plugin: 'com.android.application'
def localSdkPath= "${rootProject.projectDir.absolutePath}/../../sdk"
+def agoraSdkVersion = '4.4.1'
android {
compileSdkVersion 32
@@ -16,10 +17,28 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
+ signingConfigs {
+ myConfig {
+ storeFile new File(rootProject.rootDir.absolutePath + "/keystore.key")
+ storePassword "965606"
+ keyAlias "agora"
+ keyPassword "965606"
+ v1SigningEnabled true
+ v2SigningEnabled true
+ }
+ }
+
buildTypes {
- release {
+ debug {
minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ signingConfig signingConfigs.myConfig
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+
+ release {
+ minifyEnabled true
+ signingConfig signingConfigs.myConfig
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
@@ -28,6 +47,8 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
+
+
sourceSets {
main {
jniLibs.srcDirs += 'src/main/jniLibs'
@@ -40,6 +61,15 @@ android {
buildFeatures{
viewBinding true
}
+
+ applicationVariants.all {
+ variant ->
+ variant.outputs.all { output ->
+ outputFileName = new File(rootProject.name
+ + "_" + agoraSdkVersion
+ + "_" + new Date().format("yyyyMMddHHmm") + ".apk")
+ }
+ }
}
dependencies {
@@ -48,16 +78,15 @@ dependencies {
implementation fileTree(dir: "${localSdkPath}", include: ['*.jar', '*.aar'])
}
else{
- def agora_sdk_version = "4.3.1"
// case 1: full single lib with voice only
- implementation "io.agora.rtc:voice-sdk:${agora_sdk_version}"
+ implementation "io.agora.rtc:voice-sdk:${agoraSdkVersion}"
// case 2: partial libs with voice only
- // implementation "io.agora.rtc:voice-rtc-basic:${agora_sdk_version}"
- // implementation "io.agora.rtc:spatial-audio:${agora_sdk_version}"
- // implementation "io.agora.rtc:audio-beauty:${agora_sdk_version}"
- // implementation "io.agora.rtc:aiaec:${agora_sdk_version}"
- // implementation "io.agora.rtc:drm-loader:${agora_sdk_version}"
- // implementation "io.agora.rtc:drm:${agora_sdk_version}"
+ // implementation "io.agora.rtc:voice-rtc-basic:${agoraSdkVersion}"
+ // implementation "io.agora.rtc:spatial-audio:${agoraSdkVersion}"
+ // implementation "io.agora.rtc:audio-beauty:${agoraSdkVersion}"
+ // implementation "io.agora.rtc:aiaec:${agoraSdkVersion}"
+ // implementation "io.agora.rtc:drm-loader:${agoraSdkVersion}"
+ // implementation "io.agora.rtc:drm:${agoraSdkVersion}"
}
implementation 'androidx.appcompat:appcompat:1.5.0'
diff --git a/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/VoiceEffects.java b/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/VoiceEffects.java
index ef1abdbf1..8efd7619d 100644
--- a/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/VoiceEffects.java
+++ b/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/VoiceEffects.java
@@ -89,6 +89,9 @@
import io.agora.rtc2.RtcEngineConfig;
import io.agora.rtc2.proxy.LocalAccessPointConfiguration;
+/**
+ * The type Voice effects.
+ */
@Example(
index = 4,
group = ADVANCED,
@@ -106,7 +109,7 @@ public class VoiceEffects extends BaseFragment implements View.OnClickListener,
private EditText et_channel;
private Button join;
private Spinner audioProfile, audioScenario,
- chatBeautifier, timbreTransformation, voiceChanger, styleTransformation, roomAcoustics, pitchCorrection, _pitchModeOption, _pitchValueOption, voiceConversion, ainsMode,
+ chatBeautifier, timbreTransformation, voiceChanger, styleTransformation, roomAcoustics, pitchCorrection, _pitchModeOption, _pitchValueOption, voiceConversion, ainsMode, voiceAITuner,
customBandFreq, customReverbKey;
private ViewGroup _voice3DLayout, _pitchModeLayout, _pitchValueLayout;
private SeekBar _voice3DCircle, customPitch, customBandGain, customReverbValue, customVoiceFormant;
@@ -154,6 +157,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
_pitchValueOption = view.findViewById(R.id.audio_pitch_value_option);
voiceConversion = view.findViewById(R.id.audio_voice_conversion);
ainsMode = view.findViewById(R.id.audio_ains_mode);
+ voiceAITuner = view.findViewById(R.id.voice_ai_tuner);
chatBeautifier.setOnItemSelectedListener(this);
timbreTransformation.setOnItemSelectedListener(this);
@@ -166,6 +170,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
_pitchModeOption.setOnItemSelectedListener(this);
_pitchValueOption.setOnItemSelectedListener(this);
ainsMode.setOnItemSelectedListener(this);
+ voiceAITuner.setOnItemSelectedListener(this);
// Customize Voice Effects Layout
customPitch = view.findViewById(R.id.audio_custom_pitch); // engine.setLocalVoicePitch()
@@ -205,6 +210,7 @@ private void resetControlLayoutByJoined() {
_pitchValueLayout.setVisibility(View.GONE);
voiceConversion.setEnabled(joined);
ainsMode.setEnabled(joined);
+ voiceAITuner.setEnabled(joined);
customPitch.setEnabled(joined);
customBandFreq.setEnabled(joined);
@@ -238,30 +244,30 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
}
try {
RtcEngineConfig config = new RtcEngineConfig();
- /**
+ /*
* The context of Android Activity
*/
config.mContext = context.getApplicationContext();
- /**
+ /*
* The App ID issued to you by Agora. See How to get the App ID
*/
config.mAppId = getString(R.string.agora_app_id);
- /** Sets the channel profile of the Agora RtcEngine.
+ /* Sets the channel profile of the Agora RtcEngine.
CHANNEL_PROFILE_COMMUNICATION(0): (Default) The Communication profile.
Use this profile in one-on-one calls or group calls, where all users can talk freely.
CHANNEL_PROFILE_LIVE_BROADCASTING(1): The Live-Broadcast profile. Users in a live-broadcast
channel have a role as either broadcaster or audience. A broadcaster can both send and receive streams;
an audience can only receive streams.*/
config.mChannelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING;
- /**
+ /*
* IRtcEngineEventHandler is an abstract class providing default implementation.
* The SDK uses this class to report to the app on SDK runtime events.
*/
config.mEventHandler = iRtcEngineEventHandler;
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
- config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
+ config.mAreaCode = ((MainApplication) getActivity().getApplication()).getGlobalSettings().getAreaCode();
engine = RtcEngine.create(config);
- /**
+ /*
* This parameter is for reporting the usages of APIExample to agora background.
* Generally, it is not necessary for you to set this parameter.
*/
@@ -288,7 +294,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
@Override
public void onDestroy() {
super.onDestroy();
- /**leaveChannel and Destroy the RtcEngine instance*/
+ /*leaveChannel and Destroy the RtcEngine instance*/
if (engine != null) {
engine.leaveChannel();
}
@@ -312,15 +318,14 @@ public void onClick(View v) {
AndPermission.with(this).runtime().permission(
Permission.Group.STORAGE,
Permission.Group.MICROPHONE
- ).onGranted(permissions ->
- {
+ ).onGranted(permissions -> {
// Permissions Granted
joinChannel(channelId);
}).start();
} else {
joined = false;
resetControlLayoutByJoined();
- /**After joining a channel, the user must call the leaveChannel method to end the
+ /*After joining a channel, the user must call the leaveChannel method to end the
* call before joining another channel. This method returns 0 if the user leaves the
* channel and releases all resources related to the call. This method call is
* asynchronous, and the user has not exited the channel when the method call returns.
@@ -389,7 +394,7 @@ private int getPitch2Value(String str) {
* Users that input the same channel name join the same channel.
*/
private void joinChannel(String channelId) {
- /**In the demo, the default is to enter as the anchor.*/
+ /*In the demo, the default is to enter as the anchor.*/
engine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
// audio config
engine.setAudioProfile(
@@ -397,13 +402,13 @@ private void joinChannel(String channelId) {
Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()))
);
- /**Please configure accessToken in the string_config file.
+ /*Please configure accessToken in the string_config file.
* A temporary token generated in Console. A temporary token is valid for 24 hours. For details, see
* https://docs.agora.io/en/Agora%20Platform/token?platform=All%20Platforms#get-a-temporary-token
* A token generated at the server. This applies to scenarios with high-security requirements. For details, see
* https://docs.agora.io/en/cloud-recording/token_server_java?platform=Java*/
TokenUtils.gen(requireContext(), channelId, 0, accessToken -> {
- /** Allows a user to join a channel.
+ /* Allows a user to join a channel.
if you do not specify the uid, we will generate the uid for you*/
ChannelMediaOptions option = new ChannelMediaOptions();
@@ -588,7 +593,7 @@ public void onItemSelected(AdapterView> parent, View view, int position, long
for (Spinner spinner : voiceBeautifierSpinner) {
if (spinner != parent) {
- if(spinner.getSelectedItemPosition() != 0){
+ if (spinner.getSelectedItemPosition() != 0) {
spinner.setTag("reset");
spinner.setSelection(0);
}
@@ -605,33 +610,33 @@ public void onItemSelected(AdapterView> parent, View view, int position, long
for (Spinner spinner : audioEffectSpinner) {
if (spinner != parent) {
- if(spinner.getSelectedItemPosition() != 0){
+ if (spinner.getSelectedItemPosition() != 0) {
spinner.setTag("reset");
spinner.setSelection(0);
}
}
}
- _voice3DLayout.setVisibility(audioEffectPreset == ROOM_ACOUSTICS_3D_VOICE ? View.VISIBLE: View.GONE);
+ _voice3DLayout.setVisibility(audioEffectPreset == ROOM_ACOUSTICS_3D_VOICE ? View.VISIBLE : View.GONE);
_pitchModeLayout.setVisibility(audioEffectPreset == PITCH_CORRECTION ? View.VISIBLE : View.GONE);
_pitchValueLayout.setVisibility(audioEffectPreset == PITCH_CORRECTION ? View.VISIBLE : View.GONE);
return;
}
- if(parent == voiceConversion){
+ if (parent == voiceConversion) {
String item = parent.getSelectedItem().toString();
engine.setVoiceConversionPreset(getVoiceConversionValue(item));
return;
}
- if(parent == _pitchModeOption || parent == _pitchValueOption){
+ if (parent == _pitchModeOption || parent == _pitchValueOption) {
int effectOption1 = getPitch1Value(_pitchModeOption.getSelectedItem().toString());
int effectOption2 = getPitch2Value(_pitchValueOption.getSelectedItem().toString());
engine.setAudioEffectParameters(PITCH_CORRECTION, effectOption1, effectOption2);
}
- if(parent == ainsMode){
+ if (parent == ainsMode) {
boolean enable = position > 0;
/*
The AI noise suppression modes:
@@ -644,6 +649,12 @@ public void onItemSelected(AdapterView> parent, View view, int position, long
*/
engine.setAINSMode(enable, position - 1);
}
+
+ if (parent == voiceAITuner) {
+ boolean enable = position > 0;
+ String item = parent.getSelectedItem().toString();
+ engine.enableVoiceAITuner(enable, enable ? Constants.VOICE_AI_TUNER_TYPE.valueOf(item) : Constants.VOICE_AI_TUNER_TYPE.VOICE_AI_TUNER_MATURE_MALE);
+ }
}
private int getVoiceConversionValue(String label) {
@@ -672,7 +683,7 @@ private int getVoiceConversionValue(String label) {
return VOICE_CHANGER_DARTH_VADER;
case "VOICE_CHANGER_IRON_LADY":
return VOICE_CHANGER_IRON_LADY;
- case "VOICE_CHANGER_SHIN_CHAN":
+ case "VOICE_CHANGER_SHIN_CHAN":
return VOICE_CHANGER_SHIN_CHAN;
case "VOICE_CHANGER_GIRLISH_MAN":
return VOICE_CHANGER_GIRLISH_MAN;
@@ -807,11 +818,11 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (!fromUser) {
return;
}
- if(seekBar == _voice3DCircle){
+ if (seekBar == _voice3DCircle) {
int cicle = (int) (1 + 59 * progress * 1.0f / seekBar.getMax());
// [1,60], 10 default
engine.setAudioEffectParameters(ROOM_ACOUSTICS_3D_VOICE, cicle, 0);
- }else if(seekBar == customPitch){
+ } else if (seekBar == customPitch) {
double pitch = 0.5 + 1.5 * progress * 1.0f / seekBar.getMax();
// pitch: [0.5,2.0], 1.0 default
engine.setLocalVoicePitch(pitch);
@@ -827,11 +838,11 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// AUDIO_REVERB_ROOM_SIZE(2):[0, 100] dB
// AUDIO_REVERB_WET_DELAY(3):Wet signal, [0, 200] ms
// AUDIO_REVERB_STRENGTH(4): [0, 100]
- if(reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_DRY_LEVEL || reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_WET_LEVEL){
+ if (reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_DRY_LEVEL || reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_WET_LEVEL) {
value = (int) (-20 + 30 * progress * 1.0f / seekBar.getMax());
- }else if(reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_WET_DELAY){
+ } else if (reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_WET_DELAY) {
value = (int) (200 * progress * 1.0f / seekBar.getMax());
- }else {
+ } else {
value = (int) (100 * progress * 1.0f / seekBar.getMax());
}
engine.setLocalVoiceReverb(reverbKey, value);
diff --git a/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/utils/TokenUtils.java b/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/utils/TokenUtils.java
index 65b2ee411..4f378bf22 100644
--- a/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/utils/TokenUtils.java
+++ b/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/utils/TokenUtils.java
@@ -85,7 +85,7 @@ private static void gen(String appId, String certificate, String channelName, in
}
Request request = new Request.Builder()
- .url("https://test-toolbox.bj2.agoralab.co/v1/token/generate")
+ .url("https://service.agora.io/toolbox-global/v1/token/generate")
.addHeader("Content-Type", "application/json")
.post(RequestBody.create(postBody.toString(), null))
.build();
diff --git a/Android/APIExample-Audio/app/src/main/res/layout/fragment_joinchannel_audio_by_token.xml b/Android/APIExample-Audio/app/src/main/res/layout/fragment_joinchannel_audio_by_token.xml
index 8b5d3b857..8449bda6a 100644
--- a/Android/APIExample-Audio/app/src/main/res/layout/fragment_joinchannel_audio_by_token.xml
+++ b/Android/APIExample-Audio/app/src/main/res/layout/fragment_joinchannel_audio_by_token.xml
@@ -7,11 +7,10 @@
+ android:layout_marginBottom="16dp">
+
+
+
+
+
+
+
+
AINS_MODE_AGGRESSIVE
- AINS_MODE_ULTRALOWLATENCY
+
+
+ - OFF
+ - VOICE_AI_TUNER_MATURE_MALE
+ - VOICE_AI_TUNER_FRESH_MALE
+ - VOICE_AI_TUNER_ELEGANT_FEMALE
+ - VOICE_AI_TUNER_SWEET_FEMALE
+ - VOICE_AI_TUNER_WARM_MALE_SINGING
+ - VOICE_AI_TUNER_GENTLE_FEMALE_SINGING
+ - VOICE_AI_TUNER_HUSKY_MALE_SINGING
+ - VOICE_AI_TUNER_WARM_ELEGANT_FEMALE_SINGING
+ - VOICE_AI_TUNER_POWERFUL_MALE_SINGING
+ - VOICE_AI_TUNER_DREAMY_FEMALE_SINGING
+
\ No newline at end of file
diff --git a/Android/APIExample-Audio/app/src/main/res/values/string_configs.xml b/Android/APIExample-Audio/app/src/main/res/values/string_configs.xml
index 1592e3705..767727190 100644
--- a/Android/APIExample-Audio/app/src/main/res/values/string_configs.xml
+++ b/Android/APIExample-Audio/app/src/main/res/values/string_configs.xml
@@ -25,14 +25,16 @@
or use the console to generate a temporary token.
In order to get the APP ID, you can open the agora console (https://console.agora.io/) to create a project with the App Certificate enabled,
- then the APP Certificate can be found in the project detail page.
- PS: If the project does not have certificates enabled, leave this field blank.
+ then the APP Certificate can be found in the project detail page.If the project does not have certificates enabled, leave this field blank.
+
+ PS: It is unsafe to place the App Certificate on the client side, it is recommended to place it on the server side to ensure that the App Certificate is not leaked.
声网APP证书
Agora 提供 App certificate 用以生成 Token。您可以在您的服务器部署并生成 Token,或者使用控制台生成临时的 Token。
- 进入声网控制台(https://console.agora.io/),创建一个带证书鉴权的项目,进入项目配置页,即可看到APP证书。
- 注意:如果项目没有开启证书鉴权,这个字段留空。
+ 进入声网控制台(https://console.agora.io/),创建一个带证书鉴权的项目,进入项目配置页,即可看到APP证书。如果项目没有开启证书鉴权,这个字段留空。
+
+ 注意:App证书放在客户端不安全,推荐放在服务端以确保 App 证书不会泄露。
-->
YOUR APP CERTIFICATE
diff --git a/Android/APIExample-Audio/cloud_build.sh b/Android/APIExample-Audio/cloud_build.sh
new file mode 100755
index 000000000..812a18d85
--- /dev/null
+++ b/Android/APIExample-Audio/cloud_build.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env sh
+
+# cache gradle to /tmp/.gradle
+ls ~/.gradle || (mkdir -p /tmp/.gradle && ln -s /tmp/.gradle ~/.gradle && touch ~/.gradle/ln_$(date "+%y%m%d%H") && ls ~/.gradle)
+
+#change android maven to china repos
+sed -ie "s#google()#maven { url \"https\://maven.aliyun.com/repository/public\" }\n google()#g" settings.gradle
+sed -ie "s#https://services.gradle.org/distributions#https://mirrors.cloud.tencent.com/gradle#g" gradle/wrapper/gradle-wrapper.properties
+
+## config appId
+sed -i -e "s#YOUR APP ID#${APP_ID}#g" app/src/main/res/values/string_configs.xml
+sed -i -e "s#YOUR APP CERTIFICATE##g" app/src/main/res/values/string_configs.xml
+sed -i -e "s#YOUR ACCESS TOKEN##g" app/src/main/res/values/string_configs.xml
+rm -f app/src/main/res/values/string_configs.xml-e
+
+./gradlew clean || exit 1
+./gradlew :app:assembleRelease || exit 1
+if [ "$WORKSPACE" != "" ]; then
+SDK_VERSION=$(echo $sdk_url | cut -d "/" -f 5)
+cp app/build/outputs/apk/release/*.apk $WORKSPACE/APIExample-Audio_${BUILD_NUMBER}_${SDK_VERSION}_$(date "+%Y%m%d%H%M%S").apk
+fi
\ No newline at end of file
diff --git a/Android/APIExample-Audio/keystore.key b/Android/APIExample-Audio/keystore.key
new file mode 100644
index 000000000..a5014a522
Binary files /dev/null and b/Android/APIExample-Audio/keystore.key differ
diff --git a/Android/APIExample-Compose/README.md b/Android/APIExample-Compose/README.md
new file mode 100644
index 000000000..e2ee7b506
--- /dev/null
+++ b/Android/APIExample-Compose/README.md
@@ -0,0 +1,50 @@
+# API Example Android
+
+*English | [中文](README.zh.md)*
+
+This project presents you a set of API examples to help you understand how to use Agora APIs.
+
+## Prerequisites
+
+- Android Studio 3.0+
+- Physical Android device
+- Android simulator is supported
+
+## Quick Start
+
+This section shows you how to prepare, build, and run the sample application.
+
+### Obtain an App Id
+
+To build and run the sample application, get an App Id:
+
+1. Create a developer account at [agora.io](https://dashboard.agora.io/signin/). Once you finish the signup process, you will be redirected to the Dashboard.
+2. Navigate in the Dashboard tree on the left to **Projects** > **Project List**.
+3. Save the **App Id** from the Dashboard for later use.
+4. Save the **App Certificate** from the Dashboard for later use.
+
+5. Open `Android/APIExample-Compose` and edit the `local.properties` file. Update `YOUR APP ID` with your App Id, update `YOUR APP CERTIFICATE` with the main app certificate from dashboard. Note you can leave the certificate variable `null` if your project has not turned on security token.
+
+ ```
+ // Agora APP ID.
+ AGORA_APP_ID=YOUR APP ID
+ // Agora APP Certificate. If the project does not have certificates enabled, leave this field blank.
+ AGORA_APP_CERT=YOUR APP CERTIFICATE
+ ```
+
+You are all set. Now connect your Android device and run the project.
+
+
+## Contact Us
+
+- For potential issues, take a look at our [FAQ](https://docs.agora.io/en/faq) first
+- Dive into [Agora SDK Samples](https://github.com/AgoraIO) to see more tutorials
+- Take a look at [Agora Use Case](https://github.com/AgoraIO-usecase) for more complicated real use case
+- Repositories managed by developer communities can be found at [Agora Community](https://github.com/AgoraIO-Community)
+- You can find full API documentation at [Document Center](https://docs.agora.io/en/)
+- If you encounter problems during integration, you can ask question in [Stack Overflow](https://stackoverflow.com/questions/tagged/agora.io)
+- You can file bugs about this sample at [issue](https://github.com/AgoraIO/API-Examples/issues)
+
+## License
+
+The MIT License (MIT)
diff --git a/Android/APIExample-Compose/README.zh.md b/Android/APIExample-Compose/README.zh.md
new file mode 100644
index 000000000..21769f0e2
--- /dev/null
+++ b/Android/APIExample-Compose/README.zh.md
@@ -0,0 +1,50 @@
+# API Example Android
+
+*[English](README.md) | 中文*
+
+这个开源示例项目演示了Agora视频SDK的部分API使用示例,以帮助开发者更好地理解和运用Agora视频SDK的API。
+
+## 环境准备
+
+- Android Studio 3.0+
+- Android 真机设备
+- 支持模拟器
+
+## 运行示例程序
+
+这个段落主要讲解了如何编译和运行实例程序。
+
+### 创建Agora账号并获取AppId
+
+在编译和启动实例程序前,你需要首先获取一个可用的App Id:
+
+1. 在[agora.io](https://dashboard.agora.io/signin/)创建一个开发者账号
+2. 前往后台页面,点击左部导航栏的 **项目 > 项目列表** 菜单
+3. 复制后台的 **App Id** 并备注,稍后启动应用时会用到它
+4. 复制后台的 **App 证书** 并备注,稍后启动应用时会用到它
+
+5. 打开 `Android/APIExample` 并编辑 `local.properties`,将你的 AppID 、App主证书 分别替换到 `Your App Id` 和 `YOUR APP CERTIFICATE`
+
+ ```
+ // 声网APP ID。
+ AGORA_APP_ID=YOUR APP ID
+ // 声网APP证书。如果项目没有开启证书鉴权,这个字段留空。
+ AGORA_APP_CERT=YOUR APP CERTIFICATE
+ ```
+
+然后你就可以编译并运行项目了。
+
+## 联系我们
+
+- 如果你遇到了困难,可以先参阅 [常见问题](https://docs.agora.io/cn/faq)
+- 如果你想了解更多官方示例,可以参考 [官方SDK示例](https://github.com/AgoraIO)
+- 如果你想了解声网SDK在复杂场景下的应用,可以参考 [官方场景案例](https://github.com/AgoraIO-usecase)
+- 如果你想了解声网的一些社区开发者维护的项目,可以查看 [社区](https://github.com/AgoraIO-Community)
+- 完整的 API 文档见 [文档中心](https://docs.agora.io/cn/)
+- 若遇到问题需要开发者帮助,你可以到 [开发者社区](https://rtcdeveloper.com/) 提问
+- 如果需要售后技术支持, 你可以在 [Agora Dashboard](https://dashboard.agora.io) 提交工单
+- 如果发现了示例代码的 bug,欢迎提交 [issue](https://github.com/AgoraIO/API-Examples/issues)
+
+## 代码许可
+
+The MIT License (MIT)
diff --git a/Android/APIExample-Compose/app/build.gradle.kts b/Android/APIExample-Compose/app/build.gradle.kts
index 1c5229ad4..fb0485a35 100644
--- a/Android/APIExample-Compose/app/build.gradle.kts
+++ b/Android/APIExample-Compose/app/build.gradle.kts
@@ -1,3 +1,6 @@
+import com.android.build.gradle.internal.api.ApkVariantOutputImpl
+import java.text.SimpleDateFormat
+import java.util.Date
import java.util.Properties
plugins {
@@ -5,6 +8,8 @@ plugins {
alias(libs.plugins.jetbrainsKotlinAndroid)
}
+val localSdkPath = "${rootProject.projectDir.absolutePath}/../../sdk"
+
android {
namespace = "io.agora.api.example.compose"
compileSdk = 34
@@ -24,7 +29,7 @@ android {
val properties = Properties()
properties.load(rootProject.file("local.properties").inputStream())
val AGORA_APP_ID = properties.getProperty("AGORA_APP_ID", "")
- if(AGORA_APP_ID == ""){
+ if (AGORA_APP_ID == "") {
throw GradleException("请在项目根目录下local.properties文件里正确配置:AGORA_APP_ID=<您的声网AppId>")
}
val AGORA_APP_CERT = properties.getProperty("AGORA_APP_CERT", "")
@@ -32,12 +37,26 @@ android {
buildConfigField("String", "AGORA_APP_CERT", "\"$AGORA_APP_CERT\"")
}
+ signingConfigs(Action {
+ create("myConfig") {
+ storeFile = file(rootProject.rootDir.absolutePath + "/keystore.key")
+ storePassword = "965606"
+ keyAlias = "agora"
+ keyPassword = "965606"
+ }
+ })
+
buildFeatures {
buildConfig = true
}
buildTypes {
- release {
+ debug {
isMinifyEnabled = false
+ signingConfig = signingConfigs.getByName("myConfig")
+ }
+ release {
+ isMinifyEnabled = true
+ signingConfig = signingConfigs.getByName("myConfig")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
@@ -62,10 +81,29 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
+ android.applicationVariants.all {
+ outputs.all {
+ if (this is ApkVariantOutputImpl) {
+ this.outputFileName =
+ "${rootProject.name}_${libs.versions.agoraSdk.get()}_${
+ SimpleDateFormat("yyyyMMddHHmm").format(
+ Date()
+ )
+ }.apk"
+ }
+ }
+ }
+ sourceSets {
+ getByName("main") {
+ if (File(localSdkPath).exists()) {
+ jniLibs.srcDirs(localSdkPath)
+ }
+ }
+
+ }
}
dependencies {
-
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
@@ -77,8 +115,6 @@ dependencies {
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.datastore)
implementation(libs.androidx.datastore.preferences)
- implementation(libs.agora.full.sdk)
- implementation(libs.agora.full.screen.sharing)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
@@ -90,4 +126,11 @@ dependencies {
implementation(libs.okhttp)
implementation(libs.logging.interceptor)
+ if (File(localSdkPath).exists()) {
+ implementation(fileTree(localSdkPath).include("*.jar", "*.aar"))
+ } else {
+ implementation(libs.agora.full.sdk)
+ implementation(libs.agora.full.screen.sharing)
+ }
+
}
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/proguard-rules.pro b/Android/APIExample-Compose/app/proguard-rules.pro
index 481bb4348..a2b8a71d6 100644
--- a/Android/APIExample-Compose/app/proguard-rules.pro
+++ b/Android/APIExample-Compose/app/proguard-rules.pro
@@ -18,4 +18,12 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
-#-renamesourcefileattribute SourceFile
\ No newline at end of file
+#-renamesourcefileattribute SourceFile
+
+-keep class io.agora.**{*;}
+-dontwarn javax.**
+-dontwarn com.google.devtools.build.android.**
+
+-dontwarn org.bouncycastle.**
+-dontwarn org.conscrypt.**
+-dontwarn org.openjsse.**
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/src/main/AndroidManifest.xml b/Android/APIExample-Compose/app/src/main/AndroidManifest.xml
index e392d9d14..d05457e9e 100644
--- a/Android/APIExample-Compose/app/src/main/AndroidManifest.xml
+++ b/Android/APIExample-Compose/app/src/main/AndroidManifest.xml
@@ -5,12 +5,13 @@
+
-
+
-
-
+
+
@@ -27,13 +28,21 @@
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
- android:theme="@style/Theme.APIExampleCompose">
+ android:theme="@style/Theme.APIExampleCompose"
+ android:configChanges="screenSize|screenLayout|orientation|smallestScreenSize">
+
+
+
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/model/Examples.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/model/Examples.kt
index de56bab84..47abfdc76 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/model/Examples.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/model/Examples.kt
@@ -20,19 +20,21 @@ import io.agora.api.example.compose.samples.MediaPlayer
import io.agora.api.example.compose.samples.MediaRecorder
import io.agora.api.example.compose.samples.OriginAudioData
import io.agora.api.example.compose.samples.OriginVideoData
+import io.agora.api.example.compose.samples.PictureInPictureEntrance
import io.agora.api.example.compose.samples.PlayAudioFiles
import io.agora.api.example.compose.samples.PreCallTest
import io.agora.api.example.compose.samples.RTMPStreaming
import io.agora.api.example.compose.samples.RhythmPlayer
import io.agora.api.example.compose.samples.ScreenSharing
import io.agora.api.example.compose.samples.SendDataStream
+import io.agora.api.example.compose.samples.SpatialSound
import io.agora.api.example.compose.samples.VideoProcessExtension
import io.agora.api.example.compose.samples.VoiceEffects
data class Example(
@StringRes val name: Int,
val description: String = "",
- val content: @Composable () -> Unit
+ val content: @Composable (back: () -> Unit) -> Unit
)
val BasicExampleList = listOf(
@@ -52,6 +54,7 @@ val AdvanceExampleList = listOf(
Example(R.string.example_originvideodata) { OriginVideoData() },
Example(R.string.example_customvideosource) { CustomVideoSource() },
Example(R.string.example_customvideorender) { CustomVideoRender() },
+ Example(R.string.example_pictureinpicture) { PictureInPictureEntrance(it) },
Example(R.string.example_joinmultichannel) { JoinMultiChannel() },
Example(R.string.example_channelencryption) { ChannelEncryption() },
Example(R.string.example_playaudiofiles) { PlayAudioFiles() },
@@ -64,4 +67,5 @@ val AdvanceExampleList = listOf(
Example(R.string.example_localvideotranscoding) { LocalVideoTranscoding() },
Example(R.string.example_senddatastream) { SendDataStream() },
Example(R.string.example_hostacrosschannel) { HostAcrossChannel() },
+ Example(R.string.example_spatialsound) { SpatialSound() },
)
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/ChannelEncryption.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/ChannelEncryption.kt
index e4b496d55..198acabb0 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/ChannelEncryption.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/ChannelEncryption.kt
@@ -24,8 +24,10 @@ import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.DropdownMenuRaw
@@ -235,7 +237,7 @@ fun ChannelEncryption() {
}
@Composable
-fun ChannelEncryptionView(
+private fun ChannelEncryptionView(
rtcEngine: RtcEngine? = null,
channelName: String,
isJoined: Boolean,
@@ -274,7 +276,7 @@ fun ChannelEncryptionView(
}
)
DropdownMenuRaw(
- title = "加密方式",
+ title = stringResource(id = R.string.encryption_mode),
options = listOf(
"AES_128_XTS" to EncryptionConfig.EncryptionMode.AES_128_XTS,
"AES_128_ECB" to EncryptionConfig.EncryptionMode.AES_128_ECB,
@@ -298,7 +300,7 @@ fun ChannelEncryptionView(
value = encryptionKey,
enabled = !isJoined,
onValueChange = { onEncryptionKeyChanged(it) },
- label = { Text("加密密钥") },
+ label = { Text(stringResource(id = R.string.encryption_key)) },
singleLine = true,
shape = RectangleShape,
colors = TextFieldDefaults.colors(
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomAudioRender.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomAudioRender.kt
index 05a7839cd..b3d6d9f98 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomAudioRender.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomAudioRender.kt
@@ -205,7 +205,7 @@ fun CustomAudioRender() {
@Composable
-fun CustomAudioRenderView(
+private fun CustomAudioRenderView(
videoIdList: List,
statsMap: Map = mapOf(),
channelName: String = "",
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomAudioSource.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomAudioSource.kt
index f9f469013..e9c4e949e 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomAudioSource.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomAudioSource.kt
@@ -23,8 +23,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.AudioGrid
import io.agora.api.example.compose.ui.common.AudioStatsInfo
@@ -198,7 +200,7 @@ fun CustomAudioSource() {
@Composable
-fun CustomAudioSourceView(
+private fun CustomAudioSourceView(
videoIdList: List,
statsMap: Map = mapOf(),
channelName: String = "",
@@ -221,8 +223,8 @@ fun CustomAudioSourceView(
Spacer(modifier = Modifier.weight(1.0f))
- SwitchRaw(title = "发布本地音频", enable = isJoined, onCheckedChange = onLocalAudioPublish)
- SwitchRaw(title = "发布麦克风", enable = isJoined, onCheckedChange = onMicrophonePublish)
+ SwitchRaw(title = stringResource(id = R.string.publish_local_audio), enable = isJoined, onCheckedChange = onLocalAudioPublish)
+ SwitchRaw(title = stringResource(id = R.string.publish_microphone), enable = isJoined, onCheckedChange = onMicrophonePublish)
ChannelNameInput(
channelName = channelName,
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomVideoRender.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomVideoRender.kt
index 3f6153430..ef78e9e69 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomVideoRender.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomVideoRender.kt
@@ -278,13 +278,15 @@ class CustomVideoRenderRender(
try {
drawer.drawYuv(
yuvUploader.yuvTextures,
+ 0,
RendererCommon.convertMatrixFromAndroidGraphicsMatrix(renderMatrix),
frame.rotatedWidth,
frame.rotatedHeight,
0,
0,
viewportWidth,
- viewportHeight
+ viewportHeight,
+ 0
)
} catch (exception: NullPointerException) {
Log.e(TAG, "skip empty buffer!")
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomVideoSource.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomVideoSource.kt
index 975defac5..56a58dd61 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomVideoSource.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/CustomVideoSource.kt
@@ -221,7 +221,7 @@ fun CustomVideoSource() {
}
@Composable
-fun CustomVideoSourceView(
+private fun CustomVideoSourceView(
rtcEngine: RtcEngine? = null,
channelName: String,
isJoined: Boolean,
@@ -292,7 +292,7 @@ fun CustomVideoSourceView(
}
}
-class ExternalVideoFramePusher(
+private class ExternalVideoFramePusher(
private val context: Context,
private val engine: RtcEngine,
private val trackId: Int = 0
@@ -325,7 +325,7 @@ class ExternalVideoFramePusher(
}
fun dispose() {
- videoFileReader.start()
+ videoFileReader.stop()
textureBufferHelper?.invoke {
yuvFboProgram?.release()
yuvFboProgram = null
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/HostAcrossChannel.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/HostAcrossChannel.kt
index e8b4fe469..024344fd7 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/HostAcrossChannel.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/HostAcrossChannel.kt
@@ -19,8 +19,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.InputRaw
@@ -247,7 +249,7 @@ fun HostAcrossChannel() {
}
@Composable
-fun HostAcrossChannelView(
+private fun HostAcrossChannelView(
rtcEngine: RtcEngine?,
channelName: String,
isJoined: Boolean,
@@ -285,13 +287,15 @@ fun HostAcrossChannelView(
text = "",
label = "Across Channel Name",
editable = !isAcrossStarted,
- btnText = if (isAcrossStarted) "退出" else "加入",
+ btnText = if (isAcrossStarted) stringResource(id = R.string.exit) else stringResource(id = R.string.join),
enable = isJoined,
onBtnClick = {
onAcrossClick(it, isAcrossStarted)
},
secondVisible = true,
- secondBtnText = if (isAcrossRunning) "暂停" else "恢复",
+ secondBtnText = if (isAcrossRunning) stringResource(id = R.string.pause) else stringResource(
+ id = R.string.resume
+ ),
secondEnable = isAcrossStarted,
onSecondBtnClick = {
onAcrossRunningClick(isAcrossRunning)
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelAudio.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelAudio.kt
new file mode 100644
index 000000000..47b7a8c2b
--- /dev/null
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelAudio.kt
@@ -0,0 +1,321 @@
+package io.agora.api.example.compose.samples
+
+import android.Manifest
+import android.os.Build
+import android.widget.Toast
+import androidx.activity.compose.rememberLauncherForActivityResult
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.rememberLazyListState
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.mutableStateMapOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalLifecycleOwner
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.tooling.preview.Preview
+import androidx.compose.ui.unit.dp
+import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.data.SettingPreferences
+import io.agora.api.example.compose.ui.common.AudioGrid
+import io.agora.api.example.compose.ui.common.AudioStatsInfo
+import io.agora.api.example.compose.ui.common.ChannelNameInput
+import io.agora.api.example.compose.ui.common.DropdownMenuRaw
+import io.agora.api.example.compose.ui.common.SliderRaw
+import io.agora.api.example.compose.ui.common.SwitchRaw
+import io.agora.api.example.compose.utils.TokenUtils
+import io.agora.rtc2.ChannelMediaOptions
+import io.agora.rtc2.Constants
+import io.agora.rtc2.IRtcEngineEventHandler
+import io.agora.rtc2.RtcEngine
+import io.agora.rtc2.RtcEngineConfig
+
+@Composable
+fun JoinChannelAudio() {
+ val context = LocalContext.current
+ val lifecycleOwner = LocalLifecycleOwner.current
+ val keyboard = LocalSoftwareKeyboardController.current
+ var isJoined by rememberSaveable { mutableStateOf(false) }
+ var channelName by rememberSaveable { mutableStateOf("") }
+ var localUid by rememberSaveable { mutableIntStateOf(0) }
+ var videoIdList by rememberSaveable { mutableStateOf(listOf()) }
+ val statsMap = remember { mutableStateMapOf(0 to AudioStatsInfo()) }
+ var audioRoute by rememberSaveable { mutableIntStateOf(Constants.AUDIO_ROUTE_SPEAKERPHONE) }
+
+ val rtcEngine = remember {
+ RtcEngine.create(RtcEngineConfig().apply {
+ mAreaCode = SettingPreferences.getArea()
+ mContext = context
+ mAppId = BuildConfig.AGORA_APP_ID
+ mEventHandler = object : IRtcEngineEventHandler() {
+
+ override fun onAudioRouteChanged(routing: Int) {
+ super.onAudioRouteChanged(routing)
+ audioRoute = routing
+ }
+
+ override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
+ super.onJoinChannelSuccess(channel, uid, elapsed)
+ isJoined = true
+ localUid = uid
+ videoIdList = videoIdList + uid
+ statsMap[uid] = AudioStatsInfo()
+ }
+
+ override fun onLeaveChannel(stats: RtcStats?) {
+ super.onLeaveChannel(stats)
+ isJoined = false
+ videoIdList = emptyList()
+ statsMap.clear()
+ }
+
+ override fun onUserJoined(uid: Int, elapsed: Int) {
+ super.onUserJoined(uid, elapsed)
+ videoIdList = videoIdList + uid
+ statsMap[uid] = AudioStatsInfo()
+ }
+
+ override fun onUserOffline(uid: Int, reason: Int) {
+ super.onUserOffline(uid, reason)
+ videoIdList = videoIdList - uid
+ statsMap.remove(uid)
+ }
+
+ override fun onLocalAudioStats(stats: LocalAudioStats?) {
+ super.onLocalAudioStats(stats)
+ statsMap[localUid]?.copy(localAudioStats = stats)?.let {
+ statsMap[localUid] = it
+ }
+ }
+
+ override fun onRemoteAudioStats(stats: RemoteAudioStats?) {
+ super.onRemoteAudioStats(stats)
+ val uid = stats?.uid ?: return
+ statsMap[uid]?.copy(remoteAudioStats = stats)?.let {
+ statsMap[uid] = it
+ }
+ }
+ }
+ }).apply {
+ enableAudio()
+ setChannelProfile(Constants.CHANNEL_PROFILE_COMMUNICATION)
+ }
+ }
+ DisposableEffect(lifecycleOwner) {
+ onDispose {
+ if (isJoined) {
+ rtcEngine.leaveChannel()
+ }
+ RtcEngine.destroy()
+ }
+ }
+ val permissionLauncher =
+ rememberLauncherForActivityResult(contract = ActivityResultContracts.RequestMultiplePermissions()) { grantedMap ->
+ val allGranted = grantedMap.values.all { it }
+ if (allGranted) {
+ // Permission is granted
+ Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
+ val mediaOptions = ChannelMediaOptions()
+ mediaOptions.publishCameraTrack = false
+ mediaOptions.publishMicrophoneTrack = true
+ mediaOptions.autoSubscribeAudio = true
+ mediaOptions.autoSubscribeVideo = false
+ TokenUtils.gen(channelName, 0) {
+ rtcEngine.joinChannel(it, channelName, 0, mediaOptions)
+ }
+
+ } else {
+ // Permission is denied
+ Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
+ }
+ }
+
+ JoinChannelAudioView(
+ rtcEngine = rtcEngine,
+ videoIdList = videoIdList,
+ statsMap = statsMap,
+ audioRoute = audioRoute,
+ channelName = channelName,
+ isJoined = isJoined,
+ onJoinClick = {
+ keyboard?.hide()
+ channelName = it
+ permissionLauncher.launch(
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
+ arrayOf(
+ Manifest.permission.RECORD_AUDIO,
+ )
+ } else {
+ arrayOf(
+ Manifest.permission.RECORD_AUDIO,
+ Manifest.permission.READ_PHONE_STATE,
+ Manifest.permission.BLUETOOTH_CONNECT,
+ )
+ }
+ )
+ },
+ onLeaveClick = {
+ rtcEngine.leaveChannel()
+ }
+ )
+}
+
+@Composable
+private fun JoinChannelAudioView(
+ videoIdList: List,
+ statsMap: Map = mapOf(),
+ rtcEngine: RtcEngine? = null,
+ channelName: String = "",
+ audioRoute: Int = Constants.AUDIO_ROUTE_SPEAKERPHONE,
+ isJoined: Boolean = false,
+ onJoinClick: (String) -> Unit = {},
+ onLeaveClick: () -> Unit = {}
+) {
+ Column(
+ Modifier
+ .fillMaxHeight()
+ .fillMaxWidth()
+ ) {
+ AudioGrid(
+ modifier = Modifier.height(380.dp),
+ videoIdList = videoIdList,
+ statsMap = statsMap
+ )
+ val lazyListState = rememberLazyListState(Int.MAX_VALUE)
+
+ LazyColumn(
+ modifier = Modifier.weight(1.0f),
+ verticalArrangement = Arrangement.Bottom,
+ state = lazyListState
+ ) {
+ item {
+ DropdownMenuRaw(
+ title = "Audio Route",
+ options = listOf(
+ "Speaker" to Constants.AUDIO_ROUTE_SPEAKERPHONE,
+ "Headset" to Constants.AUDIO_ROUTE_HEADSET,
+ "Earphone" to Constants.AUDIO_ROUTE_EARPIECE,
+ "Bluetooth" to Constants.AUDIO_ROUTE_BLUETOOTH_DEVICE_HFP
+ ),
+ selectedValue = audioRoute
+ ) { _, option ->
+ val ret = rtcEngine?.setRouteInCommunicationMode(option.second)
+ if (ret != Constants.ERR_OK) {
+ // no in communication mode
+ val isSpeakerPhone = option.second == Constants.AUDIO_ROUTE_SPEAKERPHONE
+ rtcEngine?.setEnableSpeakerphone(isSpeakerPhone)
+ }
+ }
+ }
+ item {
+ Column {
+ var inEarOpen by remember { mutableStateOf(false) }
+ SwitchRaw(title = "InEar Monitor", checked = inEarOpen) {
+ inEarOpen = it
+ rtcEngine?.enableInEarMonitoring(it)
+ }
+ if (inEarOpen) {
+ SliderRaw(title = "InEar Monitor Vol") {
+ rtcEngine?.setInEarMonitoringVolume((it * 100).toInt())
+ }
+ }
+ }
+ }
+ item {
+ SliderRaw(title = "Playout Vol"){
+ rtcEngine?.adjustPlaybackSignalVolume((it * 100).toInt())
+ }
+ }
+ item {
+ SliderRaw(title = "Recording Vol"){
+ rtcEngine?.adjustRecordingSignalVolume((it * 100).toInt())
+ }
+ }
+ item {
+ DropdownMenuRaw(
+ title = "Scenario",
+ options = listOf(
+ "Default" to Constants.AUDIO_SCENARIO_DEFAULT,
+ "Game Streaming" to Constants.AUDIO_SCENARIO_GAME_STREAMING,
+ "Chatroom" to Constants.AUDIO_SCENARIO_CHATROOM,
+ "Chorus" to Constants.AUDIO_SCENARIO_CHORUS,
+ "Meeting" to Constants.AUDIO_SCENARIO_MEETING,
+ ),
+ selected = 0
+ ) { _, option ->
+ rtcEngine?.setAudioScenario(option.second)
+ }
+ }
+ item {
+ DropdownMenuRaw(
+ title = "Audio Profile",
+ options = listOf(
+ "Default" to Constants.AUDIO_PROFILE_DEFAULT,
+ "Speech Standard" to Constants.AUDIO_PROFILE_SPEECH_STANDARD,
+ "Music Standard" to Constants.AUDIO_PROFILE_MUSIC_STANDARD,
+ "Music Standard Stereo" to Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO,
+ "Music High Quality" to Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY,
+ "Music High Quality Stereo" to Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO,
+ ),
+ selected = 0
+ ) { _, option ->
+ rtcEngine?.setAudioScenario(option.second)
+ }
+ }
+ item {
+ DropdownMenuRaw(
+ title = "Channel Profile",
+ options = listOf(
+ "Communication" to Constants.CHANNEL_PROFILE_COMMUNICATION,
+ "Live Broadcasting" to Constants.CHANNEL_PROFILE_LIVE_BROADCASTING,
+ "Game" to Constants.CHANNEL_PROFILE_GAME,
+ "Cloud Gaming" to Constants.CHANNEL_PROFILE_CLOUD_GAMING,
+ "Communication 1v1" to Constants.CHANNEL_PROFILE_COMMUNICATION_1v1,
+ "Communication 1v1" to Constants.CHANNEL_PROFILE_COMMUNICATION_1v1,
+ ),
+ ) { _, option ->
+ rtcEngine?.setChannelProfile(option.second)
+ }
+ }
+ }
+
+ ChannelNameInput(
+ channelName = channelName,
+ isJoined = isJoined,
+ onJoinClick = onJoinClick,
+ onLeaveClick = onLeaveClick
+ )
+ }
+}
+
+@Preview
+@Composable
+private fun JoinChannelAudioViewPreview() {
+ JoinChannelAudioView(
+ listOf(0, 1, 2, 3),
+ mapOf(
+ 0 to AudioStatsInfo(
+ localAudioStats = IRtcEngineEventHandler.LocalAudioStats().apply {
+ numChannels = 2
+ sentSampleRate = 48000
+ sentBitrate = 128
+ },
+ ),
+ 1 to AudioStatsInfo(),
+ 2 to AudioStatsInfo(),
+ 3 to AudioStatsInfo()
+ )
+ )
+}
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelVideo.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelVideo.kt
index 85f7c9fbe..8aeeac6c9 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelVideo.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelVideo.kt
@@ -195,7 +195,7 @@ fun JoinChannelVideo() {
@Preview
@Composable
-fun JoinChannelVideoPreview() {
+private fun JoinChannelVideoPreview() {
JoinChannelVideoView(
channelName = "Channel Name",
isJoined = false,
@@ -207,7 +207,7 @@ fun JoinChannelVideoPreview() {
}
@Composable
-fun JoinChannelVideoView(
+private fun JoinChannelVideoView(
channelName: String,
isJoined: Boolean,
onJoinClick: (String) -> Unit,
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelVideoToken.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelVideoToken.kt
index ef86d0338..0322d2823 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelVideoToken.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinChannelVideoToken.kt
@@ -198,7 +198,7 @@ fun JoinChannelVideoToken() {
@Preview
@Composable
-fun JoinChannelVideoTokenPreview() {
+private fun JoinChannelVideoTokenPreview() {
JoinChannelVideoTokenView(
channelName = "Channel Name",
token = "",
@@ -211,7 +211,7 @@ fun JoinChannelVideoTokenPreview() {
}
@Composable
-fun JoinChannelVideoTokenView(
+private fun JoinChannelVideoTokenView(
channelName: String,
token: String,
isJoined: Boolean,
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinMultiChannel.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinMultiChannel.kt
index 0ea56263d..1f3a8d7a2 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinMultiChannel.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/JoinMultiChannel.kt
@@ -24,7 +24,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.SwitchRaw
@@ -244,7 +246,7 @@ fun JoinMultiChannel() {
}
@Composable
-fun JoinMultiChannelView(
+private fun JoinMultiChannelView(
rtcEngine: RtcEngineEx?,
channelName: String,
videoList: List,
@@ -299,7 +301,7 @@ fun JoinMultiChannelView(
},
enabled = exVideoList.isNotEmpty()
) {
- Text(text = "Ex频道截图")
+ Text(text = stringResource(id = R.string.snapshot_ex))
}
Button(
onClick = {
@@ -311,7 +313,9 @@ fun JoinMultiChannelView(
},
enabled = isJoin
) {
- Text(text = if (isExJoin) "离开Ex频道" else "加入Ex频道")
+ Text(text = if (isExJoin) stringResource(id = R.string.leave_ex) else stringResource(
+ id = R.string.join_ex
+ ))
}
}
}
@@ -326,9 +330,9 @@ fun JoinMultiChannelView(
if (exWillLeave) {
var stopMic by rememberSaveable { mutableStateOf(false) }
AlertDialog(
- title = { Text("离开选项") },
+ title = { Text(stringResource(id = R.string.leave_option)) },
text = {
- SwitchRaw(title = "是否停止录音", checked = stopMic) {
+ SwitchRaw(title = stringResource(id = R.string.stop_recording_or_not), checked = stopMic) {
stopMic = it
}
},
@@ -338,12 +342,12 @@ fun JoinMultiChannelView(
exWillLeave = false
onExLeaveClick(stopMic)
}) {
- Text("确定")
+ Text(stringResource(id = R.string.confirm))
}
},
dismissButton = {
TextButton(onClick = { exWillLeave = false }) {
- Text("取消")
+ Text(stringResource(id = R.string.cancel))
}
}
)
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LiveStreaming.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LiveStreaming.kt
index c383b5836..d827cb97e 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LiveStreaming.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LiveStreaming.kt
@@ -30,10 +30,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.DropdownMenuRaw
@@ -236,7 +238,7 @@ fun LiveStreaming() {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
-fun LiveStreamingView(
+private fun LiveStreamingView(
rtcEngine: RtcEngine? = null,
channelName: String,
isJoined: Boolean,
@@ -360,7 +362,7 @@ fun LiveStreamingView(
@Preview
@Composable
-fun LiveStreamingViewPreview() {
+private fun LiveStreamingViewPreview() {
Box {
LiveStreamingView(
channelName = "Channel Name",
@@ -379,7 +381,7 @@ fun LiveStreamingViewPreview() {
@Composable
-fun LiveStreamingSettingView(
+private fun LiveStreamingSettingView(
modifier: Modifier = Modifier,
rtcEngine: RtcEngine? = null,
role: Int = Constants.CLIENT_ROLE_AUDIENCE,
@@ -395,7 +397,7 @@ fun LiveStreamingSettingView(
) {
if (role == Constants.CLIENT_ROLE_AUDIENCE) {
SwitchRaw(
- title = "开启极速直播",
+ title = stringResource(id = R.string.open_low_latency_live),
checked = values["living"] as? Boolean ?: false
) { enable ->
onValueChanged("living", enable)
@@ -409,7 +411,7 @@ fun LiveStreamingSettingView(
if (role == Constants.CLIENT_ROLE_BROADCASTER) {
Divider(modifier = Modifier.padding(horizontal = 16.dp))
SwitchRaw(
- title = "水印",
+ title = stringResource(id = R.string.watermark),
checked = values["watermark"] as? Boolean ?: false
) { enable ->
onValueChanged("watermark", enable)
@@ -430,7 +432,7 @@ fun LiveStreamingSettingView(
Divider(modifier = Modifier.padding(horizontal = 16.dp))
SwitchRaw(
- title = "小流",
+ title = stringResource(id = R.string.low_stream),
checked = values["stream"] as? Boolean ?: false
) { enable ->
onValueChanged("stream", enable)
@@ -446,11 +448,11 @@ fun LiveStreamingSettingView(
Divider(modifier = Modifier.padding(horizontal = 16.dp))
DropdownMenuRaw(
- title = "编码类型",
+ title = stringResource(id = R.string.encoder_type),
options = listOf(
- "自动选择" to VideoEncoderConfiguration.ENCODING_PREFERENCE.PREFER_AUTO,
- "硬编" to VideoEncoderConfiguration.ENCODING_PREFERENCE.PREFER_HARDWARE,
- "软编" to VideoEncoderConfiguration.ENCODING_PREFERENCE.PREFER_SOFTWARE,
+ stringResource(id = R.string.encoder_auto) to VideoEncoderConfiguration.ENCODING_PREFERENCE.PREFER_AUTO,
+ stringResource(id = R.string.encoder_hardware) to VideoEncoderConfiguration.ENCODING_PREFERENCE.PREFER_HARDWARE,
+ stringResource(id = R.string.encoder_software) to VideoEncoderConfiguration.ENCODING_PREFERENCE.PREFER_SOFTWARE,
),
selected = values["encoder"] as? Int ?: 0
) { index, option ->
@@ -465,7 +467,7 @@ fun LiveStreamingSettingView(
Divider(modifier = Modifier.padding(horizontal = 16.dp))
SwitchRaw(
- title = "B帧",
+ title = stringResource(id = R.string.b_frame),
checked = values["BFrame"] as? Boolean ?: false
) { enable ->
onValueChanged("BFrame", enable)
@@ -484,7 +486,7 @@ fun LiveStreamingSettingView(
Divider(modifier = Modifier.padding(horizontal = 16.dp))
SwitchRaw(
- title = "垫片",
+ title = stringResource(id = R.string.video_image),
checked = values["padding"] as? Boolean ?: false
) { enable ->
onValueChanged("padding", enable)
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LocalVideoTranscoding.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LocalVideoTranscoding.kt
index 041a0fbec..8996bcd38 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LocalVideoTranscoding.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LocalVideoTranscoding.kt
@@ -21,8 +21,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.SwitchRaw
@@ -279,7 +281,7 @@ fun LocalVideoTranscoding() {
}
@Composable
-fun LocalVideoTranscodingView(
+private fun LocalVideoTranscodingView(
channelName: String,
isJoined: Boolean,
localUid: Int = 0,
@@ -304,7 +306,7 @@ fun LocalVideoTranscodingView(
remoteRender = { view, id, _ -> remoteRender(view, id) }
)
Spacer(modifier = Modifier.weight(1.0f))
- SwitchRaw(title = "透明背景"){
+ SwitchRaw(title = stringResource(id = R.string.alpha_background)){
onAlphaBackground(it)
}
ChannelNameInput(
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaMetadata.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaMetadata.kt
index 18f3f4eeb..5c431f8bc 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaMetadata.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaMetadata.kt
@@ -21,7 +21,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.InputRaw
@@ -35,6 +37,7 @@ import io.agora.rtc2.IMetadataObserver
import io.agora.rtc2.IRtcEngineEventHandler
import io.agora.rtc2.RtcEngine
import io.agora.rtc2.RtcEngineConfig
+import io.agora.rtc2.video.AgoraMetadata
import io.agora.rtc2.video.VideoCanvas
import io.agora.rtc2.video.VideoEncoderConfiguration
@@ -168,8 +171,8 @@ fun MediaMetadata() {
return data
}
- override fun onMetadataReceived(buffer: ByteArray?, uid: Int, timeStampMs: Long) {
- receivedMetadata = buffer?.toString(Charsets.UTF_8) ?: ""
+ override fun onMetadataReceived(metadata: AgoraMetadata) {
+ receivedMetadata = metadata.data?.toString(Charsets.UTF_8) ?: ""
}
}, IMetadataObserver.VIDEO_METADATA)
@@ -256,7 +259,7 @@ fun MediaMetadata() {
@Composable
-fun MediaMetadataView(
+private fun MediaMetadataView(
rtcEngine: RtcEngine? = null,
channelName: String,
isJoined: Boolean,
@@ -306,8 +309,8 @@ fun MediaMetadataView(
InputRaw(
text = "",
- label = "视频元数据",
- btnText = "发送",
+ label = stringResource(id = R.string.metadata_video),
+ btnText = stringResource(id = R.string.send),
enable = isJoined
) {
onVideoMetadataSend(it)
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaPlayer.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaPlayer.kt
index 9017098b5..106c0b5bf 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaPlayer.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaPlayer.kt
@@ -23,9 +23,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.InputRaw
@@ -330,7 +332,7 @@ fun MediaPlayer() {
}
@Composable
-fun MediaPlayerView(
+private fun MediaPlayerView(
channelName: String,
isJoined: Boolean,
localUid: Int = 0,
@@ -375,7 +377,7 @@ fun MediaPlayerView(
enabled = isJoined && playerReady,
onClick = onPlayClick
) {
- Text(text = "播放")
+ Text(text = stringResource(id = R.string.play))
}
Button(
modifier = Modifier
@@ -384,7 +386,7 @@ fun MediaPlayerView(
enabled = isJoined && playerReady,
onClick = onStopClick
) {
- Text(text = "停止")
+ Text(text = stringResource(id = R.string.stop))
}
Button(
modifier = Modifier
@@ -393,7 +395,7 @@ fun MediaPlayerView(
enabled = isJoined && playerReady,
onClick = onPauseClick
) {
- Text(text = "暂停")
+ Text(text = stringResource(id = R.string.pause))
}
Button(
modifier = Modifier
@@ -402,7 +404,7 @@ fun MediaPlayerView(
enabled = isJoined && playerReady,
onClick = onPushClick
) {
- Text(text = "推送")
+ Text(text = stringResource(id = R.string.publish))
}
}
@@ -434,7 +436,7 @@ fun MediaPlayerView(
@Preview
@Composable
-fun MediaPlayerViewPreview() {
+private fun MediaPlayerViewPreview() {
MediaPlayerView(channelName = "", isJoined = false, onJoinClick = {}) {
}
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaRecorder.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaRecorder.kt
index ef809a1ec..c8514fe42 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaRecorder.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/MediaRecorder.kt
@@ -26,9 +26,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.VideoGrid
@@ -264,7 +266,7 @@ fun MediaRecorder() {
TextButton(onClick = {
recoderResult = ""
}) {
- Text("确定")
+ Text(stringResource(id = R.string.confirm))
}
},
title = { Text(text = "Recorder Result") },
@@ -274,7 +276,7 @@ fun MediaRecorder() {
}
@Composable
-fun MediaRecorderView(
+private fun MediaRecorderView(
channelName: String,
isJoined: Boolean,
onJoinClick: (String) -> Unit,
@@ -301,7 +303,9 @@ fun MediaRecorderView(
onRecorderClick(id, isRecording)
})
{
- Text(text = if (!isRecording) "Start Recording" else "Stop Recording")
+ Text(text = if (!isRecording) stringResource(id = R.string.start_recording) else stringResource(
+ id = R.string.stop_recording
+ ))
}
}
)
@@ -312,7 +316,7 @@ fun MediaRecorderView(
onClick = onCameraSwitchClick,
enabled = isJoined
) {
- Text(text = "Switch Camera")
+ Text(text = stringResource(id = R.string.switch_camera))
}
ChannelNameInput(
channelName = channelName,
@@ -325,7 +329,7 @@ fun MediaRecorderView(
@Preview
@Composable
-fun MediaRecorderViewPreview() {
+private fun MediaRecorderViewPreview() {
MediaRecorderView(
channelName = "",
isJoined = false,
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/OriginAudioData.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/OriginAudioData.kt
index cc3696c30..dce16b412 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/OriginAudioData.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/OriginAudioData.kt
@@ -25,8 +25,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.AudioGrid
import io.agora.api.example.compose.ui.common.AudioStatsInfo
@@ -171,7 +173,7 @@ fun OriginAudioData() {
}
@Composable
-fun OriginAudioDataView(
+private fun OriginAudioDataView(
videoIdList: List,
statsMap: Map = mapOf(),
channelName: String = "",
@@ -193,7 +195,7 @@ fun OriginAudioDataView(
Spacer(modifier = Modifier.weight(1.0f))
- SwitchRaw(title = "音频回写", enable = isJoined, onCheckedChange = onRewriteOpen)
+ SwitchRaw(title = stringResource(id = R.string.audio_rewrite), enable = isJoined, onCheckedChange = onRewriteOpen)
ChannelNameInput(
channelName = channelName,
@@ -204,7 +206,7 @@ fun OriginAudioDataView(
}
}
-class OriginAudioDataRewriter(
+private class OriginAudioDataRewriter(
private val context: Context,
private val rtcEngine: RtcEngine
) : IAudioFrameObserver {
@@ -351,7 +353,8 @@ class OriginAudioDataRewriter(
samplesPerSec: Int,
buffer: ByteBuffer?,
renderTimeMs: Long,
- avsync_type: Int
+ avsync_type: Int,
+ rtpTimestamp: Int
) = false
override fun getObservedAudioFramePosition() =
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/OriginVideoData.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/OriginVideoData.kt
index a75c784bc..14fab7bac 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/OriginVideoData.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/OriginVideoData.kt
@@ -233,7 +233,7 @@ fun OriginVideoData() {
}
@Composable
-fun OriginVideoDataView(
+private fun OriginVideoDataView(
channelName: String,
isJoined: Boolean,
rtcEngine: RtcEngine? = null,
@@ -298,7 +298,7 @@ fun OriginVideoDataView(
}
}
-class OriginVideoDataScreenshotTaker(
+private class OriginVideoDataScreenshotTaker(
private val context: Context,
private val rtcEngine: RtcEngine
) : IVideoFrameObserver {
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PictureInPicture.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PictureInPicture.kt
new file mode 100644
index 000000000..06d045b00
--- /dev/null
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PictureInPicture.kt
@@ -0,0 +1,340 @@
+package io.agora.api.example.compose.samples
+
+import android.app.AppOpsManager
+import android.app.PictureInPictureParams
+import android.content.Intent
+import android.graphics.RectF
+import android.os.Build
+import android.os.Bundle
+import android.os.Process
+import android.util.Rational
+import android.widget.Toast
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.rememberLauncherForActivityResult
+import androidx.activity.compose.setContent
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.consumeWindowInsets
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.safeDrawing
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.toAndroidRectF
+import androidx.compose.ui.layout.boundsInWindow
+import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalLifecycleOwner
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.lifecycle.DefaultLifecycleObserver
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleOwner
+import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
+import io.agora.api.example.compose.data.SettingPreferences
+import io.agora.api.example.compose.ui.common.APIExampleScaffold
+import io.agora.api.example.compose.ui.common.ChannelNameInput
+import io.agora.api.example.compose.ui.common.TwoVideoView
+import io.agora.api.example.compose.ui.common.TwoVideoViewType
+import io.agora.api.example.compose.ui.common.VideoStatsInfo
+import io.agora.api.example.compose.ui.theme.APIExampleComposeTheme
+import io.agora.api.example.compose.utils.TokenUtils
+import io.agora.rtc2.ChannelMediaOptions
+import io.agora.rtc2.Constants
+import io.agora.rtc2.IRtcEngineEventHandler
+import io.agora.rtc2.RtcEngine
+import io.agora.rtc2.RtcEngineConfig
+import io.agora.rtc2.video.VideoCanvas
+import io.agora.rtc2.video.VideoEncoderConfiguration
+
+
+@Composable
+fun PictureInPictureEntrance(back: () -> Unit) {
+ val context = LocalContext.current
+ val intent = Intent(context, PictureInPictureActivity::class.java)
+ context.startActivity(intent)
+ back()
+}
+
+@Composable
+private fun PictureInPicture() {
+ val context = LocalContext.current as ComponentActivity
+ var isPipOn by rememberSaveable { mutableStateOf(false) }
+ val lifecycleOwner = LocalLifecycleOwner.current
+ val keyboard = LocalSoftwareKeyboardController.current
+ var isJoined by rememberSaveable { mutableStateOf(false) }
+ var channelName by rememberSaveable { mutableStateOf("") }
+ var localUid by rememberSaveable { mutableIntStateOf(0) }
+ var remoteUid by rememberSaveable { mutableIntStateOf(0) }
+ var localStats by remember { mutableStateOf(VideoStatsInfo()) }
+ var remoteStats by remember { mutableStateOf(VideoStatsInfo()) }
+ val videoViewBound = remember { RectF() }
+
+ val rtcEngine = remember {
+ RtcEngine.create(RtcEngineConfig().apply {
+ mAreaCode = SettingPreferences.getArea()
+ mContext = context
+ mAppId = BuildConfig.AGORA_APP_ID
+ mEventHandler = object : IRtcEngineEventHandler() {
+ override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
+ super.onJoinChannelSuccess(channel, uid, elapsed)
+ isJoined = true
+ localUid = uid
+ }
+
+ override fun onLeaveChannel(stats: RtcStats?) {
+ super.onLeaveChannel(stats)
+ isJoined = false
+ localUid = 0
+ localStats = VideoStatsInfo()
+ remoteUid = 0
+ remoteStats = VideoStatsInfo()
+ }
+
+ override fun onUserJoined(uid: Int, elapsed: Int) {
+ super.onUserJoined(uid, elapsed)
+ remoteUid = uid
+ remoteStats = VideoStatsInfo()
+ }
+
+ override fun onUserOffline(uid: Int, reason: Int) {
+ super.onUserOffline(uid, reason)
+ if (remoteUid == uid) {
+ remoteUid = 0
+ remoteStats = VideoStatsInfo()
+ }
+ }
+
+ override fun onRtcStats(stats: RtcStats?) {
+ super.onRtcStats(stats)
+ localStats.copy(rtcStats = stats).let {
+ localStats = it
+ }
+ }
+
+ override fun onLocalVideoStats(
+ source: Constants.VideoSourceType?,
+ stats: LocalVideoStats?
+ ) {
+ super.onLocalVideoStats(source, stats)
+ localStats.copy(localVideoStats = stats).let {
+ localStats = it
+ }
+ }
+
+ override fun onLocalAudioStats(stats: LocalAudioStats?) {
+ super.onLocalAudioStats(stats)
+ localStats.copy(localAudioStats = stats).let {
+ localStats = it
+ }
+ }
+
+ override fun onRemoteVideoStats(stats: RemoteVideoStats?) {
+ super.onRemoteVideoStats(stats)
+ val uid = stats?.uid ?: return
+ if (remoteUid == uid) {
+ remoteStats.copy(remoteVideoStats = stats).let {
+ remoteStats = it
+ }
+ }
+ }
+
+ override fun onRemoteAudioStats(stats: RemoteAudioStats?) {
+ super.onRemoteAudioStats(stats)
+ val uid = stats?.uid ?: return
+ if (remoteUid == uid) {
+ remoteStats.copy(remoteAudioStats = stats).let {
+ remoteStats = it
+ }
+ }
+ }
+ }
+ }).apply {
+ setVideoEncoderConfiguration(
+ VideoEncoderConfiguration(
+ SettingPreferences.getVideoDimensions(),
+ SettingPreferences.getVideoFrameRate(),
+ VideoEncoderConfiguration.STANDARD_BITRATE,
+ SettingPreferences.getOrientationMode()
+ )
+ )
+ enableVideo()
+ }
+ }
+ LaunchedEffect(lifecycleOwner) {
+ context.addOnPictureInPictureModeChangedListener { info ->
+ isPipOn = info.isInPictureInPictureMode
+ if (lifecycleOwner.lifecycle.currentState < Lifecycle.State.STARTED) {
+ context.finish()
+ }
+ }
+ lifecycleOwner.lifecycle.addObserver(object: DefaultLifecycleObserver {
+ override fun onDestroy(owner: LifecycleOwner) {
+ rtcEngine.stopPreview()
+ rtcEngine.leaveChannel()
+ RtcEngine.destroy()
+ }
+ })
+ }
+ val permissionLauncher =
+ rememberLauncherForActivityResult(contract = ActivityResultContracts.RequestMultiplePermissions()) { grantedMap ->
+ val allGranted = grantedMap.values.all { it }
+ if (allGranted) {
+ // Permission is granted
+ Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
+ val mediaOptions = ChannelMediaOptions()
+ mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
+ mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
+ mediaOptions.autoSubscribeAudio = true
+ mediaOptions.autoSubscribeAudio = true
+ mediaOptions.publishCameraTrack = true
+ mediaOptions.publishMicrophoneTrack = true
+ TokenUtils.gen(channelName, 0) {
+ rtcEngine.joinChannel(it, channelName, 0, mediaOptions)
+ }
+ } else {
+ // Permission is denied
+ Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
+ }
+ }
+
+ val videoView: @Composable () -> Unit = {
+ TwoVideoView(
+ modifier = Modifier
+ .height(350.dp)
+ .onGloballyPositioned {
+ videoViewBound.set(
+ it
+ .boundsInWindow()
+ .toAndroidRectF()
+ )
+ },
+ type = TwoVideoViewType.Row,
+ localUid = localUid,
+ remoteUid = remoteUid,
+ localStats = localStats,
+ remoteStats = remoteStats,
+ localRender = { view, id, _ ->
+ rtcEngine.setupLocalVideo(
+ VideoCanvas(
+ view,
+ Constants.RENDER_MODE_HIDDEN,
+ id
+ )
+ )
+ rtcEngine.startPreview()
+ },
+ remoteRender = { view, id, _ ->
+ rtcEngine.setupRemoteVideo(
+ VideoCanvas(
+ view,
+ Constants.RENDER_MODE_HIDDEN,
+ id
+ )
+ )
+ })
+ }
+
+ if (isPipOn) {
+ videoView()
+ } else {
+ APIExampleComposeTheme {
+ APIExampleScaffold(
+ topBarTitle = stringResource(id = R.string.example_pictureinpicture),
+ showSettingIcon = false,
+ showBackNavigationIcon = true,
+ onBackClick = { context.finish() },
+ ) { paddingValues ->
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .consumeWindowInsets(WindowInsets.safeDrawing)
+ .padding(paddingValues)
+ ) {
+ videoView()
+ Spacer(modifier = Modifier.weight(1f))
+
+ Button(
+ modifier = Modifier.padding(16.dp, 8.dp),
+ enabled = isJoined,
+ onClick = {
+ if (Build.VERSION.SDK_INT >= 26) {
+ val appOpsManager: AppOpsManager =
+ context.getSystemService(AppOpsManager::class.java)
+ if (appOpsManager.checkOpNoThrow(
+ AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
+ Process.myUid(),
+ context.packageName
+ ) == AppOpsManager.MODE_ALLOWED
+ ) {
+ context.enterPictureInPictureMode(
+ PictureInPictureParams.Builder()
+ .setAspectRatio(
+ Rational(
+ videoViewBound.width().toInt(),
+ videoViewBound.height().toInt()
+ )
+ )
+ .build()
+ )
+ val homeIntent = Intent(Intent.ACTION_MAIN)
+ homeIntent.addCategory(Intent.CATEGORY_HOME)
+ context.startActivity(homeIntent)
+ isPipOn = true
+ }
+ }
+ }
+ ) {
+ Text(text = "Enter Picture-in-Picture Mode")
+ }
+
+ ChannelNameInput(
+ channelName = channelName,
+ isJoined = isJoined,
+ onJoinClick = {
+ channelName = it
+ keyboard?.hide()
+ permissionLauncher.launch(
+ arrayOf(
+ android.Manifest.permission.RECORD_AUDIO,
+ android.Manifest.permission.CAMERA
+ )
+ )
+ },
+ onLeaveClick = {
+ rtcEngine.stopPreview()
+ rtcEngine.leaveChannel()
+ }
+ )
+ }
+ }
+ }
+ }
+
+}
+
+
+class PictureInPictureActivity : ComponentActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ PictureInPicture()
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PlayAudioFiles.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PlayAudioFiles.kt
index f1e249fcf..a567c743e 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PlayAudioFiles.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PlayAudioFiles.kt
@@ -26,10 +26,12 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.AudioGrid
import io.agora.api.example.compose.ui.common.AudioStatsInfo
@@ -160,7 +162,7 @@ fun PlayAudioFiles() {
@Composable
-fun PlayAudioFilesView(
+private fun PlayAudioFilesView(
videoIdList: List,
statsMap: Map = mapOf(),
rtcEngine: RtcEngine? = null,
@@ -192,7 +194,7 @@ fun PlayAudioFilesView(
.padding(16.dp, 0.dp)
) {
Text(
- text = "开始",
+ text = stringResource(id = R.string.start),
style = MaterialTheme.typography.bodySmall,
color = Color.Blue,
textAlign = TextAlign.Center,
@@ -209,7 +211,7 @@ fun PlayAudioFilesView(
}
)
Text(
- text = "恢复播放",
+ text = stringResource(id = R.string.resume),
style = MaterialTheme.typography.bodySmall,
color = Color.Blue,
textAlign = TextAlign.Center,
@@ -221,7 +223,7 @@ fun PlayAudioFilesView(
}
)
Text(
- text = "暂停",
+ text = stringResource(id = R.string.pause),
style = MaterialTheme.typography.bodySmall,
color = Color.Blue,
textAlign = TextAlign.Center,
@@ -233,7 +235,7 @@ fun PlayAudioFilesView(
}
)
Text(
- text = "停止",
+ text = stringResource(id = R.string.stop),
style = MaterialTheme.typography.bodySmall,
color = Color.Blue,
textAlign = TextAlign.Center,
@@ -246,13 +248,13 @@ fun PlayAudioFilesView(
)
}
- SliderRaw(title = "混音音量", value = 1.0f) {
+ SliderRaw(title = stringResource(id = R.string.audio_mixing_volume), value = 1.0f) {
rtcEngine?.adjustAudioMixingVolume((100 * it).toInt())
}
- SliderRaw(title = "混音播放音量", value = 1.0f) {
+ SliderRaw(title = stringResource(id = R.string.audio_mixing_playout_volume), value = 1.0f) {
rtcEngine?.adjustAudioMixingPlayoutVolume((100 * it).toInt())
}
- SliderRaw(title = "混音发布音量", value = 1.0f) {
+ SliderRaw(title = stringResource(id = R.string.audio_mixing_publish_volume), value = 1.0f) {
rtcEngine?.adjustAudioMixingPublishVolume((100 * it).toInt())
}
}
@@ -270,7 +272,7 @@ fun PlayAudioFilesView(
.fillMaxWidth()
.padding(16.dp, 0.dp)
) {
- Text(text = "开始",
+ Text(text = stringResource(id = R.string.start),
style = MaterialTheme.typography.bodySmall,
color = Color.Blue,
textAlign = TextAlign.Center,
@@ -288,7 +290,7 @@ fun PlayAudioFilesView(
true // Sets whether to publish the audio effect.
);
})
- Text(text = "恢复播放",
+ Text(text = stringResource(id = R.string.resume),
style = MaterialTheme.typography.bodySmall,
color = Color.Blue,
textAlign = TextAlign.Center,
@@ -298,7 +300,7 @@ fun PlayAudioFilesView(
.clickable {
rtcEngine?.resumeEffect(EFFECT_SOUND_ID)
})
- Text(text = "暂停",
+ Text(text = stringResource(id = R.string.pause),
style = MaterialTheme.typography.bodySmall,
color = Color.Blue,
textAlign = TextAlign.Center,
@@ -308,7 +310,7 @@ fun PlayAudioFilesView(
.clickable {
rtcEngine?.pauseEffect(EFFECT_SOUND_ID)
})
- Text(text = "停止",
+ Text(text = stringResource(id = R.string.stop),
style = MaterialTheme.typography.bodySmall,
color = Color.Blue,
textAlign = TextAlign.Center,
@@ -320,7 +322,7 @@ fun PlayAudioFilesView(
})
}
- SliderRaw(title = "音效音量", value = 1.0f) {
+ SliderRaw(title = stringResource(id = R.string.effects_volume), value = 1.0f) {
rtcEngine?.setEffectsVolume((100 * it).toDouble())
}
}
@@ -365,6 +367,6 @@ fun PlayAudioFilesView(
@Preview
@Composable
-fun PlayAudioFilesViewPreview() {
+private fun PlayAudioFilesViewPreview() {
PlayAudioFilesView(videoIdList = listOf(1, 2))
}
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PreCallTest.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PreCallTest.kt
index 2f47bd60a..f91338fe2 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PreCallTest.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/PreCallTest.kt
@@ -31,9 +31,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.VideoCell
import io.agora.rtc2.Constants
@@ -184,7 +186,7 @@ fun PreCallTest() {
}
@Composable
-fun PreCallTestView(
+private fun PreCallTestView(
isAudioEchoPretesting: Boolean = false,
isVideoEchoPretesting: Boolean = false,
isNetworkTesting: Boolean = false,
@@ -241,7 +243,7 @@ fun PreCallTestView(
}
Text(
modifier = Modifier.padding(0.dp, 8.dp),
- text = "Tip:开始测试后请对着麦克风讲话,讲话声音在${ECHO_TEST_INTERVAL_IN_SECONDS}秒后播放则测试正常。",
+ text = stringResource(id = R.string.audio_echo_pretest_tip, ECHO_TEST_INTERVAL_IN_SECONDS),
style = MaterialTheme.typography.bodySmall
)
@@ -274,7 +276,7 @@ fun PreCallTestView(
@Preview
@Composable
-fun PreCallTestViewPreview() {
+private fun PreCallTestViewPreview() {
PreCallTestView(
isVideoEchoPretesting = true
)
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/RTMPStreaming.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/RTMPStreaming.kt
index a8ea49125..dd9f718cd 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/RTMPStreaming.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/RTMPStreaming.kt
@@ -1,5 +1,7 @@
package io.agora.api.example.compose.samples
+import android.os.Handler
+import android.util.Log
import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
@@ -16,8 +18,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.InputRaw
@@ -31,7 +35,6 @@ import io.agora.rtc2.Constants
import io.agora.rtc2.IRtcEngineEventHandler
import io.agora.rtc2.RtcEngine
import io.agora.rtc2.RtcEngineConfig
-import io.agora.rtc2.SimulcastStreamConfig
import io.agora.rtc2.live.LiveTranscoding
import io.agora.rtc2.video.VideoCanvas
import io.agora.rtc2.video.VideoEncoderConfiguration
@@ -41,6 +44,7 @@ fun RTMPStreaming() {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
val keyboard = LocalSoftwareKeyboardController.current
+ val mainHandler = remember { Handler(context.mainLooper) }
var isJoined by rememberSaveable { mutableStateOf(false) }
var localLarge by rememberSaveable { mutableStateOf(true) }
var channelName by rememberSaveable { mutableStateOf("") }
@@ -147,6 +151,25 @@ fun RTMPStreaming() {
super.onClientRoleChanged(oldRole, newRole, newRoleOptions)
clientRole = newRole
}
+
+ override fun onRtmpStreamingStateChanged(url: String?, state: Int, reason: Int) {
+ super.onRtmpStreamingStateChanged(url, state, reason)
+ Log.d("RTMPStreaming", "onRtmpStreamingStateChanged: $url, $state, $reason")
+ if (state == Constants.RTMP_STREAM_PUBLISH_STATE_IDLE) {
+ pushing = false
+ } else if (state == Constants.RTMP_STREAM_PUBLISH_STATE_RUNNING) {
+ pushing = true
+ }
+ }
+
+ override fun onRtmpStreamingEvent(url: String?, event: Int) {
+ super.onRtmpStreamingEvent(url, event)
+ if (event == Constants.RTMP_STREAMING_EVENT_URL_ALREADY_IN_USE) {
+ mainHandler.post {
+ Toast.makeText(context, "URL already in use: $url", Toast.LENGTH_LONG).show()
+ }
+ }
+ }
}
}).apply {
engine = this
@@ -159,14 +182,6 @@ fun RTMPStreaming() {
)
)
enableVideo()
- setDualStreamMode(
- Constants.SimulcastStreamMode.ENABLE_SIMULCAST_STREAM,
- SimulcastStreamConfig(
- VideoEncoderConfiguration.VideoDimensions(
- 100, 100
- ), 100, 15
- )
- )
}
}
DisposableEffect(lifecycleOwner) {
@@ -222,7 +237,6 @@ fun RTMPStreaming() {
pushing = !pushing
if (pushing) {
- rtcEngine?.stopRtmpStream(url)
if (transcoding) {
rtcEngine?.startRtmpStreamWithTranscoding(url,
getRtmpStreamTranscoding(localUid, remoteUid)
@@ -256,7 +270,7 @@ fun RTMPStreaming() {
}
@Composable
-fun RTMPStreamingView(
+private fun RTMPStreamingView(
rtcEngine: RtcEngine? = null,
channelName: String,
isJoined: Boolean,
@@ -307,7 +321,7 @@ fun RTMPStreamingView(
}
)
- SwitchRaw(title = "是否转码", checked = transcoding) {
+ SwitchRaw(title = stringResource(id = R.string.transcoding_or_not), checked = transcoding) {
onTranscoding()
}
ChannelNameInput(
@@ -318,8 +332,10 @@ fun RTMPStreamingView(
)
InputRaw(
text = url,
- label = "推流地址",
- btnText = if (pushing) "关闭推流" else "开始推流",
+ label = stringResource(id = R.string.rtmp_url),
+ btnText = if (pushing) stringResource(id = R.string.stop_publish_stream) else stringResource(
+ id = R.string.start_publish_stream
+ ),
enable = isJoined,
editable = !pushing
) { u ->
@@ -333,25 +349,25 @@ private fun getRtmpStreamTranscoding(
remoteUid: Int
): LiveTranscoding {
return LiveTranscoding().apply {
- width = 640
- height = 360
+ width = 360
+ height = 640
videoBitrate = 400
videoFramerate = 15
addUser(LiveTranscoding.TranscodingUser().apply {
uid = localUid
x = 0
y = 0
- width = 640
- height = 180
+ width = 360
+ height = 320
zOrder = 1
})
if (remoteUid != 0) {
addUser(LiveTranscoding.TranscodingUser().apply {
uid = remoteUid
x = 0
- y = 180
- width = 640
- height = 180
+ y = 320
+ width = 360
+ height = 320
zOrder = 2
})
}
@@ -360,7 +376,7 @@ private fun getRtmpStreamTranscoding(
@Preview
@Composable
-fun RTMPStreamingViewPreview() {
+private fun RTMPStreamingViewPreview() {
RTMPStreamingView(
channelName = "test",
isJoined = true
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/RhythmPlayer.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/RhythmPlayer.kt
index f91be3f69..2d0baab9f 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/RhythmPlayer.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/RhythmPlayer.kt
@@ -18,8 +18,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.SliderRaw
@@ -102,8 +104,8 @@ fun RhythmPlayer() {
mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
mediaOptions.autoSubscribeAudio = true
mediaOptions.autoSubscribeVideo = true
- mediaOptions.publishRhythmPlayerTrack = true
- mediaOptions.publishMicrophoneTrack = false
+ mediaOptions.publishRhythmPlayerTrack = isPlaying
+ mediaOptions.publishMicrophoneTrack = true
mediaOptions.publishCameraTrack = false
TokenUtils.gen(channelName, 0) {
rtcEngine.joinChannel(it, channelName, 0, mediaOptions)
@@ -115,7 +117,7 @@ fun RhythmPlayer() {
}
@Composable
-fun RhythmPlayerView(
+private fun RhythmPlayerView(
rtcEngine: RtcEngine? = null,
channelName: String,
isJoined: Boolean,
@@ -151,9 +153,14 @@ fun RhythmPlayerView(
.padding(8.dp, 0.dp),
onClick = {
rtcEngine?.startRhythmPlayer(URL_UPBEAT, URL_DOWNBEAT, config)
+ if(isJoined){
+ rtcEngine?.updateChannelMediaOptions(ChannelMediaOptions().apply {
+ publishRhythmPlayerTrack = true
+ })
+ }
}
) {
- Text(text = "Play")
+ Text(text = stringResource(id = R.string.play))
}
Button(
modifier = Modifier
@@ -161,10 +168,15 @@ fun RhythmPlayerView(
.padding(8.dp, 0.dp),
onClick = {
rtcEngine?.stopRhythmPlayer()
+ if(isJoined){
+ rtcEngine?.updateChannelMediaOptions(ChannelMediaOptions().apply {
+ publishRhythmPlayerTrack = false
+ })
+ }
onPlayStopClick()
}
) {
- Text(text = "Stop")
+ Text(text = stringResource(id = R.string.stop))
}
}
}
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/ScreenSharing.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/ScreenSharing.kt
index 31f604304..1c769762d 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/ScreenSharing.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/ScreenSharing.kt
@@ -20,9 +20,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.DropdownMenuRaw
@@ -278,7 +280,7 @@ fun ScreenSharing() {
@Composable
-fun ScreenSharingView(
+private fun ScreenSharingView(
channelName: String,
isJoined: Boolean,
localUid: Int = 0,
@@ -311,14 +313,14 @@ fun ScreenSharingView(
Spacer(modifier = Modifier.weight(1.0f))
SwitchRaw(
- title = "屏幕共享本地预览",
+ title = stringResource(id = R.string.screen_sharing_local_preview),
checked = isScreenPreview,
enable = isJoined && isScreenSharing
) {
onScreenPreview(it)
}
SwitchRaw(
- title = "屏幕共享本地音频",
+ title = stringResource(id = R.string.screen_sharing_audio),
enable = isJoined && isScreenSharing
) {
onScreenAudio(it)
@@ -353,7 +355,7 @@ fun ScreenSharingView(
@Preview
@Composable
-fun ScreenSharingViewPreview() {
+private fun ScreenSharingViewPreview() {
ScreenSharingView(
channelName = "test",
isJoined = false,
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/SendDataStream.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/SendDataStream.kt
index 7be151991..9ce1aeb8b 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/SendDataStream.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/SendDataStream.kt
@@ -224,7 +224,7 @@ fun SendDataStream() {
}
@Composable
-fun SendDataStreamView(
+private fun SendDataStreamView(
rtcEngine: RtcEngine?,
channelName: String,
isJoined: Boolean,
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/SpatialSound.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/SpatialSound.kt
new file mode 100644
index 000000000..2e5b55e09
--- /dev/null
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/SpatialSound.kt
@@ -0,0 +1,655 @@
+package io.agora.api.example.compose.samples
+
+import android.util.Log
+import android.widget.Toast
+import androidx.activity.compose.rememberLauncherForActivityResult
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.annotation.DrawableRes
+import androidx.compose.foundation.Image
+import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.gestures.detectDragGestures
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.offset
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.ModalBottomSheet
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableFloatStateOf
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.alpha
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLifecycleOwner
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.IntOffset
+import androidx.compose.ui.unit.dp
+import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
+import io.agora.api.example.compose.data.SettingPreferences
+import io.agora.api.example.compose.ui.common.ChannelNameInput
+import io.agora.api.example.compose.ui.common.SliderRaw
+import io.agora.api.example.compose.ui.common.SwitchRaw
+import io.agora.api.example.compose.utils.TokenUtils
+import io.agora.mediaplayer.data.MediaPlayerSource
+import io.agora.rtc2.ChannelMediaOptions
+import io.agora.rtc2.Constants
+import io.agora.rtc2.IRtcEngineEventHandler
+import io.agora.rtc2.RtcEngine
+import io.agora.rtc2.RtcEngineConfig
+import io.agora.rtc2.SpatialAudioParams
+import io.agora.rtc2.video.VideoEncoderConfiguration
+import io.agora.spatialaudio.ILocalSpatialAudioEngine
+import io.agora.spatialaudio.LocalSpatialAudioConfig
+import io.agora.spatialaudio.RemoteVoicePositionInfo
+import kotlin.math.roundToInt
+
+
+private const val AXIS_MAX_DISTANCE = 10.0f
+
+@Composable
+fun SpatialSound() {
+ val context = LocalContext.current
+ val lifecycleOwner = LocalLifecycleOwner.current
+ val keyboard = LocalSoftwareKeyboardController.current
+ var isJoined by rememberSaveable { mutableStateOf(false) }
+ var channelName by rememberSaveable { mutableStateOf("") }
+ var localUid by rememberSaveable { mutableIntStateOf(0) }
+ var remoteUidList by rememberSaveable { mutableStateOf(listOf()) }
+ val settingCache = remember { mutableMapOf() }
+
+ val rtcEngine = remember {
+ RtcEngine.create(RtcEngineConfig().apply {
+ mAreaCode = SettingPreferences.getArea()
+ mContext = context
+ mAppId = BuildConfig.AGORA_APP_ID
+ mEventHandler = object : IRtcEngineEventHandler() {
+ override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
+ super.onJoinChannelSuccess(channel, uid, elapsed)
+ isJoined = true
+ localUid = uid
+ }
+
+ override fun onLeaveChannel(stats: RtcStats?) {
+ super.onLeaveChannel(stats)
+ isJoined = false
+ localUid = 0
+ remoteUidList = emptyList()
+ }
+
+ override fun onUserJoined(uid: Int, elapsed: Int) {
+ super.onUserJoined(uid, elapsed)
+ remoteUidList += uid
+ settingCache[uid] = SettingInfo(
+ mute = false,
+ voiceBlur = false,
+ airborneSimulation = false,
+ attenuation = 0.5f
+ )
+ }
+
+ override fun onUserOffline(uid: Int, reason: Int) {
+ super.onUserOffline(uid, reason)
+ remoteUidList -= uid
+ settingCache.remove(uid)
+ }
+
+ }
+ }).apply {
+ setVideoEncoderConfiguration(
+ VideoEncoderConfiguration(
+ SettingPreferences.getVideoDimensions(),
+ SettingPreferences.getVideoFrameRate(),
+ VideoEncoderConfiguration.STANDARD_BITRATE,
+ SettingPreferences.getOrientationMode()
+ )
+ )
+ enableAudio()
+ }
+ }
+
+ val localSpatial = remember {
+ ILocalSpatialAudioEngine.create().apply {
+ val localSpatialAudioConfig = LocalSpatialAudioConfig()
+ localSpatialAudioConfig.mRtcEngine = rtcEngine
+ initialize(localSpatialAudioConfig)
+
+ setMaxAudioRecvCount(2)
+ setAudioRecvRange(AXIS_MAX_DISTANCE)
+ setDistanceUnit(1f)
+ }
+ }
+
+ val playerLeft = remember {
+ rtcEngine.createMediaPlayer().apply {
+ setLoopCount(-1)
+ settingCache[mediaPlayerId] = SettingInfo(
+ mute = true, voiceBlur = false, airborneSimulation = false, attenuation = 0.5f
+ )
+ }
+ }
+ val playerRight = remember {
+ rtcEngine.createMediaPlayer().apply {
+ setLoopCount(-1)
+ settingCache[mediaPlayerId] = SettingInfo(
+ mute = true, voiceBlur = false, airborneSimulation = false, attenuation = 0.5f
+ )
+ }
+ }
+
+ DisposableEffect(lifecycleOwner) {
+ onDispose {
+ playerLeft.destroy()
+ playerRight.destroy()
+ rtcEngine.leaveChannel()
+ RtcEngine.destroy()
+ }
+ }
+ val permissionLauncher =
+ rememberLauncherForActivityResult(contract = ActivityResultContracts.RequestMultiplePermissions()) { grantedMap ->
+ val allGranted = grantedMap.values.all { it }
+ if (allGranted) {
+ // Permission is granted
+ Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
+ val mediaOptions = ChannelMediaOptions()
+ mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
+ mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
+ mediaOptions.autoSubscribeAudio = true
+ mediaOptions.autoSubscribeVideo = false
+ mediaOptions.publishMicrophoneTrack = true
+ mediaOptions.publishCameraTrack = false
+ TokenUtils.gen(channelName, 0) {
+ rtcEngine.joinChannel(it, channelName, 0, mediaOptions)
+ }
+ } else {
+ // Permission is denied
+ Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
+ }
+ }
+
+ SpatialSoundView(channelName = channelName,
+ isJoined = isJoined,
+ remoteUidList = remoteUidList,
+ onJoinClick = {
+ channelName = it
+ keyboard?.hide()
+ settingCache[playerLeft.mediaPlayerId] =
+ settingCache[playerLeft.mediaPlayerId]?.copy(mute = false)!!
+ settingCache[playerRight.mediaPlayerId] =
+ settingCache[playerRight.mediaPlayerId]?.copy(mute = false)!!
+ playerLeft.openWithMediaSource(MediaPlayerSource().apply {
+ url = "https://webdemo.agora.io/audiomixing.mp3"
+ isAutoPlay = true
+ })
+ playerRight.openWithMediaSource(MediaPlayerSource().apply {
+ url = "https://webdemo.agora.io/dang.mp3"
+ isAutoPlay = true
+ })
+
+ permissionLauncher.launch(
+ arrayOf(
+ android.Manifest.permission.RECORD_AUDIO,
+ )
+ )
+ },
+ onLeaveClick = {
+ playerLeft.stop()
+ playerRight.stop()
+ rtcEngine.leaveChannel()
+ },
+ onPlayerLeftPositionUpdated = { x, y ->
+ localSpatial.updatePlayerPositionInfo(playerLeft.mediaPlayerId,
+ RemoteVoicePositionInfo().apply {
+ forward = floatArrayOf(1.0f, 0f, 0f)
+ position = floatArrayOf(x * AXIS_MAX_DISTANCE, y * AXIS_MAX_DISTANCE, 0f)
+ })
+ },
+ onPlayerRightPositionUpdated = { x, y ->
+ localSpatial.updatePlayerPositionInfo(playerRight.mediaPlayerId,
+ RemoteVoicePositionInfo().apply {
+ forward = floatArrayOf(1.0f, 0f, 0f)
+ position = floatArrayOf(x * AXIS_MAX_DISTANCE, y * AXIS_MAX_DISTANCE, 0f)
+ })
+ },
+ onRemotePositionUpdated = { uid, x, y ->
+ localSpatial.updateRemotePosition(uid, RemoteVoicePositionInfo().apply {
+ forward = floatArrayOf(1.0f, 0f, 0f)
+ position = floatArrayOf(x * AXIS_MAX_DISTANCE, y * AXIS_MAX_DISTANCE, 0f)
+ })
+ },
+ onLocalPositionUpdated = { x, y ->
+ localSpatial.updateSelfPosition(
+ floatArrayOf(x * AXIS_MAX_DISTANCE, y * AXIS_MAX_DISTANCE, 0f),
+ floatArrayOf(1.0f, 0f, 0f),
+ floatArrayOf(0f, 1.0f, 0f),
+ floatArrayOf(0f, 0f, 1.0f)
+ )
+ },
+ onMute = { settingType, enable, uid ->
+ when (settingType) {
+ SETTING_TYPE_PLAYER_LEFT -> {
+ settingCache[playerLeft.mediaPlayerId] =
+ settingCache[playerLeft.mediaPlayerId]?.copy(mute = enable)!!
+ if (enable) {
+ playerLeft.pause()
+ } else {
+ playerLeft.resume()
+ }
+ }
+
+ SETTING_TYPE_PLAYER_RIGHT -> {
+ settingCache[playerRight.mediaPlayerId] =
+ settingCache[playerRight.mediaPlayerId]?.copy(mute = enable)!!
+ if (enable) {
+ playerRight.pause()
+ } else {
+ playerRight.resume()
+ }
+ }
+
+ SETTING_TYPE_REMOTE -> {
+ settingCache[uid]?.copy(mute = enable)?.let {
+ settingCache[uid] = it
+ }
+ localSpatial.muteRemoteAudioStream(uid, enable)
+ }
+ }
+ },
+ onVoiceBlur = { settingType, enable, uid ->
+ when (settingType) {
+ SETTING_TYPE_PLAYER_LEFT -> {
+ settingCache[playerLeft.mediaPlayerId] =
+ settingCache[playerLeft.mediaPlayerId]?.copy(voiceBlur = enable)!!
+ playerLeft.setSpatialAudioParams(SpatialAudioParams().apply {
+ enable_blur = enable
+ })
+ }
+
+ SETTING_TYPE_PLAYER_RIGHT -> {
+ settingCache[playerRight.mediaPlayerId] =
+ settingCache[playerRight.mediaPlayerId]?.copy(voiceBlur = enable)!!
+ playerRight.setSpatialAudioParams(SpatialAudioParams().apply {
+ enable_blur = enable
+ })
+ }
+
+ SETTING_TYPE_REMOTE -> {
+ settingCache[uid]?.copy(voiceBlur = enable)?.let {
+ settingCache[uid] = it
+ }
+ rtcEngine.setRemoteUserSpatialAudioParams(uid, SpatialAudioParams().apply {
+ enable_blur = enable
+ })
+ }
+ }
+ },
+ onAirborneSimulation = { settingType, enable, uid ->
+ when (settingType) {
+ SETTING_TYPE_PLAYER_LEFT -> {
+ settingCache[playerLeft.mediaPlayerId] =
+ settingCache[playerLeft.mediaPlayerId]?.copy(airborneSimulation = enable)!!
+ playerLeft.setSpatialAudioParams(SpatialAudioParams().apply {
+ enable_air_absorb = enable
+ })
+ }
+
+ SETTING_TYPE_PLAYER_RIGHT -> {
+ settingCache[playerRight.mediaPlayerId] =
+ settingCache[playerRight.mediaPlayerId]?.copy(airborneSimulation = enable)!!
+ playerRight.setSpatialAudioParams(SpatialAudioParams().apply {
+ enable_air_absorb = enable
+ })
+ }
+
+ SETTING_TYPE_REMOTE -> {
+ settingCache[uid]?.copy(airborneSimulation = enable)?.let {
+ settingCache[uid] = it
+ }
+ rtcEngine.setRemoteUserSpatialAudioParams(uid, SpatialAudioParams().apply {
+ enable_air_absorb = enable
+ })
+ }
+ }
+ },
+ onAttenuation = { settingType, value, uid ->
+ when (settingType) {
+ SETTING_TYPE_PLAYER_LEFT -> {
+ settingCache[playerLeft.mediaPlayerId] =
+ settingCache[playerLeft.mediaPlayerId]?.copy(attenuation = value)!!
+ localSpatial.setRemoteAudioAttenuation(
+ playerLeft.mediaPlayerId, value.toDouble(), false
+ )
+ }
+
+ SETTING_TYPE_PLAYER_RIGHT -> {
+ settingCache[playerRight.mediaPlayerId] =
+ settingCache[playerRight.mediaPlayerId]?.copy(attenuation = value)!!
+ localSpatial.setRemoteAudioAttenuation(
+ playerRight.mediaPlayerId, value.toDouble(), false
+ )
+ }
+
+ SETTING_TYPE_REMOTE -> {
+ settingCache[uid]?.copy(attenuation = value)?.let {
+ settingCache[uid] = it
+ }
+ localSpatial.setRemoteAudioAttenuation(uid, value.toDouble(), false)
+ }
+ }
+ })
+}
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+private fun SpatialSoundView(
+ channelName: String,
+ isJoined: Boolean,
+ remoteUidList: List = emptyList(),
+ settingCache: Map = emptyMap(),
+ onJoinClick: (channelName: String) -> Unit = { _ -> },
+ onLeaveClick: () -> Unit = {},
+ onMute: (settingType: Int, enable: Boolean, uid: Int) -> Unit = { _, _, _ -> },
+ onVoiceBlur: (settingType: Int, enable: Boolean, uid: Int) -> Unit = { _, _, _ -> },
+ onAirborneSimulation: (settingType: Int, enable: Boolean, uid: Int) -> Unit = { _, _, _ -> },
+ onAttenuation: (settingType: Int, value: Float, uid: Int) -> Unit = { _, _, _ -> },
+ onPlayerLeftPositionUpdated: (x: Float, y: Float) -> Unit = { _, _ -> },
+ onPlayerRightPositionUpdated: (x: Float, y: Float) -> Unit = { _, _ -> },
+ onRemotePositionUpdated: (uid: Int, x: Float, y: Float) -> Unit = { _, _, _ -> },
+ onLocalPositionUpdated: (x: Float, y: Float) -> Unit = { _, _ -> },
+) {
+ var showSetting by rememberSaveable { mutableStateOf(false) }
+ var settingUid by rememberSaveable { mutableIntStateOf(0) }
+ var settingType by rememberSaveable { mutableIntStateOf(SETTING_TYPE_PLAYER_LEFT) }
+
+
+ Column {
+ Box(modifier = Modifier.weight(1.0f)) {
+ DraggableIcon(iconId = R.drawable.ic_speaker,
+ iconSize = 60.dp,
+ axisX = -0.5f,
+ axisY = 0.5f,
+ draggable = false,
+ clickable = isJoined,
+ onClick = {
+ settingUid = 0
+ settingType = SETTING_TYPE_PLAYER_LEFT
+ showSetting = true
+ }) { x, y ->
+ Log.i("SpatialSoundView", "Speaker1 >> x=$x, y=$y")
+ onPlayerLeftPositionUpdated(x, y)
+ }
+ DraggableIcon(iconId = R.drawable.ic_speaker,
+ iconSize = 60.dp,
+ axisX = 0.5f,
+ axisY = 0.5f,
+ draggable = false,
+ clickable = isJoined,
+ onClick = {
+ settingUid = 1
+ settingType = SETTING_TYPE_PLAYER_RIGHT
+ showSetting = true
+ }) { x, y ->
+ Log.i("SpatialSoundView", "Speaker2 >> x=$x, y=$y")
+ onPlayerRightPositionUpdated(x, y)
+ }
+
+ Text(
+ modifier = Modifier
+ .align(Alignment.TopCenter)
+ .padding(top = 50.dp),
+ text = stringResource(id = R.string.spatial_sound_experience_tip),
+ style = MaterialTheme.typography.titleMedium
+ )
+ DraggableIcon(
+ iconId = R.drawable.ic_local,
+ iconSize = 50.dp,
+ axisX = 0.0f,
+ axisY = 0.0f,
+ showGuides = false,
+ clickable = false,
+ draggable = isJoined
+ ) { x, y ->
+ Log.i("SpatialSoundView", "Local >> x=$x, y=$y")
+ onLocalPositionUpdated(x, y)
+ }
+
+ remoteUidList.getOrNull(0)?.let {
+ DraggableIcon(iconId = R.drawable.ic_remote,
+ iconSize = 60.dp,
+ axisX = -0.5f,
+ axisY = -0.5f,
+ draggable = false,
+ clickable = true,
+ onClick = {
+ settingUid = it
+ settingType = SETTING_TYPE_REMOTE
+ showSetting = true
+ }) { x, y ->
+ Log.i("SpatialSoundView", "Remote1 >> x=$x, y=$y")
+ onRemotePositionUpdated(it, x, y)
+ }
+ }
+
+ remoteUidList.getOrNull(1)?.let {
+ DraggableIcon(iconId = R.drawable.ic_remote,
+ iconSize = 60.dp,
+ axisX = 0.5f,
+ axisY = -0.5f,
+ draggable = false,
+ clickable = true,
+ onClick = {
+ settingUid = it
+ settingType = SETTING_TYPE_REMOTE
+ showSetting = true
+ }) { x, y ->
+ Log.i("SpatialSoundView", "Remote2 >> x=$x, y=$y")
+ onRemotePositionUpdated(it, x, y)
+ }
+ }
+
+
+ }
+
+ ChannelNameInput(
+ channelName = channelName,
+ isJoined = isJoined,
+ onJoinClick = onJoinClick,
+ onLeaveClick = onLeaveClick
+ )
+ }
+
+ if (showSetting) {
+ ModalBottomSheet(
+ onDismissRequest = {
+ showSetting = false
+ },
+ windowInsets = WindowInsets(0),
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(bottom = 16.dp)
+ ) {
+ SwitchRaw(title = stringResource(id = R.string.mute_audio), settingCache[settingUid]?.mute ?: false) {
+ onMute(settingType, it, settingUid)
+ }
+ SwitchRaw(title = "VoiceBlur", settingCache[settingUid]?.voiceBlur ?: false) {
+ onVoiceBlur(settingType, it, settingUid)
+ }
+ SwitchRaw(
+ title = "Airborne Simulation",
+ settingCache[settingUid]?.airborneSimulation ?: false
+ ) {
+ onAirborneSimulation(settingType, it, settingUid)
+ }
+ SliderRaw(
+ title = "Attenuation",
+ value = settingCache[settingUid]?.attenuation ?: 0.5f
+ ) {
+ onAttenuation(settingType, it, settingUid)
+ }
+ }
+ }
+ }
+
+}
+
+private const val SETTING_TYPE_PLAYER_LEFT = 0
+private const val SETTING_TYPE_PLAYER_RIGHT = 1
+private const val SETTING_TYPE_REMOTE = 2
+
+private data class SettingInfo(
+ val mute: Boolean,
+ val voiceBlur: Boolean,
+ val airborneSimulation: Boolean,
+ val attenuation: Float
+)
+
+@Composable
+private fun DraggableIcon(
+ @DrawableRes iconId: Int,
+ iconSize: Dp,
+ axisX: Float,
+ axisY: Float,
+ draggable: Boolean = true,
+ showGuides: Boolean = false,
+ clickable: Boolean = true,
+ onClick: () -> Unit = { },
+ onAxisPositionChanged: (axisX: Float, axisY: Float) -> Unit = { _, _ -> }
+) {
+ var width by remember { mutableIntStateOf(0) }
+ var height by remember { mutableIntStateOf(0) }
+ var offsetX by remember { mutableFloatStateOf(0.0f) }
+ var offsetY by remember { mutableFloatStateOf(0.0f) }
+ val density = LocalDensity.current.density
+
+ Box(modifier = Modifier
+ .fillMaxSize()
+ .onGloballyPositioned { coordinates ->
+ width = coordinates.size.width
+ height = coordinates.size.height
+ offsetX = width * 1.0f / 2 - (iconSize.value * density) / 2 + width * 1.0f / 2 * axisX
+ offsetY = height * 1.0f / 2 - (iconSize.value * density) / 2 - height * 1.0f / 2 * axisY
+ onAxisPositionChanged(
+ (offsetX - (width * 1.0f / 2 - (iconSize.value * density) / 2)) / (width * 1.0f / 2),
+ -1 * (offsetY - (height * 1.0f / 2 - (iconSize.value * density) / 2)) / (height * 1.0f / 2)
+ )
+ }) {
+ if (showGuides) {
+ val row = 4
+ val col = 4
+ Column(modifier = Modifier.fillMaxSize()) {
+ for (i in 0 until row) {
+ if (i == 0) {
+ Box(
+ modifier = Modifier
+ .height(1.dp)
+ .fillMaxWidth()
+ .background(Color.Red)
+ .alpha(0.5f)
+ )
+ }
+ Spacer(modifier = Modifier.weight(1.0f))
+ Box(
+ modifier = Modifier
+ .height(1.dp)
+ .fillMaxWidth()
+ .background(Color.Red)
+ .alpha(0.5f)
+ )
+ }
+ }
+
+ Row(modifier = Modifier.fillMaxSize()) {
+ for (i in 0 until col) {
+ if (i == 0) {
+ Box(
+ modifier = Modifier
+ .width(1.dp)
+ .fillMaxHeight()
+ .background(Color.Red)
+ .alpha(0.5f)
+ )
+ }
+ Spacer(modifier = Modifier.weight(1.0f))
+ Box(
+ modifier = Modifier
+ .width(1.dp)
+ .fillMaxHeight()
+ .background(Color.Red)
+ .alpha(0.5f)
+ )
+ }
+ }
+ }
+
+ var modifier = Modifier
+ .offset { IntOffset(offsetX.roundToInt(), offsetY.roundToInt()) }
+ .size(iconSize)
+ if (draggable) {
+ modifier = modifier.pointerInput(Unit) {
+ detectDragGestures { change, dragAmount ->
+ change.consume()
+
+ var x = offsetX + dragAmount.x
+ var y = offsetY + dragAmount.y
+ if (x < 0) {
+ x = 0f
+ }
+ if (x > (width - iconSize.toPx())) {
+ x = width - iconSize.toPx()
+ }
+ if (y < 0) {
+ y = 0f
+ }
+ if (y > (height - iconSize.toPx())) {
+ y = height - iconSize.toPx()
+ }
+ offsetX = x
+ offsetY = y
+
+ onAxisPositionChanged(
+ (offsetX - (width * 1.0f / 2 - (iconSize.value * density) / 2)) / (width * 1.0f / 2),
+ -1 * (offsetY - (height * 1.0f / 2 - (iconSize.value * density) / 2)) / (height * 1.0f / 2)
+ )
+ }
+ }
+ }
+
+ if (clickable) {
+ modifier = modifier.clickable {
+ onClick()
+ }
+ }
+
+ Image(
+ modifier = modifier, painter = painterResource(id = iconId), contentDescription = null
+ )
+ }
+}
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/VideoProcessExtension.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/VideoProcessExtension.kt
index 19f7dd758..27ea702f5 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/VideoProcessExtension.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/VideoProcessExtension.kt
@@ -19,9 +19,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.RadioGroup
@@ -201,7 +203,7 @@ fun VideoProcessExtension() {
}
@Composable
-fun VideoProcessExtensionView(
+private fun VideoProcessExtensionView(
rtcEngine: RtcEngine? = null,
channelName: String,
isJoined: Boolean,
@@ -235,24 +237,24 @@ fun VideoProcessExtensionView(
val beautyOptions = remember { BeautyOptions() }
var isOpen by remember { mutableStateOf(false) }
Column {
- SwitchRaw(title = "美颜", checked = isOpen) {
+ SwitchRaw(title = stringResource(id = R.string.beauty_face), checked = isOpen) {
isOpen = it
rtcEngine?.setBeautyEffectOptions(isOpen, beautyOptions)
}
Column(modifier = Modifier.padding(16.dp, 0.dp)) {
- SliderRaw(title = "美白", value = beautyOptions.lighteningLevel) {
+ SliderRaw(title = stringResource(id = R.string.beauty_lightening), value = beautyOptions.lighteningLevel) {
beautyOptions.lighteningLevel = it
rtcEngine?.setBeautyEffectOptions(isOpen, beautyOptions)
}
- SliderRaw(title = "红润", value = beautyOptions.rednessLevel) {
+ SliderRaw(title = stringResource(id = R.string.beauty_redness), value = beautyOptions.rednessLevel) {
beautyOptions.rednessLevel = it
rtcEngine?.setBeautyEffectOptions(isOpen, beautyOptions)
}
- SliderRaw(title = "锐利", value = beautyOptions.sharpnessLevel) {
+ SliderRaw(title = stringResource(id = R.string.beauty_sharpness), value = beautyOptions.sharpnessLevel) {
beautyOptions.sharpnessLevel = it
rtcEngine?.setBeautyEffectOptions(isOpen, beautyOptions)
}
- SliderRaw(title = "平滑", value = beautyOptions.smoothnessLevel) {
+ SliderRaw(title = stringResource(id = R.string.beauty_smoothness), value = beautyOptions.smoothnessLevel) {
beautyOptions.smoothnessLevel = it
rtcEngine?.setBeautyEffectOptions(isOpen, beautyOptions)
}
@@ -260,7 +262,7 @@ fun VideoProcessExtensionView(
}
}
item {
- SwitchRaw(title = "暗光增强") {
+ SwitchRaw(title = stringResource(id = R.string.low_light_enhance)) {
val options = LowLightEnhanceOptions()
options.lowlightEnhanceLevel =
LowLightEnhanceOptions.LOW_LIGHT_ENHANCE_LEVEL_FAST
@@ -272,17 +274,17 @@ fun VideoProcessExtensionView(
val colorEnhanceOptions = remember { ColorEnhanceOptions() }
var isOpen by remember { mutableStateOf(false) }
Column {
- SwitchRaw(title = "色彩增强", checked = isOpen) {
+ SwitchRaw(title = stringResource(id = R.string.color_enhance), checked = isOpen) {
isOpen = it
rtcEngine?.setColorEnhanceOptions(isOpen, colorEnhanceOptions)
}
Column(modifier = Modifier.padding(16.dp, 0.dp)) {
- SliderRaw(title = "强度", value = colorEnhanceOptions.strengthLevel) {
+ SliderRaw(title = stringResource(id = R.string.strength), value = colorEnhanceOptions.strengthLevel) {
colorEnhanceOptions.strengthLevel = it
rtcEngine?.setColorEnhanceOptions(isOpen, colorEnhanceOptions)
}
SliderRaw(
- title = "肤色保护",
+ title = stringResource(id = R.string.skin_protect),
value = colorEnhanceOptions.skinProtectLevel
) {
colorEnhanceOptions.skinProtectLevel = it
@@ -292,7 +294,7 @@ fun VideoProcessExtensionView(
}
}
item {
- SwitchRaw(title = "视频降噪") {
+ SwitchRaw(title = stringResource(id = R.string.video_denoiser)) {
val options = VideoDenoiserOptions()
options.denoiserLevel = VideoDenoiserOptions.VIDEO_DENOISER_LEVEL_HIGH_QUALITY
options.denoiserMode = VideoDenoiserOptions.VIDEO_DENOISER_AUTO
@@ -309,16 +311,16 @@ fun VideoProcessExtensionView(
val segproperty = remember { SegmentationProperty() }
Column {
- SwitchRaw(title = "虚拟背景", checked = isOpen) {
+ SwitchRaw(title = stringResource(id = R.string.virtual_background), checked = isOpen) {
isOpen = it
rtcEngine?.enableVirtualBackground(isOpen, backgroundSource, segproperty)
}
RadioGroup(
options = listOf(
- "图片" to VirtualBackgroundSource.BACKGROUND_IMG,
- "颜色" to VirtualBackgroundSource.BACKGROUND_COLOR,
- "毛玻璃" to VirtualBackgroundSource.BACKGROUND_BLUR,
- "视频" to VirtualBackgroundSource.BACKGROUND_VIDEO,
+ stringResource(id = R.string.picture) to VirtualBackgroundSource.BACKGROUND_IMG,
+ stringResource(id = R.string.color) to VirtualBackgroundSource.BACKGROUND_COLOR,
+ stringResource(id = R.string.blur) to VirtualBackgroundSource.BACKGROUND_BLUR,
+ stringResource(id = R.string.video) to VirtualBackgroundSource.BACKGROUND_VIDEO,
),
selectedValue = backgroundSource.backgroundSourceType
) { _, option ->
@@ -357,7 +359,7 @@ fun VideoProcessExtensionView(
@Preview
@Composable
-fun VideoProcessExtensionViewPreview() {
+private fun VideoProcessExtensionViewPreview() {
VideoProcessExtensionView(channelName = "", isJoined = true, onJoinClick = {}) {
}
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/VoiceEffects.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/VoiceEffects.kt
index 4dd92a518..4df78c431 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/VoiceEffects.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/VoiceEffects.kt
@@ -25,9 +25,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.AudioGrid
import io.agora.api.example.compose.ui.common.AudioStatsInfo
@@ -151,7 +153,7 @@ fun VoiceEffects() {
}
@Composable
-fun VoiceEffectsView(
+private fun VoiceEffectsView(
videoIdList: List,
statsMap: Map = mapOf(),
rtcEngine: RtcEngine? = null,
@@ -326,9 +328,9 @@ fun VoiceEffectsView(
title = "AINS Mode",
options = listOf(
"Off" to 0,
- "均衡降噪模式" to 0,
- "强降噪模式" to 1,
- "低延时强降噪模式" to 2,
+ stringResource(id = R.string.ains_mode_0) to 0,
+ stringResource(id = R.string.ains_mode_1) to 1,
+ stringResource(id = R.string.ains_mode_2) to 2,
)
) { index, option ->
rtcEngine?.setAINSMode(index != 0, option.second)
@@ -380,6 +382,6 @@ fun VoiceEffectsView(
@Preview
@Composable
-fun VoiceEffectsViewPreview() {
+private fun VoiceEffectsViewPreview() {
VoiceEffectsView(videoIdList = listOf(0, 1, 2))
}
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/common/Widgets.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/common/Widgets.kt
index 366497db3..67fa8df16 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/common/Widgets.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/common/Widgets.kt
@@ -41,6 +41,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.TextUnit
@@ -48,6 +49,7 @@ import androidx.compose.ui.unit.TextUnitType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
+import io.agora.api.example.compose.R
import io.agora.rtc2.IRtcEngineEventHandler
@Composable
@@ -62,8 +64,8 @@ fun ChannelNameInput(
InputRaw(
modifier = modifier,
text = text,
- btnText = if (isJoined) "Leave" else "Join",
- label = "Channel Name",
+ btnText = if (isJoined) stringResource(id = R.string.leave) else stringResource(id = R.string.join),
+ label = stringResource(id = R.string.channel_name),
) {
text = it
if (isJoined) onLeaveClick() else onJoinClick(it)
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/example/Example.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/example/Example.kt
index 81a4bef1f..8e8e1e5e5 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/example/Example.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/example/Example.kt
@@ -30,7 +30,7 @@ fun Example(
.padding(paddingValues),
contentAlignment = Alignment.Center
) {
- example.content()
+ example.content(onBackClick)
}
}
}
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/settings/Settings.kt b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/settings/Settings.kt
index 53f31c05f..ba6d4ade5 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/settings/Settings.kt
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/ui/settings/Settings.kt
@@ -19,9 +19,11 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
+import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.APIExampleScaffold
import io.agora.api.example.compose.ui.common.DropdownMenuRaw
@@ -32,7 +34,7 @@ import io.agora.rtc2.video.VideoEncoderConfiguration
@Composable
fun Settings(onBackClick: () -> Unit) {
APIExampleScaffold(
- topBarTitle = "Settings",
+ topBarTitle = stringResource(id = R.string.settings),
showBackNavigationIcon = true,
onBackClick = onBackClick
) { paddingValues ->
@@ -69,7 +71,7 @@ fun Settings(onBackClick: () -> Unit) {
VideoEncoderConfiguration.VD_3840x2160,
)
DropdownMenuRaw(
- title = "Dimension",
+ title = stringResource(id = R.string.resolution),
options = dimensions.map {
it.toText() to it
},
@@ -89,7 +91,7 @@ fun Settings(onBackClick: () -> Unit) {
VideoEncoderConfiguration.FRAME_RATE.FRAME_RATE_FPS_60,
)
DropdownMenuRaw(
- title = "FrameRate",
+ title = stringResource(id = R.string.frame_rate),
options = frameRates.map { it.toText() to it},
selectedValue = SettingPreferences.getVideoFrameRate(),
) { _, option ->
@@ -103,7 +105,7 @@ fun Settings(onBackClick: () -> Unit) {
VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_FIXED_PORTRAIT,
)
DropdownMenuRaw(
- title = "Orientation",
+ title = stringResource(id = R.string.orientation),
options = orientationMode.map { it.toText() to it},
selectedValue = SettingPreferences.getOrientationMode(),
) { _, option ->
@@ -113,7 +115,7 @@ fun Settings(onBackClick: () -> Unit) {
Divider(modifier = Modifier.padding(horizontal = 16.dp))
DropdownMenuRaw(
- title = "Area",
+ title = stringResource(id = R.string.area),
options = listOf(
"Glob" to RtcEngineConfig.AreaCode.AREA_CODE_GLOB,
"China" to RtcEngineConfig.AreaCode.AREA_CODE_CN,
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/utils/TokenUtils.java b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/utils/TokenUtils.java
index 8788511e5..a4f83346b 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/utils/TokenUtils.java
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/utils/TokenUtils.java
@@ -98,7 +98,7 @@ private static void gen(String appId, String certificate, String channelName, in
}
Request request = new Request.Builder()
- .url("https://test-toolbox.bj2.agoralab.co/v1/token/generate")
+ .url("https://service.agora.io/toolbox-global/v1/token/generate")
.addHeader("Content-Type", "application/json")
.post(RequestBody.create(postBody.toString(), null))
.build();
diff --git a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/utils/YuvFboProgram.java b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/utils/YuvFboProgram.java
index bf3d6dfb4..c534c3d67 100644
--- a/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/utils/YuvFboProgram.java
+++ b/Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/utils/YuvFboProgram.java
@@ -96,7 +96,7 @@ public Integer drawYuv(byte[] yuv, int width, int height) {
matrix.preTranslate(0.5f, 0.5f);
matrix.preScale(1f, -1f); // I420-frames are upside down
matrix.preTranslate(-0.5f, -0.5f);
- glRectDrawer.drawYuv(yuvUploader.getYuvTextures(), RendererCommon.convertMatrixFromAndroidGraphicsMatrix(matrix), width, height, 0, 0, width, height);
+ glRectDrawer.drawYuv(yuvUploader.getYuvTextures(), 0, RendererCommon.convertMatrixFromAndroidGraphicsMatrix(matrix), width, height, 0, 0, width, height, 0);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
GLES20.glFlush();
diff --git a/Android/APIExample-Compose/app/src/main/res/drawable/ic_local.png b/Android/APIExample-Compose/app/src/main/res/drawable/ic_local.png
new file mode 100644
index 000000000..4968510c0
Binary files /dev/null and b/Android/APIExample-Compose/app/src/main/res/drawable/ic_local.png differ
diff --git a/Android/APIExample-Compose/app/src/main/res/drawable/ic_remote.png b/Android/APIExample-Compose/app/src/main/res/drawable/ic_remote.png
new file mode 100644
index 000000000..99c244ef7
Binary files /dev/null and b/Android/APIExample-Compose/app/src/main/res/drawable/ic_remote.png differ
diff --git a/Android/APIExample-Compose/app/src/main/res/drawable/ic_speaker.png b/Android/APIExample-Compose/app/src/main/res/drawable/ic_speaker.png
new file mode 100644
index 000000000..b1a45ff89
Binary files /dev/null and b/Android/APIExample-Compose/app/src/main/res/drawable/ic_speaker.png differ
diff --git a/Android/APIExample-Compose/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Android/APIExample-Compose/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 000000000..64c410326
Binary files /dev/null and b/Android/APIExample-Compose/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/Android/APIExample-Compose/app/src/main/res/values-zh/strings.xml b/Android/APIExample-Compose/app/src/main/res/values-zh/strings.xml
index 0e3ec3f13..2c733c923 100644
--- a/Android/APIExample-Compose/app/src/main/res/values-zh/strings.xml
+++ b/Android/APIExample-Compose/app/src/main/res/values-zh/strings.xml
@@ -1,5 +1,4 @@
- APIExample-Compose
视频互动直播
音频互动直播
RTC实时直播
@@ -25,4 +24,80 @@
创建数据流
虚拟节拍器
跨频道媒体流转发
+ 画中画
+ 空间音频
+
+ 加密方式
+ 加密密钥
+ 发布本地音频
+ 发布麦克风
+ 退出
+ 加入
+ 暂停
+ 恢复
+ Ex频道截图
+ 离开Ex频道
+ 加入Ex频道
+ 离开选项
+ 是否停止录音
+ 确定
+ 取消
+ 开启极速直播
+ 水印
+ 小流
+ 编码类型
+ 自动选择
+ 硬编
+ 软编
+ B帧
+ 垫片
+ 透明背景
+ 视频元数据
+ 发送
+ 推送
+ 停止
+ 播放
+ 开始录制
+ 停止录制
+ 切换摄像头
+ 音频回写
+ 开始
+ 音效音量
+ 混音音量
+ 混音播放音量
+ 混音发布音量
+ \"Tip:开始测试后请对着麦克风讲话,讲话声音在%d秒后播放则测试正常。
+ 推流地址
+ 关闭推流
+ 开始推流
+ 是否转码
+ 屏幕共享本地预览
+ 屏幕共享本地音频
+ 请移动红色图标体验3d音频效果
+ 静音
+ 美颜
+ 美白
+ 红润
+ 锐利
+ 平滑
+ 暗光增强
+ 色彩增强
+ 强度
+ 肤色保护
+ 视频降噪
+ 虚拟背景
+ 图片
+ 颜色
+ 毛玻璃
+ 视频
+ 均衡降噪模式
+ 强降噪模式
+ 低延时强降噪模式
+ 频道名
+ 离开
+ 设置
+ 分辨率
+ 帧率
+ 方向
+ 区域
\ No newline at end of file
diff --git a/Android/APIExample-Compose/app/src/main/res/values/strings.xml b/Android/APIExample-Compose/app/src/main/res/values/strings.xml
index 31da5a3b9..ab5edbb19 100644
--- a/Android/APIExample-Compose/app/src/main/res/values/strings.xml
+++ b/Android/APIExample-Compose/app/src/main/res/values/strings.xml
@@ -1,28 +1,104 @@
- APIExample-Compose
+ APIExample-Compose
Join Video Channel
Join Audio Channel
Live Streaming
Join Video Channel (With Token)
- 旁路推流CDN
- 音视频元数据
- 美声与音效
- 自定义音频采集
- 自定义音频渲染
- 自定义视频采集
- 自定义视频渲染
- 原始音频数据
- 原始视频数据
- 加入多频道
- 媒体流加密
- 音频文件混音
- 通话前质量检测
- 本地/远端录制
- 媒体播放器
- 屏幕共享
- 视频增强组件
- 本地合图
- 创建数据流
- 虚拟节拍器
- 跨频道媒体流转发
+ RTMP Streaming
+ Media Metadata
+ Voice Effects
+ Custom Audio Source
+ Custom Audio Render
+ Custom Video Source
+ Custom Video Render
+ Origin Audio Data
+ Origin Video Data
+ Join Multi Channel
+ Channel Encryption
+ Play Audio Files
+ Pre Call Test
+ Media Recorder
+ Media Player
+ Screen Sharing
+ Video Process Extension
+ Local Video Transcoding
+ Send Data Stream
+ Rhythm Player
+ Host Across Channel
+ Picture In Picture
+ Spaital Sound
+
+ Encryption Mode
+ Encryption Key
+ Publish Local Audio
+ Publish microphone
+ Exit
+ Join
+ Pause
+ Resume
+ Ex Channel Snapshot
+ Leave Ex Channel
+ Join Ex Channel
+ Leave Option
+ Stop Recording Or Not
+ Confirm
+ Cancel
+ Open Low Latency live
+ Watermark
+ Low Stream
+ Encoder Type
+ Auto
+ Hardware
+ Software
+ B Frame
+ Video Image
+ Alpha Background
+ Video Metadata
+ Send
+ Publish
+ Stop
+ Play
+ Start Recording
+ Stop Recording
+ Switch Camera
+ Audio Rewrite
+ Start
+ Effects Volume
+ Mixing
+ Mixing Playout Volume
+ Mixing Publish Volume
+ Tip:After starting the test, please speak into the microphone. If the speech sound plays after %d seconds, the test will be normal.
+ RTMP Url
+ Stop Publishing
+ Start Publishing
+ Transcoding Or Not
+ Screen Sharing Local Preview
+ Screen Sharing Audio
+ Please move the red icon to experience the 3D audio effect
+ Mute Audio
+ Beauty
+ Lightening
+ Redness
+ Sharpness
+ Smoothness
+ Low Light Enhance
+ Color Enhance
+ Strength
+ Skin Protext
+ Video Denoiser
+ Virtual Background
+ Picture
+ Color
+ Blur
+ Video
+ Balanced noise reduction mode
+ Strong noise reduction mode
+ ow latency and strong noise reduction mode
+ Channel Name
+ Leave
+ Settings
+ Resolution
+ Frame Rate
+ Orientation
+ Area
\ No newline at end of file
diff --git a/Android/APIExample-Compose/cloud_build.sh b/Android/APIExample-Compose/cloud_build.sh
new file mode 100755
index 000000000..66e456cb4
--- /dev/null
+++ b/Android/APIExample-Compose/cloud_build.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env sh
+
+# cache gradle to /tmp/.gradle
+ls ~/.gradle || (mkdir -p /tmp/.gradle && ln -s /tmp/.gradle ~/.gradle && touch ~/.gradle/ln_$(date "+%y%m%d%H") && ls ~/.gradle)
+
+## use open jdk 17
+SYSTEM=$(uname -s)
+if [ "$SYSTEM" = "Linux" ];then
+if [ ! -d "/tmp/jdk-17.0.2" ];then
+ curl -O https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz
+ tar zxf openjdk-17.0.2_linux-x64_bin.tar.gz
+ mv jdk-17.0.2 /tmp/
+fi
+export JAVA_HOME=/tmp/jdk-17.0.2
+export PATH=$JAVA_HOME/bin:$PATH
+java --version
+fi
+
+## config appId
+if [ ! -f "local.properties" ];then
+ touch local.properties
+ echo "AGORA_APP_ID=${APP_ID}" >> local.properties
+fi
+
+./gradlew clean || exit 1
+./gradlew :app:assembleRelease || exit 1
+if [ "$WORKSPACE" != "" ]; then
+SDK_VERSION=$(echo $sdk_url | cut -d "/" -f 5)
+cp app/build/outputs/apk/release/*.apk $WORKSPACE/APIExample-Compose_${BUILD_NUMBER}_${SDK_VERSION}_$(date "+%Y%m%d%H%M%S").apk
+fi
\ No newline at end of file
diff --git a/Android/APIExample-Compose/gradle/libs.versions.toml b/Android/APIExample-Compose/gradle/libs.versions.toml
index 699c40d4f..5e7d7eb30 100644
--- a/Android/APIExample-Compose/gradle/libs.versions.toml
+++ b/Android/APIExample-Compose/gradle/libs.versions.toml
@@ -12,7 +12,7 @@ composeBom = "2023.08.00"
loggingInterceptor = "4.10.0"
materialIconsExtended = "1.6.0"
navigationCompose = "2.7.7"
-agoraSdk = "4.3.0"
+agoraSdk = "4.4.1"
okhttp = "4.10.0"
[libraries]
diff --git a/Android/APIExample-Compose/keystore.key b/Android/APIExample-Compose/keystore.key
new file mode 100644
index 000000000..a5014a522
Binary files /dev/null and b/Android/APIExample-Compose/keystore.key differ
diff --git a/Android/APIExample/README.md b/Android/APIExample/README.md
index 56c2c20f2..37c26351a 100644
--- a/Android/APIExample/README.md
+++ b/Android/APIExample/README.md
@@ -29,6 +29,7 @@ To build and run the sample application, get an App Id:
// Agora APP ID.
YOUR APP ID
// Agora APP Certificate. If the project does not have certificates enabled, leave this field blank.
+ // PS:It is unsafe to place the App Certificate on the client side, it is recommended to place it on the server side to ensure that the App Certificate is not leaked.
YOUR APP CERTIFICATE
```
diff --git a/Android/APIExample/README.zh.md b/Android/APIExample/README.zh.md
index 876de706e..8e9142829 100644
--- a/Android/APIExample/README.zh.md
+++ b/Android/APIExample/README.zh.md
@@ -29,6 +29,7 @@
// 声网APP ID。
YOUR APP ID
// 声网APP证书。如果项目没有开启证书鉴权,这个字段留空。
+ // 注意:App证书放在客户端不安全,推荐放在服务端以确保 App 证书不会泄露。
YOUR APP CERTIFICATE
```
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h
index a3b4647a6..792137209 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h
@@ -33,31 +33,42 @@
#if defined(AGORARTC_EXPORT)
#define AGORA_API extern "C" __declspec(dllexport)
+#define AGORA_CPP_API __declspec(dllexport)
#else
#define AGORA_API extern "C" __declspec(dllimport)
+#define AGORA_CPP_API __declspec(dllimport)
#endif // AGORARTC_EXPORT
#define AGORA_CALL __cdecl
#define __deprecated
+#define AGORA_CPP_INTERNAL_API extern
+
#elif defined(__APPLE__)
#include
#define AGORA_API extern "C" __attribute__((visibility("default")))
+#define AGORA_CPP_API __attribute__((visibility("default")))
#define AGORA_CALL
+#define AGORA_CPP_INTERNAL_API __attribute__((visibility("hidden")))
+
#elif defined(__ANDROID__) || defined(__linux__)
#define AGORA_API extern "C" __attribute__((visibility("default")))
+#define AGORA_CPP_API __attribute__((visibility("default")))
#define AGORA_CALL
#define __deprecated
+#define AGORA_CPP_INTERNAL_API __attribute__((visibility("hidden")))
+
#else // !_WIN32 && !__APPLE__ && !(__ANDROID__ || __linux__)
#define AGORA_API extern "C"
+#define AGORA_CPP_API
#define AGORA_CALL
#define __deprecated
@@ -631,7 +642,7 @@ enum ERROR_CODE_TYPE {
*/
ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED = 119,
/**
- * 120: Decryption fails. The user may have tried to join the channel with a wrong
+ * 120: MediaStream decryption fails. The user may have tried to join the channel with a wrong
* password. Check your settings or try rejoining the channel.
*/
ERR_DECRYPTION_FAILED = 120,
@@ -639,6 +650,11 @@ enum ERROR_CODE_TYPE {
* 121: The user ID is invalid.
*/
ERR_INVALID_USER_ID = 121,
+ /**
+ * 122: DataStream decryption fails. The peer may have tried to join the channel with a wrong
+ * password, or did't enable datastream encryption
+ */
+ ERR_DATASTREAM_DECRYPTION_FAILED = 122,
/**
* 123: The app is banned by the server.
*/
@@ -850,7 +866,6 @@ enum INTERFACE_ID_TYPE {
AGORA_IID_RTC_CONNECTION = 7,
AGORA_IID_SIGNALING_ENGINE = 8,
AGORA_IID_MEDIA_ENGINE_REGULATOR = 9,
- AGORA_IID_CLOUD_SPATIAL_AUDIO = 10,
AGORA_IID_LOCAL_SPATIAL_AUDIO = 11,
AGORA_IID_STATE_SYNC = 13,
AGORA_IID_META_SERVICE = 14,
@@ -1163,11 +1178,12 @@ enum VIDEO_CODEC_TYPE {
*/
VIDEO_CODEC_GENERIC_H264 = 7,
/**
- * 12: AV1.
- */
+ * 12: AV1.
+ * @technical preview
+ */
VIDEO_CODEC_AV1 = 12,
/**
- * 5: VP9.
+ * 13: VP9.
*/
VIDEO_CODEC_VP9 = 13,
/**
@@ -1176,6 +1192,28 @@ enum VIDEO_CODEC_TYPE {
VIDEO_CODEC_GENERIC_JPEG = 20,
};
+/**
+ * Camera focal length type.
+ */
+enum CAMERA_FOCAL_LENGTH_TYPE {
+ /**
+ * By default, there are no wide-angle and ultra-wide-angle properties.
+ */
+ CAMERA_FOCAL_LENGTH_DEFAULT = 0,
+ /**
+ * Lens with focal length from 24mm to 35mm.
+ */
+ CAMERA_FOCAL_LENGTH_WIDE_ANGLE = 1,
+ /**
+ * Lens with focal length of less than 24mm.
+ */
+ CAMERA_FOCAL_LENGTH_ULTRA_WIDE = 2,
+ /**
+ * Telephoto lens.
+ */
+ CAMERA_FOCAL_LENGTH_TELEPHOTO = 3,
+};
+
/**
* The CC (Congestion Control) mode options.
*/
@@ -1311,6 +1349,10 @@ enum AUDIO_CODEC_TYPE {
* 12: LPCNET.
*/
AUDIO_CODEC_LPCNET = 12,
+ /**
+ * 13: Opus codec, supporting 3 to 8 channels audio.
+ */
+ AUDIO_CODEC_OPUSMC = 13,
};
/**
@@ -1511,13 +1553,38 @@ enum H264PacketizeMode {
*/
enum VIDEO_STREAM_TYPE {
/**
- * 0: The high-quality video stream, which has a higher resolution and bitrate.
+ * 0: The high-quality video stream, which has the highest resolution and bitrate.
*/
VIDEO_STREAM_HIGH = 0,
/**
- * 1: The low-quality video stream, which has a lower resolution and bitrate.
+ * 1: The low-quality video stream, which has the lowest resolution and bitrate.
*/
VIDEO_STREAM_LOW = 1,
+ /**
+ * 4: The video stream of layer_1, which has a lower resolution and bitrate than VIDEO_STREAM_HIGH.
+ */
+ VIDEO_STREAM_LAYER_1 = 4,
+ /**
+ * 5: The video stream of layer_2, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_1.
+ */
+ VIDEO_STREAM_LAYER_2 = 5,
+ /**
+ * 6: The video stream of layer_3, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_2.
+ */
+ VIDEO_STREAM_LAYER_3 = 6,
+ /**
+ * 7: The video stream of layer_4, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_3.
+ */
+ VIDEO_STREAM_LAYER_4 = 7,
+ /**
+ * 8: The video stream of layer_5, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_4.
+ */
+ VIDEO_STREAM_LAYER_5 = 8,
+ /**
+ * 9: The video stream of layer_6, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_5.
+ */
+ VIDEO_STREAM_LAYER_6 = 9,
+
};
struct VideoSubscriptionOptions {
@@ -1563,7 +1630,8 @@ struct EncodedVideoFrameInfo {
trackId(0),
captureTimeMs(0),
decodeTimeMs(0),
- streamType(VIDEO_STREAM_HIGH) {}
+ streamType(VIDEO_STREAM_HIGH),
+ presentationMs(-1) {}
EncodedVideoFrameInfo(const EncodedVideoFrameInfo& rhs)
: uid(rhs.uid),
@@ -1576,7 +1644,8 @@ struct EncodedVideoFrameInfo {
trackId(rhs.trackId),
captureTimeMs(rhs.captureTimeMs),
decodeTimeMs(rhs.decodeTimeMs),
- streamType(rhs.streamType) {}
+ streamType(rhs.streamType),
+ presentationMs(rhs.presentationMs) {}
EncodedVideoFrameInfo& operator=(const EncodedVideoFrameInfo& rhs) {
if (this == &rhs) return *this;
@@ -1591,6 +1660,7 @@ struct EncodedVideoFrameInfo {
captureTimeMs = rhs.captureTimeMs;
decodeTimeMs = rhs.decodeTimeMs;
streamType = rhs.streamType;
+ presentationMs = rhs.presentationMs;
return *this;
}
@@ -1642,6 +1712,8 @@ struct EncodedVideoFrameInfo {
*/
VIDEO_STREAM_TYPE streamType;
+ // @technical preview
+ int64_t presentationMs;
};
/**
@@ -1691,17 +1763,27 @@ struct AdvanceOptions {
*/
COMPRESSION_PREFERENCE compressionPreference;
+ /**
+ * Whether to encode and send the alpha data to the remote when alpha data is present.
+ * The default value is false.
+ */
+ bool encodeAlpha;
+
AdvanceOptions() : encodingPreference(PREFER_AUTO),
- compressionPreference(PREFER_LOW_LATENCY) {}
+ compressionPreference(PREFER_LOW_LATENCY),
+ encodeAlpha(false) {}
AdvanceOptions(ENCODING_PREFERENCE encoding_preference,
- COMPRESSION_PREFERENCE compression_preference) :
+ COMPRESSION_PREFERENCE compression_preference,
+ bool encode_alpha) :
encodingPreference(encoding_preference),
- compressionPreference(compression_preference) {}
+ compressionPreference(compression_preference),
+ encodeAlpha(encode_alpha) {}
bool operator==(const AdvanceOptions& rhs) const {
return encodingPreference == rhs.encodingPreference &&
- compressionPreference == rhs.compressionPreference;
+ compressionPreference == rhs.compressionPreference &&
+ encodeAlpha == rhs.encodeAlpha;
}
};
@@ -1724,6 +1806,17 @@ enum VIDEO_MIRROR_MODE_TYPE {
VIDEO_MIRROR_MODE_DISABLED = 2,
};
+#if defined(__APPLE__) && TARGET_OS_IOS
+/**
+ * Camera capturer configuration for format type.
+ */
+enum CAMERA_FORMAT_TYPE {
+ /** 0: (Default) NV12. */
+ CAMERA_FORMAT_NV12,
+ /** 1: BGRA. */
+ CAMERA_FORMAT_BGRA,
+};
+#endif
/** Supported codec type bit mask. */
enum CODEC_CAP_MASK {
@@ -1762,6 +1855,14 @@ struct CodecCapInfo {
CodecCapInfo(): codecType(VIDEO_CODEC_NONE), codecCapMask(0) {}
};
+/** FocalLengthInfo contains the IDs of the front and rear cameras, along with the wide-angle types. */
+struct FocalLengthInfo {
+ /** The camera direction. */
+ int cameraDirection;
+ /** Camera focal segment type. */
+ CAMERA_FOCAL_LENGTH_TYPE focalLengthType;
+};
+
/**
* The definition of the VideoEncoderConfiguration struct.
*/
@@ -1873,7 +1974,7 @@ struct VideoEncoderConfiguration {
AdvanceOptions advanceOptions;
VideoEncoderConfiguration(const VideoDimensions& d, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED)
- : codecType(VIDEO_CODEC_H265),
+ : codecType(VIDEO_CODEC_NONE),
dimensions(d),
frameRate(f),
bitrate(b),
@@ -1881,9 +1982,9 @@ struct VideoEncoderConfiguration {
orientationMode(m),
degradationPreference(MAINTAIN_QUALITY),
mirrorMode(mirror),
- advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {}
+ advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {}
VideoEncoderConfiguration(int width, int height, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED)
- : codecType(VIDEO_CODEC_H265),
+ : codecType(VIDEO_CODEC_NONE),
dimensions(width, height),
frameRate(f),
bitrate(b),
@@ -1891,7 +1992,7 @@ struct VideoEncoderConfiguration {
orientationMode(m),
degradationPreference(MAINTAIN_QUALITY),
mirrorMode(mirror),
- advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {}
+ advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {}
VideoEncoderConfiguration(const VideoEncoderConfiguration& config)
: codecType(config.codecType),
dimensions(config.dimensions),
@@ -1903,7 +2004,7 @@ struct VideoEncoderConfiguration {
mirrorMode(config.mirrorMode),
advanceOptions(config.advanceOptions) {}
VideoEncoderConfiguration()
- : codecType(VIDEO_CODEC_H265),
+ : codecType(VIDEO_CODEC_NONE),
dimensions(FRAME_WIDTH_960, FRAME_HEIGHT_540),
frameRate(FRAME_RATE_FPS_15),
bitrate(STANDARD_BITRATE),
@@ -1911,7 +2012,7 @@ struct VideoEncoderConfiguration {
orientationMode(ORIENTATION_MODE_ADAPTIVE),
degradationPreference(MAINTAIN_QUALITY),
mirrorMode(VIDEO_MIRROR_MODE_DISABLED),
- advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {}
+ advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {}
VideoEncoderConfiguration& operator=(const VideoEncoderConfiguration& rhs) {
if (this == &rhs) return *this;
@@ -1985,15 +2086,78 @@ struct SimulcastStreamConfig {
*/
int kBitrate;
/**
- * he capture frame rate (fps) of the local video. The default value is 5.
+ * The capture frame rate (fps) of the local video. The default value is 5.
*/
int framerate;
SimulcastStreamConfig() : dimensions(160, 120), kBitrate(65), framerate(5) {}
+ SimulcastStreamConfig(const SimulcastStreamConfig& other) : dimensions(other.dimensions), kBitrate(other.kBitrate), framerate(other.framerate) {}
bool operator==(const SimulcastStreamConfig& rhs) const {
return dimensions == rhs.dimensions && kBitrate == rhs.kBitrate && framerate == rhs.framerate;
}
};
+/**
+ * The configuration of the multi-layer video stream.
+ */
+struct SimulcastConfig {
+ /**
+ * The index of multi-layer video stream
+ */
+ enum StreamLayerIndex {
+ /**
+ * 0: video stream index of layer_1
+ */
+ STREAM_LAYER_1 = 0,
+ /**
+ * 1: video stream index of layer_2
+ */
+ STREAM_LAYER_2 = 1,
+ /**
+ * 2: video stream index of layer_3
+ */
+ STREAM_LAYER_3 = 2,
+ /**
+ * 3: video stream index of layer_4
+ */
+ STREAM_LAYER_4 = 3,
+ /**
+ * 4: video stream index of layer_5
+ */
+ STREAM_LAYER_5 = 4,
+ /**
+ * 5: video stream index of layer_6
+ */
+ STREAM_LAYER_6 = 5,
+ /**
+ * 6: video stream index of low
+ */
+ STREAM_LOW = 6,
+ /**
+ * 7: max count of video stream layers
+ */
+ STREAM_LAYER_COUNT_MAX = 7
+ };
+ struct StreamLayerConfig {
+ /**
+ * The video frame dimension. The default value is 0.
+ */
+ VideoDimensions dimensions;
+ /**
+ * The capture frame rate (fps) of the local video. The default value is 0.
+ */
+ int framerate;
+ /**
+ * Whether to enable the corresponding layer of video stream. The default value is false.
+ */
+ bool enable;
+ StreamLayerConfig() : dimensions(0, 0), framerate(0), enable(false) {}
+ };
+
+ /**
+ * The array of StreamLayerConfig, which contains STREAM_LAYER_COUNT_MAX layers of video stream at most.
+ */
+ StreamLayerConfig configs[STREAM_LAYER_COUNT_MAX];
+};
/**
* The location of the target area relative to the screen or window. If you do not set this parameter,
* the SDK selects the whole screen or window.
@@ -2591,6 +2755,10 @@ enum VIDEO_APPLICATION_SCENARIO_TYPE {
* 1: Meeting Scenario. This scenario is the best QoE practice of meeting application.
*/
APPLICATION_SCENARIO_MEETING = 1,
+ /**
+ * 2: Video Call Scenario. This scenario is used to optimize the video experience in video application, like 1v1 video call.
+ */
+ APPLICATION_SCENARIO_1V1 = 2,
};
/**
@@ -2635,6 +2803,27 @@ enum CAPTURE_BRIGHTNESS_LEVEL_TYPE {
CAPTURE_BRIGHTNESS_LEVEL_DARK = 2,
};
+enum CAMERA_STABILIZATION_MODE {
+ /** The camera stabilization mode is disabled.
+ */
+ CAMERA_STABILIZATION_MODE_OFF = -1,
+ /** device choose stabilization mode automatically.
+ */
+ CAMERA_STABILIZATION_MODE_AUTO = 0,
+ /** stabilization mode level 1.
+ */
+ CAMERA_STABILIZATION_MODE_LEVEL_1 = 1,
+ /** stabilization mode level 2.
+ */
+ CAMERA_STABILIZATION_MODE_LEVEL_2 = 2,
+ /** stabilization mode level 3.
+ */
+ CAMERA_STABILIZATION_MODE_LEVEL_3 = 3,
+ /** The maximum level of the camera stabilization mode.
+ */
+ CAMERA_STABILIZATION_MODE_MAX_LEVEL = CAMERA_STABILIZATION_MODE_LEVEL_3,
+};
+
/**
* Local audio states.
*/
@@ -2788,6 +2977,16 @@ enum LOCAL_VIDEO_STREAM_REASON {
* Check whether the ID of the video device is valid.
*/
LOCAL_VIDEO_STREAM_REASON_DEVICE_INVALID_ID = 10,
+ /**
+ * 14: (Android only) Video capture was interrupted, possibly due to the camera being occupied
+ * or some policy reasons such as background termination.
+ */
+ LOCAL_VIDEO_STREAM_REASON_DEVICE_INTERRUPT = 14,
+ /**
+ * 15: (Android only) The device may need to be shut down and restarted to restore camera function,
+ * or there may be a persistent hardware problem.
+ */
+ LOCAL_VIDEO_STREAM_REASON_DEVICE_FATAL_ERROR = 15,
/**
* 101: The current video capture device is unavailable due to excessive system pressure.
*/
@@ -2831,7 +3030,7 @@ enum LOCAL_VIDEO_STREAM_REASON {
LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_HIDDEN = 25,
/** 26: (Windows only) The local screen capture window is recovered from its hidden state. */
LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN = 26,
- /** 27:(Windows only) The window is recovered from miniminzed */
+ /** 27: (Windows and macOS only) The window is recovered from miniminzed */
LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_MINIMIZED = 27,
/**
* 28: The screen capture paused.
@@ -2843,6 +3042,8 @@ enum LOCAL_VIDEO_STREAM_REASON {
LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_PAUSED = 28,
/** 29: The screen capture is resumed. */
LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_RESUMED = 29,
+ /** 30: The shared display has been disconnected */
+ LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_DISPLAY_DISCONNECTED = 30,
};
@@ -2920,6 +3121,14 @@ enum REMOTE_AUDIO_STATE_REASON
* 7: The remote user leaves the channel.
*/
REMOTE_AUDIO_REASON_REMOTE_OFFLINE = 7,
+ /**
+ * 8: The local user does not receive any audio packet from remote user.
+ */
+ REMOTE_AUDIO_REASON_NO_PACKET_RECEIVE = 8,
+ /**
+ * 9: The local user receives remote audio packet but fails to play.
+ */
+ REMOTE_AUDIO_REASON_LOCAL_PLAY_FAILED = 9,
};
/**
@@ -3040,7 +3249,7 @@ enum REMOTE_USER_STATE {
struct VideoTrackInfo {
VideoTrackInfo()
: isLocal(false), ownerUid(0), trackId(0), channelId(OPTIONAL_NULLPTR)
- , streamType(VIDEO_STREAM_HIGH), codecType(VIDEO_CODEC_H265)
+ , codecType(VIDEO_CODEC_H265)
, encodedFrameOnly(false), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY)
, observationPosition(agora::media::base::POSITION_POST_CAPTURER) {}
/**
@@ -3061,10 +3270,6 @@ struct VideoTrackInfo {
* The channel ID of the video track.
*/
const char* channelId;
- /**
- * The video stream type: #VIDEO_STREAM_TYPE.
- */
- VIDEO_STREAM_TYPE streamType;
/**
* The video codec type: #VIDEO_CODEC_TYPE.
*/
@@ -4112,12 +4317,14 @@ enum CLIENT_ROLE_CHANGE_FAILED_REASON {
CLIENT_ROLE_CHANGE_FAILED_NOT_AUTHORIZED = 2,
/**
* 3: The operation of changing role is timeout.
+ * @deprecated This reason is deprecated.
*/
- CLIENT_ROLE_CHANGE_FAILED_REQUEST_TIME_OUT = 3,
+ CLIENT_ROLE_CHANGE_FAILED_REQUEST_TIME_OUT __deprecated = 3,
/**
* 4: The operation of changing role is interrupted since we lost connection with agora service.
+ * @deprecated This reason is deprecated.
*/
- CLIENT_ROLE_CHANGE_FAILED_CONNECTION_FAILED = 4,
+ CLIENT_ROLE_CHANGE_FAILED_CONNECTION_FAILED __deprecated = 4,
};
/**
@@ -4359,6 +4566,85 @@ struct BeautyOptions {
BeautyOptions() : lighteningContrastLevel(LIGHTENING_CONTRAST_NORMAL), lighteningLevel(0), smoothnessLevel(0), rednessLevel(0), sharpnessLevel(0) {}
};
+/** Face shape area options. This structure defines options for facial adjustments on different facial areas.
+ *
+ * @technical preview
+ */
+struct FaceShapeAreaOptions {
+ /** The specific facial area to be adjusted.
+ */
+ enum FACE_SHAPE_AREA {
+ /** (Default) Invalid area. */
+ FACE_SHAPE_AREA_NONE = -1,
+ /** Head Scale, reduces the size of head. */
+ FACE_SHAPE_AREA_HEADSCALE = 0,
+ /** Forehead, adjusts the size of forehead. */
+ FACE_SHAPE_AREA_FOREHEAD = 1,
+ /** Face Contour, slims the facial contour. */
+ FACE_SHAPE_AREA_FACECONTOUR = 2,
+ /** Face Length, adjusts the length of face. */
+ FACE_SHAPE_AREA_FACELENGTH = 3,
+ /** Face Width, narrows the width of face. */
+ FACE_SHAPE_AREA_FACEWIDTH = 4,
+ /** Cheekbone, adjusts the size of cheekbone. */
+ FACE_SHAPE_AREA_CHEEKBONE = 5,
+ /** Cheek, adjusts the size of cheek. */
+ FACE_SHAPE_AREA_CHEEK = 6,
+ /** Chin, adjusts the length of chin. */
+ FACE_SHAPE_AREA_CHIN = 7,
+ /** Eye Scale, adjusts the size of eyes. */
+ FACE_SHAPE_AREA_EYESCALE = 8,
+ /** Nose Length, adjusts the length of nose. */
+ FACE_SHAPE_AREA_NOSELENGTH = 9,
+ /** Nose Width, adjusts the width of nose. */
+ FACE_SHAPE_AREA_NOSEWIDTH = 10,
+ /** Mouth Scale, adjusts the size of mouth. */
+ FACE_SHAPE_AREA_MOUTHSCALE = 11,
+ };
+
+ /** The specific facial area to be adjusted, See #FACE_SHAPE_AREA.
+ */
+ FACE_SHAPE_AREA shapeArea;
+
+ /** The intensity of the pinching effect applied to the specified facial area.
+ * For the following area values: #FACE_SHAPE_AREA_FOREHEAD, #FACE_SHAPE_AREA_FACELENGTH, #FACE_SHAPE_AREA_CHIN, #FACE_SHAPE_AREA_NOSELENGTH, #FACE_SHAPE_AREA_NOSEWIDTH, #FACE_SHAPE_AREA_MOUTHSCALE, the value ranges from -100 to 100.
+ * The default value is 0. The greater the absolute value, the stronger the intensity applied to the specified facial area, and negative values indicate the opposite direction.
+ * For enumeration values other than the above, the value ranges from 0 to 100. The default value is 0. The greater the value, the stronger the intensity applied to the specified facial area.
+ */
+ int shapeIntensity;
+
+ FaceShapeAreaOptions(FACE_SHAPE_AREA shapeArea, int areaIntensity) : shapeArea(shapeArea), shapeIntensity(areaIntensity) {}
+
+ FaceShapeAreaOptions() : shapeArea(FACE_SHAPE_AREA_NONE), shapeIntensity(0) {}
+};
+
+/** Face shape beauty options. This structure defines options for facial adjustments of different facial styles.
+ *
+ * @technical preview
+ */
+struct FaceShapeBeautyOptions {
+ /** The face shape style.
+ */
+ enum FACE_SHAPE_BEAUTY_STYLE {
+ /** (Default) Female face shape style. */
+ FACE_SHAPE_BEAUTY_STYLE_FEMALE = 0,
+ /** Male face shape style. */
+ FACE_SHAPE_BEAUTY_STYLE_MALE = 1,
+ };
+
+ /** The face shape style, See #FACE_SHAPE_BEAUTY_STYLE.
+ */
+ FACE_SHAPE_BEAUTY_STYLE shapeStyle;
+
+ /** The intensity of the pinching effect applied to the specified facial style. The value ranges from 0 (original) to 100. The default value is 0. The greater the value, the stronger the intensity applied to face pinching.
+ */
+ int styleIntensity;
+
+ FaceShapeBeautyOptions(FACE_SHAPE_BEAUTY_STYLE shapeStyle, int styleIntensity) : shapeStyle(shapeStyle), styleIntensity(styleIntensity) {}
+
+ FaceShapeBeautyOptions() : shapeStyle(FACE_SHAPE_BEAUTY_STYLE_FEMALE), styleIntensity(50) {}
+};
+
struct LowlightEnhanceOptions {
/**
* The low-light enhancement mode.
@@ -4682,6 +4968,7 @@ enum VOICE_BEAUTIFIER_PRESET {
* - `ROOM_ACOUSTICS_PHONOGRAPH`
* - `ROOM_ACOUSTICS_SPACIAL`
* - `ROOM_ACOUSTICS_ETHEREAL`
+ * - `ROOM_ACOUSTICS_CHORUS`
* - `VOICE_CHANGER_EFFECT_UNCLE`
* - `VOICE_CHANGER_EFFECT_OLDMAN`
* - `VOICE_CHANGER_EFFECT_BOY`
@@ -4743,6 +5030,14 @@ enum AUDIO_EFFECT_PRESET {
* setting this enumerator.
*/
ROOM_ACOUSTICS_VIRTUAL_SURROUND_SOUND = 0x02010900,
+ /** The voice effect for chorus.
+ *
+ * @note: To achieve better audio effect quality, Agora recommends calling \ref
+ * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `profile` parameter to
+ * `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` before
+ * setting this enumerator.
+ */
+ ROOM_ACOUSTICS_CHORUS = 0x02010D00,
/** A middle-aged man's voice.
*
* @note
@@ -4875,6 +5170,41 @@ enum HEADPHONE_EQUALIZER_PRESET {
HEADPHONE_EQUALIZER_INEAR = 0x04000002
};
+/** The options for SDK voice AI tuner.
+ */
+enum VOICE_AI_TUNER_TYPE {
+ /** Uncle, deep and magnetic male voice.
+ */
+ VOICE_AI_TUNER_MATURE_MALE,
+ /** Fresh male, refreshing and sweet male voice.
+ */
+ VOICE_AI_TUNER_FRESH_MALE,
+ /** Big sister, deep and charming female voice.
+ */
+ VOICE_AI_TUNER_ELEGANT_FEMALE,
+ /** Lolita, high-pitched and cute female voice.
+ */
+ VOICE_AI_TUNER_SWEET_FEMALE,
+ /** Warm man singing, warm and melodic male voice that is suitable for male lyrical songs.
+ */
+ VOICE_AI_TUNER_WARM_MALE_SINGING,
+ /** Gentle female singing, soft and delicate female voice that is suitable for female lyrical songs.
+ */
+ VOICE_AI_TUNER_GENTLE_FEMALE_SINGING,
+ /** Smoky uncle singing, unique husky male voice that is suitable for rock or blues songs.
+ */
+ VOICE_AI_TUNER_HUSKY_MALE_SINGING,
+ /** Warm big sister singing, warm and mature female voice that is suitable for emotionally powerful songs.
+ */
+ VOICE_AI_TUNER_WARM_ELEGANT_FEMALE_SINGING,
+ /** Forceful male singing, strong and powerful male voice that is suitable for passionate songs.
+ */
+ VOICE_AI_TUNER_POWERFUL_MALE_SINGING,
+ /** Dreamy female singing, dreamlike and soft female voice that is suitable for airy and dream-like songs.
+ */
+ VOICE_AI_TUNER_DREAMY_FEMALE_SINGING,
+};
+
/**
* Screen sharing configurations.
*/
@@ -5187,6 +5517,10 @@ enum AREA_CODE {
AREA_CODE_GLOB = (0xFFFFFFFF)
};
+/**
+ Extra region code
+ @technical preview
+*/
enum AREA_CODE_EX {
/**
* Oceania
@@ -5212,6 +5546,10 @@ enum AREA_CODE_EX {
* United States
*/
AREA_CODE_US = 0x00000800,
+ /**
+ * Russia
+ */
+ AREA_CODE_RU = 0x00001000,
/**
* The global area (except China)
*/
@@ -5530,10 +5868,13 @@ struct EncryptionConfig {
* In this case, ensure that this parameter is not 0.
*/
uint8_t encryptionKdfSalt[32];
+
+ bool datastreamEncryptionEnabled;
EncryptionConfig()
: encryptionMode(AES_128_GCM2),
- encryptionKey(OPTIONAL_NULLPTR)
+ encryptionKey(OPTIONAL_NULLPTR),
+ datastreamEncryptionEnabled(false)
{
memset(encryptionKdfSalt, 0, sizeof(encryptionKdfSalt));
}
@@ -5573,13 +5914,21 @@ enum ENCRYPTION_ERROR_TYPE {
*/
ENCRYPTION_ERROR_INTERNAL_FAILURE = 0,
/**
- * 1: Decryption errors. Ensure that the receiver and the sender use the same encryption mode and key.
+ * 1: MediaStream decryption errors. Ensure that the receiver and the sender use the same encryption mode and key.
*/
ENCRYPTION_ERROR_DECRYPTION_FAILURE = 1,
/**
- * 2: Encryption errors.
+ * 2: MediaStream encryption errors.
*/
ENCRYPTION_ERROR_ENCRYPTION_FAILURE = 2,
+ /**
+ * 3: DataStream decryption errors. Ensure that the receiver and the sender use the same encryption mode and key.
+ */
+ ENCRYPTION_ERROR_DATASTREAM_DECRYPTION_FAILURE = 3,
+ /**
+ * 4: DataStream encryption errors.
+ */
+ ENCRYPTION_ERROR_DATASTREAM_ENCRYPTION_FAILURE = 4,
};
enum UPLOAD_ERROR_REASON
@@ -5621,8 +5970,8 @@ enum STREAM_SUBSCRIBE_STATE {
* - Calls `enableLocalAudio(false)` or `enableLocalVideo(false)` to disable the local audio or video capture.
* - The role of the remote user is audience.
* - The local user calls the following methods to stop receiving remote streams:
- * - Calls `muteRemoteAudioStream(true)`, `muteAllRemoteAudioStreams(true)` or `setDefaultMuteAllRemoteAudioStreams(true)` to stop receiving the remote audio streams.
- * - Calls `muteRemoteVideoStream(true)`, `muteAllRemoteVideoStreams(true)` or `setDefaultMuteAllRemoteVideoStreams(true)` to stop receiving the remote video streams.
+ * - Calls `muteRemoteAudioStream(true)`, `muteAllRemoteAudioStreams(true)` to stop receiving the remote audio streams.
+ * - Calls `muteRemoteVideoStream(true)`, `muteAllRemoteVideoStreams(true)` to stop receiving the remote video streams.
*/
SUB_STATE_NO_SUBSCRIBED = 1,
/**
@@ -5713,7 +6062,12 @@ enum EAR_MONITORING_FILTER_TYPE {
/**
* 4: Enable noise suppression to the in-ear monitor.
*/
- EAR_MONITORING_FILTER_NOISE_SUPPRESSION = (1<<2)
+ EAR_MONITORING_FILTER_NOISE_SUPPRESSION = (1<<2),
+ /**
+ * 32768: Enable audio filters by reuse post-processing filter to the in-ear monitor.
+ * This bit is intended to be used in exclusive mode, which means, if this bit is set, all other bits will be disregarded.
+ */
+ EAR_MONITORING_FILTER_REUSE_POST_PROCESSING_FILTER = (1<<15),
};
/**
@@ -5993,7 +6347,13 @@ struct LocalAccessPointConfiguration {
/** Local proxy connection, advanced Config info.
*/
AdvancedConfigInfo advancedConfig;
- LocalAccessPointConfiguration() : ipList(NULL), ipListSize(0), domainList(NULL), domainListSize(0), verifyDomainName(NULL), mode(ConnectivityFirst) {}
+ /**
+ * Whether to disable vos-aut:
+ - true: (Default)disable vos-aut.
+ - false: not disable vos-aut
+ */
+ bool disableAut;
+ LocalAccessPointConfiguration() : ipList(NULL), ipListSize(0), domainList(NULL), domainListSize(0), verifyDomainName(NULL), mode(ConnectivityFirst), disableAut(true) {}
};
/**
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraExtensionVersion.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraExtensionVersion.h
index 988e5ecc8..da4d563a3 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraExtensionVersion.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraExtensionVersion.h
@@ -58,6 +58,7 @@ class IExtensionProvider;
class IExtensionProviderV2;
class IExtensionProviderV3;
class IAudioFilter;
+class IAudioFilterV2;
class IExtensionVideoFilter;
class IScreenCaptureSource;
@@ -85,6 +86,13 @@ struct ExtensionInterfaceVersion {
}
};
+template <>
+struct ExtensionInterfaceVersion {
+ static ExtensionVersion Version() {
+ return BUMP_MAJOR_VERSION(ExtensionInterfaceVersion::Version());
+ }
+};
+
template <>
struct ExtensionInterfaceVersion {
static ExtensionVersion Version() {
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h
index 15dfd4b38..8120acb3f 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h
@@ -35,6 +35,32 @@ static const unsigned int DEFAULT_CONNECTION_ID = 0;
static const unsigned int DUMMY_CONNECTION_ID = (std::numeric_limits::max)();
struct EncodedVideoFrameInfo;
+/**
+* The definition of extension context types.
+**/
+struct ExtensionContext {
+ /**
+ * Whether the uid is valid.
+ * - true: The uid is valid.
+ * - false: The uid is invalid.
+ */
+ bool isValid;
+ /**
+ * The ID of the user.
+ * A uid of 0 indicates the local user, and a uid greater than 0 represents a remote user.
+ */
+ uid_t uid;
+ /**
+ * The provider name of the current extension.
+ */
+ const char *providerName;
+ /**
+ * The extension name of the current extension.
+ */
+ const char *extensionName;
+ ExtensionContext():isValid(false), uid(0), providerName(NULL), extensionName(NULL) {}
+};
+
/**
* Video source types definition.
@@ -88,6 +114,9 @@ enum VIDEO_SOURCE_TYPE {
/** Video for fourth screen sharing.
*/
VIDEO_SOURCE_SCREEN_FOURTH = 14,
+ /** Video for voice drive.
+ */
+ VIDEO_SOURCE_SPEECH_DRIVEN = 15,
VIDEO_SOURCE_UNKNOWN = 100
};
@@ -122,9 +151,9 @@ enum AudioRoute
*/
ROUTE_LOUDSPEAKER = 4,
/**
- * The Bluetooth Headset via HFP.
+ * The Bluetooth Device via HFP.
*/
- ROUTE_HEADSETBLUETOOTH = 5,
+ ROUTE_BLUETOOTH_DEVICE_HFP = 5,
/**
* The USB.
*/
@@ -142,9 +171,9 @@ enum AudioRoute
*/
ROUTE_AIRPLAY = 9,
/**
- * The Bluetooth Speaker via A2DP.
+ * The Bluetooth Device via A2DP.
*/
- ROUTE_BLUETOOTH_SPEAKER = 10,
+ ROUTE_BLUETOOTH_DEVICE_A2DP = 10,
};
/**
@@ -242,6 +271,10 @@ enum MEDIA_SOURCE_TYPE {
* 12: Video for transcoded.
*/
TRANSCODED_VIDEO_SOURCE = 12,
+ /**
+ * 13: Video for voice drive.
+ */
+ SPEECH_DRIVEN_VIDEO_SOURCE = 13,
/**
* 100: Internal Usage only.
*/
@@ -395,24 +428,31 @@ struct AudioPcmFrame {
rtc::BYTES_PER_SAMPLE bytes_per_sample;
/** The audio frame data. */
int16_t data_[kMaxDataSizeSamples];
+
+ /**
+ * @technical preview
+ * data_[kMaxDataSizeSamples] is real stereo data
+ */
+ bool is_stereo_;
AudioPcmFrame& operator=(const AudioPcmFrame& src) {
- if(this == &src) {
+ if (this == &src) {
return *this;
}
- this->capture_timestamp = src.capture_timestamp;
- this->samples_per_channel_ = src.samples_per_channel_;
- this->sample_rate_hz_ = src.sample_rate_hz_;
- this->bytes_per_sample = src.bytes_per_sample;
- this->num_channels_ = src.num_channels_;
+ capture_timestamp = src.capture_timestamp;
+ samples_per_channel_ = src.samples_per_channel_;
+ sample_rate_hz_ = src.sample_rate_hz_;
+ bytes_per_sample = src.bytes_per_sample;
+ num_channels_ = src.num_channels_;
+ is_stereo_ = src.is_stereo_;
size_t length = src.samples_per_channel_ * src.num_channels_;
if (length > kMaxDataSizeSamples) {
length = kMaxDataSizeSamples;
}
- memcpy(this->data_, src.data_, length * sizeof(int16_t));
+ memcpy(data_, src.data_, length * sizeof(int16_t));
return *this;
}
@@ -422,7 +462,8 @@ struct AudioPcmFrame {
samples_per_channel_(0),
sample_rate_hz_(0),
num_channels_(0),
- bytes_per_sample(rtc::TWO_BYTES_PER_SAMPLE) {
+ bytes_per_sample(rtc::TWO_BYTES_PER_SAMPLE),
+ is_stereo_(false) {
memset(data_, 0, sizeof(data_));
}
@@ -431,7 +472,8 @@ struct AudioPcmFrame {
samples_per_channel_(src.samples_per_channel_),
sample_rate_hz_(src.sample_rate_hz_),
num_channels_(src.num_channels_),
- bytes_per_sample(src.bytes_per_sample) {
+ bytes_per_sample(src.bytes_per_sample),
+ is_stereo_(src.is_stereo_) {
size_t length = src.samples_per_channel_ * src.num_channels_;
if (length > kMaxDataSizeSamples) {
length = kMaxDataSizeSamples;
@@ -502,6 +544,10 @@ enum VIDEO_PIXEL_FORMAT {
14: pixel format for iOS CVPixelBuffer BGRA
*/
VIDEO_CVPIXEL_BGRA = 14,
+ /**
+ 15: pixel format for iOS CVPixelBuffer P010(10bit NV12)
+ */
+ VIDEO_CVPIXEL_P010 = 15,
/**
* 16: I422.
*/
@@ -510,6 +556,11 @@ enum VIDEO_PIXEL_FORMAT {
* 17: ID3D11Texture2D, only support DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_TYPELESS, DXGI_FORMAT_NV12 texture format
*/
VIDEO_TEXTURE_ID3D11TEXTURE2D = 17,
+ /**
+ * 18: I010. 10bit I420 data.
+ * @technical preview
+ */
+ VIDEO_PIXEL_I010 = 18,
};
/**
@@ -565,6 +616,191 @@ class IVideoFrameMetaInfo {
virtual const char* getMetaInfoStr(META_INFO_KEY key) const = 0;
};
+struct ColorSpace {
+ enum PrimaryID {
+ // The indices are equal to the values specified in T-REC H.273 Table 2.
+ PRIMARYID_BT709 = 1,
+ PRIMARYID_UNSPECIFIED = 2,
+ PRIMARYID_BT470M = 4,
+ PRIMARYID_BT470BG = 5,
+ PRIMARYID_SMPTE170M = 6, // Identical to BT601
+ PRIMARYID_SMPTE240M = 7,
+ PRIMARYID_FILM = 8,
+ PRIMARYID_BT2020 = 9,
+ PRIMARYID_SMPTEST428 = 10,
+ PRIMARYID_SMPTEST431 = 11,
+ PRIMARYID_SMPTEST432 = 12,
+ PRIMARYID_JEDECP22 = 22, // Identical to EBU3213-E
+ };
+
+ enum RangeID {
+ // The indices are equal to the values specified at
+ // https://www.webmproject.org/docs/container/#colour for the element Range.
+ RANGEID_INVALID = 0,
+ // Limited Rec. 709 color range with RGB values ranging from 16 to 235.
+ RANGEID_LIMITED = 1,
+ // Full RGB color range with RGB valees from 0 to 255.
+ RANGEID_FULL = 2,
+ // Range is defined by MatrixCoefficients/TransferCharacteristics.
+ RANGEID_DERIVED = 3,
+ };
+
+ enum MatrixID {
+ // The indices are equal to the values specified in T-REC H.273 Table 4.
+ MATRIXID_RGB = 0,
+ MATRIXID_BT709 = 1,
+ MATRIXID_UNSPECIFIED = 2,
+ MATRIXID_FCC = 4,
+ MATRIXID_BT470BG = 5,
+ MATRIXID_SMPTE170M = 6,
+ MATRIXID_SMPTE240M = 7,
+ MATRIXID_YCOCG = 8,
+ MATRIXID_BT2020_NCL = 9,
+ MATRIXID_BT2020_CL = 10,
+ MATRIXID_SMPTE2085 = 11,
+ MATRIXID_CDNCLS = 12,
+ MATRIXID_CDCLS = 13,
+ MATRIXID_BT2100_ICTCP = 14,
+ };
+
+ enum TransferID {
+ // The indices are equal to the values specified in T-REC H.273 Table 3.
+ TRANSFERID_BT709 = 1,
+ TRANSFERID_UNSPECIFIED = 2,
+ TRANSFERID_GAMMA22 = 4,
+ TRANSFERID_GAMMA28 = 5,
+ TRANSFERID_SMPTE170M = 6,
+ TRANSFERID_SMPTE240M = 7,
+ TRANSFERID_LINEAR = 8,
+ TRANSFERID_LOG = 9,
+ TRANSFERID_LOG_SQRT = 10,
+ TRANSFERID_IEC61966_2_4 = 11,
+ TRANSFERID_BT1361_ECG = 12,
+ TRANSFERID_IEC61966_2_1 = 13,
+ TRANSFERID_BT2020_10 = 14,
+ TRANSFERID_BT2020_12 = 15,
+ TRANSFERID_SMPTEST2084 = 16,
+ TRANSFERID_SMPTEST428 = 17,
+ TRANSFERID_ARIB_STD_B67 = 18,
+ };
+
+ PrimaryID primaries;
+ TransferID transfer;
+ MatrixID matrix;
+ RangeID range;
+
+ ColorSpace()
+ : primaries(PRIMARYID_UNSPECIFIED), transfer(TRANSFERID_UNSPECIFIED),
+ matrix(MATRIXID_UNSPECIFIED), range(RANGEID_INVALID) {}
+
+ bool validate() const {
+ return primaries != PRIMARYID_UNSPECIFIED || transfer != TRANSFERID_UNSPECIFIED ||
+ matrix != MATRIXID_UNSPECIFIED ||
+ range != RANGEID_INVALID;
+ }
+};
+
+/**
+ * The definition of the Hdr10MetadataInfo struct.
+ */
+struct Hdr10MetadataInfo {
+ /**
+ * The x coordinates of the red value in the CIE1931 color space. The values need to normalized to 50,000.
+ */
+ uint16_t redPrimaryX;
+ /**
+ * The y coordinates of the red value in the CIE1931 color space. The values need to normalized to 50,000.
+ */
+ uint16_t redPrimaryY;
+ /**
+ * The x coordinates of the green value in the CIE1931 color space. The values need to normalized to 50,000.
+ */
+ uint16_t greenPrimaryX;
+ /**
+ * The y coordinates of the green value in the CIE1931 color space. The values need to normalized to 50,000.
+ */
+ uint16_t greenPrimaryY;
+ /**
+ * The x coordinates of the blue value in the CIE1931 color space. The values need to normalized to 50,000.
+ */
+ uint16_t bluePrimaryX;
+ /**
+ * The y coordinates of the blue value in the CIE1931 color space. The values need to normalized to 50,000.
+ */
+ uint16_t bluePrimaryY;
+ /**
+ * The x coordinates of the white point in the CIE1931 color space.The values need to normalized to 50,000.
+ */
+ uint16_t whitePointX;
+ /**
+ * The y coordinates of the white point in the CIE1931 color space.The values need to normalized to 50,000.
+ */
+ uint16_t whitePointY;
+ /**
+ * The maximum number of nits of the display used to master the content. The values need to normalized to 10,000.
+ */
+ unsigned int maxMasteringLuminance;
+ /**
+ * The minimum number of nits of the display used to master the content. The values need to normalized to 10,000.
+ */
+ unsigned int minMasteringLuminance;
+ /**
+ * The maximum content light level (MaxCLL). This is the nit value corresponding to the brightest pixel used anywhere in the content.
+ */
+ uint16_t maxContentLightLevel;
+ /**
+ * The maximum frame average light level (MaxFALL). This is the nit value corresponding to the average luminance of the frame which has the brightest average luminance anywhere in the content.
+ */
+ uint16_t maxFrameAverageLightLevel;
+
+ Hdr10MetadataInfo()
+ : redPrimaryX(0),
+ redPrimaryY(0),
+ greenPrimaryX(0),
+ greenPrimaryY(0),
+ bluePrimaryX(0),
+ bluePrimaryY(0),
+ whitePointX(0),
+ whitePointY(0),
+ maxMasteringLuminance(0),
+ minMasteringLuminance(0),
+ maxContentLightLevel(0),
+ maxFrameAverageLightLevel(0){}
+
+ bool validate() const {
+ return maxContentLightLevel >= 0 && maxContentLightLevel <= 20000 &&
+ maxFrameAverageLightLevel >= 0 &&
+ maxFrameAverageLightLevel <= 20000;
+ }
+};
+
+/**
+ * The relative position between alphabuffer and the frame.
+ */
+enum ALPHA_STITCH_MODE {
+ /**
+ * 0: Normal frame without alphabuffer stitched
+ */
+ NO_ALPHA_STITCH = 0,
+ /**
+ * 1: Alphabuffer is above the frame
+ */
+ ALPHA_STITCH_UP = 1,
+ /**
+ * 2: Alphabuffer is below the frame
+ */
+ ALPHA_STITCH_BELOW = 2,
+ /**
+ * 3: Alphabuffer is on the left of frame
+ */
+ ALPHA_STITCH_LEFT = 3,
+ /**
+ * 4: Alphabuffer is on the right of frame
+ */
+ ALPHA_STITCH_RIGHT = 4,
+};
+
+
/**
* The definition of the ExternalVideoFrame struct.
*/
@@ -584,11 +820,14 @@ struct ExternalVideoFrame {
eglContext(NULL),
eglType(EGL_CONTEXT10),
textureId(0),
- metadata_buffer(NULL),
- metadata_size(0),
+ fenceObject(0),
+ metadataBuffer(NULL),
+ metadataSize(0),
alphaBuffer(NULL),
- d3d11_texture_2d(NULL),
- texture_slice_index(0){}
+ fillAlphaBuffer(false),
+ alphaStitchMode(NO_ALPHA_STITCH),
+ d3d11Texture2d(NULL),
+ textureSliceIndex(0){}
/**
* The EGL context type.
@@ -690,6 +929,11 @@ struct ExternalVideoFrame {
* [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix.
*/
int textureId;
+ /**
+ * [Texture related parameter] The fence object related to the textureId parameter, indicating the synchronization status of the video data in Texture format.
+ * The default value is 0
+ */
+ long long fenceObject;
/**
* [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix.
*/
@@ -698,28 +942,53 @@ struct ExternalVideoFrame {
* [Texture related parameter] The MetaData buffer.
* The default value is NULL
*/
- uint8_t* metadata_buffer;
+ uint8_t* metadataBuffer;
/**
* [Texture related parameter] The MetaData size.
* The default value is 0
*/
- int metadata_size;
+ int metadataSize;
/**
- * Indicates the output data of the portrait segmentation algorithm, which is consistent with the size of the video frame.
- * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground (portrait).
- * The default value is NULL
+ * Indicates the alpha channel of current frame, which is consistent with the dimension of the video frame.
+ * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground.
+ * The default value is NULL.
*/
uint8_t* alphaBuffer;
+ /**
+ * [For bgra or rgba only] Extract alphaBuffer from bgra or rgba data. Set it true if you do not explicitly specify the alphabuffer.
+ * The default value is false
+ */
+ bool fillAlphaBuffer;
+ /**
+ * The relative position between alphabuffer and the frame.
+ * 0: Normal frame;
+ * 1: Alphabuffer is above the frame;
+ * 2: Alphabuffer is below the frame;
+ * 3: Alphabuffer is on the left of frame;
+ * 4: Alphabuffer is on the right of frame;
+ * The default value is 0.
+ */
+ ALPHA_STITCH_MODE alphaStitchMode;
/**
* [For Windows only] The pointer of ID3D11Texture2D used by the video frame.
*/
- void *d3d11_texture_2d;
+ void *d3d11Texture2d;
/**
* [For Windows only] The index of ID3D11Texture2D array used by the video frame.
*/
- int texture_slice_index;
+ int textureSliceIndex;
+
+ /**
+ * metadata info used for hdr video data
+ */
+ Hdr10MetadataInfo hdr10MetadataInfo;
+
+ /**
+ * The ColorSpace of the video frame.
+ */
+ ColorSpace colorSpace;
};
/**
@@ -745,6 +1014,7 @@ struct VideoFrame {
textureId(0),
d3d11Texture2d(NULL),
alphaBuffer(NULL),
+ alphaStitchMode(NO_ALPHA_STITCH),
pixelBuffer(NULL),
metaInfo(NULL){
memset(matrix, 0, sizeof(matrix));
@@ -827,11 +1097,21 @@ struct VideoFrame {
*/
float matrix[16];
/**
- * Indicates the output data of the portrait segmentation algorithm, which is consistent with the size of the video frame.
- * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground (portrait).
- * The default value is NULL
+ * Indicates the alpha channel of current frame, which is consistent with the dimension of the video frame.
+ * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground.
+ * The default value is NULL.
*/
uint8_t* alphaBuffer;
+ /**
+ * The relative position between alphabuffer and the frame.
+ * 0: Normal frame;
+ * 1: Alphabuffer is above the frame;
+ * 2: Alphabuffer is below the frame;
+ * 3: Alphabuffer is on the left of frame;
+ * 4: Alphabuffer is on the right of frame;
+ * The default value is 0.
+ */
+ ALPHA_STITCH_MODE alphaStitchMode;
/**
*The type of CVPixelBufferRef, for iOS and macOS only.
*/
@@ -840,6 +1120,16 @@ struct VideoFrame {
* The pointer to IVideoFrameMetaInfo, which is the interface to get metainfo contents from VideoFrame.
*/
IVideoFrameMetaInfo* metaInfo;
+
+ /**
+ * metadata info used for hdr video data
+ */
+ Hdr10MetadataInfo hdr10MetadataInfo;
+
+ /**
+ * The ColorSpace of the video frame
+ */
+ ColorSpace colorSpace;
};
/**
@@ -981,6 +1271,10 @@ class IAudioFrameObserverBase {
* The number of the audio track.
*/
int audioTrackNumber;
+ /**
+ * RTP timestamp of the first sample in the audio frame
+ */
+ uint32_t rtpTimestamp;
AudioFrame() : type(FRAME_TYPE_PCM16),
samplesPerChannel(0),
@@ -991,7 +1285,8 @@ class IAudioFrameObserverBase {
renderTimeMs(0),
avsync_type(0),
presentationMs(0),
- audioTrackNumber(0) {}
+ audioTrackNumber(0),
+ rtpTimestamp(0) {}
};
enum AUDIO_FRAME_POSITION {
@@ -1609,6 +1904,21 @@ struct MediaRecorderConfiguration {
MediaRecorderConfiguration() : storagePath(NULL), containerFormat(FORMAT_MP4), streamType(STREAM_TYPE_BOTH), maxDurationMs(120000), recorderInfoUpdateInterval(0) {}
MediaRecorderConfiguration(const char* path, MediaRecorderContainerFormat format, MediaRecorderStreamType type, int duration, int interval) : storagePath(path), containerFormat(format), streamType(type), maxDurationMs(duration), recorderInfoUpdateInterval(interval) {}
};
+
+class IFaceInfoObserver {
+public:
+ /**
+ * Occurs when the face info is received.
+ * @param outFaceInfo The output face info.
+ * @return
+ * - true: The face info is valid.
+ * - false: The face info is invalid.
+ */
+ virtual bool onFaceInfo(const char* outFaceInfo) = 0;
+
+ virtual ~IFaceInfoObserver() {}
+};
+
/**
* Information for the recording file.
*
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraFileUploader.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraFileUploader.h
index f0611fe38..f531e4853 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraFileUploader.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraFileUploader.h
@@ -9,7 +9,7 @@
#pragma once // NOLINT(build/header_guard)
#include "AgoraRefPtr.h"
-#include
+#include
namespace agora {
namespace rtc {
@@ -38,8 +38,8 @@ struct ImagePayloadData {
class IFileUploaderService : public RefCountInterface {
public:
virtual ~IFileUploaderService() {}
- virtual int startImageUpload(const ImagePayloadData* imgData, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
- virtual int stopImageUpload(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int startImageUpload(const ImagePayloadData* imgData, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int stopImageUpload(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
};
} // namespace rtc
} // namespace agora
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraLog.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraLog.h
index 2fae3aa13..20b6416ef 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraLog.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraLog.h
@@ -37,6 +37,7 @@ OPTIONAL_ENUM_CLASS LOG_LEVEL {
LOG_LEVEL_ERROR = 0x0004,
LOG_LEVEL_FATAL = 0x0008,
LOG_LEVEL_API_CALL = 0x0010,
+ LOG_LEVEL_DEBUG = 0x0020,
};
/*
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraMediaPlayerSource.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraMediaPlayerSource.h
index 00be02233..99da405bc 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraMediaPlayerSource.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraMediaPlayerSource.h
@@ -42,17 +42,6 @@ class IMediaPlayerSource : public RefCountInterface {
* - < 0: Failure.
*/
virtual int open(const char* url, int64_t startPos) = 0;
-
- /**
- * @deprecated
- * @brief Open media file or stream with custom soucrce.
- * @param startPos Set the starting position for playback, in seconds
- * @param observer dataProvider object
- * @return
- * - 0: Success.
- * - < 0: Failure.
- */
- virtual int openWithCustomSource(int64_t startPos, media::base::IMediaPlayerCustomDataProvider* provider) __deprecated = 0;
/**
* Opens a media file with a media file source.
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraParameter.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraParameter.h
index b88969e1d..f50afe9b5 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraParameter.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraParameter.h
@@ -39,8 +39,7 @@
* set the video encoder mode (hardware or software)
*/
#define KEY_RTC_VIDEO_ENABLED_HW_ENCODER "engine.video.enable_hw_encoder"
-#define KEY_RTC_VIDEO_HARDWARE_ENCODEING "che.hardware_encoding"
-#define KEY_RTC_VIDEO_H264_HWENC "che.video.h264.hwenc"
+#define KEY_RTC_VIDEO_HARDWARE_ENCODEING "che.hardware_encoding" // deprecated, please use engine.video.enable_hw_encoder
/**
* set the hardware video encoder provider (nv for nvidia or qsv for intel)
*/
@@ -50,7 +49,7 @@
* set the video decoder mode (hardware or software)
*/
#define KEY_RTC_VIDEO_ENABLED_HW_DECODER "engine.video.enable_hw_decoder"
-#define KEY_RTC_VIDEO_HARDWARE_DECODING "che.hardware_decoding"
+#define KEY_RTC_VIDEO_HARDWARE_DECODING "che.hardware_decoding" // deprecated, please use engine.video.enable_hw_decoder
/**
* set the hardware video decoder provider (h264_cuvid(default) or h264_qsv)
@@ -115,8 +114,7 @@
/**
* set the video codec type, such as "H264", "JPEG"
*/
-#define KEY_RTC_VIDEO_CODEC_TYPE "engine.video.codec_type"
-#define KEY_RTC_VIDEO_MINOR_STREAM_CODEC_TYPE "engine.video.minor_stream_codec_type"
+#define KEY_RTC_VIDEO_MINOR_STREAM_CODEC_INDEX "engine.video.minor_stream_codec_index"
#define KEY_RTC_VIDEO_CODEC_INDEX "che.video.videoCodecIndex"
/**
* only use average QP for quality scaling
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmService.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmService.h
index 1ce7c5f91..580790c30 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmService.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmService.h
@@ -7,7 +7,7 @@
#pragma once
#include
-#include
+#include
namespace agora {
@@ -520,7 +520,7 @@ class IChannel {
* Sets an event handler for IChannel.
* @param eventHandler The pointer to the event handler of IChannel: IChannelEventHandler.
*/
- virtual int setEventHandler(IChannelEventHandler *eventHandler, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setEventHandler(IChannelEventHandler *eventHandler, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Joins the current channel.
*
@@ -530,7 +530,7 @@ class IChannel {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int join(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int join(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Leaves the current channel.
*
@@ -539,7 +539,7 @@ class IChannel {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int leave(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int leave(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sends a channel message.
*
@@ -550,7 +550,7 @@ class IChannel {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int sendMessage(const IMessage *message, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int sendMessage(const IMessage *message, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Updates the channel attributes.
*
@@ -561,7 +561,7 @@ class IChannel {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int updateAttributes(IChannelAttributes *attributes, int64_t &requestId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int updateAttributes(IChannelAttributes *attributes, int64_t &requestId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Removes the channel attributes.
*
@@ -572,7 +572,7 @@ class IChannel {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int deleteAttributes(IChannelAttributes *attributes, int64_t &requestId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int deleteAttributes(IChannelAttributes *attributes, int64_t &requestId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the current request ID.
* @return
@@ -675,14 +675,14 @@ class IRtmService {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int login(const char *token, const char *userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int login(const char *token, const char *userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Logs out of the RTM service.
* @return
* - 0: Success.
* - < 0: Failure.
*/
- virtual int logout(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int logout(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sends a peer message to a specified remote user.
*
@@ -692,7 +692,7 @@ class IRtmService {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int sendMessageToPeer(const char *peerId, const IMessage *message, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int sendMessageToPeer(const char *peerId, const IMessage *message, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Creates an RTM channel.
*
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmpStreamingService.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmpStreamingService.h
index 0f6a1eec8..e9c3568c2 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmpStreamingService.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmpStreamingService.h
@@ -12,7 +12,7 @@
#include "AgoraRefPtr.h"
#include "IAgoraService.h"
#include "NGIAgoraRtcConnection.h"
-#include
+#include
namespace agora {
namespace rtc {
@@ -110,7 +110,7 @@ class IRtmpStreamingService : public RefCountInterface {
* - #ERR_NOT_INITIALIZED (7): You have not initialized the RTC engine when publishing the stream.
* - #ERR_ALREADY_IN_USE (19): This streaming URL is already in use. Use a new streaming URL for CDN streaming.
*/
- virtual int startRtmpStreamWithoutTranscoding(const char* url, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int startRtmpStreamWithoutTranscoding(const char* url, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Publishes the local stream with transcoding to a specified CDN live RTMP address. (CDN live only.)
@@ -133,7 +133,7 @@ class IRtmpStreamingService : public RefCountInterface {
* - #ERR_NOT_INITIALIZED (7): You have not initialized the RTC engine when publishing the stream.
* - #ERR_ALREADY_IN_USE (19): This streaming URL is already in use. Use a new streaming URL for CDN streaming.
*/
- virtual int startRtmpStreamWithTranscoding(const char* url, const LiveTranscoding& transcoding, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int startRtmpStreamWithTranscoding(const char* url, const LiveTranscoding& transcoding, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Update the video layout and audio settings for CDN live. (CDN live only.)
* @note This method applies to Live Broadcast only.
@@ -144,7 +144,7 @@ class IRtmpStreamingService : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Stop an RTMP stream with transcoding or without transcoding from the CDN. (CDN live only.)
* This method removes the RTMP URL address (added by the \ref IRtcEngine::startRtmpStreamWithoutTranscoding "startRtmpStreamWithoutTranscoding" method
@@ -163,7 +163,7 @@ class IRtmpStreamingService : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int stopRtmpStream(const char* url, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int stopRtmpStream(const char* url, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Registers an RTMP streaming observer.
@@ -172,7 +172,7 @@ class IRtmpStreamingService : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerObserver(IRtmpStreamingObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerObserver(IRtmpStreamingObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the RTMP streaming observer created by registerObserver().
* @param observer The pointer to the RTMP streaming observer that you want to release. See \ref agora::rtc::IRtmpStreamingObserver "IRtmpStreamingObserver".
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraService.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraService.h
index 9feb0c914..200807f3b 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraService.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraService.h
@@ -8,7 +8,7 @@
#include "IAgoraLog.h"
#include "AgoraBase.h"
#include "AgoraOptional.h"
-#include
+#include
namespace agora {
class ILocalDataChannel;
@@ -71,6 +71,8 @@ class IRtmService;
namespace base {
class IServiceObserver;
+class ISyncClient;
+struct SyncConfig;
/**
* The global configurations for \ref agora::base::IAgoraService "AgoraService".
@@ -144,9 +146,9 @@ struct AgoraServiceConfiguration {
IServiceObserver* serviceObserver;
/**
- * Thread priority for SDK common threads
+ * @deprecated Thread priority for SDK common threads
*/
- Optional threadPriority;
+ Optional threadPriority __deprecated;
/**
* Whether use egl context in current thread as sdk‘s root egl context
* which shared by all egl related modules. eg. camera capture, video renderer.
@@ -286,6 +288,13 @@ struct AudioSessionConfiguration {
*/
Optional outputNumberOfChannels;
+#if defined(WEBRTC_IOS)
+ /**
+ * Initialize the AudioSession with the value for category. (iOS only)
+ */
+ Optional category;
+#endif
+
void SetAll(const AudioSessionConfiguration& change) {
SetFrom(&playbackAndRecord, change.playbackAndRecord);
SetFrom(&chatMode, change.chatMode);
@@ -299,6 +308,9 @@ struct AudioSessionConfiguration {
SetFrom(&ioBufferDuration, change.ioBufferDuration);
SetFrom(&inputNumberOfChannels, change.inputNumberOfChannels);
SetFrom(&outputNumberOfChannels, change.outputNumberOfChannels);
+#if defined(WEBRTC_IOS)
+ SetFrom(&category, change.category);
+#endif
}
bool operator==(const AudioSessionConfiguration& o) const {
@@ -308,7 +320,12 @@ struct AudioSessionConfiguration {
allowBluetooth == o.allowBluetooth && allowBluetoothA2DP == o.allowBluetoothA2DP && sampleRate == o.sampleRate &&
ioBufferDuration == o.ioBufferDuration &&
inputNumberOfChannels == o.inputNumberOfChannels &&
+#if defined(WEBRTC_IOS)
+ outputNumberOfChannels == o.outputNumberOfChannels &&
+ category == o.category;
+#else
outputNumberOfChannels == o.outputNumberOfChannels;
+#endif
}
bool operator!=(const AudioSessionConfiguration& o) const { return !(*this == o); }
@@ -393,7 +410,7 @@ class IAgoraService {
/**
* Flush log & cache before exit
*/
- virtual int atExit(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int atExit(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the \ref agora::base::IAgoraService "AgoraService" object.
@@ -413,7 +430,7 @@ class IAgoraService {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Customizes the audio session configuration.
@@ -423,7 +440,7 @@ class IAgoraService {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the audio session configuration.
@@ -454,7 +471,7 @@ class IAgoraService {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setLogFile(const char* filePath, unsigned int fileSize, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setLogFile(const char* filePath, unsigned int fileSize, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the SDK log output filter.
*
@@ -473,7 +490,7 @@ class IAgoraService {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setLogFilter(unsigned int filters, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setLogFilter(unsigned int filters, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Creates an \ref agora::rtc::IRtcConnection "RtcConnection" object and returns the pointer.
@@ -635,12 +652,13 @@ class IAgoraService {
* @param audioSource The pointer to the recording device source. See \ref agora::rtc::IRecordingDeviceSource "IRecordingDeviceSource".
* @param enableAec Whether enable audio echo cancellation for loopback recording. If loopback
* recording device is a virtual sound card, it should be false, or it should be true.
+ * @param overlap Whether overlap playout signal.
* @return
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
* - A null pointer: Failure.
*/
virtual agora_refptr createRecordingDeviceAudioTrack(
- agora_refptr audioSource, bool enableAec) = 0;
+ agora_refptr audioSource, bool enableAec, bool overlap) = 0;
/**
* Creates an audio device manager object and returns the pointer.
@@ -866,9 +884,9 @@ class IAgoraService {
*/
virtual rtm::IRtmService* createRtmService() = 0;
- virtual int addExtensionObserver(agora::agora_refptr observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int addExtensionObserver(agora::agora_refptr observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
- virtual int removeExtensionObserver(agora::agora_refptr observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int removeExtensionObserver(agora::agora_refptr observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Creates an audio device manager and returns the pointer.
@@ -924,7 +942,7 @@ class IAgoraService {
*/
virtual int enableExtension(
const char* provider_name, const char* extension_name, const char* track_id = NULL,
- bool auto_enable_on_track = false, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ bool auto_enable_on_track = false, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Disable extension.
*
@@ -937,7 +955,7 @@ class IAgoraService {
* - < 0: Failure.
*/
virtual int disableExtension(
- const char* provider_name, const char* extension_name, const char* track_id = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ const char* provider_name, const char* extension_name, const char* track_id = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the IAgoraParameter object.
@@ -956,6 +974,32 @@ class IAgoraService {
* - A null pointer: Failure.
*/
virtual agora_refptr getConfigCenter() = 0;
+
+ /**
+ * Get the \ref agora::rtc::ISyncClient "ISyncClient" object and return the pointer.
+ *
+ * @return
+ * - The pointer to \ref rtc::ISyncClient "ISyncClient": Success.
+ * - A null pointer: Failure.
+ */
+ virtual agora_refptr createSyncClient(const base::SyncConfig& config) = 0;
+
+ /**
+ * Set the logWriter for the sdk log.
+ * @param logWriter the log writer
+ * @return
+ * - 0: Success.
+ * - < 0: Failure.
+ */
+ virtual int32_t setLogWriter(agora::commons::ILogWriter* logWriter) = 0;
+
+ /**
+ * Release logWriter for the sdk log.
+ * @return
+ * -The pointer to \ref agora::commons::ILogWriter
+ * - A null pointer: Failure.
+ */
+ virtual agora::commons::ILogWriter* releaseLogWriter() = 0;
protected:
virtual ~IAgoraService() {}
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioDeviceManager.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioDeviceManager.h
index 6374ca11c..621b5a077 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioDeviceManager.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioDeviceManager.h
@@ -10,7 +10,7 @@
#include "AgoraBase.h"
#include "AgoraRefPtr.h"
-#include
+#include
namespace agora {
namespace media {
namespace base {
@@ -37,6 +37,11 @@ struct AudioDeviceInfo {
* The name of the device. The maximum name size is 128 bytes. The default value is 0.
*/
char deviceName[kAdmMaxDeviceNameSize];
+ /**
+ * The type name of the device. such as Built-in, USB, HDMI, etc. The maximum size is 128 bytes. The default value is 0.
+ * @note This member applies to macOS only.
+ */
+ char deviceTypeName[kAdmMaxDeviceNameSize];
/**
* The ID of the device. The maximum size is 128 bytes. The default value is 0.
*/
@@ -57,6 +62,7 @@ struct AudioDeviceInfo {
AudioDeviceInfo() : isCurrentSelected(false),
isPlayoutDevice(true) {
memset(deviceName, 0, sizeof(deviceName));
+ memset(deviceTypeName, 0, sizeof(deviceTypeName));
memset(deviceId, 0, sizeof(deviceId));
}
};
@@ -147,7 +153,7 @@ class IRecordingDeviceSource : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int startRecording(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int startRecording(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stop the recording device.
@@ -155,7 +161,7 @@ class IRecordingDeviceSource : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int stopRecording(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int stopRecording(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Registers an audio frame observer.
@@ -165,7 +171,7 @@ class IRecordingDeviceSource : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the registered IAudioFrameObserver object.
@@ -183,7 +189,7 @@ class IRecordingDeviceSource : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setLoopbackDeviceParameter(const LoopbackRecordingOption &option, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setLoopbackDeviceParameter(const LoopbackRecordingOption &option, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
virtual ~IRecordingDeviceSource() {}
};
@@ -213,7 +219,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setMicrophoneVolume(unsigned int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setMicrophoneVolume(unsigned int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the volume of the microphone.
* @param volume The volume of the microphone.
@@ -229,7 +235,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setSpeakerVolume(unsigned int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setSpeakerVolume(unsigned int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the volume of the speaker.
* @param volume The volume of the speaker.
@@ -247,7 +253,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setMicrophoneMute(bool mute, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setMicrophoneMute(bool mute, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the mute state of the microphone.
* @param mute The mute state of the microphone.
@@ -265,7 +271,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setSpeakerMute(bool mute, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setSpeakerMute(bool mute, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the mute state of the speaker.
* @param mute A reference to the mute state of the speaker.
@@ -309,7 +315,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setDefaultAudioRouting(AudioRoute route, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setDefaultAudioRouting(AudioRoute route, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Changes the current audio routing.
*
@@ -321,7 +327,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int changeAudioRouting(AudioRoute route, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int changeAudioRouting(AudioRoute route, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Changes the speaker status on/off.
*
@@ -333,7 +339,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setAudioRoutingSpeakerOn(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioRoutingSpeakerOn(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the current audio routing.
*
@@ -405,7 +411,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setPlayoutDevice(int index, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setPlayoutDevice(int index, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the recording device.
*
@@ -417,7 +423,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setRecordingDevice(int index, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRecordingDevice(int index, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** The status of following system default playback device.
@note The status of following system default playback device.
@@ -429,7 +435,7 @@ class INGAudioDeviceManager : public RefCountInterface {
- 0: Success.
- < 0: Failure.
*/
- virtual int followSystemPlaybackDevice(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int followSystemPlaybackDevice(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** The status of following system default recording device.
@@ -442,7 +448,7 @@ class INGAudioDeviceManager : public RefCountInterface {
- 0: Success.
- < 0: Failure.
*/
- virtual int followSystemRecordingDevice(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int followSystemRecordingDevice(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
#endif // _WIN32 || (TARGET_OS_MAC && !TARGET_OS_IPHONE)
#if defined(_WIN32)
@@ -457,7 +463,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setApplicationVolume(unsigned int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setApplicationVolume(unsigned int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the volume of the app.
*
@@ -483,7 +489,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setApplicationMuteState(bool mute, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setApplicationMuteState(bool mute, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the mute state of the app.
*
@@ -518,7 +524,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setLoopbackDevice(int index, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setLoopbackDevice(int index, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** The status of following system default loopback device.
@note The status of following system default loopback device.
@@ -530,7 +536,7 @@ class INGAudioDeviceManager : public RefCountInterface {
- 0: Success.
- < 0: Failure.
*/
- virtual int followSystemLoopbackDevice(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int followSystemLoopbackDevice(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
#endif // _WIN32
/**
@@ -544,7 +550,7 @@ class INGAudioDeviceManager : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerObserver(IAudioDeviceManagerObserver* observer, void(*safeDeleter)(IAudioDeviceManagerObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerObserver(IAudioDeviceManagerObserver* observer, void(*safeDeleter)(IAudioDeviceManagerObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the IAudioDeviceManagerObserver object.
* @param observer The pointer to the IAudioDeviceManagerObserver class registered using #registerObserver.
@@ -554,7 +560,7 @@ class INGAudioDeviceManager : public RefCountInterface {
*/
virtual int unregisterObserver(IAudioDeviceManagerObserver* observer) = 0;
- virtual int setupAudioAttributeContext(void* audioAttr, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setupAudioAttributeContext(void* audioAttr, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
protected:
~INGAudioDeviceManager() {}
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioTrack.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioTrack.h
index 1d24933ed..e877e370e 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioTrack.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioTrack.h
@@ -9,7 +9,7 @@
#pragma once // NOLINT(build/header_guard)
#include "AgoraBase.h"
-#include
+#include
// FIXME(Ender): use this class instead of AudioSendStream as local track
namespace agora {
@@ -87,7 +87,7 @@ class IAudioTrack : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int adjustPlayoutVolume(int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int adjustPlayoutVolume(int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the current playback volume.
@@ -104,11 +104,12 @@ class IAudioTrack : public RefCountInterface {
* By adding an audio filter, you can apply various audio effects to the audio, for example, voice change.
* @param filter A pointer to the audio filter. See \ref agora::rtc::IAudioFilter "IAudioFilter".
* @param position The position of the audio filter. See \ref agora::rtc::IAudioTrack::AudioFilterPosition "AudioFilterPosition".
+ * @param extContext The context of current filter. See \ref agora::rtc::ExtensionContext "ExtensionContext".
* @return
* - `true`: Success.
* - `false`: Failure.
*/
- virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position, ExtensionContext *extContext = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Removes the audio filter added by callling `addAudioFilter`.
*
@@ -118,7 +119,7 @@ class IAudioTrack : public RefCountInterface {
* - `true`: Success.
* - `false`: Failure.
*/
- virtual bool removeAudioFilter(agora_refptr filter, AudioFilterPosition position, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual bool removeAudioFilter(agora_refptr filter, AudioFilterPosition position, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Enable / Disable specified audio filter
@@ -129,7 +130,7 @@ class IAudioTrack : public RefCountInterface {
* - 0: success
* - <0: failure
*/
- virtual int enableAudioFilter(const char* id, bool enable, AudioFilterPosition position, ahpl_ref_t ares = AHPL_REF_INVALID) {
+ virtual int enableAudioFilter(const char* id, bool enable, AudioFilterPosition position, aosl_ref_t ares = AOSL_REF_INVALID) {
(void)id;
(void)enable;
(void)position;
@@ -146,7 +147,7 @@ class IAudioTrack : public RefCountInterface {
* - 0: success
* - <0: failure
*/
- virtual int setFilterProperty(const char* id, const char* key, const char* jsonValue, AudioFilterPosition position, ahpl_ref_t ares = AHPL_REF_INVALID) {
+ virtual int setFilterProperty(const char* id, const char* key, const char* jsonValue, AudioFilterPosition position, aosl_ref_t ares = AOSL_REF_INVALID) {
(void)id;
(void)key;
(void)jsonValue;
@@ -194,7 +195,7 @@ class IAudioTrack : public RefCountInterface {
* - `true`: Success.
* - `false`: Failure.
*/
- virtual bool addAudioSink(agora_refptr sink, const AudioSinkWants& wants, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual bool addAudioSink(agora_refptr sink, const AudioSinkWants& wants, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Removes an audio sink.
@@ -204,7 +205,7 @@ class IAudioTrack : public RefCountInterface {
* - `true`: Success.
* - `false`: Failure.
*/
- virtual bool removeAudioSink(agora_refptr sink, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual bool removeAudioSink(agora_refptr sink, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
};
/**
@@ -315,7 +316,7 @@ class ILocalAudioTrack : public IAudioTrack {
* - `true`: Enable the local audio track.
* - `false`: Disable the local audio track.
*/
- virtual int setEnabled(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setEnabled(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets whether the local audio track is enabled.
@@ -345,7 +346,7 @@ class ILocalAudioTrack : public IAudioTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int adjustPublishVolume(int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int adjustPublishVolume(int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the current volume for publishing.
@@ -368,7 +369,7 @@ class ILocalAudioTrack : public IAudioTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int enableLocalPlayback(bool enable, bool sync = true, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int enableLocalPlayback(bool enable, bool sync = true, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Enables in-ear monitoring (for Android and iOS only).
@@ -381,7 +382,7 @@ class ILocalAudioTrack : public IAudioTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int enableEarMonitor(bool enable, int includeAudioFilters, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int enableEarMonitor(bool enable, int includeAudioFilters, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Register an local audio track observer
*
* @param observer A pointer to the local audio track observer: \ref agora::rtc::ILocalAudioTrackObserver
@@ -390,7 +391,7 @@ class ILocalAudioTrack : public IAudioTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerTrackObserver(ILocalAudioTrackObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerTrackObserver(ILocalAudioTrackObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Releases the local audio track observer
*
* @param observer A pointer to the local audio track observer: \ref agora::rtc::ILocalAudioTrackObserver
@@ -401,6 +402,21 @@ class ILocalAudioTrack : public IAudioTrack {
*/
virtual int unregisterTrackObserver(ILocalAudioTrackObserver* observer) = 0;
+ /** set Max buffered audio frame number
+ *
+ * @param number : the buffer number set,unit is 10ms
+ *
+ */
+ virtual void setMaxBufferedAudioFrameNumber(int number) = 0;
+
+ /** clear sender buffer
+ *
+ * @return
+ * - >= 0: Frame number in sender buffer.
+ * - < 0: Failure.
+ */
+ virtual int ClearSenderBuffer() = 0;
+
protected:
~ILocalAudioTrack() {}
};
@@ -535,6 +551,14 @@ struct RemoteAudioTrackStats {
* The time of 200 ms frozen in 2 seconds
*/
uint16_t frozen_time_200_ms;
+ /**
+ * The full time of 80 ms frozen in 2 seconds
+ */
+ uint16_t full_frozen_time_80_ms;
+ /**
+ * The full time of 200 ms frozen in 2 seconds
+ */
+ uint16_t full_frozen_time_200_ms;
/**
* The estimate delay
*/
@@ -617,6 +641,8 @@ struct RemoteAudioTrackStats {
frozen_time_80_ms(0),
frozen_count_200_ms(0),
frozen_time_200_ms(0),
+ full_frozen_time_80_ms(0),
+ full_frozen_time_200_ms(0),
delay_estimate_ms(0),
mos_value(0),
frozen_rate_by_custom_plc_count(0),
@@ -663,7 +689,7 @@ class IRemoteAudioTrack : public IAudioTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerMediaPacketReceiver(IMediaPacketReceiver* packetReceiver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerMediaPacketReceiver(IMediaPacketReceiver* packetReceiver, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the `IMediaPacketReceiver` object.
@@ -686,7 +712,7 @@ class IRemoteAudioTrack : public IAudioTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerAudioEncodedFrameReceiver(IAudioEncodedFrameReceiver* packetReceiver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerAudioEncodedFrameReceiver(IAudioEncodedFrameReceiver* packetReceiver, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the `IAudioEncodedFrameReceiver` object.
@@ -709,8 +735,45 @@ class IRemoteAudioTrack : public IAudioTrack {
- 0: Success.
- < 0: Failure.
*/
- virtual int setRemoteVoicePosition(float pan, float gain, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRemoteVoicePosition(float pan, float gain, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+
+ /** Sets the volume of each audio decoded channel
+
+ @param decoded_index The channel index of the remote user. The value ranges from 0 to 100:
+ @param volume The channel index of the remote user. The value ranges from 0 to 100.
+ - 0: mute the channel.
+ - 100: keep the origin volume of the channel.
+
+ @return
+ - 0: Success.
+ - < 0: Failure.
+ */
+ virtual int adjustDecodedAudioVolume(int decoded_index, int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+
+ /** mute remote stream from timestamp
+
+ @note
+ - unmuteRemoteFromTimestamp should be called after muteRemoteFromTimestamp, othewise this stream will be muted all time
+
+ @param timestamp The rtp timestamp of start mute
+ @return
+ - 0: Success.
+ - < 0: Failure.
+ */
+ virtual int muteRemoteFromTimestamp(uint32_t timestamp) = 0;
+
+ /** unmute remote stream from timestamp
+
+ @note
+ - unmuteRemoteFromTimestamp should be called after muteRemoteFromTimestamp, othewise this stream will be muted all time
+ @param timestamp The rtp timestamp of start unmute
+ @return
+ - 0: Success.
+ - < 0: Failure.
+ */
+ virtual int unmuteRemoteFromTimestamp(uint32_t timestamp) = 0;
+
/** set percentage of audio acceleration during poor network
@note
@@ -724,7 +787,7 @@ class IRemoteAudioTrack : public IAudioTrack {
- 0: Success.
- < 0: Failure.
*/
- virtual int adjustAudioAcceleration(int percentage, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int adjustAudioAcceleration(int percentage, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** set percentage of audio deceleration during poor network
@@ -739,7 +802,7 @@ class IRemoteAudioTrack : public IAudioTrack {
- 0: Success.
- < 0: Failure.
*/
- virtual int adjustAudioDeceleration(int percentage, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int adjustAudioDeceleration(int percentage, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** enable spatial audio
@@ -750,7 +813,7 @@ class IRemoteAudioTrack : public IAudioTrack {
- 0: Success.
- < 0: Failure.
*/
- virtual int enableSpatialAudio(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int enableSpatialAudio(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Sets remote user parameters for spatial audio
@@ -760,7 +823,7 @@ class IRemoteAudioTrack : public IAudioTrack {
- 0: Success.
- < 0: Failure.
*/
- virtual int setRemoteUserSpatialAudioParams(const agora::SpatialAudioParams& params, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRemoteUserSpatialAudioParams(const agora::SpatialAudioParams& params, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
};
} // namespace rtc
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraCameraCapturer.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraCameraCapturer.h
index 09da1d422..5b089a441 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraCameraCapturer.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraCameraCapturer.h
@@ -8,7 +8,7 @@
#include "AgoraBase.h"
#include "AgoraRefPtr.h"
-#include
+#include
namespace agora {
namespace rtc {
@@ -32,6 +32,10 @@ class ICameraCapturer : public RefCountInterface {
* The camera source is the front camera.
*/
CAMERA_FRONT,
+ /**
+ * The camera source is the extra camera.
+ */
+ CAMERA_EXTRA,
};
/**
@@ -121,7 +125,7 @@ class ICameraCapturer : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setCameraSource(CAMERA_SOURCE source, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setCameraSource(CAMERA_SOURCE source, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the camera source.
*
@@ -137,7 +141,7 @@ class ICameraCapturer : public RefCountInterface {
* @note
* This method applies to Android and iOS only.
*/
- virtual int switchCamera(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int switchCamera(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Returns whether zooming is supported by the current device.
* @note
@@ -161,7 +165,7 @@ class ICameraCapturer : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int32_t setCameraZoom(float zoomValue, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int32_t setCameraZoom(float zoomValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the max zooming factor of the device.
*
@@ -192,7 +196,7 @@ class ICameraCapturer : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int32_t setCameraFocus(float x, float y, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int32_t setCameraFocus(float x, float y, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Returns whether auto face focus is supported by the current device.
* @note
@@ -214,7 +218,7 @@ class ICameraCapturer : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int32_t setCameraAutoFaceFocus(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int32_t setCameraAutoFaceFocus(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Enables or disables auto face detection.
* @note
@@ -225,7 +229,7 @@ class ICameraCapturer : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int32_t enableFaceDetection(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int32_t enableFaceDetection(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Checks whether the camera face detect is supported.
@@ -274,7 +278,7 @@ class ICameraCapturer : public RefCountInterface {
* - 0: Success
* - < 0: Failure
*/
- virtual int setCameraTorchOn(bool on, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setCameraTorchOn(bool on, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Checks whether the camera exposure function is supported.
*
@@ -304,7 +308,7 @@ class ICameraCapturer : public RefCountInterface {
* < 0: Failure.
*
*/
- virtual int setCameraExposurePosition(float positionXinView, float positionYinView, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setCameraExposurePosition(float positionXinView, float positionYinView, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Returns whether exposure value adjusting is supported by the current device.
@@ -330,7 +334,7 @@ class ICameraCapturer : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setCameraExposureFactor(float value, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setCameraExposureFactor(float value, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
#if (defined(__APPLE__) && TARGET_OS_IOS)
/**
@@ -344,7 +348,7 @@ class ICameraCapturer : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual bool enableMultiCamera(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual bool enableMultiCamera(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Checks whether the camera auto exposure function is supported.
*
@@ -368,7 +372,14 @@ class ICameraCapturer : public RefCountInterface {
* < 0: Failure.
*
*/
- virtual int setCameraAutoExposureFaceModeEnabled(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setCameraAutoExposureFaceModeEnabled(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+
+ /**
+ * set camera stabilization mode.If open stabilization mode, fov will be smaller and capture latency will be longer.
+ *
+ * @param mode specifies the camera stabilization mode.
+ */
+ virtual int setCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode) = 0;
#endif
#elif defined(_WIN32) || (defined(__linux__) && !defined(__ANDROID__)) || \
@@ -410,11 +421,32 @@ class ICameraCapturer : public RefCountInterface {
virtual int initWithDeviceName(const char* deviceName) = 0;
#endif
+#if defined(__APPLE__)
+ /**
+ * Checks whether the center stage is supported. Use this method after starting the camera.
+ *
+ * @return
+ * - true: The center stage is supported.
+ * - false: The center stage is not supported.
+ */
+ virtual bool isCenterStageSupported() = 0;
+
+ /** Enables the camera Center Stage.
+ * @param enabled enable Center Stage:
+ * - true: Enable Center Stage.
+ * - false: Disable Center Stage.
+ * @return
+ * - 0: Success.
+ * - < 0: Failure.
+ */
+ virtual int enableCenterStage(bool enabled) = 0;
+#endif
+
/**
* Set the device orientation of the capture device
* @param VIDEO_ORIENTATION orientaion of the device 0(by default), 90, 180, 270
*/
- virtual int setDeviceOrientation(VIDEO_ORIENTATION orientation, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setDeviceOrientation(VIDEO_ORIENTATION orientation, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the format of the video captured by the camera.
@@ -423,7 +455,7 @@ class ICameraCapturer : public RefCountInterface {
*
* @param capture_format The reference to the video format: VideoFormat.
*/
- virtual int setCaptureFormat(const VideoFormat& capture_format, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setCaptureFormat(const VideoFormat& capture_format, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the format of the video captured by the camera.
* @return
@@ -435,7 +467,7 @@ class ICameraCapturer : public RefCountInterface {
*
* @param observer Instance of the capture observer.
*/
- virtual int registerCameraObserver(ICameraCaptureObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerCameraObserver(ICameraCaptureObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Unregisters the camera observer.
*
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraDataChannel.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraDataChannel.h
index a79b2c79e..d62a64ee1 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraDataChannel.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraDataChannel.h
@@ -9,7 +9,7 @@
#include "AgoraRefPtr.h"
#include "AgoraBase.h"
-#include
+#include
namespace agora {
/**
@@ -92,7 +92,7 @@ class ILocalDataChannel : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int sendDataPacket(const char* packet, size_t length, uint64_t capture_time_ms, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int sendDataPacket(const char* packet, size_t length, uint64_t capture_time_ms, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Send meta data to this data channel before publishing.
*
@@ -102,7 +102,7 @@ class ILocalDataChannel : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setMetaData(const char* metaData, size_t length, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setMetaData(const char* metaData, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* return configured channel id
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraExtensionProvider.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraExtensionProvider.h
index 9a1a54141..4dff21248 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraExtensionProvider.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraExtensionProvider.h
@@ -106,7 +106,7 @@ class IExtensionProvider : public RefCountInterface {
virtual agora_refptr createVideoSink(const char* name) {
return NULL;
}
-
+
virtual void setProperty(const char* key, const char* value) {}
protected:
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraLocalUser.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraLocalUser.h
index 8a9d885bb..2db3c9dcf 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraLocalUser.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraLocalUser.h
@@ -11,7 +11,7 @@
#include
#include "AgoraBase.h"
#include "AgoraOptional.h"
-#include
+#include
namespace agora {
namespace media {
@@ -41,6 +41,7 @@ struct LocalVideoTrackStats;
struct RemoteVideoTrackStats;
class IMediaPacketReceiver;
class IVideoSinkBase;
+
/**
* The ILocalUser class defines the behavior and state of a local user.
*
@@ -280,7 +281,7 @@ class ILocalUser {
* as `role`, the connection fails with the \ref IRtcConnectionObserver::onConnectionFailure "onConnectionFailure" callback.
* @param role The role of the user. See \ref rtc::CLIENT_ROLE_TYPE "CLIENT_ROLE_TYPE".
*/
- virtual int setUserRole(rtc::CLIENT_ROLE_TYPE role, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setUserRole(rtc::CLIENT_ROLE_TYPE role, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the role of the user.
@@ -296,7 +297,7 @@ class ILocalUser {
* @param level The latency level of an audience member in interactive live streaming. See AUDIENCE_LATENCY_LEVEL_TYPE.
* @param role The user role determined by the config. If it's -1, it means there is no configured role.
*/
- virtual int setAudienceLatencyLevel(AUDIENCE_LATENCY_LEVEL_TYPE level, int role, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudienceLatencyLevel(AUDIENCE_LATENCY_LEVEL_TYPE level, int role, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
virtual AUDIENCE_LATENCY_LEVEL_TYPE getAudienceLatencyLevel() = 0;
@@ -310,7 +311,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setAudioEncoderConfiguration(const rtc::AudioEncoderConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioEncoderConfiguration(const rtc::AudioEncoderConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the audio parameters and application scenarios.
@@ -321,7 +322,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setAudioScenario(AUDIO_SCENARIO_TYPE scenario, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioScenario(AUDIO_SCENARIO_TYPE scenario, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* You can call this method to set the expected video scenario.
@@ -333,7 +334,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setVideoScenario(VIDEO_APPLICATION_SCENARIO_TYPE scenarioType, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setVideoScenario(VIDEO_APPLICATION_SCENARIO_TYPE scenarioType, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the Video qoe preference.
@@ -348,7 +349,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setVideoQoEPreference(VIDEO_QOE_PREFERENCE_TYPE qoePreference, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setVideoQoEPreference(VIDEO_QOE_PREFERENCE_TYPE qoePreference, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the detailed statistics of the local audio.
@@ -371,7 +372,7 @@ class ILocalUser {
* - < 0: Failure.
* - -5(ERR_REFUSED), if the role of the local user is not broadcaster.
*/
- virtual int publishAudio(agora_refptr audioTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int publishAudio(agora_refptr audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops publishing the local audio track to the channel.
@@ -381,7 +382,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int unpublishAudio(agora_refptr audioTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unpublishAudio(agora_refptr audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Publishes a local video track to the channel.
@@ -391,7 +392,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int publishVideo(agora_refptr videoTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int publishVideo(agora_refptr videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops publishing the local video track to the channel.
@@ -401,7 +402,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int unpublishVideo(agora_refptr videoTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unpublishVideo(agora_refptr videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Subscribes to the audio of a specified remote user in channel.
@@ -412,7 +413,7 @@ class ILocalUser {
* - < 0: Failure.
* - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid.
*/
- virtual int subscribeAudio(user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int subscribeAudio(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Subscribes to the audio of all remote users in the channel.
@@ -423,7 +424,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int subscribeAllAudio(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int subscribeAllAudio(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops subscribing to the audio of a specified remote user in the channel.
@@ -434,7 +435,7 @@ class ILocalUser {
* - < 0: Failure.
* - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid.
*/
- virtual int unsubscribeAudio(user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unsubscribeAudio(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops subscribing to the audio of all remote users in the channel.
@@ -446,7 +447,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int unsubscribeAllAudio(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unsubscribeAllAudio(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Adjusts the playback signal volume.
@@ -458,7 +459,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int adjustPlaybackSignalVolume(int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int adjustPlaybackSignalVolume(int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the current playback signal volume.
@@ -489,7 +490,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int adjustUserPlaybackSignalVolume(user_id_t userId, int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int adjustUserPlaybackSignalVolume(user_id_t userId, int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the current playback signal volume of specified user.
@@ -513,7 +514,7 @@ class ILocalUser {
- 0: Success.
- < 0: Failure.
*/
- virtual int enableSoundPositionIndication(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int enableSoundPositionIndication(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Sets the sound position and gain of a remote user.
@@ -535,7 +536,7 @@ class ILocalUser {
- 0: Success.
- < 0: Failure.
*/
- virtual int setRemoteVoicePosition(user_id_t userId, double pan, double gain, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRemoteVoicePosition(user_id_t userId, double pan, double gain, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** enable spatial audio
@@ -546,7 +547,7 @@ class ILocalUser {
- 0: Success.
- < 0: Failure.
*/
- virtual int enableSpatialAudio(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int enableSpatialAudio(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Sets remote user parameters for spatial audio
@@ -557,7 +558,7 @@ class ILocalUser {
- 0: Success.
- < 0: Failure.
*/
- virtual int setRemoteUserSpatialAudioParams(user_id_t userId, const agora::SpatialAudioParams& param, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRemoteUserSpatialAudioParams(user_id_t userId, const agora::SpatialAudioParams& param, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrame
@@ -578,7 +579,7 @@ class ILocalUser {
virtual int setPlaybackAudioFrameParameters(size_t numberOfChannels,
uint32_t sampleRateHz,
RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY,
- int samplesPerCall = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ int samplesPerCall = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onRecordAudioFrame
* "onRecordAudioFrame" callback.
@@ -598,7 +599,7 @@ class ILocalUser {
virtual int setRecordingAudioFrameParameters(size_t numberOfChannels,
uint32_t sampleRateHz,
RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY,
- int samplesPerCall = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ int samplesPerCall = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onMixedAudioFrame
* "onMixedAudioFrame" callback.
@@ -615,7 +616,7 @@ class ILocalUser {
*/
virtual int setMixedAudioFrameParameters(size_t numberOfChannels,
uint32_t sampleRateHz,
- int samplesPerCall = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ int samplesPerCall = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onEarMonitoringAudioFrame
@@ -639,7 +640,7 @@ class ILocalUser {
size_t numberOfChannels,
uint32_t sampleRateHz,
RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY,
- int samplesPerCall = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ int samplesPerCall = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrameBeforeMixing
@@ -656,7 +657,7 @@ class ILocalUser {
* - < 0: Failure.
*/
virtual int setPlaybackAudioFrameBeforeMixingParameters(size_t numberOfChannels,
- uint32_t sampleRateHz, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ uint32_t sampleRateHz, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Registers an audio frame observer.
@@ -674,7 +675,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerAudioFrameObserver(agora::media::IAudioFrameObserverBase* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerAudioFrameObserver(agora::media::IAudioFrameObserverBase* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the audio frame observer.
*
@@ -695,7 +696,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int enableAudioSpectrumMonitor(int intervalInMS = 100, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int enableAudioSpectrumMonitor(int intervalInMS = 100, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Disalbe the audio spectrum monitor.
*
@@ -703,7 +704,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int disableAudioSpectrumMonitor(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int disableAudioSpectrumMonitor(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Registers an audio spectrum observer.
@@ -719,7 +720,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerAudioSpectrumObserver(agora::media::IAudioSpectrumObserver * observer, void (*safeDeleter)(agora::media::IAudioSpectrumObserver*), ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerAudioSpectrumObserver(agora::media::IAudioSpectrumObserver * observer, void (*safeDeleter)(agora::media::IAudioSpectrumObserver*), aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the audio spectrum observer.
*
@@ -743,7 +744,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerLocalVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerLocalVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object.
* @param observer The pointer to the `IVideoEncodedFrameObserver` object.
@@ -759,7 +760,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int forceNextIntraFrame(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int forceNextIntraFrame(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Registers an \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object.
*
@@ -772,7 +773,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object.
* @param observer The pointer to the `IVideoEncodedFrameObserver` object.
@@ -794,7 +795,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerVideoFrameObserver(IVideoFrameObserver2* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerVideoFrameObserver(IVideoFrameObserver2* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the \ref agora::rtc::IVideoFrameObserver2 "IVideoFrameObserver2" object.
* @param observer The pointer to the `IVideoFrameObserver2` object.
@@ -805,12 +806,14 @@ class ILocalUser {
virtual int unregisterVideoFrameObserver(IVideoFrameObserver2* observer) = 0;
virtual int setVideoSubscriptionOptions(user_id_t userId,
- const VideoSubscriptionOptions& options, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ const VideoSubscriptionOptions& options, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
- virtual int setHighPriorityUserList(uid_t* vipList, int uidNum, int option, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setHighPriorityUserList(uid_t* vipList, int uidNum, int option, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
virtual int getHighPriorityUserList(std::vector& vipList, int& option) = 0;
+ virtual int setRemoteSubscribeFallbackOption(int option, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+
/**
* Sets the blocklist of subscribe remote stream audio.
*
@@ -825,7 +828,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setSubscribeAudioBlocklist(user_id_t* userList, int userNumber, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setSubscribeAudioBlocklist(user_id_t* userList, int userNumber, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the allowlist of subscribe remote stream audio.
@@ -843,7 +846,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setSubscribeAudioAllowlist(user_id_t* userList, int userNumber, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setSubscribeAudioAllowlist(user_id_t* userList, int userNumber, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the blocklist of subscribe remote stream video.
@@ -859,7 +862,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setSubscribeVideoBlocklist(user_id_t* userList, int userNumber, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setSubscribeVideoBlocklist(user_id_t* userList, int userNumber, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the allowlist of subscribe remote stream video.
@@ -877,7 +880,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setSubscribeVideoAllowlist(user_id_t* userList, int userNumber, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setSubscribeVideoAllowlist(user_id_t* userList, int userNumber, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Subscribes to the video of a specified remote user in the channel.
@@ -892,7 +895,7 @@ class ILocalUser {
* - -2(ERR_INVALID_ARGUMENT), if `userId` is invalid.
*/
virtual int subscribeVideo(user_id_t userId,
- const VideoSubscriptionOptions &subscriptionOptions, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ const VideoSubscriptionOptions &subscriptionOptions, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Subscribes to the video of all remote users in the channel.
@@ -904,7 +907,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int subscribeAllVideo(const VideoSubscriptionOptions &subscriptionOptions, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int subscribeAllVideo(const VideoSubscriptionOptions &subscriptionOptions, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops subscribing to the video of a specified remote user in the channel.
@@ -915,7 +918,7 @@ class ILocalUser {
* - < 0: Failure.
* - -2(ERR_INVALID_ARGUMENT), if `userId` is invalid.
*/
- virtual int unsubscribeVideo(user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unsubscribeVideo(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops subscribing to the video of all remote users in the channel.
@@ -927,7 +930,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int unsubscribeAllVideo(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unsubscribeAllVideo(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the time interval and the volume smoothing factor of the \ref agora::rtc::ILocalUserObserver::onAudioVolumeIndication "onAudioVolumeIndication" callback.
@@ -948,7 +951,7 @@ class ILocalUser {
* - < 0: Failure.
* - -2(ERR_INVALID_ARGUMENT), if `intervalInMS` or `smooth` is out of range.
*/
- virtual int setAudioVolumeIndicationParameters(int intervalInMS, int smooth, bool reportVad, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioVolumeIndicationParameters(int intervalInMS, int smooth, bool reportVad, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Registers a local user observer object.
@@ -963,7 +966,7 @@ class ILocalUser {
*/
virtual int registerLocalUserObserver(
ILocalUserObserver* observer,
- void(*safeDeleter)(ILocalUserObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ void(*safeDeleter)(ILocalUserObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the \ref agora::rtc::ILocalUserObserver "ILocalUserObserver" object.
@@ -996,7 +999,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerMediaControlPacketReceiver(IMediaControlPacketReceiver* ctrlPacketReceiver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerMediaControlPacketReceiver(IMediaControlPacketReceiver* ctrlPacketReceiver, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the media control packet receiver.
@@ -1017,7 +1020,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int sendIntraRequest(user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int sendIntraRequest(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set local audio filterable by topn
@@ -1030,7 +1033,7 @@ class ILocalUser {
* - < 0: Failure.
*/
- virtual int setAudioFilterable(bool filterable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioFilterable(bool filterable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Enable / Disable specified audio filter
@@ -1041,7 +1044,7 @@ class ILocalUser {
* - 0: success
* - <0: failure
*/
- virtual int enableRemoteAudioTrackFilter(user_id_t userId, const char* id, bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int enableRemoteAudioTrackFilter(user_id_t userId, const char* id, bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* set the properties of the specified audio filter
@@ -1053,7 +1056,7 @@ class ILocalUser {
* - 0: success
* - <0: failure
*/
- virtual int setRemoteAudioTrackFilterProperty(user_id_t userId, const char* id, const char* key, const char* jsonValue, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRemoteAudioTrackFilterProperty(user_id_t userId, const char* id, const char* key, const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* get the properties of the specified audio filter
@@ -1075,7 +1078,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int publishDataChannel(agora_refptr channel, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int publishDataChannel(agora_refptr channel, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops publishing the data channel to the channel.
*
@@ -1084,7 +1087,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int unpublishDataChannel(agora_refptr channel, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unpublishDataChannel(agora_refptr channel, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Subscribes to a specified data channel of a specified remote user in channel.
*
@@ -1094,7 +1097,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int subscribeDataChannel(user_id_t userId, int channelId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int subscribeDataChannel(user_id_t userId, int channelId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops subscribing to the data channel of a specified remote user in the channel.
*
@@ -1105,7 +1108,7 @@ class ILocalUser {
* - < 0: Failure.
* - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid.
*/
- virtual int unsubscribeDataChannel(user_id_t userId, int channelId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unsubscribeDataChannel(user_id_t userId, int channelId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Registers an data channel observer.
*
@@ -1116,7 +1119,7 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerDataChannelObserver(IDataChannelObserver * observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerDataChannelObserver(IDataChannelObserver * observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the data channel observer.
*
@@ -1137,7 +1140,7 @@ class ILocalUser {
* - 0: success
* - <0: failure
*/
- virtual int SetAudioNsMode(bool NsEnable, NS_MODE NsMode, NS_LEVEL NsLevel, NS_DELAY NsDelay, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int SetAudioNsMode(bool NsEnable, NS_MODE NsMode, NS_LEVEL NsLevel, NS_DELAY NsDelay, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* enable the mix track that mix special track
*
@@ -1149,7 +1152,7 @@ class ILocalUser {
* - 0: success
* - <0: failure
*/
- virtual int EnableLocalMixedAudioTrack(agora_refptr& track, bool enable, bool MixLocal, bool MixRemote, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int EnableLocalMixedAudioTrack(agora_refptr& track, bool enable, bool MixLocal, bool MixRemote, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Trigger data channel update callback with all data channel infos.
*
@@ -1157,7 +1160,18 @@ class ILocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int takeDataChannelSnapshot(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int takeDataChannelSnapshot(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ /**
+ * send audio metadata
+ *
+ * @param metadata The pointer of metadata
+ * @param length Size of metadata
+ * @return
+ * - 0: success
+ * - <0: failure
+ * @technical preview
+ */
+ virtual int sendAudioMetadata(const char* metadata, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
};
/**
@@ -1494,6 +1508,20 @@ class ILocalUserObserver {
*/
virtual void onVideoSizeChanged(user_id_t userId, int width, int height, int rotation) = 0;
+ /**
+ * The audio metadata received.
+ *
+ * @param userId ID of the remote user.
+ * @param metadata The pointer of metadata
+ * @param length Size of metadata
+ * @technical preview
+ */
+ virtual void onAudioMetadataReceived(user_id_t userId, const char* metadata, size_t length) {
+ (void)userId;
+ (void)metadata;
+ (void)length;
+ }
+
/**
* The media information of a specified user.
*/
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNode.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNode.h
index f74fb00ed..0b2bc0152 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNode.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNode.h
@@ -4,7 +4,7 @@
#include "IAgoraLog.h"
#include "NGIAgoraVideoFrame.h"
#include "AgoraExtensionVersion.h"
-#include
+#include
#ifndef OPTIONAL_PROCESSRESULT_SPECIFIER
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
@@ -140,6 +140,32 @@ class IAudioFilter : public IAudioFilterBase {
~IAudioFilter() {}
};
+class IAudioFilterV2 : public IAudioFilter {
+public:
+ class Control : public RefCountInterface {
+ public:
+ /**
+ * @brief Post an event and notify the end users.
+ * @param key '\0' ended string that describes the key of the event
+ * @param value '\0' ended string that describes the value of the event
+ */
+ virtual int postEvent(const char* key, const char* value) = 0;
+ /**
+ * @brief print log to the SDK.
+ * @param level Log level @ref agora::commons::LOG_LEVEL
+ * @param format log formatter string
+ * @param ... variadic arguments
+ */
+ virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
+ };
+public:
+ /**
+ * @brief AgoraSDK set IAudioFilterV2::Control to filter
+ * @param control IAudioFilterV2::Control
+ */
+ virtual void setExtensionControl(agora::agora_refptr control) = 0;
+};
+
/**
* The `IVideoFilterBase` class is the base class for video filters. You can use this class to implement your own filter
* and add the filter to a video track.
@@ -365,6 +391,64 @@ class IExtensionVideoFilter : public IVideoFilter {
}
};
+class ILipSyncFilter : public RefCountInterface {
+ public:
+ enum ProcessResult {
+ kSuccess, // Video frame data is successfully processed
+ kBypass, // Video frame data should bypass the current filter and flow to its successsors
+ kDrop, // Video Frame data should be discarded
+ };
+
+ class Control : public RefCountInterface {
+ public:
+ /**
+ * @brief Post an event and notify the end users.
+ * @param key '\0' ended string that describes the key of the event
+ * @param value '\0' ended string that describes the value of the event
+ */
+ virtual int postEvent(const char* key, const char* value) = 0;
+ /**
+ * @brief print log to the SDK.
+ * @param level Log level @ref agora::commons::LOG_LEVEL
+ * @param format log formatter string
+ * @param ... variadic arguments
+ */
+ virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
+ /**
+ * @brief Ask SDK to disable the current filter if a fatal error is detected
+ * @param error error code
+ * @param msg error message
+ */
+ virtual void disableMe(int error, const char* msg) = 0;
+ /**
+ * @brief report counter to the SDK.
+ * @param counter_id counter id
+ * @param value counter value
+ */
+ virtual void ReportCounter(int32_t counter_id, int32_t value) = 0;
+ /**
+ * @brief get stats to the SDK.
+ * @param counter_id counter id
+ */
+ virtual int GetStats(int32_t counter_id) = 0;
+ };
+
+ virtual int start(agora::agora_refptr control) = 0;
+
+ virtual int stop() = 0;
+
+ virtual int setProperty(const char* key, const void* buf, size_t buf_size) { return -1; }
+ /**
+ * Convert the audio frame to face info.
+ * @param inAudioFrame The reference to the audio frame that you want to convert.
+ * @param outFaceInfo The reference to the face info.
+ * @return see @ref ProcessResult
+ */
+ virtual ProcessResult convertAudioFrameToFaceInfo(const agora::media::base::AudioPcmFrame& inAudioFrame, char* outFaceInfo) {
+ return kBypass;
+ }
+};
+
/**
* The `IVideoSinkBase` class is the base class for the custom video sink.
*/
@@ -434,10 +518,10 @@ class IVideoSinkBase : public RefCountInterface {
class IMediaExtensionObserver : public RefCountInterface {
public:
virtual ~IMediaExtensionObserver() {}
- virtual void onEvent(const char* provider, const char* extension, const char* key, const char* json_value) {}
- virtual void onExtensionStopped(const char* provider, const char* extension) {}
- virtual void onExtensionStarted(const char* provider, const char* extension) {}
- virtual void onExtensionError(const char* provider, const char* extension, int error, const char* message) {}
+ virtual void onEventWithContext(const ExtensionContext& context, const char* key, const char* json_value) {}
+ virtual void onExtensionStoppedWithContext(const ExtensionContext& context) {}
+ virtual void onExtensionStartedWithContext(const ExtensionContext& context) {}
+ virtual void onExtensionErrorWithContext(const ExtensionContext& context, int error, const char* message) {}
};
/**
@@ -465,7 +549,7 @@ class IAudioPcmDataSender : public RefCountInterface {
const size_t samples_per_channel, // for 10ms Data, number_of_samples * 100 = sample_rate
const agora::rtc::BYTES_PER_SAMPLE bytes_per_sample, // 2
const size_t number_of_channels,
- const uint32_t sample_rate, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; // sample_rate > 8000)
+ const uint32_t sample_rate, aosl_ref_t ares = AOSL_REF_INVALID) = 0; // sample_rate > 8000)
protected:
~IAudioPcmDataSender() {}
@@ -493,7 +577,7 @@ class IAudioEncodedFrameSender : public RefCountInterface {
* - `false`: Failure.
*/
virtual bool sendEncodedAudioFrame(const uint8_t* payload_data, size_t payload_size,
- const EncodedAudioFrameInfo& audioFrameInfo, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ const EncodedAudioFrameInfo& audioFrameInfo, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
protected:
~IAudioEncodedFrameSender() {}
@@ -576,7 +660,7 @@ class IMediaPacketSender : public RefCountInterface {
* - `false`: Failure.
*/
virtual int sendMediaPacket(const uint8_t *packet, size_t length,
- const media::base::PacketOptions &options, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ const media::base::PacketOptions &options, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
protected:
~IMediaPacketSender() {}
};
@@ -604,7 +688,7 @@ class IMediaControlPacketSender {
*/
virtual int sendPeerMediaControlPacket(media::base::user_id_t userId,
const uint8_t *packet,
- size_t length, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sends the media transport control packet to all users.
@@ -616,7 +700,7 @@ class IMediaControlPacketSender {
* - `true`: Success.
* - `false`: Failure.
*/
- virtual int sendBroadcastMediaControlPacket(const uint8_t *packet, size_t length, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int sendBroadcastMediaControlPacket(const uint8_t *packet, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
virtual ~IMediaControlPacketSender() {}
};
@@ -658,7 +742,7 @@ class IVideoFrameSender : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int sendVideoFrame(const media::base::ExternalVideoFrame& videoFrame, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int sendVideoFrame(const media::base::ExternalVideoFrame& videoFrame, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
protected:
~IVideoFrameSender() {}
@@ -685,7 +769,7 @@ class IVideoEncodedImageSender : public RefCountInterface {
* - `false`: Failure.
*/
virtual bool sendEncodedVideoImage(const uint8_t* imageBuffer, size_t length,
- const EncodedVideoFrameInfo& videoEncodedFrameInfo, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ const EncodedVideoFrameInfo& videoEncodedFrameInfo, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
protected:
~IVideoEncodedImageSender() {}
@@ -779,7 +863,7 @@ class IVideoRenderer : public IVideoSinkBase {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the render mode of the view.
* @param view the view to set render mode.
@@ -788,7 +872,7 @@ class IVideoRenderer : public IVideoSinkBase {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setRenderMode(void* view, media::base::RENDER_MODE_TYPE renderMode, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRenderMode(void* view, media::base::RENDER_MODE_TYPE renderMode, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets whether to mirror the video.
* @param mirror Whether to mirror the video:
@@ -798,7 +882,7 @@ class IVideoRenderer : public IVideoSinkBase {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setMirror(bool mirror, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setMirror(bool mirror, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets whether to mirror the video.
* @param view the view to set mirror mode.
@@ -809,7 +893,7 @@ class IVideoRenderer : public IVideoSinkBase {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setMirror(void* view, bool mirror, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setMirror(void* view, bool mirror, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the video display window.
* @param view The pointer to the video display window.
@@ -817,7 +901,7 @@ class IVideoRenderer : public IVideoSinkBase {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setView(void* view, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setView(void* view, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the video display window.
* @param view The pointer to the video display window.
@@ -826,14 +910,14 @@ class IVideoRenderer : public IVideoSinkBase {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int addView(void* view, const Rectangle& cropArea, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int addView(void* view, const Rectangle& cropArea, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops rendering the video view on the window.
* @return
* - 0: Success.
* - < 0: Failure.
*/
- virtual int unsetView(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unsetView(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* remove rendering the video view on the window.
* @return
@@ -852,8 +936,8 @@ class IVideoTrack;
class IVideoFrameTransceiver : public RefCountInterface {
public:
virtual int getTranscodingDelayMs() = 0;
- virtual int addVideoTrack(agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
- virtual int removeVideoTrack(agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int addVideoTrack(agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int removeVideoTrack(agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
};
}
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNodeFactory.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNodeFactory.h
index fb57b852e..a22242b23 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNodeFactory.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNodeFactory.h
@@ -7,7 +7,7 @@
#pragma once // NOLINT(build/header_guard)
#include "AgoraBase.h"
-#include
+#include
namespace agora {
namespace rtc {
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRemoteAudioMixerSource.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRemoteAudioMixerSource.h
index 12aa0d80d..98bdf2bd2 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRemoteAudioMixerSource.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRemoteAudioMixerSource.h
@@ -7,7 +7,7 @@
#pragma once
#include "AgoraRefPtr.h"
-#include
+#include
namespace agora {
namespace rtc {
@@ -27,13 +27,13 @@ class IRemoteAudioMixerSource : public RefCountInterface {
* Add a audio track for mixing. Automatically starts mixing if add audio track
* @param track The instance of the audio track that you want mixer to receive its audio stream.
*/
- virtual int addAudioTrack(agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int addAudioTrack(agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Remove a audio track for mixing. Automatically stops the mixed stream if all audio tracks are removed
* @param track The instance of the audio track that you want to remove from the mixer.
*/
- virtual int removeAudioTrack(agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int removeAudioTrack(agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the delay time for mix.
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtcConnection.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtcConnection.h
index 4085bd1d6..2959d06da 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtcConnection.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtcConnection.h
@@ -9,7 +9,7 @@
#include "AgoraBase.h"
#include "time_utils.h"
-#include
+#include
namespace agora {
namespace rtc {
@@ -212,7 +212,7 @@ class IRtcConnection : public RefCountInterface {
* - -2(ERR_INVALID_ARGUMENT): The argument that you pass is invalid.
* - -8(ERR_INVALID_STATE): The current connection state is not CONNECTION_STATE_DISCONNECTED(1).
*/
- virtual int connect(const char* token, const char* channelId, user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int connect(const char* token, const char* channelId, user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Connects to an Agora channel.
@@ -225,7 +225,7 @@ class IRtcConnection : public RefCountInterface {
* The SDK also triggers `onConnected` or `onDisconnected` to notify you of the state change.
* @param settings The settings of connecting.
*/
- virtual int connect(const TConnectSettings& settings, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int connect(const TConnectSettings& settings, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Disconnects from the Agora channel.
@@ -238,7 +238,7 @@ class IRtcConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int disconnect(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int disconnect(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Starts the last-mile network probe test.
@@ -267,7 +267,7 @@ class IRtcConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int startLastmileProbeTest(const LastmileProbeConfig& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int startLastmileProbeTest(const LastmileProbeConfig& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops the last-mile network probe test.
@@ -275,7 +275,7 @@ class IRtcConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int stopLastmileProbeTest(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int stopLastmileProbeTest(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Renews the token.
@@ -286,7 +286,7 @@ class IRtcConnection : public RefCountInterface {
*
* @param token The pointer to the new token.
*/
- virtual int renewToken(const char* token, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int renewToken(const char* token, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the connection information.
@@ -340,7 +340,7 @@ class IRtcConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerObserver(IRtcConnectionObserver* observer, void(*safeDeleter)(IRtcConnectionObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerObserver(IRtcConnectionObserver* observer, void(*safeDeleter)(IRtcConnectionObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the registered IRtcConnectionObserver object.
@@ -361,7 +361,7 @@ class IRtcConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerNetworkObserver(INetworkObserver* observer, void(*safeDeleter)(INetworkObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerNetworkObserver(INetworkObserver* observer, void(*safeDeleter)(INetworkObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the registered INetworkObserver object.
@@ -437,7 +437,7 @@ class IRtcConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int sendStreamMessage(int streamId, const char* data, size_t length, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int sendStreamMessage(int streamId, const char* data, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Enables/Disables the built-in encryption.
*
@@ -457,7 +457,7 @@ class IRtcConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int enableEncryption(bool enabled, const EncryptionConfig& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int enableEncryption(bool enabled, const EncryptionConfig& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Reports a custom event to Agora.
@@ -472,7 +472,7 @@ class IRtcConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int sendCustomReportMessage(const char* id, const char* category, const char* event, const char* label, int value, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int sendCustomReportMessage(const char* id, const char* category, const char* event, const char* label, int value, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/** Gets the user information by user account, which is in string format.
*
* @param userAccount The user account of the user.
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpConnection.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpConnection.h
index d0516cb6d..1fabd7339 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpConnection.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpConnection.h
@@ -9,7 +9,7 @@
#include "AgoraBase.h"
#include "AgoraRefPtr.h"
-#include
+#include
namespace agora {
namespace rtc {
@@ -231,10 +231,8 @@ enum RTMP_CONNECTION_STATE {
struct RtmpConnectionConfiguration {
RtmpStreamingAudioConfiguration audioConfig;
RtmpStreamingVideoConfiguration videoConfig;
- bool enableWriteFlvFile;
bool audioOnly;
- RtmpConnectionConfiguration() : enableWriteFlvFile(false),
- audioOnly(false) {}
+ RtmpConnectionConfiguration() : audioOnly(false) {}
};
/**
@@ -339,7 +337,7 @@ class IRtmpConnection : public RefCountInterface {
* - ERR_INVALID_ARGUMENT: The passed in argument is invalid.
* - ERR_INVALID_STATE: The current connection state is not STATE_DISCONNECTED(3).
*/
- virtual int connect(const char* url, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int connect(const char* url, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Disconnects from the RTMP server.
@@ -348,7 +346,7 @@ class IRtmpConnection : public RefCountInterface {
* STATE_DISCONNECTED(4). You will be notified with the callback
* \ref onDisconnected "onDisconnected".
*/
- virtual int disconnect(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int disconnect(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the current connection information.
@@ -376,7 +374,7 @@ class IRtmpConnection : public RefCountInterface {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerObserver(IRtmpConnectionObserver* observer, void(*safeDeleter)(IRtmpConnectionObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerObserver(IRtmpConnectionObserver* observer, void(*safeDeleter)(IRtmpConnectionObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the registered IRtmpConnectionObserver object.
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpLocalUser.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpLocalUser.h
index 4b2531f47..e5ee27f0c 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpLocalUser.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpLocalUser.h
@@ -134,7 +134,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setAudioStreamConfiguration(const RtmpStreamingAudioConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioStreamConfiguration(const RtmpStreamingAudioConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set the parameters of the video encoder when pushing the stream
@@ -145,7 +145,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setVideoStreamConfiguration(const RtmpStreamingVideoConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setVideoStreamConfiguration(const RtmpStreamingVideoConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Adjusts the audio volume for publishing.
@@ -156,7 +156,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int adjustRecordingSignalVolume(int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int adjustRecordingSignalVolume(int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the current volume for publishing.
@@ -182,7 +182,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int adjustVideoBitrate(VideoBitrateAdjustType type, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int adjustVideoBitrate(VideoBitrateAdjustType type, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set whether to enable local video
@@ -195,7 +195,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setVideoEnabled(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setVideoEnabled(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Publishes a local audio track to the RTMP connection.
@@ -205,7 +205,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int publishAudio(agora_refptr audioTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int publishAudio(agora_refptr audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops publishing the local audio track to the RTMP connection.
@@ -215,7 +215,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int unpublishAudio(agora_refptr audioTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unpublishAudio(agora_refptr audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Publishes a local video track to the RTMP connection.
@@ -225,7 +225,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int publishVideo(agora_refptr videoTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int publishVideo(agora_refptr videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Stops publishing the local video track to the RTMP connection.
@@ -234,7 +234,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int unpublishVideo(agora_refptr videoTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int unpublishVideo(agora_refptr videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Registers a RTMP user observer object.
@@ -247,7 +247,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerRtmpUserObserver(IRtmpLocalUserObserver* observer, void(*safeDeleter)(IRtmpLocalUserObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerRtmpUserObserver(IRtmpLocalUserObserver* observer, void(*safeDeleter)(IRtmpLocalUserObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the IRtmpLocalUserObserver object previously registered using registerRtmpUserObserver().
@@ -267,7 +267,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Unregisters an audio frame observer object.
@@ -285,7 +285,7 @@ class IRtmpLocalUser {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerVideoFrameObserver(media::base::IVideoFrameObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerVideoFrameObserver(media::base::IVideoFrameObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Unregisters a video frame observer object.
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraScreenCapturer.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraScreenCapturer.h
index ee1633fb6..3204f9916 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraScreenCapturer.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraScreenCapturer.h
@@ -8,7 +8,7 @@
#include "AgoraBase.h"
#include "AgoraRefPtr.h"
-#include
+#include
namespace agora {
namespace rtc {
@@ -91,7 +91,7 @@ class IScreenCapturer : public RefCountInterface {
* - < 0: Failure.
* - ERR_NOT_READY: No screen or window is being shared.
*/
- virtual int setContentHint(VIDEO_CONTENT_HINT contentHint, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setContentHint(VIDEO_CONTENT_HINT contentHint, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Updates the screen capture region.
@@ -103,19 +103,19 @@ class IScreenCapturer : public RefCountInterface {
* - < 0: Failure.
* - No screen or window is being shared.
*/
- virtual int updateScreenCaptureRegion(const Rectangle& regionRect, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int updateScreenCaptureRegion(const Rectangle& regionRect, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set orientation of the captured screen image
* @param VIDEO_ORIENTATION orientaion of the device 0(by default), 90, 180, 270
*/
- virtual int setScreenOrientation(VIDEO_ORIENTATION orientation, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setScreenOrientation(VIDEO_ORIENTATION orientation, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set frame rate of the screen capture source
* @param rate frame rate (in fps)
*/
- virtual int setFrameRate(int rate, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setFrameRate(int rate, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
#if defined(__ANDROID__)
/**
@@ -155,7 +155,7 @@ class IScreenCapturer2 : public RefCountInterface {
* - < 0: Failure.
* - ERR_INVALID_ARGUMENT if data is null.
*/
- virtual int setScreenCaptureDimensions(const VideoDimensions& dimensions, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setScreenCaptureDimensions(const VideoDimensions& dimensions, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Updates the screen capture region.
@@ -167,13 +167,13 @@ class IScreenCapturer2 : public RefCountInterface {
* - < 0: Failure.
* - No screen or window is being shared.
*/
- virtual int updateScreenCaptureRegion(const Rectangle& regionRect, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int updateScreenCaptureRegion(const Rectangle& regionRect, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set frame rate of the screen capture source
* @param rate frame rate (in fps)
*/
- virtual int setFrameRate(int rate, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setFrameRate(int rate, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set channels and sample rate of screen audio capturing
@@ -183,7 +183,7 @@ class IScreenCapturer2 : public RefCountInterface {
* - 0: Sucess.
* - < 0: Failure
*/
- virtual int setAudioRecordConfig(int channels, int sampleRate, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioRecordConfig(int channels, int sampleRate, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set volume of screen audio capturing
@@ -192,7 +192,7 @@ class IScreenCapturer2 : public RefCountInterface {
* - 0: Sucess.
* - < 0: Failure
*/
- virtual int setAudioVolume(uint32_t volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setAudioVolume(uint32_t volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
protected:
virtual ~IScreenCapturer2() {}
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraSyncClient.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraSyncClient.h
new file mode 100644
index 000000000..7c8880de2
--- /dev/null
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraSyncClient.h
@@ -0,0 +1,139 @@
+// Copyright (c) 2020 Agora.io. All rights reserved
+
+// This program is confidential and proprietary to Agora.io.
+// And may not be copied, reproduced, modified, disclosed to others, published
+// or used, in whole or in part, without the express prior written permission
+// of Agora.io.
+
+#pragma once // NOLINT(build/header_guard)
+#include "AgoraRefPtr.h"
+#include "AgoraBase.h"
+#include
+#include
+
+namespace agora {
+namespace base {
+
+enum SyncClientError {
+ kOk = 0,
+ kFail = -1,
+ kConnectSyncFailed = -2,
+ kConnectDatabaseFailed = -3,
+ kDisconnectDatabaseFailed = -4,
+ kDatabaseNotConnected = -5,
+ kCreateCollectionFailed = -6,
+ kCollectionNotCreated = -7,
+ kCollectionExisted = -8,
+ kInvalidParams = -9,
+ kNotLoggedIn = -10,
+ kQueryDocFailed = -11,
+ kDocNotCreated = -12,
+};
+
+typedef void(*syncClientCallback)(SyncClientError, void*);
+typedef void(*dataBaseOpCallback)(SyncClientError, const char*, void*);
+typedef void(*collectionOpCallback)(SyncClientError, const char*, const char*, void*);
+typedef void(*queryDocCallback)(SyncClientError error, const char* resultJson, size_t count, bool more, void* userData);
+
+enum SyncEventType {
+ kInserted = 0,
+ kPut = 1,
+ kDeleted = 2,
+
+ kToBeInserted = 3,
+ kToBePut = 4,
+ kToBeDeleted = 5,
+
+ kTransactionBegin = 6,
+ kTransactionEnd = 7,
+ kDocSyncEnd = 8,
+};
+
+/**
+ * sync client observer
+ */
+class ISyncClientObserver {
+ public:
+ struct CollectionEvent {
+ SyncEventType type;
+ const char* path;
+ const char* value;
+ };
+ virtual void onCollectionEvent(const char* previousJson, const char* curJson, const char* collection, const char* docName,
+ const CollectionEvent* events, int eventSize) = 0;
+ virtual void onDatabaseEvent(const char* databaseName, SyncClientError error) = 0;
+ virtual void onDataException(const char* databaseName, const char* collectionName) = 0;
+ virtual ~ISyncClientObserver() {};
+};
+
+/**
+ * sync configuration
+ */
+struct SyncConfig {
+ const char* appId;
+ /* shakehand interval in seconds, 0 means enable manual shake hand */
+ uint32_t shakehand_interval;
+ /* connection timeout in seconds */
+ uint32_t connection_timeout;
+ /* compact interval in seconds */
+ uint32_t compact_interval;
+ SyncConfig() : shakehand_interval(1), connection_timeout(10), compact_interval(3600 * 1000) {}
+};
+
+class ISyncClient : public RefCountInterface {
+protected:
+ virtual ~ISyncClient() {}
+public:
+
+ virtual int32_t registerSyncClientObserver(ISyncClientObserver* observer, void(*safeDeleter)(ISyncClientObserver*) = OPTIONAL_NULLPTR, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t unregisterSyncClientObserver(ISyncClientObserver* observer) = 0;
+ // client operations
+ virtual int32_t login(const char* token, const char* channelName, user_id_t userId, syncClientCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t queryDoc(const char* database, const char* coll, const char* range_start, const char* range_end, int64_t limits, bool doc_only, bool count_only, queryDocCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t logout(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t renewToken(const char* token, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+
+ // database operations
+ virtual int32_t connectDatabase(const char* database, dataBaseOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t disconnectDatabase(const char* database,
+ dataBaseOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t createCollection(const char* database, const char* collection,
+ const char** readable, int readSize,
+ collectionOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t deleteCollection(const char* database, const char* collection,
+ collectionOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+
+ // collection operations
+ virtual int32_t subscribe(const char* database, const char* collection,
+ util::AString& snapshotJson) = 0;
+ virtual int32_t unsubscribe(const char* database, const char* collection, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t putDoc(const char* database, const char* collection,
+ const char* docName, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t deleteDoc(const char* database, const char* collection,
+ const char* docName, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t getDocs(const char* database, const char* collection,
+ util::AString* docNames, uint32_t docSize) = 0;
+
+ // document operations
+ virtual int32_t putDocValue(const char* database, const char* collection,
+ const char* docName, const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t updateDocValue(const char* database, const char* collection,
+ const char* docName, const char* path,
+ const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t deleteDocValue(const char* database, const char* collection,
+ const char* docName, const char* path, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t deleteDocValues(const char* database, const char* collection, const char* docName,
+ const char** path, uint32_t pathSize,
+ aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+ virtual int32_t getDocValue(const char* database, const char* collection,
+ const char* docName, util::AString& jsonValue) = 0;
+ virtual int32_t hasPath(const char* database, const char* collection,
+ const char* docName, const char* path, bool& result) = 0;
+ virtual int32_t keepAliveDoc(const char* database, const char* collection,
+ const char* docName, uint32_t ttl, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+
+ // sync operations
+ virtual int32_t shakehand(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
+};
+}// namespace base
+}// namespace agora
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoFrame.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoFrame.h
index 9b114002f..3823ec28b 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoFrame.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoFrame.h
@@ -40,6 +40,7 @@ struct TextureInfo {
EglContextType context_type;
void* shared_context;
int texture_id;
+ int64_t fence_object;
float transform_matrix[16];
};
@@ -73,84 +74,6 @@ struct PaddedRawPixelBuffer {
: data(NULL), size(0), stride(0) {}
};
-struct ColorSpace {
- enum PrimaryID {
- // The indices are equal to the values specified in T-REC H.273 Table 2.
- PRIMARYID_BT709 = 1,
- PRIMARYID_UNSPECIFIED = 2,
- PRIMARYID_BT470M = 4,
- PRIMARYID_BT470BG = 5,
- PRIMARYID_SMPTE170M = 6, // Identical to BT601
- PRIMARYID_SMPTE240M = 7,
- PRIMARYID_FILM = 8,
- PRIMARYID_BT2020 = 9,
- PRIMARYID_SMPTEST428 = 10,
- PRIMARYID_SMPTEST431 = 11,
- PRIMARYID_SMPTEST432 = 12,
- PRIMARYID_JEDECP22 = 22, // Identical to EBU3213-E
- };
-
- enum RangeID {
- // The indices are equal to the values specified at
- // https://www.webmproject.org/docs/container/#colour for the element Range.
- RANGEID_INVALID = 0,
- // Limited Rec. 709 color range with RGB values ranging from 16 to 235.
- RANGEID_LIMITED = 1,
- // Full RGB color range with RGB valees from 0 to 255.
- RANGEID_FULL = 2,
- // Range is defined by MatrixCoefficients/TransferCharacteristics.
- RANGEID_DERIVED = 3,
- };
-
- enum MatrixID {
- // The indices are equal to the values specified in T-REC H.273 Table 4.
- MATRIXID_RGB = 0,
- MATRIXID_BT709 = 1,
- MATRIXID_UNSPECIFIED = 2,
- MATRIXID_FCC = 4,
- MATRIXID_BT470BG = 5,
- MATRIXID_SMPTE170M = 6,
- MATRIXID_SMPTE240M = 7,
- MATRIXID_YCOCG = 8,
- MATRIXID_BT2020_NCL = 9,
- MATRIXID_BT2020_CL = 10,
- MATRIXID_SMPTE2085 = 11,
- MATRIXID_CDNCLS = 12,
- MATRIXID_CDCLS = 13,
- MATRIXID_BT2100_ICTCP = 14,
- };
-
- enum TransferID {
- // The indices are equal to the values specified in T-REC H.273 Table 3.
- TRANSFERID_BT709 = 1,
- TRANSFERID_UNSPECIFIED = 2,
- TRANSFERID_GAMMA22 = 4,
- TRANSFERID_GAMMA28 = 5,
- TRANSFERID_SMPTE170M = 6,
- TRANSFERID_SMPTE240M = 7,
- TRANSFERID_LINEAR = 8,
- TRANSFERID_LOG = 9,
- TRANSFERID_LOG_SQRT = 10,
- TRANSFERID_IEC61966_2_4 = 11,
- TRANSFERID_BT1361_ECG = 12,
- TRANSFERID_IEC61966_2_1 = 13,
- TRANSFERID_BT2020_10 = 14,
- TRANSFERID_BT2020_12 = 15,
- TRANSFERID_SMPTEST2084 = 16,
- TRANSFERID_SMPTEST428 = 17,
- TRANSFERID_ARIB_STD_B67 = 18,
- };
-
- PrimaryID primaries;
- TransferID transfer;
- MatrixID matrix;
- RangeID range;
-
- ColorSpace()
- : primaries(PRIMARYID_UNSPECIFIED), transfer(TRANSFERID_UNSPECIFIED),
- matrix(MATRIXID_UNSPECIFIED), range(RANGEID_INVALID) {}
-};
-
/**
* This structure defines underlying detailed video frame data of @ref agora::rtc::IVideoFrame
*
@@ -173,7 +96,7 @@ struct VideoFrameData {
int width;
int height;
int rotation;
- ColorSpace color_space;
+ agora::media::base::ColorSpace color_space;
int64_t timestamp_ms; // Capture time in milli-seconds
};
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoMixerSource.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoMixerSource.h
index 7cbe7183c..58d085b6b 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoMixerSource.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoMixerSource.h
@@ -51,7 +51,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int addVideoTrack(const char* id, agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int addVideoTrack(const char* id, agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Remove the video track.
* @param id The unique id of the stream.
@@ -60,7 +60,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int removeVideoTrack(const char* id, agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int removeVideoTrack(const char* id, agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Configures the layout of video frames comming from a specific track (indicated by uid)
* on the mixer canvas.
@@ -70,7 +70,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int setStreamLayout(const char* id, const MixerLayoutConfig& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setStreamLayout(const char* id, const MixerLayoutConfig& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Remove the user layout on the mixer canvas
* @param id The unique id of the stream.
@@ -79,7 +79,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int delStreamLayout(const char* id, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int delStreamLayout(const char* id, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Add a image source to the mixer with its layout configuration on the mixer canvas.
* @param id The unique id of the image.
@@ -88,7 +88,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int addImageSource(const char* id, const MixerLayoutConfig& config, ImageType type = kPng, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int addImageSource(const char* id, const MixerLayoutConfig& config, ImageType type = kPng, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Delete a image source to the mixer.
* @param id The unique id of the image.
@@ -96,18 +96,18 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int delImageSource(const char* id, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int delImageSource(const char* id, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Clear all the layout settings set previously
*/
- virtual int clearLayout(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int clearLayout(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Refresh the user layout on the mixer canvas
* @return
* 0 - Success
* <0 - Failure
*/
- virtual int refresh(ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int refresh(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set the mixer canvas background to override the default configuration
* @param width width of the canvas
@@ -118,7 +118,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int setBackground(uint32_t width, uint32_t height, int fps, uint32_t color_argb = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setBackground(uint32_t width, uint32_t height, int fps, uint32_t color_argb = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set the mixer canvas background to override the default configuration
* @param width width of the canvas
@@ -129,7 +129,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int setBackground(uint32_t width, uint32_t height, int fps, const char* url, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setBackground(uint32_t width, uint32_t height, int fps, const char* url, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set the rotation of the mixed video stream
* @param rotation:0:none, 1:90°, 2:180°, 3:270°
@@ -137,7 +137,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int setRotation(uint8_t rotation, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setRotation(uint8_t rotation, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Get the average delay in ms introduced by the mixer module, which includes the average
* mixing delay plus the encoder delay.
@@ -152,7 +152,7 @@ class IVideoMixerSource : public RefCountInterface {
* 0 - Success
* <0 - Failure
*/
- virtual int setMasterClockSource(const char* id = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setMasterClockSource(const char* id = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
};
} //namespace rtc
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoTrack.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoTrack.h
index a79cb5e45..ea36ee93e 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoTrack.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoTrack.h
@@ -9,7 +9,7 @@
#pragma once // NOLINT(build/header_guard)
#include "AgoraBase.h"
-#include
+#include
#ifndef OPTIONAL_OVERRIDE
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
@@ -26,6 +26,65 @@ class IVideoEncodedFrameObserver;
class IMediaPacketReceiver;
class IVideoSinkBase;
+enum StreamLayerIndexInternal {
+ STREAM_LAYER_1 = 1,
+ STREAM_LAYER_2 = 2,
+ STREAM_LAYER_3 = 3,
+ STREAM_LAYER_4 = 4,
+ STREAM_LAYER_5 = 5,
+ STREAM_LAYER_6 = 6,
+ STREAM_LOW = 7,
+ STREAM_LAYER_COUNT_MAX = 8
+ };
+
+struct StreamLayerConfigInternal {
+ VideoDimensions dimensions;
+ int framerate;
+ int bitrate_kbps;
+ bool enable;
+ StreamLayerConfigInternal() : dimensions(0, 0), framerate(0), bitrate_kbps(STANDARD_BITRATE), enable(false) {}
+ StreamLayerConfigInternal(const StreamLayerConfigInternal& other) : dimensions(other.dimensions), framerate(other.framerate), bitrate_kbps(other.bitrate_kbps), enable(other.enable) {}
+ bool operator==(const StreamLayerConfigInternal& rhs) const {
+ return dimensions == rhs.dimensions && bitrate_kbps == rhs.bitrate_kbps && framerate == rhs.framerate && enable == rhs.enable;
+ }
+
+ StreamLayerConfigInternal& operator=(const SimulcastConfig::StreamLayerConfig& slc) {
+ dimensions = slc.dimensions;
+ framerate = slc.framerate;
+ enable = slc.enable;
+ return *this;
+ }
+
+ void reset() {
+ dimensions.width = 0;
+ dimensions.height = 0;
+ framerate = 0;
+ bitrate_kbps = STANDARD_BITRATE;
+ enable = false;
+ }
+};
+
+struct SimulcastConfigInternal {
+ StreamLayerConfigInternal simulcastlayerConfigs[STREAM_LAYER_COUNT_MAX];
+
+ void reset() {
+ for (int i = STREAM_LAYER_1; i < STREAM_LAYER_COUNT_MAX; i++) {
+ simulcastlayerConfigs[i].reset();
+ }
+ }
+
+ bool operator==(const SimulcastConfigInternal& rhs) const {
+ for (int i = 0; i < STREAM_LAYER_COUNT_MAX; i++) {
+ if (simulcastlayerConfigs[i] == rhs.simulcastlayerConfigs[i]) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+};
+
enum VideoTrackType {
LOCAL_VIDEO_TRACK,
REMOTE_VIDEO_TRACK,
@@ -56,7 +115,7 @@ class IVideoTrack : public RefCountInterface {
*/
virtual bool addVideoFilter(
agora_refptr filter, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_POST_CAPTURER,
- const char* id = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ const char* id = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Removes the video filter added by `addVideoFilter` from the video track.
@@ -70,7 +129,7 @@ class IVideoTrack : public RefCountInterface {
*/
virtual bool removeVideoFilter(
agora_refptr filter, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_POST_CAPTURER,
- const char* id = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ const char* id = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Whether a video filter exists
@@ -95,7 +154,7 @@ class IVideoTrack : public RefCountInterface {
* - `true`: The video renderer is added successfully.
* - `false`: The video renderer fails to be added.
*/
- virtual bool addRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual bool addRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Removes the video renderer added by `addRenderer` from the video track.
*
@@ -105,7 +164,7 @@ class IVideoTrack : public RefCountInterface {
* - `true`: The video renderer is removed successfully.
* - `false`: The video renderer fails to be removed.
*/
- virtual bool removeRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual bool removeRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Get the track type of the video track
* @return
@@ -121,7 +180,7 @@ class IVideoTrack : public RefCountInterface {
* - 0: success
* - <0: failure
*/
- virtual int enableVideoFilter(const char* id, bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) { return -1; }
+ virtual int enableVideoFilter(const char* id, bool enable, aosl_ref_t ares = AOSL_REF_INVALID) { return -1; }
/**
* set the properties of the specified video filter
@@ -132,7 +191,7 @@ class IVideoTrack : public RefCountInterface {
* - 0: success
* - <0: failure
*/
- virtual int setFilterProperty(const char* id, const char* key, const char* json_value, ahpl_ref_t ares = AHPL_REF_INVALID) { return -1; }
+ virtual int setFilterProperty(const char* id, const char* key, const char* json_value, aosl_ref_t ares = AOSL_REF_INVALID) { return -1; }
/**
* get the properties of the specified video filter
@@ -143,12 +202,18 @@ class IVideoTrack : public RefCountInterface {
* - 0: success
* - <0: failure
*/
- virtual int getFilterProperty(const char* id, const char* key, char* json_value, size_t buf_size, ahpl_ref_t ares = AHPL_REF_INVALID) { return -1; }
+ virtual int getFilterProperty(const char* id, const char* key, char* json_value, size_t buf_size, aosl_ref_t ares = AOSL_REF_INVALID) { return -1; }
protected:
~IVideoTrack() {}
};
+struct SimulcastStreamProfile {
+ int width;
+ int height;
+ int framerate;
+ int bitrate;
+};
/**
* The statistics of the local video track.
*/
@@ -255,6 +320,8 @@ struct LocalVideoTrackStats {
/** The brightness level of the video image captured by the local camera. See #CAPTURE_BRIGHTNESS_LEVEL_TYPE.
*/
CAPTURE_BRIGHTNESS_LEVEL_TYPE capture_brightness_level;
+
+ SimulcastStreamProfile simulcast_stream_profile[STREAM_LAYER_COUNT_MAX];
LocalVideoTrackStats() : number_of_streams(0),
bytes_major_stream(0),
@@ -307,7 +374,7 @@ class ILocalVideoTrack : public IVideoTrack {
* - `true`: Enable the local video track.
* - `false`: Disable the local video track.
*/
- virtual int setEnabled(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setEnabled(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Sets the video encoder configuration.
@@ -325,7 +392,7 @@ class ILocalVideoTrack : public IVideoTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setVideoEncoderConfiguration(const VideoEncoderConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setVideoEncoderConfiguration(const VideoEncoderConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Set simulcast stream mode, enable, disable or auto enable
@@ -336,7 +403,7 @@ class ILocalVideoTrack : public IVideoTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastConfigInternal& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Gets the state of the local video stream.
@@ -388,6 +455,9 @@ struct RemoteVideoTrackStats {
* The bitrate (Kbps) received in the reported interval.
*/
int receivedBitrate;
+ /** The decoder input frame rate (fps) of the remote video track.
+ */
+ int decoderInputFrameRate;
/** The decoder output frame rate (fps) of the remote video track.
*/
int decoderOutputFrameRate;
@@ -457,13 +527,17 @@ struct RemoteVideoTrackStats {
decoder vender id, VideoCodecVenderId
*/
uint32_t decoder_vender_id;
+ /**
+ The decoder codec type of the remote video track
+ */
+ uint32_t decoder_type;
RemoteVideoTrackStats() : uid(0), delay(0), width(0), height(0),
- receivedBitrate(0), decoderOutputFrameRate(0), rendererOutputFrameRate(0),
+ receivedBitrate(0), decoderInputFrameRate(0), decoderOutputFrameRate(0), rendererOutputFrameRate(0),
frameLossRate(0), packetLossRate(0), rxStreamType(VIDEO_STREAM_HIGH),
totalFrozenTime(0), frozenRate(0), received_bytes(0), totalDecodedFrames(0), avSyncTimeMs(0),
downlink_process_time_ms(0), frame_render_delay_ms(0), totalActiveTime(0),
- publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0), decoder_vender_id(0) {}
+ publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0), decoder_vender_id(0), decoder_type(0) {}
};
/**
@@ -504,7 +578,7 @@ class IRemoteVideoTrack : public IVideoTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* encodedObserver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* encodedObserver, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object.
* @param encodedObserver The pointer to the `IVideoEncodedFrameObserver` object.
@@ -526,7 +600,7 @@ class IRemoteVideoTrack : public IVideoTrack {
* - 0: Success.
* - < 0: Failure.
*/
- virtual int registerMediaPacketReceiver(IMediaPacketReceiver* videoReceiver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0;
+ virtual int registerMediaPacketReceiver(IMediaPacketReceiver* videoReceiver, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
/**
* Releases the \ref agora::rtc::IMediaPacketReceiver "IMediaPacketReceiver" object.
* @param videoReceiver The pointer to the `IMediaPacketReceiver` object.
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ares.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_ares.h
similarity index 60%
rename from Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ares.h
rename to Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_ares.h
index 92c409bb3..9b5ba7b1f 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ares.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_ares.h
@@ -1,22 +1,22 @@
/*************************************************************
* Author: Lionfore Hao (haolianfu@agora.io)
* Date : May 30th, 2023
- * Module: AHPL async result object header file
+ * Module: AOSL async result object header file
*
*
- * This is a part of the Advanced High Performance Library.
+ * This is a part of the Advanced Operating System Layer.
* Copyright (C) 2018 ~ 2023 Agora IO
* All rights reserved.
*
*************************************************************/
-#ifndef __AHPL_ARES_H__
-#define __AHPL_ARES_H__
+#ifndef __AOSL_ARES_H__
+#define __AOSL_ARES_H__
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
#ifdef __cplusplus
extern "C" {
@@ -28,9 +28,9 @@ extern "C" {
* Parameter:
* arg: the parameter attached with the async result object;
* Return value:
- * the async result object ref id just created, AHPL_REF_INVALID when failed.
+ * the async result object ref id just created, AOSL_REF_INVALID when failed.
**/
-extern __ahpl_api__ ahpl_ref_t ahpl_ares_create (void *arg);
+extern __aosl_api__ aosl_ref_t aosl_ares_create (void *arg);
/**
* Complete the specified async result object.
@@ -38,10 +38,10 @@ extern __ahpl_api__ ahpl_ref_t ahpl_ares_create (void *arg);
* ref: the async result object ref id;
* result: a result value which can be retrieved by wait function;
* Return value:
- * <0: error occured, and ahpl_errno indicates which error;
+ * <0: error occured, and aosl_errno indicates which error;
* >=0: successful;
**/
-extern __ahpl_api__ int ahpl_ares_complete (ahpl_ref_t ref, intptr_t result);
+extern __aosl_api__ int aosl_ares_complete (aosl_ref_t ref, intptr_t result);
/**
* Wait the specified async result object to complete.
@@ -50,23 +50,23 @@ extern __ahpl_api__ int ahpl_ares_complete (ahpl_ref_t ref, intptr_t result);
* timeo: maximum waiting time in milliseconds;
* result: variable address for the value which was set by complete function,
* NOTE: the *result only will be set when the return value of wait
- * function is AHPL_POLL_ST_SIGNALED and result != NULL, if you
+ * function is AOSL_POLL_ST_SIGNALED and result != NULL, if you
* do not care the complete result, just passing NULL to it;
* Return value:
- * <0: error occured, and ahpl_errno indicates which error;
- * >=0: AHPL_POLL_ST_* macros value;
+ * <0: error occured, and aosl_errno indicates which error;
+ * >=0: AOSL_POLL_ST_* macros value;
**/
-extern __ahpl_api__ int ahpl_ares_wait (ahpl_ref_t ref, intptr_t timeo, intptr_t *result);
+extern __aosl_api__ int aosl_ares_wait (aosl_ref_t ref, intptr_t timeo, intptr_t *result);
/**
* Reset the specified async result object to non signaled state.
* Parameters:
* ref: the async result object ref id
* Return value:
- * <0: error occured, and ahpl_errno indicates which error;
+ * <0: error occured, and aosl_errno indicates which error;
* >=0: successful;
**/
-extern __ahpl_api__ int ahpl_ares_reset (ahpl_ref_t ref);
+extern __aosl_api__ int aosl_ares_reset (aosl_ref_t ref);
@@ -74,4 +74,4 @@ extern __ahpl_api__ int ahpl_ares_reset (ahpl_ref_t ref);
}
#endif
-#endif /* __AHPL_ARES_H__ */
\ No newline at end of file
+#endif /* __AOSL_ARES_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_defs.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_defs.h
similarity index 70%
rename from Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_defs.h
rename to Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_defs.h
index 3f1cb6a02..ce2386549 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_defs.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_defs.h
@@ -1,21 +1,21 @@
/*************************************************************
* Author: Lionfore Hao (haolianfu@agora.io)
* Date : Jul 21st, 2018
- * Module: AHPL common definitions header file
+ * Module: AOSL common definitions header file
*
*
- * This is a part of the Advanced High Performance Library.
+ * This is a part of the Advanced Operating System Layer.
* Copyright (C) 2018 Agora IO
* All rights reserved.
*
*************************************************************/
-#ifndef __AHPL_DEFS_H__
-#define __AHPL_DEFS_H__
+#ifndef __AOSL_DEFS_H__
+#define __AOSL_DEFS_H__
-#define ahpl_stringify_1(x) #x
-#define ahpl_stringify(x) ahpl_stringify_1(x)
+#define aosl_stringify_1(x) #x
+#define aosl_stringify(x) aosl_stringify_1(x)
#ifndef __MAKERCORE_ASSEMBLY__
@@ -42,17 +42,17 @@ extern "C" {
#endif
#endif
-#define ahpl_rela_addr(type, field) (&((type *)0)->field)
-#define ahpl_base_addr(ptr, type, field) \
+#define aosl_rela_addr(type, field) (&((type *)0)->field)
+#define aosl_base_addr(ptr, type, field) \
((type *)((uintptr_t)(ptr) - (uintptr_t)(&((type *)0)->field)))
-#define ahpl_min(x, y) ((x) < (y) ? (x) : (y))
-#define ahpl_max(x, y) ((x) > (y) ? (x) : (y))
+#define aosl_min(x, y) ((x) < (y) ? (x) : (y))
+#define aosl_max(x, y) ((x) > (y) ? (x) : (y))
/* I think 64 args is big enough */
-#define AHPL_VAR_ARGS_MAX 64
+#define AOSL_VAR_ARGS_MAX 64
#ifdef BUILD_TARGET_SHARED
@@ -66,17 +66,17 @@ extern "C" {
#endif
-#ifndef __ahpl_api__
+#ifndef __aosl_api__
#if defined (_MSC_VER) && defined (BUILDING_API_IMPL_SOURCE) && defined (BUILD_TARGET_SHARED)
-#define __ahpl_api__ __declspec (dllexport)
+#define __aosl_api__ __declspec (dllexport)
#elif defined (_MSC_VER) && !defined (BUILDING_API_IMPL_SOURCE)
-#define __ahpl_api__ __declspec (dllimport)
+#define __aosl_api__ __declspec (dllimport)
#else
-#define __ahpl_api__
+#define __aosl_api__
#endif
#endif
-#if defined (BUILDING_API_IMPL_SOURCE) || defined (STATIC_LINKING_AHPL)
+#if defined (BUILDING_API_IMPL_SOURCE) || defined (STATIC_LINKING_AOSL)
#if defined (__GNUC__)
#define __so_api__ __attribute__ ((visibility ("default")))
@@ -99,34 +99,34 @@ extern "C" {
#ifdef __GNUC__
#ifndef __MACH__
-#define AHPL_DEFINE_BIN(v, f) \
+#define AOSL_DEFINE_BIN(v, f) \
__asm__ (".section .rodata\n\t" \
".globl "#v"_bin_begin\n\t" \
".hidden "#v"_bin_begin\n\t" \
".align 4\n\t" \
#v"_bin_begin:\n\t" \
- ".incbin \"" ahpl_stringify(MAKERCORE_THIS_FILE_DIR/f)"\"\n\t" \
+ ".incbin \"" aosl_stringify(MAKERCORE_THIS_FILE_DIR/f)"\"\n\t" \
".globl "#v"_bin_end\n\t" \
".hidden "#v"_bin_end\n\t" \
#v"_bin_end:\n\t" \
".previous\n\t")
#else
-#define AHPL_DEFINE_BIN(v, f) \
+#define AOSL_DEFINE_BIN(v, f) \
__asm__ (".section __TEXT,__const\n\t" \
".globl _"#v"_bin_begin\n\t" \
".private_extern _"#v"_bin_begin\n\t" \
".align 4\n\t" \
"_"#v"_bin_begin:\n\t" \
- ".incbin \"" ahpl_stringify (MAKERCORE_THIS_FILE_DIR/f) "\"\n\t" \
+ ".incbin \"" aosl_stringify (MAKERCORE_THIS_FILE_DIR/f) "\"\n\t" \
".globl _"#v"_bin_end\n\t" \
".private_extern _"#v"_bin_end\n\t" \
"_"#v"_bin_end:\n\t" \
".previous\n\t")
#endif
-#define AHPL_DECLARE_BIN(v) extern unsigned char v##_bin_begin, v##_bin_end
-#define AHPL_BIN_ADDR(v) ((void *)&v##_bin_begin)
-#define AHPL_BIN_SIZE(v) ((size_t)((unsigned char *)&v##_bin_end - (unsigned char *)&v##_bin_begin))
+#define AOSL_DECLARE_BIN(v) extern unsigned char v##_bin_begin, v##_bin_end
+#define AOSL_BIN_ADDR(v) ((void *)&v##_bin_begin)
+#define AOSL_BIN_SIZE(v) ((size_t)((unsigned char *)&v##_bin_end - (unsigned char *)&v##_bin_begin))
#endif
@@ -138,26 +138,26 @@ __asm__ (".section __TEXT,__const\n\t" \
#ifdef __GNUC__
#ifndef __MACH__
-.macro AHPL_DEFINE_BIN_S v, f
+.macro AOSL_DEFINE_BIN_S v, f
.section .rodata
.globl \v\()_bin_begin
.hidden \v\()_bin_begin
.align 4
\v\()_bin_begin:
- .incbin ahpl_stringify (MAKERCORE_THIS_FILE_DIR/\f)
+ .incbin aosl_stringify (MAKERCORE_THIS_FILE_DIR/\f)
.globl \v\()_bin_end
.hidden \v\()_bin_end
\v\()_bin_end:
.previous
.endm
#else
-.macro AHPL_DEFINE_BIN_S v, f
+.macro AOSL_DEFINE_BIN_S v, f
.section __TEXT,__const
.globl _\()\v\()_bin_begin
.private_extern _\()\v\()_bin_begin
.align 4
_\()\v\()_bin_begin:
- .incbin ahpl_stringify (MAKERCORE_THIS_FILE_DIR/\f)
+ .incbin aosl_stringify (MAKERCORE_THIS_FILE_DIR/\f)
.globl _\()\v\()_bin_end
.private_extern _\()\v\()_bin_end
_\()\v\()_bin_end:
@@ -168,4 +168,4 @@ __asm__ (".section __TEXT,__const\n\t" \
#endif /* __MAKERCORE_ASSEMBLY__ */
-#endif /* __AHPL_DEFS_H__ */
\ No newline at end of file
+#endif /* __AOSL_DEFS_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_poll.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_poll.h
similarity index 65%
rename from Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_poll.h
rename to Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_poll.h
index d8d1e7785..4eac74a0d 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_poll.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_poll.h
@@ -1,21 +1,21 @@
/*************************************************************
* Author: Lionfore Hao (haolianfu@agora.io)
* Date : May 30th, 2023
- * Module: AHPL poll functionality definition header file
+ * Module: AOSL poll functionality definition header file
*
*
- * This is a part of the Advanced High Performance Library.
+ * This is a part of the Advanced Operating System Layer.
* Copyright (C) 2018 ~ 2023 Agora IO
* All rights reserved.
*
*************************************************************/
-#ifndef __AHPL_POLL_H__
-#define __AHPL_POLL_H__
+#ifndef __AOSL_POLL_H__
+#define __AOSL_POLL_H__
-#include
-#include
-#include
+#include
+#include
+#include
#ifdef __cplusplus
extern "C" {
@@ -23,9 +23,9 @@ extern "C" {
-#define AHPL_POLL_ST_NONE 0
-#define AHPL_POLL_ST_SIGNALED 1
-#define AHPL_POLL_ST_DESTROY 2
+#define AOSL_POLL_ST_NONE 0
+#define AOSL_POLL_ST_SIGNALED 1
+#define AOSL_POLL_ST_DESTROY 2
/**
* Poll the objects specified in refs, return their states.
@@ -37,10 +37,10 @@ extern "C" {
* then wake up immediately regardless min parameter.
* timeo: maximum waiting time in milliseconds;
* Return value:
- * <0: error occured, and ahpl_errno indicates which error;
+ * <0: error occured, and aosl_errno indicates which error;
* >=0: the signaled refs count before timeout;
**/
-extern __ahpl_api__ ssize_t ahpl_poll (ahpl_ref_t refs [], size_t count, size_t min, intptr_t timeo);
+extern __aosl_api__ ssize_t aosl_poll (aosl_ref_t refs [], size_t count, size_t min, intptr_t timeo);
@@ -48,4 +48,4 @@ extern __ahpl_api__ ssize_t ahpl_poll (ahpl_ref_t refs [], size_t count, size_t
}
#endif
-#endif /* __AHPL_POLL_H__ */
\ No newline at end of file
+#endif /* __AOSL_POLL_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ref.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_ref.h
similarity index 51%
rename from Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ref.h
rename to Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_ref.h
index b5264468b..4a2f439fa 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ref.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_ref.h
@@ -1,21 +1,21 @@
/*************************************************************
* Author: Lionfore Hao (haolianfu@agora.io)
* Date : Nov 19th, 2018
- * Module: AHPL reference object definition file
+ * Module: AOSL reference object definition file
*
*
- * This is a part of the Advanced High Performance Library.
+ * This is a part of the Advanced Operating System Layer.
* Copyright (C) 2018 Agora IO
* All rights reserved.
*
*************************************************************/
-#ifndef __AHPL_REF_H__
-#define __AHPL_REF_H__
+#ifndef __AOSL_REF_H__
+#define __AOSL_REF_H__
-#include
-#include
+#include
+#include
#ifdef __cplusplus
@@ -24,22 +24,22 @@ extern "C" {
-typedef struct _internal_ref_od_ *ahpl_ref_t;
+typedef struct _internal_ref_od_ *aosl_ref_t;
-#define AHPL_REF_INVALID ((ahpl_ref_t)(intptr_t)-1)
+#define AOSL_REF_INVALID ((aosl_ref_t)(intptr_t)NULL)
-#define ahpl_ref_invalid(ref) (((int)(intptr_t)(ref)) < 0)
+#define aosl_ref_invalid(ref) ((int)(intptr_t)(ref) <= 0)
/**
* The reference object destructor function prototype, which invoked when application
- * calling ahpl_ref_destroy functions to release resources.
+ * calling aosl_ref_destroy functions to release resources.
* Parameter:
* arg: the parameter passed in when creating the reference object;
* Return value:
* none.
**/
-typedef void (*ahpl_ref_dtor_t) (void *arg);
+typedef void (*aosl_ref_dtor_t) (void *arg);
/**
* The reference object creating function prototype, which is used to create a ref object.
@@ -51,9 +51,9 @@ typedef void (*ahpl_ref_dtor_t) (void *arg);
* none-0 guarantee the ref object relatives must be freed in the caller thread
* 0 the ref object relatives could be freed in any thread
* Return value:
- * the ref object id, please use ahpl_ref_invalid macro to check whether failed.
+ * the ref object id, please use aosl_ref_invalid macro to check whether failed.
**/
-extern __ahpl_api__ ahpl_ref_t ahpl_ref_create (void *arg, ahpl_ref_dtor_t dtor, int caller_free);
+extern __aosl_api__ aosl_ref_t aosl_ref_create (void *arg, aosl_ref_dtor_t dtor, int caller_free);
/**
@@ -61,13 +61,13 @@ extern __ahpl_api__ ahpl_ref_t ahpl_ref_create (void *arg, ahpl_ref_dtor_t dtor,
* Parameter:
* arg: the ref object argument which was passed in when creating;
* argc: specify the argv array elements count, the same as the argc
- * when invoking ahpl_ref_[get|read|write] functions;
+ * when invoking aosl_ref_[get|read|write] functions;
* argv: array for passing variable args, the same as the args
- * when invoking ahpl_task_exec_* functions;
+ * when invoking aosl_task_exec_* functions;
* Return value:
* none.
**/
-typedef void (*ahpl_ref_func_t) (void *arg, uintptr_t argc, uintptr_t argv []);
+typedef void (*aosl_ref_func_t) (void *arg, uintptr_t argc, uintptr_t argv []);
/**
* Hold the ref object, and invoke the specified callback function.
@@ -78,11 +78,11 @@ typedef void (*ahpl_ref_func_t) (void *arg, uintptr_t argc, uintptr_t argv []);
* ...: variable args
* Return value:
* 0: success
- * <0: failure with ahpl_errno set
+ * <0: failure with aosl_errno set
**/
-extern __ahpl_api__ int ahpl_ref_hold (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...);
-extern __ahpl_api__ int ahpl_ref_hold_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args);
-extern __ahpl_api__ int ahpl_ref_hold_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
+extern __aosl_api__ int aosl_ref_hold (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...);
+extern __aosl_api__ int aosl_ref_hold_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args);
+extern __aosl_api__ int aosl_ref_hold_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
/**
* Hold the ref object and read lock it, then invoke the specified callback function.
@@ -93,11 +93,11 @@ extern __ahpl_api__ int ahpl_ref_hold_argv (ahpl_ref_t ref, ahpl_ref_func_t f, u
* ...: variable args
* Return value:
* 0: success
- * <0: failure with ahpl_errno set
+ * <0: failure with aosl_errno set
**/
-extern __ahpl_api__ int ahpl_ref_read (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...);
-extern __ahpl_api__ int ahpl_ref_read_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args);
-extern __ahpl_api__ int ahpl_ref_read_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
+extern __aosl_api__ int aosl_ref_read (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...);
+extern __aosl_api__ int aosl_ref_read_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args);
+extern __aosl_api__ int aosl_ref_read_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
/**
* Hold the ref object and write lock it, then invoke the specified callback function.
@@ -108,11 +108,26 @@ extern __ahpl_api__ int ahpl_ref_read_argv (ahpl_ref_t ref, ahpl_ref_func_t f, u
* ...: variable args
* Return value:
* 0: success
- * <0: failure with ahpl_errno set
+ * <0: failure with aosl_errno set
**/
-extern __ahpl_api__ int ahpl_ref_write (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...);
-extern __ahpl_api__ int ahpl_ref_write_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args);
-extern __ahpl_api__ int ahpl_ref_write_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
+extern __aosl_api__ int aosl_ref_write (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...);
+extern __aosl_api__ int aosl_ref_write_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args);
+extern __aosl_api__ int aosl_ref_write_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
+
+/**
+ * Hold the ref object and set it unsafe, then invoke the specified callback function.
+ * Parameter:
+ * ref: the ref object id;
+ * f: the callback function;
+ * argc: the args count
+ * ...: variable args
+ * Return value:
+ * 0: success
+ * <0: failure with aosl_errno set
+ **/
+extern __aosl_api__ int aosl_ref_unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...);
+extern __aosl_api__ int aosl_ref_unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args);
+extern __aosl_api__ int aosl_ref_unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
/**
* Hold the ref object and set it maystall, then invoke the specified callback function.
@@ -123,17 +138,17 @@ extern __ahpl_api__ int ahpl_ref_write_argv (ahpl_ref_t ref, ahpl_ref_func_t f,
* ...: variable args
* Return value:
* 0: success
- * <0: failure with ahpl_errno set
+ * <0: failure with aosl_errno set
**/
-extern __ahpl_api__ int ahpl_ref_maystall (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...);
-extern __ahpl_api__ int ahpl_ref_maystall_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args);
-extern __ahpl_api__ int ahpl_ref_maystall_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
+extern __aosl_api__ int aosl_ref_maystall (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...);
+extern __aosl_api__ int aosl_ref_maystall_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args);
+extern __aosl_api__ int aosl_ref_maystall_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
-typedef void *ahpl_refobj_t;
+typedef void *aosl_refobj_t;
-#define AHPL_FREE_ONLY_OBJ ((ahpl_refobj_t)(uintptr_t)1)
-#define ahpl_is_free_only(robj) ((int)((ahpl_refobj_t)(robj) == AHPL_FREE_ONLY_OBJ))
+#define AOSL_FREE_ONLY_OBJ ((aosl_refobj_t)(uintptr_t)1)
+#define aosl_is_free_only(robj) ((int)((aosl_refobj_t)(robj) == AOSL_FREE_ONLY_OBJ))
/**
* Retrieve the ref object arg.
@@ -142,7 +157,7 @@ typedef void *ahpl_refobj_t;
* Return value:
* the ref object arg;
**/
-extern __ahpl_api__ void *ahpl_refobj_arg (ahpl_refobj_t robj);
+extern __aosl_api__ void *aosl_refobj_arg (aosl_refobj_t robj);
/**
* Get the ref id of the specified ref object.
@@ -151,7 +166,7 @@ extern __ahpl_api__ void *ahpl_refobj_arg (ahpl_refobj_t robj);
* Return value:
* the ref id.
**/
-extern __ahpl_api__ ahpl_ref_t ahpl_refobj_id (ahpl_refobj_t robj);
+extern __aosl_api__ aosl_ref_t aosl_refobj_id (aosl_refobj_t robj);
/**
* Make sure read lock the ref object specified by robj, then invoke the specified callback function.
@@ -162,11 +177,26 @@ extern __ahpl_api__ ahpl_ref_t ahpl_refobj_id (ahpl_refobj_t robj);
* ...: variable args
* Return value:
* 0: success
- * <0: failure with ahpl_errno set
+ * <0: failure with aosl_errno set
+ **/
+extern __aosl_api__ int aosl_refobj_read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...);
+extern __aosl_api__ int aosl_refobj_read_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args);
+extern __aosl_api__ int aosl_refobj_read_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
+
+/**
+ * Make sure set the ref object specified by robj unsafe, then invoke the specified callback function.
+ * Parameter:
+ * robj: the ref object itself;
+ * f: the callback function;
+ * argc: the args count
+ * ...: variable args
+ * Return value:
+ * 0: success
+ * <0: failure with aosl_errno set
**/
-extern __ahpl_api__ int ahpl_refobj_read (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, ...);
-extern __ahpl_api__ int ahpl_refobj_read_args (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, va_list args);
-extern __ahpl_api__ int ahpl_refobj_read_argv (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
+extern __aosl_api__ int aosl_refobj_unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...);
+extern __aosl_api__ int aosl_refobj_unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args);
+extern __aosl_api__ int aosl_refobj_unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
/**
* Make sure set the ref object specified by robj maystall, then invoke the specified callback function.
@@ -177,11 +207,11 @@ extern __ahpl_api__ int ahpl_refobj_read_argv (ahpl_refobj_t robj, ahpl_ref_func
* ...: variable args
* Return value:
* 0: success
- * <0: failure with ahpl_errno set
+ * <0: failure with aosl_errno set
**/
-extern __ahpl_api__ int ahpl_refobj_maystall (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, ...);
-extern __ahpl_api__ int ahpl_refobj_maystall_args (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, va_list args);
-extern __ahpl_api__ int ahpl_refobj_maystall_argv (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
+extern __aosl_api__ int aosl_refobj_maystall (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...);
+extern __aosl_api__ int aosl_refobj_maystall_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args);
+extern __aosl_api__ int aosl_refobj_maystall_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []);
/**
@@ -193,7 +223,7 @@ extern __ahpl_api__ int ahpl_refobj_maystall_argv (ahpl_refobj_t robj, ahpl_ref_
* 0: not read locked
* none zero: read locked by calling thread
**/
-extern __ahpl_api__ int ahpl_ref_locked (ahpl_ref_t ref);
+extern __aosl_api__ int aosl_ref_locked (aosl_ref_t ref);
/**
* Set the living scope ref object of the specified ref object.
@@ -202,10 +232,10 @@ extern __ahpl_api__ int ahpl_ref_locked (ahpl_ref_t ref);
* scope_ref: the living scope ref, the ref object will be destroyed
* when the object specified by scope_ref was destroyed;
* Return value:
- * <0: error occured, and ahpl_errno indicates which error;
+ * <0: error occured, and aosl_errno indicates which error;
* >=0: successful;
**/
-extern __ahpl_api__ int ahpl_ref_set_scope (ahpl_ref_t ref, ahpl_ref_t scope_ref);
+extern __aosl_api__ int aosl_ref_set_scope (aosl_ref_t ref, aosl_ref_t scope_ref);
/**
* Destroy the reference object specified by ref.
@@ -215,9 +245,9 @@ extern __ahpl_api__ int ahpl_ref_set_scope (ahpl_ref_t ref, ahpl_ref_t scope_ref
* non-0 value for deleting it
* Return value:
* 0: success
- * <0: failed, and ahpl_errno indicates what error occurs
+ * <0: failed, and aosl_errno indicates what error occurs
**/
-extern __ahpl_api__ int ahpl_ref_destroy (ahpl_ref_t ref, int do_delete);
+extern __aosl_api__ int aosl_ref_destroy (aosl_ref_t ref, int do_delete);
@@ -227,4 +257,4 @@ extern __ahpl_api__ int ahpl_ref_destroy (ahpl_ref_t ref, int do_delete);
-#endif /* __AHPL_REF_H__ */
\ No newline at end of file
+#endif /* __AOSL_REF_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_types.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_types.h
similarity index 61%
rename from Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_types.h
rename to Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_types.h
index 0617d3326..6afa42c98 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_types.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/aosl_types.h
@@ -1,17 +1,17 @@
/*************************************************************
* Author: Lionfore Hao (haolianfu@agora.io)
* Date : Jul 27th, 2020
- * Module: AHPL POSIX definitions header file
+ * Module: AOSL POSIX definitions header file
*
*
- * This is a part of the Advanced High Performance Library.
+ * This is a part of the Advanced Operating System Layer.
* Copyright (C) 2020 Agora IO
* All rights reserved.
*
*************************************************************/
-#ifndef __AHPL_TYPES_H__
-#define __AHPL_TYPES_H__
+#ifndef __AOSL_TYPES_H__
+#define __AOSL_TYPES_H__
#include
#include
@@ -21,7 +21,7 @@
#include
#endif
-#include
+#include
#ifdef __cplusplus
extern "C" {
@@ -41,21 +41,21 @@ typedef intptr_t ssize_t;
#endif
-/* The AHPL timestamp type */
-typedef unsigned long long ahpl_ts_t;
+/* The AOSL timestamp type */
+typedef unsigned long long aosl_ts_t;
-/* The proto for a general ahpl var args function with argc & argv. */
-typedef void (*ahpl_argv_f) (uintptr_t argc, uintptr_t argv []);
+/* The proto for a general aosl var args function with argc & argv. */
+typedef void (*aosl_argv_f) (uintptr_t argc, uintptr_t argv []);
-/* The proto for a general ahpl object destructor function. */
-typedef ahpl_argv_f ahpl_obj_dtor_t;
+/* The proto for a general aosl object destructor function. */
+typedef aosl_argv_f aosl_obj_dtor_t;
#if !defined (_WIN32) && !defined (__kspreadtrum__)
-typedef int ahpl_fd_t;
-#define AHPL_INVALID_FD ((ahpl_fd_t)-1)
+typedef int aosl_fd_t;
+#define AOSL_INVALID_FD ((aosl_fd_t)-1)
-static __inline__ int ahpl_fd_invalid (ahpl_fd_t fd)
+static __inline__ int aosl_fd_invalid (aosl_fd_t fd)
{
return (int)(fd < 0);
}
@@ -71,19 +71,19 @@ static __inline__ int ahpl_fd_invalid (ahpl_fd_t fd)
#include
#include
-typedef HANDLE ahpl_fd_t;
-#define AHPL_INVALID_FD ((ahpl_fd_t)INVALID_HANDLE_VALUE)
+typedef HANDLE aosl_fd_t;
+#define AOSL_INVALID_FD ((aosl_fd_t)INVALID_HANDLE_VALUE)
#elif defined (__kspreadtrum__)
#include
#include
-typedef TCPIP_SOCKET_T ahpl_fd_t;
-#define AHPL_INVALID_FD ((ahpl_fd_t)-1)
+typedef TCPIP_SOCKET_T aosl_fd_t;
+#define AOSL_INVALID_FD ((aosl_fd_t)-1)
#endif
-static __inline__ int ahpl_fd_invalid (ahpl_fd_t fd)
+static __inline__ int aosl_fd_invalid (aosl_fd_t fd)
{
- return (int)(fd == AHPL_INVALID_FD);
+ return (int)(fd == AOSL_INVALID_FD);
}
#endif
@@ -93,4 +93,4 @@ static __inline__ int ahpl_fd_invalid (ahpl_fd_t fd)
#endif
-#endif /* __AHPL_TYPES_H__ */
\ No newline at end of file
+#endif /* __AOSL_TYPES_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ares_class.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ares_class.h
deleted file mode 100644
index 8643c0b78..000000000
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ares_class.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*************************************************************
- * Author: Lionfore Hao (haolianfu@agora.io)
- * Date : Jun 23rd, 2023
- * Module: AHPL async result object for C++ definition file
- *
- *
- * This is a part of the Advanced High Performance Library.
- * Copyright (C) 2018 ~ 2023 Agora IO
- * All rights reserved.
- *
- *************************************************************/
-
-#ifndef __AHPL_ARES_CLASS_H__
-#define __AHPL_ARES_CLASS_H__
-
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-
-class ahpl_ares_class: public ahpl_ref_class {
-public:
- ahpl_ares_class (): ahpl_ref_class (ahpl_ares_create (this))
- {
- if (ahpl_ref_invalid (ref ()))
- abort ();
- }
-
- /**
- * The destructor of this class is very different with
- * base class and other derivatives, destroy the ref
- * in the destructor and the destructor is public.
- **/
- virtual ~ahpl_ares_class ()
- {
- ahpl_ref_t refid = ref ();
- if (!ahpl_ref_invalid (refid))
- ahpl_ref_destroy (refid, true);
- }
-
- /* complete the async result */
- int complete (intptr_t result = 0)
- {
- return ahpl_ares_complete (ref (), result);
- }
-
- /* wait the async result to be completed */
- int wait (intptr_t timeo, intptr_t *result = NULL)
- {
- return ahpl_ares_wait (ref (), timeo, result);
- }
-
- /* reset the signaled state */
- int reset (void)
- {
- return ahpl_ares_reset (ref ());
- }
-
- operator ahpl_ref_t () const
- {
- return ref ();
- }
-
-private:
- /* we do not allow invoke the destroy function of base class */
- int destroy (bool do_delete = true)
- {
- abort ();
- return 0;
- }
-
-#if (__cplusplus >= 201103) || defined (_MSC_VER)
-private:
- ahpl_ares_class (const ahpl_ares_class &) = delete;
- ahpl_ares_class (ahpl_ares_class &&) = delete;
- ahpl_ares_class &operator = (const ahpl_ares_class &) = delete;
- ahpl_ares_class &operator = (ahpl_ares_class &&) = delete;
-#else
-private:
- ahpl_ares_class (const ahpl_ares_class &);
- ahpl_ares_class &operator = (const ahpl_ares_class &);
-#endif /* C++11 */
-};
-
-
-#endif /* __AHPL_ARES_CLASS_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ref_class.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ref_class.h
deleted file mode 100644
index 85958718e..000000000
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ref_class.h
+++ /dev/null
@@ -1,1002 +0,0 @@
-/*************************************************************
- * Author: Lionfore Hao (haolianfu@agora.io)
- * Date : Nov 19th, 2018
- * Module: AHPL reference object for C++ definition file
- *
- *
- * This is a part of the Advanced High Performance Library.
- * Copyright (C) 2018 Agora IO
- * All rights reserved.
- *
- *************************************************************/
-
-#ifndef __AHPL_REF_OBJ_CPP_H__
-#define __AHPL_REF_OBJ_CPP_H__
-
-
-#include
-
-#include
-#include
-#include
-
-#ifdef COMPILING_WITH_MPQ_H
-#include
-#ifdef COMPILING_WITH_MPQP_H
-#include
-#endif
-#endif
-
-#ifdef COMPILING_WITH_ASYNC_H
-#include
-#endif
-
-#if (__cplusplus >= 201103) || defined (_MSC_VER)
-#include
-#include
-#endif
-
-class ahpl_ref_class {
-private:
- ahpl_ref_t ref_id;
-
-public:
- ahpl_ref_class (bool caller_free = true)
- {
- ref_id = ahpl_ref_create (this, __dtor, (int)caller_free);
- if (ahpl_ref_invalid (ref_id))
- abort ();
- }
-
- ahpl_ref_class (ahpl_ref_t ref)
- {
- ref_id = ref;
- }
-
- ahpl_ref_t ref () const
- {
- return ref_id;
- }
-
- int hold (ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_ref_hold_args (ref (), f, argc, args);
- va_end (args);
-
- return err;
- }
-
- int hold_args (ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_ref_hold_args (ref (), f, argc, args);
- }
-
- int hold_argv (ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_ref_hold_argv (ref (), f, argc, argv);
- }
-
- int read (ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_ref_read_args (ref (), f, argc, args);
- va_end (args);
-
- return err;
- }
-
- int read_args (ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_ref_read_args (ref (), f, argc, args);
- }
-
- int read_argv (ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_ref_read_argv (ref (), f, argc, argv);
- }
-
- int write (ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_ref_write_args (ref (), f, argc, args);
- va_end (args);
-
- return err;
- }
-
- int write_args (ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_ref_write_args (ref (), f, argc, args);
- }
-
- int write_argv (ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_ref_write_argv (ref (), f, argc, argv);
- }
-
- int maystall (ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_ref_maystall_args (ref (), f, argc, args);
- va_end (args);
-
- return err;
- }
-
- int maystall_args (ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_ref_maystall_args (ref (), f, argc, args);
- }
-
- int maystall_argv (ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_ref_maystall_argv (ref (), f, argc, argv);
- }
-
- /* The static version of member functions */
- static int hold (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_ref_hold_args (ref, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- static int hold_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_ref_hold_args (ref, f, argc, args);
- }
-
- static int hold_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_ref_hold_argv (ref, f, argc, argv);
- }
-
- static int read (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_ref_read_args (ref, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- static int read_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_ref_read_args (ref, f, argc, args);
- }
-
- static int read_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_ref_read_argv (ref, f, argc, argv);
- }
-
- static int write (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_ref_write_args (ref, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- static int write_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_ref_write_args (ref, f, argc, args);
- }
-
- static int write_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_ref_write_argv (ref, f, argc, argv);
- }
-
- static int maystall (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_ref_maystall_args (ref, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- static int maystall_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_ref_maystall_args (ref, f, argc, args);
- }
-
- static int maystall_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_ref_maystall_argv (ref, f, argc, argv);
- }
-
- static int read (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_refobj_read_args (robj, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- static int read_args (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_refobj_read_args (robj, f, argc, args);
- }
-
- static int read_argv (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_refobj_read_argv (robj, f, argc, argv);
- }
-
- static int maystall (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_refobj_maystall_args (robj, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- static int maystall_args (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, va_list args)
- {
- return ahpl_refobj_maystall_args (robj, f, argc, args);
- }
-
- static int maystall_argv (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
- {
- return ahpl_refobj_maystall_argv (robj, f, argc, argv);
- }
-
- static ahpl_ref_class *from_refobj (ahpl_refobj_t robj)
- {
- return (ahpl_ref_class *)ahpl_refobj_arg (robj);
- }
-
- /* set the living scope ref object of this ref object */
- int set_scope (ahpl_ref_t scope_ref)
- {
- return ahpl_ref_set_scope (ref (), scope_ref);
- }
-
- int destroy (bool do_delete = true)
- {
- if (!ahpl_ref_invalid (ref_id))
- return ahpl_ref_destroy (ref_id, (int)do_delete);
-
- if (do_delete)
- delete this;
-
- return 0;
- }
-
-public:
- class deleter {
- public:
- void operator () (ahpl_ref_class *obj_ptr) const
- {
- if (obj_ptr != NULL)
- obj_ptr->destroy ();
- }
- };
-
-protected:
- /* We do not allow delete this object directly. */
- virtual ~ahpl_ref_class ()
- {
- }
-
-private:
- static void __dtor (void *arg)
- {
- ahpl_ref_class *__this = (ahpl_ref_class *)arg;
- ::delete __this;
- }
-
-#ifdef __AHPL_MPQ_H__
- /* MPQ relative encapsulations */
-public:
- int queue (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_mpq_queue_args (tq, dq, ref (), f_name, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- int queue_args (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args)
- {
- return ahpl_mpq_queue_args (tq, dq, ref (), f_name, f, argc, args);
- }
-
- int queue_argv (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
- {
- return ahpl_mpq_queue_argv (tq, dq, ref (), f_name, f, argc, argv);
- }
-
- int queue_data (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data)
- {
- return ahpl_mpq_queue_data (tq, dq, ref (), f_name, f, len, data);
- }
-
- int call (ahpl_mpq_t q, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_mpq_call_args (q, ref (), f_name, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- int call_args (ahpl_mpq_t q, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args)
- {
- return ahpl_mpq_call_args (q, ref (), f_name, f, argc, args);
- }
-
- int call_argv (ahpl_mpq_t q, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
- {
- return ahpl_mpq_call_argv (q, ref (), f_name, f, argc, argv);
- }
-
- int call_data (ahpl_mpq_t q, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data)
- {
- return ahpl_mpq_call_data (q, ref (), f_name, f, len, data);
- }
-
- int run (ahpl_mpq_t q, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_mpq_run_args (q, dq, ref (), f_name, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- int run_args (ahpl_mpq_t q, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args)
- {
- return ahpl_mpq_run_args (q, dq, ref (), f_name, f, argc, args);
- }
-
- int run_argv (ahpl_mpq_t q, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
- {
- return ahpl_mpq_run_argv (q, dq, ref (), f_name, f, argc, argv);
- }
-
- int run_data (ahpl_mpq_t q, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data)
- {
- return ahpl_mpq_run_data (q, dq, ref (), f_name, f, len, data);
- }
-
-#ifdef __AHPL_MPQP_H__
- /* MPQP relative encapsulations */
- ahpl_mpq_t queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...)
- {
- va_list args;
- ahpl_mpq_t qid;
-
- va_start (args, argc);
- qid = ahpl_mpqp_queue_args (qp, dq, ref (), f_name, f, argc, args);
- va_end (args);
-
- return qid;
- }
-
- ahpl_mpq_t queue_args (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args)
- {
- return ahpl_mpqp_queue_args (qp, dq, ref (), f_name, f, argc, args);
- }
-
- ahpl_mpq_t queue_argv (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
- {
- return ahpl_mpqp_queue_argv (qp, dq, ref (), f_name, f, argc, argv);
- }
-
- ahpl_mpq_t queue_data (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data)
- {
- return ahpl_mpqp_queue_data (qp, dq, ref (), f_name, f, len, data);
- }
-
- ahpl_mpq_t call (ahpl_mpqp_t qp, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...)
- {
- va_list args;
- ahpl_mpq_t qid;
-
- va_start (args, argc);
- qid = ahpl_mpqp_call_args (qp, ref (), f_name, f, argc, args);
- va_end (args);
-
- return qid;
- }
-
- ahpl_mpq_t call_args (ahpl_mpqp_t qp, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args)
- {
- return ahpl_mpqp_call_args (qp, ref (), f_name, f, argc, args);
- }
-
- ahpl_mpq_t call_argv (ahpl_mpqp_t qp, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
- {
- return ahpl_mpqp_call_argv (qp, ref (), f_name, f, argc, argv);
- }
-
- ahpl_mpq_t call_data (ahpl_mpqp_t qp, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data)
- {
- return ahpl_mpqp_call_data (qp, ref (), f_name, f, len, data);
- }
-
- ahpl_mpq_t run (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...)
- {
- va_list args;
- ahpl_mpq_t qid;
-
- va_start (args, argc);
- qid = ahpl_mpqp_run_args (qp, dq, ref (), f_name, f, argc, args);
- va_end (args);
-
- return qid;
- }
-
- ahpl_mpq_t run_args (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args)
- {
- return ahpl_mpqp_run_args (qp, dq, ref (), f_name, f, argc, args);
- }
-
- ahpl_mpq_t run_argv (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
- {
- return ahpl_mpqp_run_argv (qp, dq, ref (), f_name, f, argc, argv);
- }
-
- ahpl_mpq_t run_data (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data)
- {
- return ahpl_mpqp_run_data (qp, dq, ref (), f_name, f, len, data);
- }
-
- int pool_tail_queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...)
- {
- va_list args;
- int err;
-
- va_start (args, argc);
- err = ahpl_mpqp_pool_tail_queue_args (qp, dq, ref (), f_name, f, argc, args);
- va_end (args);
-
- return err;
- }
-
- int pool_tail_queue_args (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args)
- {
- return ahpl_mpqp_pool_tail_queue_args (qp, dq, ref (), f_name, f, argc, args);
- }
-
- int pool_tail_queue_argv (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
- {
- return ahpl_mpqp_pool_tail_queue_argv (qp, dq, ref (), f_name, f, argc, argv);
- }
-#endif /* __AHPL_MPQP_H__ */
-#endif /* __AHPL_MPQ_H__ */
-
- /* C++11 lambda encapsulations */
-#if (__cplusplus >= 201103) || defined (_MSC_VER)
-public:
- typedef std::function ahpl_ref_lambda_f;
-
- int hold (ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::hold (____ref_f, 1, &lambda_obj);
- }
-
- int read (ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::read (____ref_f, 1, &lambda_obj);
- }
-
- int write (ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::write (____ref_f, 1, &lambda_obj);
- }
-
- int maystall (ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::maystall (____ref_f, 1, &lambda_obj);
- }
-
- static int hold (ahpl_ref_t ref, ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::hold (ref, ____ref_f, 1, &lambda_obj);
- }
-
- static int read (ahpl_ref_t ref, ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::read (ref, ____ref_f, 1, &lambda_obj);
- }
-
- static int write (ahpl_ref_t ref, ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::write (ref, ____ref_f, 1, &lambda_obj);
- }
-
- static int maystall (ahpl_ref_t ref, ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::maystall (ref, ____ref_f, 1, &lambda_obj);
- }
-
- static int read (ahpl_refobj_t robj, ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::read (robj, ____ref_f, 1, &lambda_obj);
- }
-
- static int maystall (ahpl_refobj_t robj, ahpl_ref_lambda_f &&lambda_f)
- {
- ahpl_ref_lambda_f lambda_obj (std::move (lambda_f));
- return ahpl_ref_class::maystall (robj, ____ref_f, 1, &lambda_obj);
- }
-
-private:
- static void ____ref_f (void *arg, uintptr_t argc, uintptr_t argv [])
- {
- ahpl_ref_lambda_f *lambda_obj = reinterpret_cast(argv [0]);
- (*lambda_obj) ((ahpl_ref_class *)arg);
- }
-
-#ifdef __AHPL_MPQ_H__
-public:
- typedef std::function ahpl_ref_mpq_lambda_f;
-
- /* MPQ encapsulations */
- int queue (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- int err = ahpl_ref_class::queue (tq, dq, f_name, ____mpq_f, 1, task_obj);
- if (err < 0)
- delete task_obj;
-
- return err;
- }
-
- int call (ahpl_mpq_t q, const char *f_name, ahpl_ref_mpq_lambda_f&& task, void *task_result = NULL)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- int err = ahpl_ref_class::call (q, f_name, ____mpq_f, 2, task_obj, task_result);
- if (err < 0)
- delete task_obj;
-
- return err;
- }
-
- int run (ahpl_mpq_t q, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- int err = ahpl_ref_class::run (q, AHPL_MPQ_INVALID, f_name, ____mpq_f, 1, task_obj);
- if (err < 0)
- delete task_obj;
-
- return err;
- }
-
-#ifdef __AHPL_MPQP_H__
- /* MPQP encapsulations */
- ahpl_mpq_t queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- ahpl_mpq_t qid = ahpl_ref_class::queue (qp, dq, f_name, ____mpq_f, 1, task_obj);
- if (ahpl_mpq_invalid (qid))
- delete task_obj;
-
- return qid;
- }
-
- ahpl_mpq_t call (ahpl_mpqp_t qp, const char *f_name, ahpl_ref_mpq_lambda_f&& task, void *task_result = NULL)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- ahpl_mpq_t qid = ahpl_ref_class::call (qp, f_name, ____mpq_f, 2, task_obj, task_result);
- if (ahpl_mpq_invalid (qid))
- delete task_obj;
-
- return qid;
- }
-
- ahpl_mpq_t run (ahpl_mpqp_t qp, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- ahpl_mpq_t qid = ahpl_ref_class::run (qp, AHPL_MPQ_INVALID, f_name, ____mpq_f, 1, task_obj);
- if (ahpl_mpq_invalid (qid))
- delete task_obj;
-
- return qid;
- }
-
- int pool_tail_queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- int err = ahpl_ref_class::pool_tail_queue (qp, dq, f_name, ____mpq_f, 1, task_obj);
- if (err < 0)
- delete task_obj;
-
- return err;
- }
-#endif /* __AHPL_MPQP_H__ */
-
- /* MPQ with specified ref encapsulations */
- static int queue (ahpl_mpq_t tq, ahpl_mpq_t dq, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- int err = ahpl_mpq_queue (tq, dq, ref, f_name, ____mpq_f, 1, task_obj);
- if (err < 0)
- delete task_obj;
-
- return err;
- }
-
- static int call (ahpl_mpq_t q, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task, void *task_result = NULL)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- int err = ahpl_mpq_call (q, ref, f_name, ____mpq_f, 2, task_obj, task_result);
- if (err < 0)
- delete task_obj;
-
- return err;
- }
-
- static int run (ahpl_mpq_t q, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- int err = ahpl_mpq_run (q, AHPL_MPQ_INVALID, ref, f_name, ____mpq_f, 1, task_obj);
- if (err < 0)
- delete task_obj;
-
- return err;
- }
-
-#ifdef __AHPL_MPQP_H__
- /* MPQP with specified ref encapsulations */
- static ahpl_mpq_t queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- ahpl_mpq_t qid = ahpl_mpqp_queue (qp, dq, ref, f_name, ____mpq_f, 1, task_obj);
- if (ahpl_mpq_invalid (qid))
- delete task_obj;
-
- return qid;
- }
-
- static ahpl_mpq_t call (ahpl_mpqp_t qp, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task, void *task_result = NULL)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- ahpl_mpq_t qid = ahpl_mpqp_call (qp, ref, f_name, ____mpq_f, 2, task_obj, task_result);
- if (ahpl_mpq_invalid (qid))
- delete task_obj;
-
- return qid;
- }
-
- static ahpl_mpq_t run (ahpl_mpqp_t qp, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- ahpl_mpq_t qid = ahpl_mpqp_run (qp, AHPL_MPQ_INVALID, ref, f_name, ____mpq_f, 1, task_obj);
- if (ahpl_mpq_invalid (qid))
- delete task_obj;
-
- return qid;
- }
-
- static int pool_tail_queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task)
- {
- ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task));
- int err = ahpl_mpqp_pool_tail_queue (qp, dq, ref, f_name, ____mpq_f, 1, task_obj);
- if (err < 0)
- delete task_obj;
-
- return err;
- }
-#endif /* __AHPL_MPQP_H__ */
-
- static void *call_result_var_addr (void)
- {
- void *var_addr;
-
- if (ahpl_mpq_run_func_arg (1, (uintptr_t *)&var_addr) < 0)
- return NULL;
-
- return var_addr;
- }
-
-private:
- static void ____mpq_f (const ahpl_ts_t *queued_ts_p, ahpl_refobj_t robj, uintptr_t argc, uintptr_t argv [])
- {
- ahpl_ref_mpq_lambda_f *task_obj = reinterpret_cast(argv [0]);
- ahpl_mpq_t done_qid = ahpl_mpq_run_func_done_qid ();
- (*task_obj) (*queued_ts_p, robj);
- if (ahpl_mpq_invalid (done_qid) || ahpl_is_free_only (robj)) {
- /**
- * We only free the task object when the running function has no
- * done mpq id, due to the task object would be still in use if
- * the function has a done mpq id when queuing back to the done
- * mpq.
- * -- Lionfore Hao Nov 19th, 2018
- **/
- delete task_obj;
- }
- }
-#endif /* __AHPL_MPQ_H__ */
-
-#ifdef __AHPL_ASYNC_H__
- /**
- * The stackless coroutine like implementation in AHPL. We could not
- * support the real stackless coroutine except in the language level,
- * so we just provide similar equivalent functionals here.
- **/
-public:
- typedef std::function ahpl_async_prepare_lambda_f;
-
- int prepare (ahpl_stack_id_t stack_id, const char *f_name, ahpl_async_prepare_lambda_f&& task)
- {
- ahpl_async_prepare_lambda_f *prepare_f = new ahpl_async_prepare_lambda_f (std::move (task));
- int err = ahpl_async_prepare (stack_id, ref (), f_name, ____async_prepare_f, 1, prepare_f);
- if (err < 0)
- delete prepare_f;
-
- return err;
- }
-
- static int prepare (ahpl_stack_id_t stack_id, ahpl_ref_t ref, const char *f_name, ahpl_async_prepare_lambda_f&& task)
- {
- ahpl_async_prepare_lambda_f *prepare_f = new ahpl_async_prepare_lambda_f (std::move (task));
- int err = ahpl_async_prepare (stack_id, ref, f_name, ____async_prepare_f, 1, prepare_f);
- if (err < 0)
- delete prepare_f;
-
- return err;
- }
-
-private:
- static int ____async_prepare_f (int free_only, uintptr_t argc, uintptr_t argv [])
- {
- ahpl_async_prepare_lambda_f *prepare_f = reinterpret_cast(argv [0]);
- int err;
- err = (*prepare_f) (free_only);
- delete prepare_f;
- return err;
- }
-
-public:
- typedef std::function ahpl_async_resume_lambda_f;
-
- int resume (ahpl_stack_id_t stack_id, const char *f_name, ahpl_async_resume_lambda_f&& task)
- {
- ahpl_async_resume_lambda_f *resume_f = new ahpl_async_resume_lambda_f (std::move (task));
- int err = ahpl_async_resume (stack_id, ref (), f_name, ____async_resume_f, 1, resume_f);
- if (err < 0)
- delete resume_f;
-
- return err;
- }
-
- static int resume (ahpl_stack_id_t stack_id, ahpl_ref_t ref, const char *f_name, ahpl_async_resume_lambda_f&& task)
- {
- ahpl_async_resume_lambda_f *resume_f = new ahpl_async_resume_lambda_f (std::move (task));
- int err = ahpl_async_resume (stack_id, ref, f_name, ____async_resume_f, 1, resume_f);
- if (err < 0)
- delete resume_f;
-
- return err;
- }
-
-private:
- static void ____async_resume_f (int free_only, uintptr_t argc, uintptr_t argv [])
- {
- ahpl_async_resume_lambda_f *resume_f = reinterpret_cast(argv [0]);
- (*resume_f) (free_only);
- delete resume_f;
- }
-#endif /* __AHPL_ASYNC_H__ */
-#endif /* C++11 */
-
-#if (__cplusplus >= 201103) || defined (_MSC_VER)
-private:
- ahpl_ref_class (const ahpl_ref_class &) = delete;
- ahpl_ref_class (ahpl_ref_class &&) = delete;
- ahpl_ref_class &operator = (const ahpl_ref_class &) = delete;
- ahpl_ref_class &operator = (ahpl_ref_class &&) = delete;
-#else
-private:
- ahpl_ref_class (const ahpl_ref_class &);
- ahpl_ref_class &operator = (const ahpl_ref_class &);
-#endif /* C++11 */
-};
-
-
-/**
- * The T_ref_cls argument of this template must be
- * ahpl_ref_class or its derivatives.
- **/
-template
-class ahpl_ref_unique_ptr {
-private:
- T_ref_cls *_ptr;
-
-public:
- ahpl_ref_unique_ptr (): _ptr (NULL) {}
- ahpl_ref_unique_ptr (T_ref_cls *p): _ptr (p) {}
-
- ahpl_ref_unique_ptr &operator = (T_ref_cls *p)
- {
- reset ();
- _ptr = p;
- return *this;
- }
-
- T_ref_cls *operator -> () const
- {
- return _ptr;
- }
-
- T_ref_cls *get () const
- {
- return _ptr;
- }
-
- operator bool () const
- {
- return _ptr != NULL;
- }
-
- T_ref_cls *release ()
- {
- T_ref_cls *p = _ptr;
- _ptr = NULL;
- return p;
- }
-
- void reset (T_ref_cls *p = NULL)
- {
- T_ref_cls *old = _ptr;
-
- /**
- * We do the destroy and not delete the object
- * before we set the pointer to the new value,
- * this is very important to make sure that no
- * any async operation is executing.
- **/
- if (old != NULL)
- old->destroy (false/* not delete */);
-
- _ptr = p;
-
- /**
- * The destroy with delete operation must be
- * the last action, and don't touch any member
- * of this object anymore after it.
- **/
- if (old != NULL)
- old->destroy (true/* do delete */);
- }
-
- ~ahpl_ref_unique_ptr ()
- {
- reset ();
- }
-
-#if (__cplusplus >= 201103) || defined (_MSC_VER)
-private:
- ahpl_ref_unique_ptr (const ahpl_ref_unique_ptr &) = delete;
- ahpl_ref_unique_ptr &operator = (const ahpl_ref_unique_ptr &) = delete;
-
-public:
- ahpl_ref_unique_ptr (ahpl_ref_unique_ptr &&src): _ptr (src.release ()) {}
- ahpl_ref_unique_ptr &operator = (ahpl_ref_unique_ptr &&ptr)
- {
- reset (ptr.release ());
- return *this;
- }
-#else
-private:
- ahpl_ref_unique_ptr (const ahpl_ref_unique_ptr &);
- ahpl_ref_unique_ptr &operator = (const ahpl_ref_unique_ptr &);
-#endif /* C++11 */
-};
-
-
-template
-inline bool operator == (const ahpl_ref_unique_ptr &ptr, intptr_t _null)
-{
- return ptr.get () == (T_ref_cls *)_null;
-}
-
-template
-inline bool operator != (const ahpl_ref_unique_ptr &ptr, intptr_t _null)
-{
- return ptr.get () != (T_ref_cls *)_null;
-}
-
-template
-inline bool operator == (intptr_t _null, const ahpl_ref_unique_ptr &ptr)
-{
- return (T_ref_cls *)_null == ptr.get ();
-}
-
-template
-inline bool operator != (intptr_t _null, const ahpl_ref_unique_ptr &ptr)
-{
- return (T_ref_cls *)_null != ptr.get ();
-}
-
-#if (__cplusplus >= 201103) || defined (_MSC_VER)
-template
-inline bool operator == (const ahpl_ref_unique_ptr &ptr, nullptr_t)
-{
- return !ptr;
-}
-
-template
-inline bool operator != (const ahpl_ref_unique_ptr &ptr, nullptr_t)
-{
- return ptr;
-}
-
-template
-inline bool operator == (nullptr_t, const ahpl_ref_unique_ptr &ptr)
-{
- return !ptr;
-}
-
-template
-inline bool operator != (nullptr_t, const ahpl_ref_unique_ptr &ptr)
-{
- return ptr;
-}
-#endif /* C++11 */
-
-
-typedef ahpl_ref_unique_ptr ahpl_ref_class_unique_ptr;
-
-
-#endif /* __AHPL_REF_OBJ_CPP_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_ares_class.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_ares_class.h
new file mode 100644
index 000000000..634096300
--- /dev/null
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_ares_class.h
@@ -0,0 +1,91 @@
+/*************************************************************
+ * Author: Lionfore Hao (haolianfu@agora.io)
+ * Date : Jun 23rd, 2023
+ * Module: AOSL async result object for C++ definition file
+ *
+ *
+ * This is a part of the Advanced Operating System Layer.
+ * Copyright (C) 2018 ~ 2023 Agora IO
+ * All rights reserved.
+ *
+ *************************************************************/
+
+#ifndef __AOSL_ARES_CLASS_H__
+#define __AOSL_ARES_CLASS_H__
+
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+
+class aosl_ares_class: public aosl_ref_class {
+public:
+ aosl_ares_class (): aosl_ref_class (aosl_ares_create (this))
+ {
+ if (aosl_ref_invalid (ref ()))
+ abort ();
+ }
+
+ /**
+ * The destructor of this class is very different with
+ * base class and other derivatives, destroy the ref
+ * in the destructor and the destructor is public.
+ **/
+ virtual ~aosl_ares_class ()
+ {
+ aosl_ref_t refid = ref ();
+ if (!aosl_ref_invalid (refid))
+ aosl_ref_destroy (refid, true);
+ }
+
+ /* complete the async result */
+ int complete (intptr_t result = 0)
+ {
+ return aosl_ares_complete (ref (), result);
+ }
+
+ /* wait the async result to be completed */
+ int wait (intptr_t timeo, intptr_t *result = NULL)
+ {
+ return aosl_ares_wait (ref (), timeo, result);
+ }
+
+ /* reset the signaled state */
+ int reset (void)
+ {
+ return aosl_ares_reset (ref ());
+ }
+
+ operator aosl_ref_t () const
+ {
+ return ref ();
+ }
+
+private:
+ /* we do not allow invoke the destroy function of base class */
+ int destroy (bool do_delete = true)
+ {
+ abort ();
+ return 0;
+ }
+
+#if (__cplusplus >= 201103) || defined (_MSC_VER)
+private:
+ aosl_ares_class (const aosl_ares_class &) = delete;
+ aosl_ares_class (aosl_ares_class &&) = delete;
+ aosl_ares_class &operator = (const aosl_ares_class &) = delete;
+ aosl_ares_class &operator = (aosl_ares_class &&) = delete;
+#else
+private:
+ aosl_ares_class (const aosl_ares_class &);
+ aosl_ares_class &operator = (const aosl_ares_class &);
+#endif /* C++11 */
+};
+
+
+#endif /* __AOSL_ARES_CLASS_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_poll_class.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_poll_class.h
similarity index 55%
rename from Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_poll_class.h
rename to Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_poll_class.h
index 2253b5d34..54d1a0560 100644
--- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_poll_class.h
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_poll_class.h
@@ -1,24 +1,24 @@
/*************************************************************
* Author: Lionfore Hao (haolianfu@agora.io)
* Date : Jun 23rd, 2023
- * Module: AHPL poll functionality for C++ definition file
+ * Module: AOSL poll functionality for C++ definition file
*
*
- * This is a part of the Advanced High Performance Library.
+ * This is a part of the Advanced Operating System Layer.
* Copyright (C) 2018 ~ 2023 Agora IO
* All rights reserved.
*
*************************************************************/
-#ifndef __AHPL_POLL_CLASS_H__
-#define __AHPL_POLL_CLASS_H__
+#ifndef __AOSL_POLL_CLASS_H__
+#define __AOSL_POLL_CLASS_H__
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
#if (__cplusplus >= 201103) || defined (_MSC_VER)
#include
@@ -29,46 +29,52 @@
#include
-class ahpl_poll_class {
+class aosl_poll_class {
private:
- std::map poll_refs;
- std::vector signaled_refs;
+ std::map poll_refs;
+ std::vector signaled_refs;
public:
- int add (const ahpl_ares_class &tail)
+ void add (const aosl_ares_class &tail)
{
poll_refs [tail.ref ()] = &tail;
- return 0;
}
#if (__cplusplus >= 201103) || defined (_MSC_VER)
template
- int add (const T &head, const Targs&... rest)
+ void add (const T &head, const Targs&... rest)
{
poll_refs [head.ref ()] = &head;
- return add (rest...);
+ add (rest...);
}
/* constructor with variable args */
template
- ahpl_poll_class (Targs&... args)
+ aosl_poll_class (Targs&... args)
{
add (args...);
}
#endif /* C++11 */
+ aosl_poll_class (const aosl_ares_class * const areses [], size_t count)
+ {
+ size_t i;
+ for (i = 0; i < count; i++)
+ add (*areses [i]);
+ }
+
/* poll the constructed async results */
int poll (size_t min, intptr_t timeo)
{
- ahpl_ref_t local_refs [32];
- ahpl_ref_t *refs = local_refs;
+ aosl_ref_t local_refs [32];
+ aosl_ref_t *refs = local_refs;
size_t count = poll_refs.size ();
- std::map::iterator it;
+ std::map::iterator it;
int i;
int err;
if (count > sizeof local_refs / sizeof local_refs [0]) {
- refs = new ahpl_ref_t [count];
+ refs = new aosl_ref_t [count];
if (refs == NULL)
return -1;
}
@@ -77,7 +83,7 @@ class ahpl_poll_class {
for (it = poll_refs.begin (); it != poll_refs.end (); it++)
refs [i++] = it->first;
- err = ahpl_poll (refs, count, min, timeo);
+ err = aosl_poll (refs, count, min, timeo);
signaled_refs.clear ();
for (i = 0; i < err; i++) {
it = poll_refs.find (refs [i]);
@@ -104,7 +110,7 @@ class ahpl_poll_class {
}
/* operator for accessing the signaled async results */
- const ahpl_ares_class *operator [] (size_t idx)
+ const aosl_ares_class *operator [] (size_t idx)
{
if (idx < signaled_refs.size ())
return signaled_refs [idx];
@@ -114,16 +120,16 @@ class ahpl_poll_class {
#if (__cplusplus >= 201103) || defined (_MSC_VER)
private:
- ahpl_poll_class (const ahpl_poll_class &) = delete;
- ahpl_poll_class (ahpl_poll_class &&) = delete;
- ahpl_poll_class &operator = (const ahpl_poll_class &) = delete;
- ahpl_poll_class &operator = (ahpl_poll_class &&) = delete;
+ aosl_poll_class (const aosl_poll_class &) = delete;
+ aosl_poll_class (aosl_poll_class &&) = delete;
+ aosl_poll_class &operator = (const aosl_poll_class &) = delete;
+ aosl_poll_class &operator = (aosl_poll_class &&) = delete;
#else
private:
- ahpl_poll_class (const ahpl_poll_class &);
- ahpl_poll_class &operator = (const ahpl_poll_class &);
+ aosl_poll_class (const aosl_poll_class &);
+ aosl_poll_class &operator = (const aosl_poll_class &);
#endif
};
-#endif /* __AHPL_POLL_CLASS_H__ */
\ No newline at end of file
+#endif /* __AOSL_POLL_CLASS_H__ */
\ No newline at end of file
diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_ref_class.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_ref_class.h
new file mode 100644
index 000000000..4dab3878b
--- /dev/null
+++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/aosl_ref_class.h
@@ -0,0 +1,1956 @@
+/*************************************************************
+ * Author: Lionfore Hao (haolianfu@agora.io)
+ * Date : Nov 19th, 2018
+ * Module: AOSL reference object for C++ definition file
+ *
+ *
+ * This is a part of the Advanced Operating System Layer.
+ * Copyright (C) 2018 Agora IO
+ * All rights reserved.
+ *
+ *************************************************************/
+
+#ifndef __AOSL_REF_OBJ_CPP_H__
+#define __AOSL_REF_OBJ_CPP_H__
+
+
+#include
+
+#include
+#include
+#include
+
+#ifdef COMPILING_WITH_MPQ_H
+#include
+#ifdef COMPILING_WITH_MPQP_H
+#include
+#endif
+#endif
+
+#ifdef COMPILING_WITH_ASYNC_H
+#include
+#endif
+
+#if (__cplusplus >= 201103) || defined (_MSC_VER)
+#include
+#include
+typedef std::function aosl_ref_lambda_f;
+typedef std::function aosl_ref_mpq_lambda_f;
+typedef std::function aosl_ref_mpq_lambda_0arg_f;
+typedef std::function aosl_async_prepare_lambda_f;
+typedef std::function aosl_async_resume_lambda_f;
+#endif
+
+class aosl_ref_class {
+public:
+ class aosl_ref_t_oop {
+ private:
+ /**
+ * We do not allow create any object of this class directly,
+ * only the pointer of this class is significant.
+ **/
+ aosl_ref_t_oop ();
+
+ public:
+ static aosl_ref_t_oop *create (void *arg = NULL, aosl_ref_dtor_t dtor = NULL, bool caller_free = true)
+ {
+ return (aosl_ref_t_oop *)aosl_ref_create (arg, dtor, (int)caller_free);
+ }
+
+ static aosl_ref_t_oop *from_aosl_ref_t (aosl_ref_t ref)
+ {
+ return (aosl_ref_t_oop *)ref;
+ }
+
+ static void operator delete (void *ptr)
+ {
+ ((aosl_ref_t_oop *)ptr)->destroy (true);
+ }
+
+ aosl_ref_t ref () const
+ {
+ return (aosl_ref_t)this;
+ }
+
+ int hold (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_hold_args (ref (), f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int hold_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_hold_args (ref (), f, argc, args);
+ }
+
+ int hold_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_hold_argv (ref (), f, argc, argv);
+ }
+
+ int read (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_read_args (ref (), f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int read_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_read_args (ref (), f, argc, args);
+ }
+
+ int read_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_read_argv (ref (), f, argc, argv);
+ }
+
+ int write (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_write_args (ref (), f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int write_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_write_args (ref (), f, argc, args);
+ }
+
+ int write_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_write_argv (ref (), f, argc, argv);
+ }
+
+ int unsafe (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_unsafe_args (ref (), f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int unsafe_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_unsafe_args (ref (), f, argc, args);
+ }
+
+ int unsafe_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_unsafe_argv (ref (), f, argc, argv);
+ }
+
+ /* The static version of member functions */
+ static int hold (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_hold_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int hold_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_hold_args (ref, f, argc, args);
+ }
+
+ static int hold_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_hold_argv (ref, f, argc, argv);
+ }
+
+ static int read (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_read_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int read_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_read_args (ref, f, argc, args);
+ }
+
+ static int read_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_read_argv (ref, f, argc, argv);
+ }
+
+ static int write (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_write_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int write_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_write_args (ref, f, argc, args);
+ }
+
+ static int write_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_write_argv (ref, f, argc, argv);
+ }
+
+ static int unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_unsafe_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_unsafe_args (ref, f, argc, args);
+ }
+
+ static int unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_unsafe_argv (ref, f, argc, argv);
+ }
+
+ static int read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_refobj_read_args (robj, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int read_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_refobj_read_args (robj, f, argc, args);
+ }
+
+ static int read_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_refobj_read_argv (robj, f, argc, argv);
+ }
+
+ static int unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_refobj_unsafe_args (robj, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_refobj_unsafe_args (robj, f, argc, args);
+ }
+
+ static int unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_refobj_unsafe_argv (robj, f, argc, argv);
+ }
+
+ /* set the living scope ref object of this ref object */
+ int set_scope (aosl_ref_t scope_ref)
+ {
+ return aosl_ref_set_scope (ref (), scope_ref);
+ }
+
+ int destroy (bool do_delete = true)
+ {
+ if (!aosl_ref_invalid (ref ()))
+ return aosl_ref_destroy (ref (), (int)do_delete);
+
+ return -1;
+ }
+
+ #ifdef __AOSL_MPQ_H__
+ /* MPQ relative encapsulations */
+ public:
+ int queue (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_mpq_queue_args (tq, dq, ref (), f_name, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int queue_args (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_mpq_queue_args (tq, dq, ref (), f_name, f, argc, args);
+ }
+
+ int queue_argv (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return aosl_mpq_queue_argv (tq, dq, ref (), f_name, f, argc, argv);
+ }
+
+ int queue_data (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return aosl_mpq_queue_data (tq, dq, ref (), f_name, f, len, data);
+ }
+
+ int call (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_mpq_call_args (q, ref (), f_name, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int call_args (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_mpq_call_args (q, ref (), f_name, f, argc, args);
+ }
+
+ int call_argv (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return aosl_mpq_call_argv (q, ref (), f_name, f, argc, argv);
+ }
+
+ int call_data (aosl_mpq_t q, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return aosl_mpq_call_data (q, ref (), f_name, f, len, data);
+ }
+
+ int run (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_mpq_run_args (q, dq, ref (), f_name, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int run_args (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_mpq_run_args (q, dq, ref (), f_name, f, argc, args);
+ }
+
+ int run_argv (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return aosl_mpq_run_argv (q, dq, ref (), f_name, f, argc, argv);
+ }
+
+ int run_data (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return aosl_mpq_run_data (q, dq, ref (), f_name, f, len, data);
+ }
+
+ #ifdef __AOSL_MPQP_H__
+ /* MPQP relative encapsulations */
+ aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ aosl_mpq_t qid;
+
+ va_start (args, argc);
+ qid = aosl_mpqp_queue_args (qp, dq, ref (), f_name, f, argc, args);
+ va_end (args);
+
+ return qid;
+ }
+
+ aosl_mpq_t queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_mpqp_queue_args (qp, dq, ref (), f_name, f, argc, args);
+ }
+
+ aosl_mpq_t queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return aosl_mpqp_queue_argv (qp, dq, ref (), f_name, f, argc, argv);
+ }
+
+ aosl_mpq_t queue_data (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return aosl_mpqp_queue_data (qp, dq, ref (), f_name, f, len, data);
+ }
+
+ aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ aosl_mpq_t qid;
+
+ va_start (args, argc);
+ qid = aosl_mpqp_call_args (qp, ref (), f_name, f, argc, args);
+ va_end (args);
+
+ return qid;
+ }
+
+ aosl_mpq_t call_args (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_mpqp_call_args (qp, ref (), f_name, f, argc, args);
+ }
+
+ aosl_mpq_t call_argv (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return aosl_mpqp_call_argv (qp, ref (), f_name, f, argc, argv);
+ }
+
+ aosl_mpq_t call_data (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return aosl_mpqp_call_data (qp, ref (), f_name, f, len, data);
+ }
+
+ aosl_mpq_t run (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ aosl_mpq_t qid;
+
+ va_start (args, argc);
+ qid = aosl_mpqp_run_args (qp, dq, ref (), f_name, f, argc, args);
+ va_end (args);
+
+ return qid;
+ }
+
+ aosl_mpq_t run_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_mpqp_run_args (qp, dq, ref (), f_name, f, argc, args);
+ }
+
+ aosl_mpq_t run_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return aosl_mpqp_run_argv (qp, dq, ref (), f_name, f, argc, argv);
+ }
+
+ aosl_mpq_t run_data (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return aosl_mpqp_run_data (qp, dq, ref (), f_name, f, len, data);
+ }
+
+ int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_mpqp_pool_tail_queue_args (qp, dq, ref (), f_name, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int pool_tail_queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_mpqp_pool_tail_queue_args (qp, dq, ref (), f_name, f, argc, args);
+ }
+
+ int pool_tail_queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return aosl_mpqp_pool_tail_queue_argv (qp, dq, ref (), f_name, f, argc, argv);
+ }
+ #endif /* __AOSL_MPQP_H__ */
+ #endif /* __AOSL_MPQ_H__ */
+
+ /* C++11 lambda encapsulations */
+ #if (__cplusplus >= 201103) || defined (_MSC_VER)
+ public:
+ int hold (aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::hold (____ref_f, 1, &lambda_obj);
+ }
+
+ int read (aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::read (____ref_f, 1, &lambda_obj);
+ }
+
+ int write (aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::write (____ref_f, 1, &lambda_obj);
+ }
+
+ int unsafe (aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::unsafe (____ref_f, 1, &lambda_obj);
+ }
+
+ static int hold (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::hold (ref, ____ref_f, 1, &lambda_obj);
+ }
+
+ static int read (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::read (ref, ____ref_f, 1, &lambda_obj);
+ }
+
+ static int write (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::write (ref, ____ref_f, 1, &lambda_obj);
+ }
+
+ static int unsafe (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::unsafe (ref, ____ref_f, 1, &lambda_obj);
+ }
+
+ static int read (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::read (robj, ____ref_f, 1, &lambda_obj);
+ }
+
+ static int unsafe (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f)
+ {
+ aosl_ref_lambda_f lambda_obj (std::move (lambda_f));
+ return aosl_ref_t_oop::unsafe (robj, ____ref_f, 1, &lambda_obj);
+ }
+
+ private:
+ static void ____ref_f (void *arg, uintptr_t argc, uintptr_t argv [])
+ {
+ aosl_ref_lambda_f *lambda_obj = reinterpret_cast(argv [0]);
+ (*lambda_obj) (arg);
+ }
+
+ #ifdef __AOSL_MPQ_H__
+ public:
+ /* MPQ encapsulations */
+ int queue (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ int err = aosl_ref_t_oop::queue (tq, dq, f_name, ____mpq_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ int call (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ int err = aosl_ref_t_oop::call (q, f_name, ____mpq_f, 2, task_obj, task_result);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ int run (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ int err = aosl_ref_t_oop::run (q, AOSL_MPQ_INVALID, f_name, ____mpq_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ int queue (aosl_mpq_t tq, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ int err = aosl_ref_t_oop::queue (tq, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ int call (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ int err = aosl_ref_t_oop::call (q, f_name, ____mpq_0arg_f, 2, task_obj, task_result);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ int run (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ int err = aosl_ref_t_oop::run (q, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ #ifdef __AOSL_MPQP_H__
+ /* MPQP encapsulations */
+ aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ aosl_mpq_t qid = aosl_ref_t_oop::queue (qp, dq, f_name, ____mpq_f, 1, task_obj);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ aosl_mpq_t qid = aosl_ref_t_oop::call (qp, f_name, ____mpq_f, 2, task_obj, task_result);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ aosl_mpq_t run (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ aosl_mpq_t qid = aosl_ref_t_oop::run (qp, AOSL_MPQ_INVALID, f_name, ____mpq_f, 1, task_obj);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ int err = aosl_ref_t_oop::pool_tail_queue (qp, dq, f_name, ____mpq_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ aosl_mpq_t queue (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ aosl_mpq_t qid = aosl_ref_t_oop::queue (qp, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ aosl_mpq_t qid = aosl_ref_t_oop::call (qp, f_name, ____mpq_0arg_f, 2, task_obj, task_result);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ aosl_mpq_t run (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ aosl_mpq_t qid = aosl_ref_t_oop::run (qp, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ int pool_tail_queue (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ int err = aosl_ref_t_oop::pool_tail_queue (qp, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+ #endif /* __AOSL_MPQP_H__ */
+
+ /* MPQ with specified ref encapsulations */
+ static int queue (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ int err = aosl_mpq_queue (tq, dq, ref, f_name, ____mpq_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ static int call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ int err = aosl_mpq_call (q, ref, f_name, ____mpq_f, 2, task_obj, task_result);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ static int run (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ int err = aosl_mpq_run (q, AOSL_MPQ_INVALID, ref, f_name, ____mpq_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ static int queue (aosl_mpq_t tq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ int err = aosl_mpq_queue (tq, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ static int call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ int err = aosl_mpq_call (q, ref, f_name, ____mpq_0arg_f, 2, task_obj, task_result);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ static int run (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ int err = aosl_mpq_run (q, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ #ifdef __AOSL_MPQP_H__
+ /* MPQP with specified ref encapsulations */
+ static aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ aosl_mpq_t qid = aosl_mpqp_queue (qp, dq, ref, f_name, ____mpq_f, 1, task_obj);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ static aosl_mpq_t call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ aosl_mpq_t qid = aosl_mpqp_call (qp, ref, f_name, ____mpq_f, 2, task_obj, task_result);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ static aosl_mpq_t run (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ aosl_mpq_t qid = aosl_mpqp_run (qp, AOSL_MPQ_INVALID, ref, f_name, ____mpq_f, 1, task_obj);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ static int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task));
+ int err = aosl_mpqp_pool_tail_queue (qp, dq, ref, f_name, ____mpq_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+
+ static aosl_mpq_t queue (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ aosl_mpq_t qid = aosl_mpqp_queue (qp, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ static aosl_mpq_t call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ aosl_mpq_t qid = aosl_mpqp_call (qp, ref, f_name, ____mpq_0arg_f, 2, task_obj, task_result);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ static aosl_mpq_t run (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ aosl_mpq_t qid = aosl_mpqp_run (qp, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (aosl_mpq_invalid (qid))
+ delete task_obj;
+
+ return qid;
+ }
+
+ static int pool_tail_queue (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task));
+ int err = aosl_mpqp_pool_tail_queue (qp, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj);
+ if (err < 0)
+ delete task_obj;
+
+ return err;
+ }
+ #endif /* __AOSL_MPQP_H__ */
+
+ static void *call_result_var_addr (void)
+ {
+ void *var_addr;
+
+ if (aosl_mpq_run_func_arg (1, (uintptr_t *)&var_addr) < 0)
+ return NULL;
+
+ return var_addr;
+ }
+
+ private:
+ static void ____mpq_f (const aosl_ts_t *queued_ts_p, aosl_refobj_t robj, uintptr_t argc, uintptr_t argv [])
+ {
+ aosl_ref_mpq_lambda_f *task_obj = reinterpret_cast(argv [0]);
+ aosl_mpq_t done_qid = aosl_mpq_run_func_done_qid ();
+ (*task_obj) (*queued_ts_p, robj);
+ if (aosl_mpq_invalid (done_qid) || aosl_is_free_only (robj)) {
+ /**
+ * We only free the task object when the running function has no
+ * done mpq id, due to the task object would be still in use if
+ * the function has a done mpq id when queuing back to the done
+ * mpq.
+ * -- Lionfore Hao Nov 19th, 2018
+ **/
+ delete task_obj;
+ }
+ }
+
+ static void ____mpq_0arg_f (const aosl_ts_t *queued_ts_p, aosl_refobj_t robj, uintptr_t argc, uintptr_t argv [])
+ {
+ aosl_ref_mpq_lambda_0arg_f *task_obj = reinterpret_cast(argv [0]);
+ aosl_mpq_t done_qid = aosl_mpq_run_func_done_qid ();
+ if (!aosl_is_free_only (robj))
+ (*task_obj) ();
+ if (aosl_mpq_invalid (done_qid) || aosl_is_free_only (robj)) {
+ /**
+ * We only free the task object when the running function has no
+ * done mpq id, due to the task object would be still in use if
+ * the function has a done mpq id when queuing back to the done
+ * mpq.
+ * -- Lionfore Hao Nov 19th, 2018
+ **/
+ delete task_obj;
+ }
+ }
+ #endif /* __AOSL_MPQ_H__ */
+
+ #ifdef __AOSL_ASYNC_H__
+ /**
+ * The stackless coroutine like implementation in AOSL. We could not
+ * support the real stackless coroutine except in the language level,
+ * so we just provide similar equivalent functionals here.
+ **/
+ public:
+ int prepare (aosl_stack_id_t stack_id, const char *f_name, aosl_async_prepare_lambda_f&& task)
+ {
+ aosl_async_prepare_lambda_f *prepare_f = new aosl_async_prepare_lambda_f (std::move (task));
+ int err = aosl_async_prepare (stack_id, ref (), f_name, ____async_prepare_f, 1, prepare_f);
+ if (err < 0)
+ delete prepare_f;
+
+ return err;
+ }
+
+ static int prepare (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_async_prepare_lambda_f&& task)
+ {
+ aosl_async_prepare_lambda_f *prepare_f = new aosl_async_prepare_lambda_f (std::move (task));
+ int err = aosl_async_prepare (stack_id, ref, f_name, ____async_prepare_f, 1, prepare_f);
+ if (err < 0)
+ delete prepare_f;
+
+ return err;
+ }
+
+ private:
+ static int ____async_prepare_f (int free_only, uintptr_t argc, uintptr_t argv [])
+ {
+ aosl_async_prepare_lambda_f *prepare_f = reinterpret_cast(argv [0]);
+ int err;
+ err = (*prepare_f) (free_only);
+ delete prepare_f;
+ return err;
+ }
+
+ public:
+ int resume (aosl_stack_id_t stack_id, const char *f_name, aosl_async_resume_lambda_f&& task)
+ {
+ aosl_async_resume_lambda_f *resume_f = new aosl_async_resume_lambda_f (std::move (task));
+ int err = aosl_async_resume (stack_id, ref (), f_name, ____async_resume_f, 1, resume_f);
+ if (err < 0)
+ delete resume_f;
+
+ return err;
+ }
+
+ static int resume (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_async_resume_lambda_f&& task)
+ {
+ aosl_async_resume_lambda_f *resume_f = new aosl_async_resume_lambda_f (std::move (task));
+ int err = aosl_async_resume (stack_id, ref, f_name, ____async_resume_f, 1, resume_f);
+ if (err < 0)
+ delete resume_f;
+
+ return err;
+ }
+
+ private:
+ static void ____async_resume_f (int free_only, uintptr_t argc, uintptr_t argv [])
+ {
+ aosl_async_resume_lambda_f *resume_f = reinterpret_cast(argv [0]);
+ (*resume_f) (free_only);
+ delete resume_f;
+ }
+ #endif /* __AOSL_ASYNC_H__ */
+ #endif /* C++11 */
+
+ #if (__cplusplus >= 201103) || defined (_MSC_VER)
+ private:
+ aosl_ref_t_oop (const aosl_ref_t_oop &) = delete;
+ aosl_ref_t_oop (aosl_ref_t_oop &&) = delete;
+ aosl_ref_t_oop &operator = (const aosl_ref_t_oop &) = delete;
+ aosl_ref_t_oop &operator = (aosl_ref_t_oop &&) = delete;
+ #else
+ private:
+ aosl_ref_t_oop (const aosl_ref_t_oop &);
+ aosl_ref_t_oop &operator = (const aosl_ref_t_oop &);
+ #endif /* C++11 */
+ };
+
+private:
+ aosl_ref_t_oop *refoop;
+
+public:
+ aosl_ref_class (bool caller_free = true)
+ {
+ refoop = aosl_ref_t_oop::create (this, __dtor, caller_free);
+ if (aosl_ref_invalid (refoop))
+ abort ();
+ }
+
+ aosl_ref_class (aosl_ref_t_oop *obj)
+ {
+ refoop = obj;
+ }
+
+ aosl_ref_class (aosl_ref_t ref)
+ {
+ refoop = aosl_ref_t_oop::from_aosl_ref_t (ref);
+ }
+
+ aosl_ref_t_oop *ref_oop () const
+ {
+ return refoop;
+ }
+
+ aosl_ref_t ref () const
+ {
+ return refoop->ref ();
+ }
+
+ int hold (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->hold_args (f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int hold_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->hold_args (f, argc, args);
+ }
+
+ int hold_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return refoop->hold_argv (f, argc, argv);
+ }
+
+ int read (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->read_args (f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int read_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->read_args (f, argc, args);
+ }
+
+ int read_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return refoop->read_argv (f, argc, argv);
+ }
+
+ int write (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->write_args (f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int write_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->write_args (f, argc, args);
+ }
+
+ int write_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return refoop->write_argv (f, argc, argv);
+ }
+
+ int unsafe (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->unsafe_args (f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int unsafe_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->unsafe_args (f, argc, args);
+ }
+
+ int unsafe_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return refoop->unsafe_argv (f, argc, argv);
+ }
+
+ int maystall (aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->unsafe_args (f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int maystall_args (aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->unsafe_args (f, argc, args);
+ }
+
+ int maystall_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return refoop->unsafe_argv (f, argc, argv);
+ }
+
+ /* The static version of member functions */
+ static int hold (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_t_oop::hold_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int hold_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_t_oop::hold_args (ref, f, argc, args);
+ }
+
+ static int hold_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_t_oop::hold_argv (ref, f, argc, argv);
+ }
+
+ static int read (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_t_oop::read_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int read_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_t_oop::read_args (ref, f, argc, args);
+ }
+
+ static int read_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_t_oop::read_argv (ref, f, argc, argv);
+ }
+
+ static int write (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_t_oop::write_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int write_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_t_oop::write_args (ref, f, argc, args);
+ }
+
+ static int write_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_t_oop::write_argv (ref, f, argc, argv);
+ }
+
+ static int unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_t_oop::unsafe_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_t_oop::unsafe_args (ref, f, argc, args);
+ }
+
+ static int unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_t_oop::unsafe_argv (ref, f, argc, argv);
+ }
+
+ static int maystall (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_t_oop::unsafe_args (ref, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int maystall_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_t_oop::unsafe_args (ref, f, argc, args);
+ }
+
+ static int maystall_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_t_oop::unsafe_argv (ref, f, argc, argv);
+ }
+
+ static int read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_t_oop::read_args (robj, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int read_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_t_oop::read_args (robj, f, argc, args);
+ }
+
+ static int read_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_t_oop::read_argv (robj, f, argc, argv);
+ }
+
+ static int unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_t_oop::unsafe_args (robj, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_t_oop::unsafe_args (robj, f, argc, args);
+ }
+
+ static int unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_t_oop::unsafe_argv (robj, f, argc, argv);
+ }
+
+ static int maystall (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = aosl_ref_t_oop::unsafe_args (robj, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ static int maystall_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args)
+ {
+ return aosl_ref_t_oop::unsafe_args (robj, f, argc, args);
+ }
+
+ static int maystall_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv [])
+ {
+ return aosl_ref_t_oop::unsafe_argv (robj, f, argc, argv);
+ }
+
+ static aosl_ref_class *from_refobj (aosl_refobj_t robj)
+ {
+ return (aosl_ref_class *)aosl_refobj_arg (robj);
+ }
+
+ /* set the living scope ref object of this ref object */
+ int set_scope (aosl_ref_t scope_ref)
+ {
+ return refoop->set_scope (scope_ref);
+ }
+
+ int destroy (bool do_delete = true)
+ {
+ int err = refoop->destroy (do_delete);
+ if (err < 0 && do_delete) {
+ ::delete this;
+ return 0;
+ }
+
+ return err;
+ }
+
+public:
+ class deleter {
+ public:
+ void operator () (aosl_ref_class *obj_ptr) const
+ {
+ if (obj_ptr != NULL)
+ obj_ptr->destroy ();
+ }
+ };
+
+protected:
+ /* We do not allow delete this object directly. */
+ virtual ~aosl_ref_class ()
+ {
+ }
+
+private:
+ static void __dtor (void *arg)
+ {
+ aosl_ref_class *__this = (aosl_ref_class *)arg;
+ ::delete __this;
+ }
+
+#ifdef __AOSL_MPQ_H__
+ /* MPQ relative encapsulations */
+public:
+ int queue (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->queue_args (tq, dq, f_name, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int queue_args (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->queue_args (tq, dq, f_name, f, argc, args);
+ }
+
+ int queue_argv (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return refoop->queue_argv (tq, dq, f_name, f, argc, argv);
+ }
+
+ int queue_data (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return refoop->queue_data (tq, dq, f_name, f, len, data);
+ }
+
+ int call (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->call_args (q, f_name, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int call_args (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->call_args (q, f_name, f, argc, args);
+ }
+
+ int call_argv (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return refoop->call_argv (q, f_name, f, argc, argv);
+ }
+
+ int call_data (aosl_mpq_t q, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return refoop->call_data (q, f_name, f, len, data);
+ }
+
+ int run (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->run_args (q, dq, f_name, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int run_args (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->run_args (q, dq, f_name, f, argc, args);
+ }
+
+ int run_argv (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return refoop->run_argv (q, dq, f_name, f, argc, argv);
+ }
+
+ int run_data (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return refoop->run_data (q, dq, f_name, f, len, data);
+ }
+
+#ifdef __AOSL_MPQP_H__
+ /* MPQP relative encapsulations */
+ aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ aosl_mpq_t qid;
+
+ va_start (args, argc);
+ qid = refoop->queue_args (qp, dq, f_name, f, argc, args);
+ va_end (args);
+
+ return qid;
+ }
+
+ aosl_mpq_t queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->queue_args (qp, dq, f_name, f, argc, args);
+ }
+
+ aosl_mpq_t queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return refoop->queue_argv (qp, dq, f_name, f, argc, argv);
+ }
+
+ aosl_mpq_t queue_data (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return refoop->queue_data (qp, dq, f_name, f, len, data);
+ }
+
+ aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ aosl_mpq_t qid;
+
+ va_start (args, argc);
+ qid = refoop->call_args (qp, f_name, f, argc, args);
+ va_end (args);
+
+ return qid;
+ }
+
+ aosl_mpq_t call_args (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->call_args (qp, f_name, f, argc, args);
+ }
+
+ aosl_mpq_t call_argv (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return refoop->call_argv (qp, f_name, f, argc, argv);
+ }
+
+ aosl_mpq_t call_data (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return refoop->call_data (qp, f_name, f, len, data);
+ }
+
+ aosl_mpq_t run (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ aosl_mpq_t qid;
+
+ va_start (args, argc);
+ qid = refoop->run_args (qp, dq, f_name, f, argc, args);
+ va_end (args);
+
+ return qid;
+ }
+
+ aosl_mpq_t run_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->run_args (qp, dq, f_name, f, argc, args);
+ }
+
+ aosl_mpq_t run_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return refoop->run_argv (qp, dq, f_name, f, argc, argv);
+ }
+
+ aosl_mpq_t run_data (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data)
+ {
+ return refoop->run_data (qp, dq, f_name, f, len, data);
+ }
+
+ int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...)
+ {
+ va_list args;
+ int err;
+
+ va_start (args, argc);
+ err = refoop->pool_tail_queue_args (qp, dq, f_name, f, argc, args);
+ va_end (args);
+
+ return err;
+ }
+
+ int pool_tail_queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args)
+ {
+ return refoop->pool_tail_queue_args (qp, dq, f_name, f, argc, args);
+ }
+
+ int pool_tail_queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv)
+ {
+ return refoop->pool_tail_queue_argv (qp, dq, f_name, f, argc, argv);
+ }
+#endif /* __AOSL_MPQP_H__ */
+#endif /* __AOSL_MPQ_H__ */
+
+ /* C++11 lambda encapsulations */
+#if (__cplusplus >= 201103) || defined (_MSC_VER)
+public:
+ int hold (aosl_ref_lambda_f &&lambda_f)
+ {
+ return refoop->hold (std::move (lambda_f));
+ }
+
+ int read (aosl_ref_lambda_f &&lambda_f)
+ {
+ return refoop->read (std::move (lambda_f));
+ }
+
+ int write (aosl_ref_lambda_f &&lambda_f)
+ {
+ return refoop->write (std::move (lambda_f));
+ }
+
+ int unsafe (aosl_ref_lambda_f &&lambda_f)
+ {
+ return refoop->unsafe (std::move (lambda_f));
+ }
+
+ int maystall (aosl_ref_lambda_f &&lambda_f)
+ {
+ return refoop->unsafe (std::move (lambda_f));
+ }
+
+ static int hold (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ return aosl_ref_t_oop::hold (ref, std::move (lambda_f));
+ }
+
+ static int read (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ return aosl_ref_t_oop::read (ref, std::move (lambda_f));
+ }
+
+ static int write (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ return aosl_ref_t_oop::write (ref, std::move (lambda_f));
+ }
+
+ static int unsafe (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ return aosl_ref_t_oop::unsafe (ref, std::move (lambda_f));
+ }
+
+ static int maystall (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f)
+ {
+ return aosl_ref_t_oop::unsafe (ref, std::move (lambda_f));
+ }
+
+ static int read (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f)
+ {
+ return aosl_ref_t_oop::read (robj, std::move (lambda_f));
+ }
+
+ static int unsafe (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f)
+ {
+ return aosl_ref_t_oop::unsafe (robj, std::move (lambda_f));
+ }
+
+ static int maystall (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f)
+ {
+ return aosl_ref_t_oop::unsafe (robj, std::move (lambda_f));
+ }
+
+#ifdef __AOSL_MPQ_H__
+public:
+ typedef std::function aosl_ref_mpq_lambda_f;
+ typedef std::function aosl_ref_mpq_lambda_0arg_f;
+
+ /* MPQ encapsulations */
+ int queue (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return refoop->queue (tq, dq, f_name, std::move (task));
+ }
+
+ int call (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL)
+ {
+ return refoop->call (q, f_name, std::move (task), task_result);
+ }
+
+ int run (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return refoop->run (q, f_name, std::move (task));
+ }
+
+ int queue (aosl_mpq_t tq, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return refoop->queue (tq, f_name, std::move (task));
+ }
+
+ int call (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL)
+ {
+ return refoop->call (q, f_name, std::move (task), task_result);
+ }
+
+ int run (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return refoop->run (q, f_name, std::move (task));
+ }
+
+#ifdef __AOSL_MPQP_H__
+ /* MPQP encapsulations */
+ aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return refoop->queue (qp, dq, f_name, std::move (task));
+ }
+
+ aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL)
+ {
+ return refoop->call (qp, f_name, std::move (task), task_result);
+ }
+
+ aosl_mpq_t run (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return refoop->run (qp, f_name, std::move (task));
+ }
+
+ int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return refoop->pool_tail_queue (qp, dq, f_name, std::move (task));
+ }
+
+ aosl_mpq_t queue (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return refoop->queue (qp, f_name, std::move (task));
+ }
+
+ aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL)
+ {
+ return refoop->call (qp, f_name, std::move (task), task_result);
+ }
+
+ aosl_mpq_t run (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return refoop->run (qp, f_name, std::move (task));
+ }
+
+ int pool_tail_queue (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return refoop->pool_tail_queue (qp, f_name, std::move (task));
+ }
+#endif /* __AOSL_MPQP_H__ */
+
+ /* MPQ with specified ref encapsulations */
+ static int queue (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return aosl_ref_t_oop::queue (tq, dq, ref, f_name, std::move (task));
+ }
+
+ static int call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL)
+ {
+ return aosl_ref_t_oop::call (q, ref, f_name, std::move (task), task_result);
+ }
+
+ static int run (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return aosl_ref_t_oop::run (q, ref, f_name, std::move (task));
+ }
+
+ static int queue (aosl_mpq_t tq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return aosl_ref_t_oop::queue (tq, ref, f_name, std::move (task));
+ }
+
+ static int call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL)
+ {
+ return aosl_ref_t_oop::call (q, ref, f_name, std::move (task), task_result);
+ }
+
+ static int run (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return aosl_ref_t_oop::run (q, ref, f_name, std::move (task));
+ }
+
+#ifdef __AOSL_MPQP_H__
+ /* MPQP with specified ref encapsulations */
+ static aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return aosl_ref_t_oop::queue (qp, dq, ref, f_name, std::move (task));
+ }
+
+ static aosl_mpq_t call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL)
+ {
+ return aosl_ref_t_oop::call (qp, ref, f_name, std::move (task), task_result);
+ }
+
+ static aosl_mpq_t run (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return aosl_ref_t_oop::run (qp, ref, f_name, std::move (task));
+ }
+
+ static int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task)
+ {
+ return aosl_ref_t_oop::pool_tail_queue (qp, dq, ref, f_name, std::move (task));
+ }
+
+ static aosl_mpq_t queue (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return aosl_ref_t_oop::queue (qp, ref, f_name, std::move (task));
+ }
+
+ static aosl_mpq_t call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL)
+ {
+ return aosl_ref_t_oop::call (qp, ref, f_name, std::move (task), task_result);
+ }
+
+ static aosl_mpq_t run (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return aosl_ref_t_oop::run (qp, ref, f_name, std::move (task));
+ }
+
+ static int pool_tail_queue (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task)
+ {
+ return aosl_ref_t_oop::pool_tail_queue (qp, ref, f_name, std::move (task));
+ }
+#endif /* __AOSL_MPQP_H__ */
+#endif /* __AOSL_MPQ_H__ */
+
+#ifdef __AOSL_ASYNC_H__
+ /**
+ * The stackless coroutine like implementation in AOSL. We could not
+ * support the real stackless coroutine except in the language level,
+ * so we just provide similar equivalent functionals here.
+ **/
+public:
+ int prepare (aosl_stack_id_t stack_id, const char *f_name, aosl_async_prepare_lambda_f&& task)
+ {
+ return refoop->prepare (stack_id, f_name, std::move (task));
+ }
+
+ static int prepare (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_async_prepare_lambda_f&& task)
+ {
+ return aosl_ref_t_oop::prepare (stack_id, ref, f_name, std::move (task));
+ }
+
+public:
+ typedef std::function aosl_async_resume_lambda_f;
+
+ int resume (aosl_stack_id_t stack_id, const char *f_name, aosl_async_resume_lambda_f&& task)
+ {
+ return refoop->resume (stack_id, f_name, std::move (task));
+ }
+
+ static int resume (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_async_resume_lambda_f&& task)
+ {
+ return aosl_ref_t_oop::resume (stack_id, ref, f_name, std::move (task));
+ }
+#endif /* __AOSL_ASYNC_H__ */
+#endif /* C++11 */
+
+#if (__cplusplus >= 201103) || defined (_MSC_VER)
+private:
+ aosl_ref_class (const aosl_ref_class &) = delete;
+ aosl_ref_class (aosl_ref_class &&) = delete;
+ aosl_ref_class &operator = (const aosl_ref_class &) = delete;
+ aosl_ref_class &operator = (aosl_ref_class &&) = delete;
+#else
+private:
+ aosl_ref_class (const aosl_ref_class &);
+ aosl_ref_class &operator = (const aosl_ref_class &);
+#endif /* C++11 */
+};
+
+
+/**
+ * The T_ref_cls argument of this template must be
+ * aosl_ref_class or its derivatives.
+ **/
+template
+class aosl_ref_unique_ptr {
+private:
+ T_ref_cls *_ptr;
+
+public:
+ aosl_ref_unique_ptr (): _ptr (NULL) {}
+ aosl_ref_unique_ptr (T_ref_cls *p): _ptr (p) {}
+
+ aosl_ref_unique_ptr &operator = (T_ref_cls *p)
+ {
+ reset ();
+ _ptr = p;
+ return *this;
+ }
+
+ T_ref_cls *operator -> () const
+ {
+ return _ptr;
+ }
+
+ T_ref_cls *get () const
+ {
+ return _ptr;
+ }
+
+ operator bool () const
+ {
+ return _ptr != NULL;
+ }
+
+ T_ref_cls *release ()
+ {
+ T_ref_cls *p = _ptr;
+ _ptr = NULL;
+ return p;
+ }
+
+ void reset (T_ref_cls *p = NULL)
+ {
+ T_ref_cls *old = _ptr;
+
+ /**
+ * We do the destroy and not delete the object
+ * before we set the pointer to the new value,
+ * this is very important to make sure that no
+ * any async operation is executing.
+ **/
+ if (old != NULL)
+ old->destroy (false/* not delete */);
+
+ _ptr = p;
+
+ /**
+ * The destroy with delete operation must be
+ * the last action, and don't touch any member
+ * of this object anymore after it.
+ **/
+ if (old != NULL)
+ old->destroy (true/* do delete */);
+ }
+
+ ~aosl_ref_unique_ptr ()
+ {
+ reset ();
+ }
+
+#if (__cplusplus >= 201103) || defined (_MSC_VER)
+private:
+ aosl_ref_unique_ptr (const aosl_ref_unique_ptr &) = delete;
+ aosl_ref_unique_ptr &operator = (const aosl_ref_unique_ptr &) = delete;
+
+public:
+ aosl_ref_unique_ptr (aosl_ref_unique_ptr &&src): _ptr (src.release ()) {}
+ aosl_ref_unique_ptr &operator = (aosl_ref_unique_ptr &&ptr)
+ {
+ reset (ptr.release ());
+ return *this;
+ }
+#else
+private:
+ aosl_ref_unique_ptr (const aosl_ref_unique_ptr &);
+ aosl_ref_unique_ptr &operator = (const aosl_ref_unique_ptr &);
+#endif /* C++11 */
+};
+
+
+template
+inline bool operator == (const aosl_ref_unique_ptr &ptr, intptr_t _null)
+{
+ return ptr.get () == (T_ref_cls *)_null;
+}
+
+template
+inline bool operator != (const aosl_ref_unique_ptr &ptr, intptr_t _null)
+{
+ return ptr.get () != (T_ref_cls *)_null;
+}
+
+template
+inline bool operator == (intptr_t _null, const aosl_ref_unique_ptr &ptr)
+{
+ return (T_ref_cls *)_null == ptr.get ();
+}
+
+template
+inline bool operator != (intptr_t _null, const aosl_ref_unique_ptr &ptr)
+{
+ return (T_ref_cls *)_null != ptr.get ();
+}
+
+#if (__cplusplus >= 201103) || defined (_MSC_VER)
+template
+inline bool operator == (const aosl_ref_unique_ptr