Skip to content

Commit

Permalink
Merge pull request #348 from AgoraIO/dev/4.2.1
Browse files Browse the repository at this point in the history
Dev/4.2.2
  • Loading branch information
zhangtao1104 authored Jul 27, 2023
2 parents 188fa99 + c1ee2b5 commit 18515f2
Show file tree
Hide file tree
Showing 302 changed files with 13,955 additions and 7,205 deletions.
2 changes: 1 addition & 1 deletion Android/APIExample-Audio/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
implementation fileTree(dir: "${localSdkPath}", include: ['*.jar', '*.aar'])
}
else{
def agora_sdk_version = "4.2.1"
def agora_sdk_version = "4.2.2"
// case 1: full single lib with voice only
implementation "io.agora.rtc:voice-sdk:${agora_sdk_version}"
// case 2: partial libs with voice only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ protected final void showLongToast(final String msg)
});
}

protected final void showShortToast(final String msg)
{
runOnUIThread(() -> {
Context context = getContext();
if(context == null){
return;
}
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
});
}

protected final void runOnUIThread(Runnable runnable){
this.runOnUIThread(runnable, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void onDestroy()
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (parent == audioScenario) {
engine.setAudioScenario(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()).ordinal());
engine.setAudioScenario(Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString())));
}
}

Expand Down Expand Up @@ -356,8 +356,8 @@ private void joinChannel(String channelId)
/**In the demo, the default is to enter as the anchor.*/
engine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
engine.setAudioProfile(
Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString()).ordinal(),
Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()).ordinal()
Constants.AudioProfile.getValue(Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString())),
Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()))
);

