Skip to content

Commit 5829092

Browse files
author
zhaoyongqiang
committed
Merge branch 'dev/4.0.1' of github.com:AgoraIO/API-Examples into dev/4.0.1
2 parents c47e63c + a830e9a commit 5829092

76 files changed

Lines changed: 4282 additions & 3228 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ci/build/build_android.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ rm ./$unzip_name/commits
6767
rm ./$unzip_name/package_size_report.txt
6868
mkdir ./$unzip_name/samples
6969
mkdir ./$unzip_name/samples/API-example
70-
cp -rf ./Android/** ./$unzip_name/samples/API-example
70+
cp -rf ./Android/APIExample/** ./$unzip_name/samples/API-example
7171
7za a -tzip result.zip -r $unzip_name
72-
cp result.zip $WORKSPACE/withAPIExample_$zip_name
72+
cp result.zip $WORKSPACE/withAPIExample_$zip_name

.github/ci/build/build_ios.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ rm -rf ./$unzip_name/bin
6363
rm ./$unzip_name/commits
6464
rm ./$unzip_name/package_size_report.txt
6565
mkdir ./$unzip_name/samples
66-
mkdir ./$unzip_name/samples/API-example
67-
cp -rf ./iOS/** ./$unzip_name/samples/API-example
66+
mkdir ./$unzip_name/samples/API-Example
67+
cp -rf ./iOS/** ./$unzip_name/samples/API-Example
68+
rm -rf ./$unzip_name/samples/API-Example/APIExample-Audio
69+
mv ./$unzip_name/samples/API-Example/APIExample ./$unzip_name/samples/APIExample
70+
rm -rf ./$unzip_name/samples/API-Example
6871
7za a -tzip result.zip -r $unzip_name
69-
cp result.zip $WORKSPACE/withAPIExample_$zip_name
72+
cp result.zip $WORKSPACE/withAPIExample_$zip_name

.github/ci/build/build_windows.bat

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ del /F /Q Agora_Native_SDK_for_Windows_FULL\commits
7979
del /F /Q Agora_Native_SDK_for_Windows_FULL\package_size_report.txt
8080
mkdir Agora_Native_SDK_for_Windows_FULL\samples
8181
mkdir Agora_Native_SDK_for_Windows_FULL\samples\API-example
82-
xcopy /Y /E windows Agora_Native_SDK_for_Windows_FULL\samples\API-example
82+
rmdir /S /Q windows\cicd
83+
del /F /Q windows\APIExample\ci.py
84+
xcopy /Y /E windows\APIExample Agora_Native_SDK_for_Windows_FULL\samples\API-example
85+
xcopy /Y /E windows\README.md Agora_Native_SDK_for_Windows_FULL\samples\API-example
86+
xcopy /Y /E windows\README.zh.md Agora_Native_SDK_for_Windows_FULL\samples\API-example
8387
7z a -tzip result.zip -r Agora_Native_SDK_for_Windows_FULL
84-
copy result.zip %WORKSPACE%\\withAPIExample_%zip_name%
88+
copy result.zip %WORKSPACE%\\withAPIExample_%zip_name%

Android/APIExample-Audio/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ Test/
2020
# sdk files
2121
*.so
2222
agora-rtc-sdk.jar
23+
AgoraScreenShareExtension.aar
2324
/release

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState)
183183
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
184184
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
185185
engine = RtcEngine.create(config);
186+
/**
187+
* This parameter is for reporting the usages of APIExample to agora background.
188+
* Generally, it is not necessary for you to set this parameter.
189+
*/
190+
engine.setParameters("{"
191+
+ "\"rtc.report_app_scenario\":"
192+
+ "{"
193+
+ "\"appScenario\":" + 100 + ","
194+
+ "\"serviceType\":" + 11 + ","
195+
+ "\"appVersion\":\"" + RtcEngine.getSdkVersion() + "\""
196+
+ "}"
197+
+ "}");
186198
preloadAudioEffect();
187199
}
188200
catch (Exception e)

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/PreCallTest.java

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public class PreCallTest extends BaseFragment implements View.OnClickListener {
4141

4242
private RtcEngine engine;
4343
private int myUid;
44-
private Button btn_lastmile, btn_echo;
44+
private Button btn_lastmile, btn_echo, btn_device_test;
4545
private StatisticsInfo statisticsInfo;
46-
private TextView lastmileQuality, lastmileResult;
46+
private TextView lastmileQuality, lastmileResult, labelDeviceTest;
4747
private static final Integer MAX_COUNT_DOWN = 8;
4848
private int num;
49-
private Timer timer;
49+
private Timer echoTimer;
5050

5151
@Override
5252
public void onCreate(@Nullable Bundle savedInstanceState) {
@@ -94,6 +94,18 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
9494
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
9595
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
9696
engine = RtcEngine.create(config);
97+
/**
98+
* This parameter is for reporting the usages of APIExample to agora background.
99+
* Generally, it is not necessary for you to set this parameter.
100+
*/
101+
engine.setParameters("{"
102+
+ "\"rtc.report_app_scenario\":"
103+
+ "{"
104+
+ "\"appScenario\":" + 100 + ","
105+
+ "\"serviceType\":" + 11 + ","
106+
+ "\"appVersion\":\"" + RtcEngine.getSdkVersion() + "\""
107+
+ "}"
108+
+ "}");
97109
}
98110
catch (Exception e) {
99111
e.printStackTrace();
@@ -109,10 +121,19 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
109121
btn_echo.setOnClickListener(this);
110122
btn_lastmile = view.findViewById(R.id.btn_lastmile);
111123
btn_lastmile.setOnClickListener(this);
124+
btn_device_test = view.findViewById(R.id.btn_device_test);
125+
btn_device_test.setOnClickListener(this);
126+
labelDeviceTest = view.findViewById(R.id.lb_device_test);
112127
lastmileQuality = view.findViewById(R.id.lastmile_quality);
113128
lastmileResult = view.findViewById(R.id.lastmile_result);
114129
}
115130

131+
@Override
132+
public void onDestroy() {
133+
super.onDestroy();
134+
RtcEngine.destroy();
135+
}
136+
116137
@Override
117138
public void onClick(View v) {
118139
if (v.getId() == R.id.btn_lastmile)
@@ -137,17 +158,17 @@ else if (v.getId() == R.id.btn_echo){
137158
engine.startEchoTest(MAX_COUNT_DOWN);
138159
btn_echo.setEnabled(false);
139160
btn_echo.setText("Recording on Microphone ...");
140-
timer = new Timer(true);
141-
timer.schedule(new TimerTask(){
161+
echoTimer = new Timer(true);
162+
echoTimer.schedule(new TimerTask(){
142163
public void run() {
143164
num++;
144165
if(num >= MAX_COUNT_DOWN * 2){
145166
handler.post(() -> {
146167
btn_echo.setEnabled(true);
147-
btn_echo.setText("Start");
168+
btn_echo.setText(R.string.start);
148169
});
149170
engine.stopEchoTest();
150-
timer.cancel();
171+
echoTimer.cancel();
151172
}
152173
else if(num >= MAX_COUNT_DOWN) {
153174
handler.post(() -> btn_echo.setText("PLaying with " + (MAX_COUNT_DOWN * 2 - num) + "Seconds"));
@@ -157,6 +178,19 @@ else if(num >= MAX_COUNT_DOWN) {
157178
}
158179
}
159180
}, 1000, 1000);
181+
}else if(v.getId() == R.id.btn_device_test){
182+
boolean enable = btn_device_test.getTag() instanceof Boolean && (Boolean) btn_device_test.getTag();
183+
if(!enable){
184+
engine.startRecordingDeviceTest(500);
185+
btn_device_test.setText(R.string.stop);
186+
btn_device_test.setTag(true);
187+
handler.postDelayed(() -> onClick(v), 10* 1000);
188+
}else{
189+
engine.stopRecordingDeviceTest();
190+
btn_device_test.setText(R.string.start);
191+
btn_device_test.setTag(null);
192+
labelDeviceTest.setText("");
193+
}
160194
}
161195
}
162196

@@ -284,9 +318,15 @@ public void onLastmileProbeResult(LastmileProbeResult lastmileProbeResult) {
284318
updateLastMileResult();
285319
handler.post(() -> {
286320
btn_lastmile.setEnabled(true);
287-
btn_lastmile.setText("Start");
321+
btn_lastmile.setText(R.string.start);
288322
});
289323
}
324+
325+
@Override
326+
public void onAudioVolumeIndication(AudioVolumeInfo[] speakers, int totalVolume) {
327+
super.onAudioVolumeIndication(speakers, totalVolume);
328+
runOnUIThread(() -> labelDeviceTest.append("totalVolume=" + totalVolume + "\n"));
329+
}
290330
};
291331

292332
private void updateLastMileResult() {

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/ProcessAudioRawData.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
165165
config.mEventHandler = iRtcEngineEventHandler;
166166
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
167167
engine = RtcEngine.create(config);
168+
/**
169+
* This parameter is for reporting the usages of APIExample to agora background.
170+
* Generally, it is not necessary for you to set this parameter.
171+
*/
172+
engine.setParameters("{"
173+
+ "\"rtc.report_app_scenario\":"
174+
+ "{"
175+
+ "\"appScenario\":" + 100 + ","
176+
+ "\"serviceType\":" + 11 + ","
177+
+ "\"appVersion\":\"" + RtcEngine.getSdkVersion() + "\""
178+
+ "}"
179+
+ "}");
168180
engine.registerAudioFrameObserver(iAudioFrameObserver);
169181
engine.setRecordingAudioFrameParameters(SAMPLE_RATE, SAMPLE_NUM_OF_CHANNEL, Constants.RAW_AUDIO_FRAME_OP_MODE_READ_WRITE, SAMPLES);
170182
engine.setPlaybackAudioFrameParameters(SAMPLE_RATE, SAMPLE_NUM_OF_CHANNEL, Constants.RAW_AUDIO_FRAME_OP_MODE_READ_WRITE, SAMPLES);
@@ -309,6 +321,11 @@ public boolean onMixedAudioFrame(String channel, int audioFrameType, int samples
309321
return false;
310322
}
311323

324+
@Override
325+
public boolean onEarMonitoringAudioFrame(int type, int samplesPerChannel, int bytesPerSample, int channels, int samplesPerSec, ByteBuffer buffer, long renderTimeMs, int avsync_type) {
326+
return false;
327+
}
328+
312329
@Override
313330
public boolean onPlaybackAudioFrameBeforeMixing(String channel, int uid, int audioFrameType, int samples, int bytesPerSample, int channels, int samplesPerSec, ByteBuffer byteBuffer, long renderTimeMs, int bufferLength) {
314331
return false;
@@ -333,6 +350,11 @@ public AudioParams getPlaybackAudioParams() {
333350
public AudioParams getMixedAudioParams() {
334351
return null;
335352
}
353+
354+
@Override
355+
public AudioParams getEarMonitoringAudioParams() {
356+
return null;
357+
}
336358
};
337359

338360
/**

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/RhythmPlayer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState)
126126
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
127127
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
128128
engine = RtcEngine.create(config);
129+
/**
130+
* This parameter is for reporting the usages of APIExample to agora background.
131+
* Generally, it is not necessary for you to set this parameter.
132+
*/
133+
engine.setParameters("{"
134+
+ "\"rtc.report_app_scenario\":"
135+
+ "{"
136+
+ "\"appScenario\":" + 100 + ","
137+
+ "\"serviceType\":" + 11 + ","
138+
+ "\"appVersion\":\"" + RtcEngine.getSdkVersion() + "\""
139+
+ "}"
140+
+ "}");
129141
}
130142
catch (Exception e)
131143
{

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
184184
config.mEventHandler = iRtcEngineEventHandler;
185185
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
186186
engine = RtcEngine.create(config);
187+
/**
188+
* This parameter is for reporting the usages of APIExample to agora background.
189+
* Generally, it is not necessary for you to set this parameter.
190+
*/
191+
engine.setParameters("{"
192+
+ "\"rtc.report_app_scenario\":"
193+
+ "{"
194+
+ "\"appScenario\":" + 100 + ","
195+
+ "\"serviceType\":" + 11 + ","
196+
+ "\"appVersion\":\"" + RtcEngine.getSdkVersion() + "\""
197+
+ "}"
198+
+ "}");
187199
mediaPlayer = engine.createMediaPlayer();
188200
mediaPlayer.registerPlayerObserver(iMediaPlayerObserver);
189201
} catch (Exception e) {
@@ -227,11 +239,6 @@ public void onPreloadEvent(String src, Constants.MediaPlayerPreloadEvent event)
227239

228240
}
229241

230-
@Override
231-
public void onCompleted() {
232-
233-
}
234-
235242
@Override
236243
public void onAgoraCDNTokenWillExpire() {
237244

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/VoiceEffects.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
241241
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
242242
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
243243
engine = RtcEngine.create(config);
244+
/**
245+
* This parameter is for reporting the usages of APIExample to agora background.
246+
* Generally, it is not necessary for you to set this parameter.
247+
*/
248+
engine.setParameters("{"
249+
+ "\"rtc.report_app_scenario\":"
250+
+ "{"
251+
+ "\"appScenario\":" + 100 + ","
252+
+ "\"serviceType\":" + 11 + ","
253+
+ "\"appVersion\":\"" + RtcEngine.getSdkVersion() + "\""
254+
+ "}"
255+
+ "}");
244256
} catch (Exception e) {
245257
e.printStackTrace();
246258
getActivity().onBackPressed();

0 commit comments

Comments
 (0)