Commit 2f449777 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added new table with audio hacks for some Android devices + fix android build

parent 12c21083
......@@ -201,6 +201,12 @@ endif #BUILD_MATROSKA
endif #_BUILD_VIDEO
ifeq ($(BUILD_NON_FREE_CODECS),1)
LOCAL_CFLAGS += -DHAVE_NON_FREE_CODECS=1
else
LOCAL_CFLAGS += -DHAVE_NON_FREE_CODECS=0
endif
ifeq ($(BUILD_OPUS),1)
LOCAL_CFLAGS += -DHAVE_OPUS
LOCAL_SRC_FILES += \
......
......@@ -505,6 +505,11 @@ static MS2_INLINE void audio_stream_enable_adaptive_jittcomp(AudioStream *stream
media_stream_enable_adaptive_jittcomp(&stream->ms, enabled);
}
MS2_PUBLIC void audio_stream_set_mic_gain_db(AudioStream *stream, float gain_db);
/**
* deprecated
* */
MS2_PUBLIC void audio_stream_set_mic_gain(AudioStream *stream, float gain);
/**
......
......@@ -30,13 +30,18 @@
#ifdef ANDROID
/*
* 1st column: list of triplet frequency, gain, width
* 2nd column: mic gain in db
*/
static SoundDeviceAudioHacks SonySGP511Hacks = { "50:0.01:100 600:0.2:100 1350:0.2:100 2000:0.2:100", -4 };
/*
* 1st column: value of ro.product.manufacturer
* 2nd column: value of ro.product.model
* 3rd column: value of ro.board.platform (and is optional)
* All these values can be obtained from the device using "adb shell getprop"
*/
static SoundDeviceDescription devices[]={
{ "HTC", "Nexus One", "qsd8k", 0, 300 },
{ "HTC", "HTC One X", "tegra", 0, 150 }, /*has a very good acoustic isolation, which result in calibration saying no echo. */
......@@ -93,7 +98,7 @@ static SoundDeviceDescription devices[]={
{ "samsung", "GT-P7510", "", DEVICE_HAS_BUILTIN_AEC, 0 }, /* Galaxy Tab*/
{ "samsung", "GT-I915", "", DEVICE_HAS_BUILTIN_AEC, 0 }, /* Verizon Tab*/
{ "samsung", "GT-I8190N", "montblanc", DEVICE_HAS_BUILTIN_AEC | DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0, 16000 }, /* Galaxy S3 Mini*/
{ "samsung", "GT-I8190", "montblanc", DEVICE_HAS_BUILTIN_AEC | DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0, 16000 }, /*Galaxy S3 mini*/
{ "samsung", "GT-I8190", "montblanc", DEVICE_HAS_BUILTIN_AEC | DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0, 16000 }, /*Galaxy S3 mini*/
{ "Sony Ericsson","ST15a", "", 0, 150 },
......@@ -111,6 +116,9 @@ static SoundDeviceDescription devices[]={
{ "Sony Ericsson","MT11i", "", 0, 150 },
{ "Sony Ericsson","MT15i", "", 0, 150 },
{ "Sony Ericsson","ST15i", "msm7x30", 0, 150 },
{ "Sony", "SGP511", "msm8974", DEVICE_HAS_BUILTIN_AEC_CRAPPY, 130, 0, &SonySGP511Hacks},
{ "Sony", "D6503", "msm8974", DEVICE_HAS_BUILTIN_AEC_CRAPPY, 280},
{ "Sony", "D6603", "msm8974", DEVICE_HAS_BUILTIN_AEC_CRAPPY, 280},
{ "asus", "Nexus 7", "", 0, 170},
{ "asus", "K00E", "clovertrail", 0, 200},
......@@ -120,13 +128,10 @@ static SoundDeviceDescription devices[]={
{ "Enspert", "IGGY", "" , 0, 320 ,0}, /*Wiko iggy*/
{ "Yota Devices Limited", "YD201", "msm8974", DEVICE_HAS_BUILTIN_AEC | DEVICE_HAS_BUILTIN_OPENSLES_AEC, 0, 48000 }, /* Yotaphone 2 */
{ "Sony", "D6503", "msm8974",DEVICE_HAS_BUILTIN_AEC_CRAPPY,280},
{ "Sony", "D6603", "msm8974",DEVICE_HAS_BUILTIN_AEC_CRAPPY,280},
{ NULL, NULL, NULL, 0, 0,0}
};
static SoundDeviceDescription undefined={"Generic", "Generic", "Generic", 0, 250, 0};
static SoundDeviceDescription undefined={"Generic", "Generic", "Generic", 0, 250, 0, 0};
JNIEXPORT void JNICALL Java_org_linphone_mediastream_MediastreamerAndroidContext_addSoundDeviceDescription(JNIEnv* env, jobject thiz, jstring jmanufacturer, jstring jmodel, jstring jplatform, jint flags, jint delay, jint rate) {
const char *manufacturer = jmanufacturer ? (*env)->GetStringUTFChars(env, jmanufacturer, NULL) : NULL;
......
......@@ -29,6 +29,13 @@
#define DEVICE_USE_ANDROID_MIC (1<<2) /*set when the device needs to capture using MIC instead of Voice communication (I.E kindle fire) */
#define DEVICE_HAS_BUILTIN_OPENSLES_AEC (1<<3) /*set when the device automatically enables it's AEC when using OpenSLES */
struct SoundDeviceAudioHacks {
const char *equalizer;
float mic_gain;
};
typedef struct SoundDeviceAudioHacks SoundDeviceAudioHacks;
struct SoundDeviceDescription{
const char *manufacturer;
const char *model;
......@@ -36,6 +43,7 @@ struct SoundDeviceDescription{
unsigned int flags;
int delay;
int recommended_rate;
SoundDeviceAudioHacks *hacks;
};
typedef struct SoundDeviceDescription SoundDeviceDescription;
......
......@@ -38,7 +38,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/msgenericplc.h"
#include "private.h"
#ifdef ANDROID
#include "audiofilters/devices.h"
#endif
#include <sys/types.h>
......@@ -872,13 +874,11 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
ms_filter_call_method(stream->soundwrite,MS_FILTER_SET_NCHANNELS,&nchannels);
if (stream->ec){
if (!stream->is_ec_delay_set){
if (!stream->is_ec_delay_set) {
int delay_ms=ms_snd_card_get_minimal_latency(captcard);
if (delay_ms!=0){
ms_message("Setting echo canceller delay with value provided by soundcard: %i ms",delay_ms);
}
ms_message("Setting echo canceller delay with value provided by soundcard: %i ms",delay_ms);
ms_filter_call_method(stream->ec,MS_ECHO_CANCELLER_SET_DELAY,&delay_ms);
}else {
} else {
ms_message("Setting echo canceller delay with value configured by application.");
}
ms_filter_call_method(stream->ec,MS_FILTER_SET_SAMPLE_RATE,&sample_rate);
......@@ -926,6 +926,30 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
}
}else
stream->equalizer=NULL;
#ifdef ANDROID
/*configure equalizer if needed*/
audio_stream_set_mic_gain_db(stream, 0);
if (stream->equalizer) {
SoundDeviceDescription *device = sound_device_description_get();
if (device && device->hacks) {
const char *gains = device->hacks->equalizer;
if (gains) {
stream->eq_loc = MSEqualizerMic;
ms_message("Found equalizer configuration in the devices table");
do {
int bytes;
MSEqualizerGain g;
if (sscanf(gains, "%f:%f:%f %n", &g.frequency, &g.gain, &g.width, &bytes) == 3) {
ms_message("Read equalizer gains: %f(~%f) --> %f", g.frequency, g.width, g.gain);
ms_filter_call_method(stream->equalizer, MS_EQUALIZER_SET_GAIN, &g);
gains += bytes;
} else break;
} while(1);
}
}
}
#endif
/*configure resamplers if needed*/
if (stream->read_resampler){
......@@ -1323,6 +1347,22 @@ void audio_stream_enable_noise_gate(AudioStream *stream, bool_t val){
}
}
void audio_stream_set_mic_gain_db(AudioStream *stream, float gain_db) {
float gain = gain_db;
#ifdef ANDROID
SoundDeviceDescription *device = sound_device_description_get();
if (device && device->hacks) {
gain += device->hacks->mic_gain;
ms_message("Applying %f db to mic gain based on parameter and audio hack value in device table", gain);
}
#endif
if (stream->volsend){
ms_filter_call_method(stream->volsend, MS_VOLUME_SET_DB_GAIN, &gain);
} else ms_warning("Could not apply gain: gain control wasn't activated. "
"Use audio_stream_enable_gain_control() before starting the stream.");
}
void audio_stream_set_mic_gain(AudioStream *stream, float gain){
if (stream->volsend){
ms_filter_call_method(stream->volsend,MS_VOLUME_SET_GAIN,&gain);
......
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