Commit 110e3cf0 authored by Erwan Croze's avatar Erwan Croze 👋🏻

Use the device table of msfactory

parent 39ebebd6
......@@ -31,4 +31,8 @@ public class Factory{
public boolean filterFromNameEnabled(String name){
return filterFromNameEnabled(mNativePtr, name);
}
private native void setDeviceInfo(long nativePtr, String manufacturer, String model, String platform, int flags, int delay, int recommended_rate);
public void setDeviceInfo(String manufacturer, String model, String platform, int flags, int delay, int recommended_rate) {
setDeviceInfo(mNativePtr, manufacturer, model, platform, flags, delay, recommended_rate);
}
};
......@@ -26,23 +26,21 @@ import android.os.Build;
public class MediastreamerAndroidContext {
private static final int DEVICE_CHOICE = 0; // The device has the API to tell us it as or not a builtin AEC and we can trust it
private static final int DEVICE_HAS_BUILTIN_AEC = 1; // Says the device has a builtin AEC because the API that would tell us that isn't available
private static final int DEVICE_HAS_BUILTIN_AEC_CRAPPY = 2; // The device has the API to tell us it has a builtin AEC but we shouldn't trust it (so we'll use software AEC)
private static final int DEVICE_USE_ANDROID_MIC = 4;
private static final int DEVICE_HAS_BUILTIN_OPENSLES_AEC = 8; // The device has a builtin AEC and it is working with OpenSLES (which is uncommon)
public static final int DEVICE_HAS_BUILTIN_AEC = 1; // Says the device has a builtin AEC because the API that would tell us that isn't available
public static final int DEVICE_HAS_BUILTIN_AEC_CRAPPY = 2; // The device has the API to tell us it has a builtin AEC but we shouldn't trust it (so we'll use software AEC)
public static final int DEVICE_USE_ANDROID_MIC = 4;
public static final int DEVICE_HAS_BUILTIN_OPENSLES_AEC = 8; // The device has a builtin AEC and it is working with OpenSLES (which is uncommon)
private native void setDeviceFavoriteSampleRate(int samplerate);
private native void setDeviceFavoriteBufferSize(int bufferSize);
private native void addSoundDeviceDescription(String manufacturer, String model, String platform, int flags, int delay, int recommended_rate);
private static Context mContext;
private MediastreamerAndroidContext() {
}
private static MediastreamerAndroidContext instance;
private static MediastreamerAndroidContext getInstance() {
if (instance == null)
instance = new MediastreamerAndroidContext();
......@@ -52,16 +50,12 @@ public class MediastreamerAndroidContext {
public static Context getContext(){
return mContext;
}
public static void addSoundDeviceDesc(String manufacturer, String model, String platform, int flags, int delay, int recommended_rate) {
getInstance().addSoundDeviceDescription(manufacturer, model, platform, flags, delay, recommended_rate);
}
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void setContext(Object c) {
if (c == null)
return;
mContext = (Context)c;
boolean hasLowLatencyFeature = mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
......@@ -114,7 +108,7 @@ public class MediastreamerAndroidContext {
* @param name A name for the filter. refer to ms2 internals to get list of filters
* @return enable, true/false
* @deprecated
** */
* */
public static boolean filterFromNameEnabled(String name) {
return getInstance().filterFromNameEnabledImpl(name);
}
......
......@@ -64,7 +64,7 @@ static SoundDeviceDescription devices[]={
{ "motorola", "XT907", "", 0, 500 },
{ "motorola", "DROIX X2", "", 0, 320 },
{ "motorola", "MotoG3", "msm8916", DEVICE_HAS_BUILTIN_AEC_CRAPPY, 100 }, /*The MotoG3 audio capture hangs for several seconds when switching to speaker mode*/
{ "motorola", "Nexus 6", "msm8084", DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0}, /* Nexus 6*/
{ "samsung", "GT-S5360", "bcm21553", 0, 250 }, /*<Galaxy Y*/
{ "samsung", "GT-S5360L", "", 0, 250 }, /*<Galaxy Y*/
{ "samsung", "GT-S6102", "", DEVICE_HAS_BUILTIN_AEC, 0 }, /*<Galaxy Y duo*/
......@@ -91,6 +91,7 @@ static SoundDeviceDescription devices[]={
{ "samsung", "GT-I9305", "", DEVICE_HAS_BUILTIN_AEC | DEVICE_HAS_UNSTANDARD_LIBMEDIA | DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0 }, /*Galaxy S3*/
{ "samsung", "SAMSUNG-SGH-I337", "", DEVICE_HAS_BUILTIN_AEC | DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0 }, /* Galaxy S4 ? */
{ "samsung", "GT-I9195", "", DEVICE_HAS_BUILTIN_AEC | DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0 }, /* Galaxy S4 mini*/
{ "samsung", "SM-G920F", "exynos5", DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0 }, /* Galaxy S6*/
{ "samsung", "GT-N7000", "", DEVICE_HAS_BUILTIN_AEC, 0 }, /*Galaxy Note*/
{ "samsung", "GT-N7100", "exynos4", DEVICE_HAS_BUILTIN_AEC, 0 }, /*Galaxy Note 2 */
{ "samsung", "GT-N7105", "", DEVICE_HAS_BUILTIN_AEC|DEVICE_HAS_UNSTANDARD_LIBMEDIA, 0 }, /*Galaxy Note 2 t0lte*/
......@@ -303,7 +304,6 @@ SoundDeviceDescription* ms_devices_info_get_sound_device_description(MSDevicesIn
ms_message("Found information for [%s/%s/%s] from internal table", manufacturer, model, platform);
exact_match = TRUE;
}
if (declares_builtin_aec) {
if (exact_match && (d->flags & DEVICE_HAS_BUILTIN_AEC_CRAPPY)) {
ms_warning("This device declares a builtin AEC but according to internal tables it is known to be misfunctionning, so trusting tables.");
......
......@@ -207,6 +207,21 @@ extern MSWebCamDesc static_image_desc;
extern MSWebCamDesc ms_mire_webcam_desc;
#ifdef ANDROID
extern MSWebCamDesc ms_android_video_capture_desc;
JNIEXPORT void JNICALL Java_org_linphone_mediastream_Factory_setDeviceInfo(JNIEnv* env, jobject obj,
jlong factoryPtr, jstring jmanufacturer, jstring jmodel, jstring jplatform, jint flags, jint delay, jint recommended_rate) {
const char *manufacturer = (*env)->GetStringUTFChars(env, jmanufacturer, NULL);
const char *model = (*env)->GetStringUTFChars(env, jmodel, NULL);
const char *platform = (*env)->GetStringUTFChars(env, jplatform, NULL);
ms_message("Device infos: [%s,%s,%s], Flags: %d, Delay: %d, Rate: %d",manufacturer,model,platform,flags,delay,recommended_rate);
ms_devices_info_add(((MSFactory *) factoryPtr)->devices_info, manufacturer, model, platform, flags, delay, recommended_rate);
(*env)->ReleaseStringUTFChars(env, jmanufacturer, manufacturer);
(*env)->ReleaseStringUTFChars(env, jmodel, model);
(*env)->ReleaseStringUTFChars(env, jplatform, platform);
}
#endif
#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment