Improved call stats updater + updated liblinphone

This commit is contained in:
Sylvain Berfini 2012-10-02 10:28:08 +02:00
parent 90e2b7f4b0
commit a7449bb46b
3 changed files with 60 additions and 59 deletions

View file

@ -30,7 +30,7 @@
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/> <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/>
<application android:label="@string/app_name" android:debuggable="true" android:icon="@drawable/logo_linphone_57x57" android:largeHeap="true"> <application android:label="@string/app_name" android:debuggable= "true" android:icon="@drawable/logo_linphone_57x57" android:largeHeap="true">
<activity android:name="org.linphone.LinphoneLauncherActivity" <activity android:name="org.linphone.LinphoneLauncherActivity"
android:label="@string/app_name" android:label="@string/app_name"

View file

@ -70,6 +70,8 @@ public class StatusFragment extends Fragment {
private Toast zrtpToast; private Toast zrtpToast;
private CountDownTimer zrtpHack; private CountDownTimer zrtpHack;
private boolean hideZrtpToast = false; private boolean hideZrtpToast = false;
private Timer mTimer;
private TimerTask mTask;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -159,7 +161,7 @@ public class StatusFragment extends Fragment {
sliderContentAccounts.setVisibility(View.GONE); sliderContentAccounts.setVisibility(View.GONE);
callStats.setVisibility(View.GONE); callStats.setVisibility(View.GONE);
if (isInCall && getResources().getBoolean(R.bool.display_call_stats)) { if (isInCall && isAttached && getResources().getBoolean(R.bool.display_call_stats)) {
callStats.setVisibility(View.VISIBLE); callStats.setVisibility(View.VISIBLE);
LinphoneCall call = LinphoneManager.getLc().getCurrentCall(); LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
initCallStatsRefresher(call, callStats); initCallStatsRefresher(call, callStats);
@ -445,68 +447,67 @@ public class StatusFragment extends Fragment {
} }
private void initCallStatsRefresher(final LinphoneCall call, final View view) { private void initCallStatsRefresher(final LinphoneCall call, final View view) {
new Thread(new Runnable() { if (mTimer != null && mTask != null) {
return;
}
mTimer = new Timer();
mTask = new TimerTask() {
@Override @Override
public void run() { public void run() {
final Timer timer = new Timer(); if (call == null) {
TimerTask lTask = new TimerTask() { mTimer.cancel();
@Override return;
public void run() { }
if (call == null) {
timer.cancel();
return;
}
final TextView title = (TextView) view.findViewById(R.id.call_stats_title); final TextView title = (TextView) view.findViewById(R.id.call_stats_title);
final TextView codec = (TextView) view.findViewById(R.id.codec); final TextView codec = (TextView) view.findViewById(R.id.codec);
final TextView dl = (TextView) view.findViewById(R.id.downloadBandwith); final TextView dl = (TextView) view.findViewById(R.id.downloadBandwith);
final TextView ul = (TextView) view.findViewById(R.id.uploadBandwith); final TextView ul = (TextView) view.findViewById(R.id.uploadBandwith);
final TextView ice = (TextView) view.findViewById(R.id.ice); final TextView ice = (TextView) view.findViewById(R.id.ice);
if (codec == null || dl == null || ul == null || ice == null) { if (codec == null || dl == null || ul == null || ice == null) {
timer.cancel(); mTimer.cancel();
return; return;
} }
if (call.getCurrentParamsCopy().getVideoEnabled()) { if (call.getCurrentParamsCopy().getVideoEnabled()) {
final LinphoneCallStats videoStats = call.getVideoStats(); final LinphoneCallStats videoStats = call.getVideoStats();
if (videoStats != null) { if (videoStats != null) {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
title.setText("Audio"); title.setText("Video");
PayloadType payload = call.getCurrentParamsCopy().getUsedVideoCodec(); PayloadType payload = call.getCurrentParamsCopy().getUsedVideoCodec();
if (payload != null) { if (payload != null) {
codec.setText(payload.getMime()); codec.setText(payload.getMime());
} }
dl.setText(String.valueOf((int) videoStats.getDownloadBandwidth()) + " kbits/s"); dl.setText(String.valueOf((int) videoStats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) videoStats.getUploadBandwidth()) + " kbits/s"); ul.setText(String.valueOf((int) videoStats.getUploadBandwidth()) + " kbits/s");
ice.setText(videoStats.getIceState().toString()); ice.setText(videoStats.getIceState().toString());
}
});
} }
} else { });
final LinphoneCallStats audioStats = call.getAudioStats();
if (audioStats != null) {
mHandler.post(new Runnable() {
@Override
public void run() {
title.setText("Video");
PayloadType payload = call.getCurrentParamsCopy().getUsedAudioCodec();
if (payload != null) {
codec.setText(payload.getMime());
}
dl.setText(String.valueOf((int) audioStats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) audioStats.getUploadBandwidth()) + " kbits/s");
ice.setText(audioStats.getIceState().toString());
}
});
}
}
} }
}; } else {
timer.scheduleAtFixedRate(lTask, 0, 1500); final LinphoneCallStats audioStats = call.getAudioStats();
if (audioStats != null) {
mHandler.post(new Runnable() {
@Override
public void run() {
title.setText("Audio");
PayloadType payload = call.getCurrentParamsCopy().getUsedAudioCodec();
if (payload != null) {
codec.setText(payload.getMime());
}
dl.setText(String.valueOf((int) audioStats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) audioStats.getUploadBandwidth()) + " kbits/s");
ice.setText(audioStats.getIceState().toString());
}
});
}
}
} }
}).start(); };
mTimer.scheduleAtFixedRate(mTask, 0, 1500);
} }
class AccountsListAdapter extends BaseAdapter { class AccountsListAdapter extends BaseAdapter {

@ -1 +1 @@
Subproject commit e6d835fa745550a043e18a3b850d0cb353ef9ae8 Subproject commit 438a8f4f73e54aa53cd9ac349f354601704a5862