问题
I have implement an option of Video Conference on my application using the following example: https://github.com/androidthings/sample-videoRTC
basically is is working very well but i have one major issue. the sreaming audio volume is very very low even when i put the maximum volume on my device.
I have tried to check if there is any parameter that can define the audio volume but is was not able to find such parameters beside the AudioBitRate(=32) and the AudioCodec=("OPUS").
These are the parameters that is am using for creating the peerConnection:
peerConnectionParameters =
new PeerConnectionClient.PeerConnectionParameters(true,
false,
false,
videoWidth,
videoHeight,
0,
Integer.parseInt(getString(R.string.pref_maxvideobitratevalue_default)),
getString(R.string.pref_videocodec_default),
true,
false,
Integer.parseInt(getString(R.string.pref_startaudiobitratevalue_default)),
getString(R.string.pref_audiocodec_default),
false,
false,
false,
false,
false,
false,
false,
false,
null);
Is anyone have some idea how can I improve the audio volume?
Ihave tried to replace the default Audio Codec but the result was the same low vloume.
回答1:
After many check and investigation i have found the problem. i am answering it here if someone else will have the same problem.
i have notice that the voice is not routed to the speaker but to the ear cap...so i add the bellow code to turn on the speaker and the problem has solved !
audioManager = (AudioManager) this.activity.getSystemService(Context.AUDIO_SERVICE);
audioManager.setSpeakerphoneOn(true);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
To answer the question where i put the code, i have actually add a new icon to give the user to switch between headset and speaker.
here is the full code:
toggleSpeakerHeadset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (speakerOn) {
setHeadsetOn();
} else {
setSpeakerOn();
}
}
});
private void setSpeakerOn() {
speakerOn = true;
toggleSpeakerHeadset.setImageResource(R.drawable.headset);
audioManager.setSpeakerphoneOn(true);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
}
private void setHeadsetOn() {
speakerOn = false;
toggleSpeakerHeadset.setImageResource(R.drawable.speaker);
audioManager.setSpeakerphoneOn(false);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
}
来源:https://stackoverflow.com/questions/56212048/android-webrtc-implementaion-very-low-volume