/**Please configure accessToken in the string_config file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ private void joinChannel(String channelId) {
engine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
// audio config
engine.setAudioProfile(
Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString()).ordinal(),
Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()).ordinal()
Constants.AudioProfile.getValue(Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString())),
Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()))
);

/**Please configure accessToken in the string_config file.
Expand Down Expand Up @@ -566,7 +566,7 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
}

if (parent == audioScenario) {
engine.setAudioScenario(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()).ordinal());
engine.setAudioScenario(Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString())));
return;
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,51 +46,13 @@
public class JoinChannelAudioByToken extends BaseFragment implements View.OnClickListener
{
private static final String TAG = JoinChannelAudioByToken.class.getSimpleName();
private Spinner audioProfileInput;
private Spinner audioScenarioInput;
private EditText et_app_id, et_channel, et_token;
private Button mute, join, speaker;
private SeekBar record, playout, inear;
private Switch inEarSwitch;
private Button join;
private RtcEngine engine;
private int myUid;
private boolean joined = false;
private AudioSeatManager audioSeatManager;

private SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if(engine == null){
return;
}
if(seekBar.getId() == record.getId()){
engine.adjustRecordingSignalVolume(progress);
}
else if(seekBar.getId() == playout.getId()){
engine.adjustPlaybackSignalVolume(progress);
}
else if(seekBar.getId() == inear.getId()){
if(progress == 0){
engine.enableInEarMonitoring(false);
}
else {
engine.enableInEarMonitoring(true);
engine.setInEarMonitoringVolume(progress);
}
}
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
};

@Override
public void onCreate(@Nullable Bundle savedInstanceState)
{
Expand All @@ -114,47 +76,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
et_app_id = view.findViewById(R.id.et_app_id);
et_channel = view.findViewById(R.id.et_channel);
et_token = view.findViewById(R.id.et_token);
audioProfileInput = view.findViewById(R.id.audio_profile_spinner);
audioScenarioInput = view.findViewById(R.id.audio_scenario_spinner);
audioScenarioInput.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if(joined){
int scenario = Constants.AudioScenario.valueOf(audioScenarioInput.getSelectedItem().toString()).ordinal();
engine.setAudioScenario(scenario);
}
}

@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});
view.findViewById(R.id.btn_join).setOnClickListener(this);
mute = view.findViewById(R.id.microphone);
mute.setOnClickListener(this);
speaker = view.findViewById(R.id.btn_speaker);
speaker.setOnClickListener(this);
speaker.setActivated(true);
record = view.findViewById(R.id.recordingVol);
playout = view.findViewById(R.id.playoutVol);
inear = view.findViewById(R.id.inEarMonitorVol);
record.setOnSeekBarChangeListener(seekBarChangeListener);
playout.setOnSeekBarChangeListener(seekBarChangeListener);
inear.setOnSeekBarChangeListener(seekBarChangeListener);
inEarSwitch = view.findViewById(R.id.inEarMonitorSwitch);
inEarSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if(engine == null){
return;
}
engine.enableInEarMonitoring(isChecked);
inear.setEnabled(isChecked);
});
record.setEnabled(false);
playout.setEnabled(false);
inear.setEnabled(false);
inEarSwitch.setEnabled(false);

audioSeatManager = new AudioSeatManager(
view.findViewById(R.id.audio_place_01),
view.findViewById(R.id.audio_place_02),
Expand Down Expand Up @@ -189,7 +111,6 @@ private boolean createRtcEngine(String appId) {
* The SDK uses this class to report to the app on SDK runtime events.
*/
config.mEventHandler = iRtcEngineEventHandler;
config.mAudioScenario = Constants.AudioScenario.valueOf(audioScenarioInput.getSelectedItem().toString()).ordinal();
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
engine = RtcEngine.create(config);
/**
Expand Down Expand Up @@ -254,47 +175,16 @@ public void onClick(View v)

if (createRtcEngine(appId)) {
joinChannel(channelId, token);
audioProfileInput.setEnabled(false);
}
}
else
{
joined = false;
join.setText(getString(R.string.join));
speaker.setText(getString(R.string.speaker));
speaker.setEnabled(false);
mute.setText(getString(R.string.closemicrophone));
mute.setEnabled(false);
audioProfileInput.setEnabled(true);
record.setEnabled(false);
playout.setEnabled(false);
inear.setEnabled(false);
inEarSwitch.setEnabled(false);
inEarSwitch.setChecked(false);
audioSeatManager.downAllSeats();
destroyRtcEngine();
}
}
else if (v.getId() == R.id.microphone)
{
if(engine == null){
return;
}
mute.setActivated(!mute.isActivated());
mute.setText(getString(mute.isActivated() ? R.string.openmicrophone : R.string.closemicrophone));
/**Turn off / on the microphone, stop / start local audio collection and push streaming.*/
engine.muteLocalAudioStream(mute.isActivated());
}
else if (v.getId() == R.id.btn_speaker)
{
if(engine == null){
return;
}
speaker.setActivated(!speaker.isActivated());
speaker.setText(getString(speaker.isActivated() ? R.string.speaker : R.string.earpiece));
/**Turn off / on the speaker and change the audio playback route.*/
engine.setEnableSpeakerphone(speaker.isActivated());
}
}

/**
Expand All @@ -305,12 +195,6 @@ private void joinChannel(String channelId, String token)
/**In the demo, the default is to enter as the anchor.*/
engine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);

int profile = Constants.AudioProfile.valueOf(audioProfileInput.getSelectedItem().toString()).ordinal();
engine.setAudioProfile(profile);

int scenario = Constants.AudioScenario.valueOf(audioScenarioInput.getSelectedItem().toString()).ordinal();
engine.setAudioScenario(scenario);

engine.setDefaultAudioRoutetoSpeakerphone(true);

ChannelMediaOptions option = new ChannelMediaOptions();
Expand Down Expand Up @@ -387,14 +271,8 @@ public void onJoinChannelSuccess(String channel, int uid, int elapsed)
@Override
public void run()
{
speaker.setEnabled(true);
mute.setEnabled(true);
join.setEnabled(true);
join.setText(getString(R.string.leave));
record.setEnabled(true);
playout.setEnabled(true);
inear.setEnabled(inEarSwitch.isChecked());
inEarSwitch.setEnabled(true);
audioSeatManager.upLocalSeat(uid);
}
});
Expand Down
Loading

0 comments on commit 18515f2

Please sign in to comment.