From 84610f02e7562a62bde5755d8d0f80e3f7b20f0c Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 27 Sep 2013 13:45:41 +0200 Subject: [PATCH] Sound redirection in android client now allows selecting server side sound. --- .../Android/FreeRDPCore/jni/android_freerdp.c | 30 ++++++++++++------- .../Android/FreeRDPCore/jni/android_freerdp.h | 2 +- .../jni/generated/android_freerdp_jni.c | 2 +- ..._freerdp_freerdpcore_services_LibFreeRDP.h | 2 +- .../FreeRDPCore/res/values-es/strings.xml | 10 +++++++ .../FreeRDPCore/res/values-fr/strings.xml | 10 +++++++ .../FreeRDPCore/res/values-nl/strings.xml | 10 +++++++ .../FreeRDPCore/res/values/strings.xml | 12 +++++++- .../FreeRDPCore/res/xml/advanced_settings.xml | 2 +- .../freerdpcore/domain/BookmarkBase.java | 16 +++++----- .../services/BookmarkBaseGateway.java | 2 +- .../freerdpcore/services/LibFreeRDP.java | 10 +++---- 12 files changed, 79 insertions(+), 29 deletions(-) diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.c b/client/Android/FreeRDPCore/jni/android_freerdp.c index 9c5f208e5..8def1f662 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.c +++ b/client/Android/FreeRDPCore/jni/android_freerdp.c @@ -668,21 +668,27 @@ JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls } JNIEXPORT void JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, - jclass cls, jint instance, jboolean enable) + jclass cls, jint instance, jint redirect) { char** p; int count = 1; freerdp* inst = (freerdp*)instance; rdpSettings * settings = inst->settings; - DEBUG_ANDROID("sound redirect: %s", enable ? "TRUE" : "FALSE"); + DEBUG_ANDROID("sound: %s", + redirect ? ((redirect == 1) ? "Server" : "Redirect") : "None"); - p = malloc(sizeof(char*)); - p[0] = "rdpsnd"; + settings->AudioPlayback = (redirect == 2) ? TRUE : FALSE; + settings->RemoteConsoleAudio = (redirect == 1) ? TRUE : FALSE; + if (settings->AudioPlayback) + { + p = malloc(sizeof(char*)); + p[0] = "rdpsnd"; - freerdp_client_add_static_channel(settings, count, p); + freerdp_client_add_static_channel(settings, count, p); - free(p); + free(p); + } } JNIEXPORT void JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, @@ -695,12 +701,16 @@ JNIEXPORT void JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, DEBUG_ANDROID("microphone redirect: %s", enable ? "TRUE" : "FALSE"); - p = malloc(sizeof(char*)); - p[0] = "audin"; + settings->AudioCapture = enable; + if (enable) + { + p = malloc(sizeof(char*)); + p[0] = "audin"; - freerdp_client_add_dynamic_channel(settings, count, p); + freerdp_client_add_dynamic_channel(settings, count, p); - free(p); + free(p); + } } JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable) diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.h b/client/Android/FreeRDPCore/jni/android_freerdp.h index 717585d9d..98c94478d 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.h +++ b/client/Android/FreeRDPCore/jni/android_freerdp.h @@ -45,7 +45,7 @@ JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(JNIEnv *env, jclass cls jboolean disableMenuAnimations, jboolean disableTheming, jboolean enableFontSmoothing, jboolean enableDesktopComposition); JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls, jint instance, jstring jRemoteProgram, jstring jWorkDir); JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath); -JNIEXPORT void JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable); +JNIEXPORT void JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, jclass cls, jint instance, jint redirect); JNIEXPORT void JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable); JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable); JNIEXPORT void JNICALL jni_freerdp_set_gateway_info(JNIEnv *env, jclass cls, jint instance, jstring jgatewayhostname, jint port, jstring jgatewayusername, jstring jgatewaypassword, jstring jgatewaydomain); diff --git a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c index 4339b539f..597285aa8 100644 --- a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c +++ b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c @@ -77,7 +77,7 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ } JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1sound_1redirection - (JNIEnv *env, jclass cls, jint inst, jboolean redirect) + (JNIEnv *env, jclass cls, jint inst, jint redirect) { jni_freerdp_set_sound_redirection(env, cls, inst, redirect); } diff --git a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h index 7d258a981..868b49518 100644 --- a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h +++ b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h @@ -93,7 +93,7 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ * Signature: (IZ)V */ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1sound_1redirection - (JNIEnv *, jclass, jint, jboolean); + (JNIEnv *, jclass, jint, jint); /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP diff --git a/client/Android/FreeRDPCore/res/values-es/strings.xml b/client/Android/FreeRDPCore/res/values-es/strings.xml index 5405299bc..ac50cc01e 100644 --- a/client/Android/FreeRDPCore/res/values-es/strings.xml +++ b/client/Android/FreeRDPCore/res/values-es/strings.xml @@ -116,6 +116,16 @@ Gateway Settings Redirect SDCard Redirect Sound + + None + Server + Client + + + 0 + 1 + 2 + Redirect Microphone Seguridad diff --git a/client/Android/FreeRDPCore/res/values-fr/strings.xml b/client/Android/FreeRDPCore/res/values-fr/strings.xml index 95c4e7861..a324a105f 100644 --- a/client/Android/FreeRDPCore/res/values-fr/strings.xml +++ b/client/Android/FreeRDPCore/res/values-fr/strings.xml @@ -115,6 +115,16 @@ Gateway Settings "Redirect SDCard" Redirect Sound + + None + Server + Client + + + 0 + 1 + 2 + Redirect Microphone "Securité" diff --git a/client/Android/FreeRDPCore/res/values-nl/strings.xml b/client/Android/FreeRDPCore/res/values-nl/strings.xml index 94fb069f5..9abf968b4 100644 --- a/client/Android/FreeRDPCore/res/values-nl/strings.xml +++ b/client/Android/FreeRDPCore/res/values-nl/strings.xml @@ -116,6 +116,16 @@ Gateway instellingen SDCard aankoppelen Redirect Sound + + None + Server + Client + + + 0 + 1 + 2 + Redirect Microphone Beveiliging diff --git a/client/Android/FreeRDPCore/res/values/strings.xml b/client/Android/FreeRDPCore/res/values/strings.xml index 7062ab06d..49a8a603f 100644 --- a/client/Android/FreeRDPCore/res/values/strings.xml +++ b/client/Android/FreeRDPCore/res/values/strings.xml @@ -112,7 +112,17 @@ Enable Gateway Gateway Settings Redirect SDCard - Redirect Sound + Redirect Sound + + None + Server + Client + + + 0 + 1 + 2 + Redirect Microphone Security diff --git a/client/Android/FreeRDPCore/res/xml/advanced_settings.xml b/client/Android/FreeRDPCore/res/xml/advanced_settings.xml index b5dccfdcd..77e819732 100644 --- a/client/Android/FreeRDPCore/res/xml/advanced_settings.xml +++ b/client/Android/FreeRDPCore/res/xml/advanced_settings.xml @@ -36,7 +36,7 @@ - + diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java index 857abf2cf..9a9f54a0d 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java @@ -295,7 +295,7 @@ public class BookmarkBase implements Parcelable, Cloneable private ScreenSettings screen3G; private PerformanceFlags performance3G; private boolean redirectSDCard; - private boolean redirectSound; + private int redirectSound; private boolean redirectMicrophone; private int security; private boolean consoleMode; @@ -311,7 +311,7 @@ public class BookmarkBase implements Parcelable, Cloneable screen3G = parcel.readParcelable(ScreenSettings.class.getClassLoader()); performance3G = parcel.readParcelable(PerformanceFlags.class.getClassLoader()); redirectSDCard = (parcel.readInt() == 1) ? true : false; - redirectSound = (parcel.readInt() == 1) ? true : false; + redirectSound = parcel.readInt(); redirectMicrophone = (parcel.readInt() == 1) ? true : false; security = parcel.readInt(); consoleMode = (parcel.readInt() == 1) ? true : false; @@ -324,7 +324,7 @@ public class BookmarkBase implements Parcelable, Cloneable screen3G = new ScreenSettings(); performance3G = new PerformanceFlags(); redirectSDCard = false; - redirectSound = false; + redirectSound = 0; redirectMicrophone = false; security = 0; consoleMode = false; @@ -364,11 +364,11 @@ public class BookmarkBase implements Parcelable, Cloneable return redirectSDCard; } - public void setRedirectSound(boolean redirect) { + public void setRedirectSound(int redirect) { this.redirectSound = redirect; } - public boolean getRedirectSound() { + public int getRedirectSound() { return redirectSound; } @@ -440,7 +440,7 @@ public class BookmarkBase implements Parcelable, Cloneable out.writeParcelable(screen3G, flags); out.writeParcelable(performance3G, flags); out.writeInt(redirectSDCard ? 1 : 0); - out.writeInt(redirectSound ? 1 : 0); + out.writeInt(redirectSound); out.writeInt(redirectMicrophone ? 1 : 0); out.writeInt(security); out.writeInt(consoleMode ? 1 : 0); @@ -644,7 +644,7 @@ public class BookmarkBase implements Parcelable, Cloneable editor.putBoolean("bookmark.perf_themes_3g", advancedSettings.getPerformance3G().getTheming()); editor.putBoolean("bookmark.redirect_sdcard", advancedSettings.getRedirectSDCard()); - editor.putBoolean("bookmark.redirect_sound", advancedSettings.getRedirectSound()); + editor.putInt("bookmark.redirect_sound", advancedSettings.getRedirectSound()); editor.putBoolean("bookmark.redirect_microphone", advancedSettings.getRedirectMicrophone()); editor.putInt("bookmark.security", advancedSettings.getSecurity()); editor.putString("bookmark.remote_program", advancedSettings.getRemoteProgram()); @@ -688,7 +688,7 @@ public class BookmarkBase implements Parcelable, Cloneable advancedSettings.getPerformance3G().setTheming(sharedPrefs.getBoolean("bookmark.perf_themes_3g", false)); advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean("bookmark.redirect_sdcard", false)); - advancedSettings.setRedirectSound(sharedPrefs.getBoolean("bookmark.redirect_sound", false)); + advancedSettings.setRedirectSound(sharedPrefs.getInt("bookmark.redirect_sound", 0)); advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean("bookmark.redirect_microphone", false)); advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0)); advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", "")); diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java index bfc33ad38..593cecdf8 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java @@ -283,7 +283,7 @@ public abstract class BookmarkBaseGateway readScreenSettings3G(bookmark, cursor); readPerformanceFlags3G(bookmark, cursor); bookmark.getAdvancedSettings().setRedirectSDCard(cursor.getInt(cursor.getColumnIndex("redirect_sdcard")) == 0 ? false : true); - bookmark.getAdvancedSettings().setRedirectSound(cursor.getInt(cursor.getColumnIndex("redirect_sound")) == 0 ? false : true); + bookmark.getAdvancedSettings().setRedirectSound(cursor.getInt(cursor.getColumnIndex("redirect_sound"))); bookmark.getAdvancedSettings().setRedirectMicrophone(cursor.getInt(cursor.getColumnIndex("redirect_microphone")) == 0 ? false : true); bookmark.getAdvancedSettings().setSecurity(cursor.getInt(cursor.getColumnIndex("security"))); bookmark.getAdvancedSettings().setConsoleMode(cursor.getInt(cursor.getColumnIndex("console_mode")) == 0 ? false : true); diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java index b72db7ae1..32ce83d27 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java @@ -40,7 +40,7 @@ public class LibFreeRDP private static native void freerdp_set_data_directory(int inst, String directory); private static native void freerdp_set_clipboard_redirection(int inst, boolean enable); - private static native void freerdp_set_sound_redirection(int inst, boolean enable); + private static native void freerdp_set_sound_redirection(int inst, int redirect); private static native void freerdp_set_microphone_redirection(int inst, boolean enable); private static native void freerdp_set_drive_redirection(int inst, String path); @@ -169,12 +169,12 @@ public class LibFreeRDP } // Sound redirection - if (advancedSettings.getRedirectSound()) - freerdp_set_sound_redirection(inst, true); + freerdp_set_sound_redirection(inst, + advancedSettings.getRedirectSound()); // Microphone redirection - if (advancedSettings.getRedirectMicrophone()) - freerdp_set_microphone_redirection(inst, true); + freerdp_set_microphone_redirection(inst, + advancedSettings.getRedirectMicrophone()); return true; }