Fixed current CallParams not copied.

Fixed not always sending static image on camera muted.
Improved organization of preference activity.
This commit is contained in:
Guillaume Beraudo 2010-12-06 14:31:49 +01:00
parent 1d7b076475
commit 720a8aa7a9
8 changed files with 122 additions and 48 deletions

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_video">Video</string>
<string name="pref_preferences">Preferences</string>
<string name="pref_video_codec_h263_title">H263</string> <string name="pref_video_codec_h263_title">H263</string>
<string name="pref_video_codec_h263_key">pref_video_codec_h263_key</string> <string name="pref_video_codec_h263_key">pref_video_codec_h263_key</string>
<string name="pref_video_codec_mpeg4_title">MPEG4</string> <string name="pref_video_codec_mpeg4_title">MPEG4</string>

View file

@ -1,50 +1,117 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_sipaccount"> <PreferenceCategory android:title="@string/pref_sipaccount">
<EditTextPreference android:title="@string/pref_username" <EditTextPreference android:title="@string/pref_username"
android:key="@string/pref_username_key"></EditTextPreference> android:key="@string/pref_username_key"></EditTextPreference>
<EditTextPreference android:title="@string/pref_passwd" <EditTextPreference android:title="@string/pref_passwd"
android:key="@string/pref_passwd_key" android:password="true"></EditTextPreference> android:key="@string/pref_passwd_key" android:password="true"></EditTextPreference>
<EditTextPreference android:title="@string/pref_domain" <EditTextPreference android:title="@string/pref_domain"
android:key="@string/pref_domain_key"></EditTextPreference> android:key="@string/pref_domain_key"></EditTextPreference>
<EditTextPreference android:title="@string/pref_proxy" <EditTextPreference android:title="@string/pref_proxy"
android:key="@string/pref_proxy_key"></EditTextPreference> android:key="@string/pref_proxy_key"></EditTextPreference>
<CheckBoxPreference android:enabled="true" android:selectable="true" android:key="@string/pref_enable_outbound_proxy_key" android:title="@string/pref_enable_outbound_proxy"></CheckBoxPreference>
</PreferenceCategory> <CheckBoxPreference android:enabled="true"
<PreferenceCategory android:title="@string/pref_advanced"> android:selectable="true" android:key="@string/pref_enable_outbound_proxy_key"
<EditTextPreference android:title="@string/pref_stun_server" android:key="@string/pref_stun_server_key"></EditTextPreference> android:title="@string/pref_enable_outbound_proxy"></CheckBoxPreference>
<PreferenceScreen android:title="@string/pref_codecs" android:key="@string/pref_codecs_key"> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_preferences">
<CheckBoxPreference android:title="@string/pref_autostart"
android:key="@string/pref_autostart_key" android:defaultValue="false"></CheckBoxPreference>
<CheckBoxPreference android:defaultValue="true"
android:title="@string/pref_video_enable_title" android:key="@string/pref_video_enable_key" />
<CheckBoxPreference android:title="@string/pref_handle_outcall"
android:key="@string/pref_handle_outcall_key" android:summary="@string/pref_handle_outcall_summarry"></CheckBoxPreference>
<EditTextPreference android:title="@string/pref_stun_server"
android:key="@string/pref_stun_server_key"></EditTextPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_audio">
<PreferenceScreen android:title="@string/pref_codecs"
android:key="@string/pref_codecs_key">
<CheckBoxPreference android:key="@string/pref_codec_speex16_key" <CheckBoxPreference android:key="@string/pref_codec_speex16_key"
android:title="@string/pref_codec_speex16" android:defaultValue="true" android:enabled="false"></CheckBoxPreference> android:title="@string/pref_codec_speex16" android:defaultValue="true"
android:enabled="false"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_codec_speex8_key" <CheckBoxPreference android:key="@string/pref_codec_speex8_key"
android:title="@string/pref_codec_speex8" android:defaultValue="true"></CheckBoxPreference> android:title="@string/pref_codec_speex8" android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_codec_ilbc_key" android:title="@string/pref_codec_ilbc" android:enabled="false" android:shouldDisableView="true" android:defaultValue="true" android:summary="@string/pref_ilbc_summary"></CheckBoxPreference> <CheckBoxPreference android:key="@string/pref_codec_ilbc_key"
android:title="@string/pref_codec_ilbc" android:enabled="false"
android:shouldDisableView="true" android:defaultValue="true"
android:summary="@string/pref_ilbc_summary"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_codec_gsm_key" <CheckBoxPreference android:key="@string/pref_codec_gsm_key"
android:title="@string/pref_codec_gsm" android:defaultValue="true"></CheckBoxPreference> android:title="@string/pref_codec_gsm" android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_codec_pcmu_key" <CheckBoxPreference android:key="@string/pref_codec_pcmu_key"
android:title="@string/pref_codec_pcmu" android:defaultValue="true"></CheckBoxPreference> android:title="@string/pref_codec_pcmu" android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_codec_pcma_key" <CheckBoxPreference android:key="@string/pref_codec_pcma_key"
android:title="@string/pref_codec_pcma" android:defaultValue="true"></CheckBoxPreference> android:title="@string/pref_codec_pcma" android:defaultValue="true"></CheckBoxPreference>
</PreferenceScreen><CheckBoxPreference android:title="@string/pref_autostart" android:key="@string/pref_autostart_key" android:defaultValue="false"></CheckBoxPreference> </PreferenceScreen>
<CheckBoxPreference android:title="@string/pref_handle_outcall" android:key="@string/pref_handle_outcall_key" android:summary="@string/pref_handle_outcall_summarry"></CheckBoxPreference><CheckBoxPreference android:key="@string/pref_echo_cancellation_key" android:title="@string/pref_echo_cancellation" android:summary="@string/pref_echo_cancellation_summary"></CheckBoxPreference><EditTextPreference android:title="@string/pref_prefix"
<CheckBoxPreference android:key="@string/pref_echo_cancellation_key"
android:title="@string/pref_echo_cancellation" android:summary="@string/pref_echo_cancellation_summary"></CheckBoxPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_video" android:dependency="@string/pref_video_enable_key" android:shouldDisableView="true">
<PreferenceScreen android:dependency="@string/pref_video_enable_key"
android:shouldDisableView="true" android:key="@string/pref_video_codecs_key"
android:title="@string/pref_video_codecs_title">
<CheckBoxPreference android:key="@string/pref_video_codec_h264_key"
android:title="@string/pref_video_codec_h264_title"
android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_video_codec_mpeg4_key"
android:title="@string/pref_video_codec_mpeg4_title"
android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_video_codec_h263_key"
android:title="@string/pref_video_codec_h263_title" android:enabled="false"
android:defaultValue="false" android:selectable="false"></CheckBoxPreference>
</PreferenceScreen>
<PreferenceScreen android:title="@string/pref_video_settings_title"
android:dependency="@string/pref_video_enable_key"
android:shouldDisableView="true">
<CheckBoxPreference android:key="@string/pref_video_initiate_call_with_video_key"
android:defaultValue="false"
android:title="@string/pref_video_initiate_call_with_video_title"
android:summary="@string/pref_video_initiate_call_with_video"
android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
<CheckBoxPreference
android:key="@string/pref_video_automatically_share_my_video_key"
android:title="@string/pref_video_automatically_share_my_video_title"
android:defaultValue="false"
android:summary="@string/pref_video_automatically_share_my_video"
android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_advanced">
<EditTextPreference android:title="@string/pref_prefix"
android:key="@string/pref_prefix_key"></EditTextPreference> android:key="@string/pref_prefix_key"></EditTextPreference>
<CheckBoxPreference android:key="@string/pref_escape_plus_key" android:title="@string/pref_escape_plus"></CheckBoxPreference><CheckBoxPreference android:key="@string/pref_debug_key" <CheckBoxPreference android:key="@string/pref_escape_plus_key"
android:title="@string/pref_escape_plus"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_debug_key"
android:title="@string/pref_debug" android:enabled="true"></CheckBoxPreference> android:title="@string/pref_debug" android:enabled="true"></CheckBoxPreference>
</PreferenceCategory>
<CheckBoxPreference android:defaultValue="true" android:title="@string/pref_video_enable_title" android:key="@string/pref_video_enable_key" />
<PreferenceScreen android:title="@string/pref_video_settings_title" android:dependency="@string/pref_video_enable_key" android:shouldDisableView="true"><CheckBoxPreference android:key="@string/pref_video_initiate_call_with_video_key" android:defaultValue="false" android:title="@string/pref_video_initiate_call_with_video_title" android:summary="@string/pref_video_initiate_call_with_video" android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_video_automatically_share_my_video_key" android:title="@string/pref_video_automatically_share_my_video_title" android:defaultValue="false" android:summary="@string/pref_video_automatically_share_my_video" android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
</PreferenceScreen>
<PreferenceScreen android:dependency="@string/pref_video_enable_key" android:shouldDisableView="true" android:key="@string/pref_video_codecs_key" android:title="@string/pref_video_codecs_title"><CheckBoxPreference android:key="@string/pref_video_codec_h264_key" android:title="@string/pref_video_codec_h264_title" android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_video_codec_mpeg4_key" android:title="@string/pref_video_codec_mpeg4_title" android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_video_codec_h263_key" android:title="@string/pref_video_codec_h263_title" android:enabled="false" android:defaultValue="false" android:selectable="false"></CheckBoxPreference>
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View file

@ -88,7 +88,7 @@ public class BandwidthManager {
if (lc.isIncall()) { if (lc.isIncall()) {
LinphoneCall lCall = lc.getCurrentCall(); LinphoneCall lCall = lc.getCurrentCall();
LinphoneCallParams params = lCall.getCurrentParamsReadOnly().copy(); LinphoneCallParams params = lCall.getCurrentParamsCopy();
// Update video parm if // Update video parm if
if (newProfile == LOW_BANDWIDTH) { if (newProfile == LOW_BANDWIDTH) {

View file

@ -169,7 +169,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
public void onClick(View v) { public void onClick(View v) {
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
LinphoneCall lCall = lLinphoneCore.getCurrentCall(); LinphoneCall lCall = lLinphoneCore.getCurrentCall();
LinphoneCallParams params = lCall.getCurrentParamsReadOnly(); LinphoneCallParams params = lCall.getCurrentParamsCopy();
if (params.getVideoEnabled()) { if (params.getVideoEnabled()) {
// In video call; going back to video call activity // In video call; going back to video call activity
startVideoView(VIDEO_VIEW_ACTIVITY); startVideoView(VIDEO_VIEW_ACTIVITY);
@ -470,7 +470,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
} else if (state == LinphoneCall.State.CallEnd) { } else if (state == LinphoneCall.State.CallEnd) {
exitCallMode(); exitCallMode();
} else if (state == LinphoneCall.State.StreamsRunning) { } else if (state == LinphoneCall.State.StreamsRunning) {
if (LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsReadOnly().getVideoEnabled()) { if (LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsCopy().getVideoEnabled()) {
if (!VideoCallActivity.launched) { if (!VideoCallActivity.launched) {
startVideoView(VIDEO_VIEW_ACTIVITY); startVideoView(VIDEO_VIEW_ACTIVITY);
} }
@ -598,7 +598,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
lAddress.setDisplayName(mDisplayName); lAddress.setDisplayName(mDisplayName);
try { try {
LinphoneCallParams lParams = lLinphoneCore.createDefaultCallParameters().copy(); LinphoneCallParams lParams = lLinphoneCore.createDefaultCallParameters();
boolean prefVideoEnable = mPref.getBoolean(getString(R.string.pref_video_enable_key), false); boolean prefVideoEnable = mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
boolean prefInitiateWithVideo = mPref.getBoolean(getString(R.string.pref_video_initiate_call_with_video_key), false); boolean prefInitiateWithVideo = mPref.getBoolean(getString(R.string.pref_video_initiate_call_with_video_key), false);

View file

@ -53,6 +53,8 @@ public class VideoCallActivity extends Activity {
recordManager = AndroidCameraRecordManager.getInstance(); recordManager = AndroidCameraRecordManager.getInstance();
recordManager.setSurfaceView(mVideoCaptureView, rotation); recordManager.setSurfaceView(mVideoCaptureView, rotation);
mVideoCaptureView.setZOrderOnTop(true); mVideoCaptureView.setZOrderOnTop(true);
if (!recordManager.isMuted()) sendStaticImage(false);
} }
@ -85,16 +87,24 @@ public class VideoCallActivity extends Activity {
return true; return true;
} }
private void sendStaticImage(boolean send) {
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
if (lc.isIncall()) {
lc.getCurrentCall().enableCamera(!send);
}
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.videocall_menu_back_to_dialer: case R.id.videocall_menu_back_to_dialer:
if (!recordManager.isMuted()) sendStaticImage(true);
finish(); finish();
break; break;
case R.id.videocall_menu_change_resolution: case R.id.videocall_menu_change_resolution:
BandwidthManager manager = BandwidthManager.getInstance(); BandwidthManager manager = BandwidthManager.getInstance();
manager.setUserRestriction(!manager.isUserRestriction()); manager.setUserRestriction(!manager.isUserRestriction());
sendStaticImage(recordManager.isMuted());
rewriteChangeResolutionItem(item); rewriteChangeResolutionItem(item);
break; break;
case R.id.videocall_menu_terminate_call: case R.id.videocall_menu_terminate_call:
@ -106,10 +116,7 @@ public class VideoCallActivity extends Activity {
break; break;
case R.id.videocall_menu_toggle_camera: case R.id.videocall_menu_toggle_camera:
recordManager.toggleMute(); recordManager.toggleMute();
LinphoneCore lc = LinphoneService.instance().getLinphoneCore(); sendStaticImage(recordManager.isMuted());
if (lc.isIncall()) {
lc.getCurrentCall().enableCamera(!recordManager.isMuted());
}
rewriteToggleCameraItem(item); rewriteToggleCameraItem(item);
break; break;
default: default:

View file

@ -29,7 +29,7 @@ class LinphoneCallImpl implements LinphoneCall {
private native boolean isIncoming(long nativePtr); private native boolean isIncoming(long nativePtr);
native private long getRemoteAddress(long nativePtr); native private long getRemoteAddress(long nativePtr);
native private int getState(long nativePtr); native private int getState(long nativePtr);
private native long getCurrentParams(long nativePtr); private native long getCurrentParamsCopy(long nativePtr);
private native void enableCamera(long nativePtr, boolean enabled); private native void enableCamera(long nativePtr, boolean enabled);
protected LinphoneCallImpl(long aNativePtr) { protected LinphoneCallImpl(long aNativePtr) {
@ -61,11 +61,8 @@ class LinphoneCallImpl implements LinphoneCall {
public State getState() { public State getState() {
return LinphoneCall.State.fromInt(getState(nativePtr)); return LinphoneCall.State.fromInt(getState(nativePtr));
} }
public LinphoneCallParams getCurrentParamsReadOnly() { public LinphoneCallParams getCurrentParamsCopy() {
return new LinphoneCallParamsImpl(getCurrentParams(nativePtr)); return new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
}
public LinphoneCallParams getCurrentParamsReadWrite() {
return getCurrentParamsReadOnly().copy();
} }
public void enableCamera(boolean enabled) { public void enableCamera(boolean enabled) {

View file

@ -27,7 +27,7 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams {
private native void enableVideo(long nativePtr, boolean b); private native void enableVideo(long nativePtr, boolean b);
private native boolean getVideoEnabled(long nativePtr); private native boolean getVideoEnabled(long nativePtr);
private native long copy(long nativePtr); private native void destroy(long nativePtr);
public boolean getVideoEnabled() { public boolean getVideoEnabled() {
@ -37,9 +37,10 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams {
public void setVideoEnabled(boolean b) { public void setVideoEnabled(boolean b) {
enableVideo(nativePtr, b); enableVideo(nativePtr, b);
} }
public LinphoneCallParams copy() { @Override
return new LinphoneCallParamsImpl(copy(nativePtr)); protected void finalize() throws Throwable {
destroy(nativePtr);
super.finalize();
} }
} }

@ -1 +1 @@
Subproject commit 8b3112cca81a31e4b35b0c4e9e7c6217fefb5c4c Subproject commit 9fc45b990045768c65a346e5b41a37ab8087d0b5