Fix video issues
This commit is contained in:
parent
260cceb90e
commit
9171c0dd1e
1 changed files with 34 additions and 10 deletions
|
@ -41,6 +41,7 @@ import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.opengl.Visibility;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -383,7 +384,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == R.id.video) {
|
if (id == R.id.video) {
|
||||||
switchVideo(!isVideoEnabled(LinphoneManager.getLc().getCurrentCall()), true);
|
enabledOrDisabledVideo(!isVideoEnabled(LinphoneManager.getLc().getCurrentCall()));
|
||||||
}
|
}
|
||||||
else if (id == R.id.micro) {
|
else if (id == R.id.micro) {
|
||||||
toggleMicro();
|
toggleMicro();
|
||||||
|
@ -455,6 +456,32 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enabledOrDisabledVideo(final boolean isVideoEnabled) {
|
||||||
|
final LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
|
||||||
|
if (call == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!isVideoEnabled) {
|
||||||
|
video.setEnabled(true);
|
||||||
|
LinphoneCallParams params = call.getCurrentParamsCopy();
|
||||||
|
params.setVideoEnabled(false);
|
||||||
|
LinphoneManager.getLc().updateCall(call, params);
|
||||||
|
} else {
|
||||||
|
if (!call.getRemoteParams().isLowBandwidthEnabled()) {
|
||||||
|
LinphoneManager.getInstance().addVideo();
|
||||||
|
} else {
|
||||||
|
displayCustomToast(getString(R.string.error_low_bandwidth), Toast.LENGTH_LONG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void displayCustomToast(final String message, final int duration) {
|
public void displayCustomToast(final String message, final int duration) {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -474,7 +501,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchVideo(final boolean displayVideo, final boolean isInitiator) {
|
private void switchVideo(final boolean displayVideo) {
|
||||||
final LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
|
final LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -484,15 +511,11 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!displayVideo) {
|
if (!displayVideo) {
|
||||||
if (isInitiator) {
|
|
||||||
LinphoneCallParams params = call.getCurrentParamsCopy();
|
|
||||||
params.setVideoEnabled(false);
|
|
||||||
LinphoneManager.getLc().updateCall(call, params);
|
|
||||||
}
|
|
||||||
showAudioView();
|
showAudioView();
|
||||||
} else {
|
} else {
|
||||||
if (!call.getRemoteParams().isLowBandwidthEnabled()) {
|
if (!call.getRemoteParams().isLowBandwidthEnabled()) {
|
||||||
if (LinphoneManager.getInstance().addVideo())
|
LinphoneManager.getInstance().addVideo();
|
||||||
|
if (videoCallFragment == null || !videoCallFragment.isVisible())
|
||||||
showVideoView();
|
showVideoView();
|
||||||
} else {
|
} else {
|
||||||
displayCustomToast(getString(R.string.error_low_bandwidth), Toast.LENGTH_LONG);
|
displayCustomToast(getString(R.string.error_low_bandwidth), Toast.LENGTH_LONG);
|
||||||
|
@ -517,6 +540,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
speaker.setBackgroundResource(R.drawable.speaker_on);
|
speaker.setBackgroundResource(R.drawable.speaker_on);
|
||||||
}
|
}
|
||||||
video.setBackgroundResource(R.drawable.video_off);
|
video.setBackgroundResource(R.drawable.video_off);
|
||||||
|
video.setEnabled(true);
|
||||||
|
|
||||||
LinphoneManager.stopProximitySensorForActivity(InCallActivity.this);
|
LinphoneManager.stopProximitySensorForActivity(InCallActivity.this);
|
||||||
replaceFragmentAudioByVideo();
|
replaceFragmentAudioByVideo();
|
||||||
|
@ -1107,7 +1131,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == State.StreamsRunning) {
|
if (state == State.StreamsRunning) {
|
||||||
switchVideo(isVideoEnabled(call), false);
|
switchVideo(isVideoEnabled(call));
|
||||||
|
|
||||||
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
|
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue