forked from mirrors/linphone-iphone
add ec calibrator to Android
This commit is contained in:
parent
803b795c4e
commit
4166afa48f
12 changed files with 136 additions and 12 deletions
|
|
@ -46,7 +46,8 @@ LOCAL_SRC_FILES = \
|
|||
sal_eXosip2_sdp.c \
|
||||
offeranswer.c \
|
||||
callbacks.c \
|
||||
linphonecall.c
|
||||
linphonecall.c \
|
||||
ec-calibrator.c
|
||||
|
||||
LOCAL_CFLAGS += \
|
||||
-D_BYTE_ORDER=_LITTLE_ENDIAN \
|
||||
|
|
|
|||
|
|
@ -39,10 +39,15 @@ static void ecc_init_filters(EcCalibrator *ecc){
|
|||
|
||||
ecc->play=ms_filter_new(MS_FILE_PLAYER_ID);
|
||||
ecc->gen=ms_filter_new(MS_DTMF_GEN_ID);
|
||||
ecc->resampler=ms_filter_new(MS_RESAMPLE_ID);
|
||||
ecc->sndwrite=ms_snd_card_create_writer(ecc->capt_card);
|
||||
|
||||
ms_filter_link(ecc->play,0,ecc->gen,0);
|
||||
ms_filter_link(ecc->gen,0,ecc->sndwrite,0);
|
||||
ms_filter_link(ecc->gen,0,ecc->resampler,0);
|
||||
ms_filter_link(ecc->resampler,0,ecc->sndwrite,0);
|
||||
unsigned int rate;
|
||||
ms_filter_call_method(ecc->sndwrite,MS_FILTER_GET_SAMPLE_RATE,&rate);
|
||||
ms_filter_call_method(ecc->resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&rate);
|
||||
|
||||
ms_ticker_attach(ecc->ticker,ecc->play);
|
||||
ms_ticker_attach(ecc->ticker,ecc->sndread);
|
||||
|
|
@ -53,7 +58,8 @@ static void ecc_deinit_filters(EcCalibrator *ecc){
|
|||
ms_ticker_detach(ecc->ticker,ecc->sndread);
|
||||
|
||||
ms_filter_unlink(ecc->play,0,ecc->gen,0);
|
||||
ms_filter_unlink(ecc->gen,0,ecc->sndwrite,0);
|
||||
ms_filter_unlink(ecc->gen,0,ecc->resampler,0);
|
||||
ms_filter_unlink(ecc->resampler,0,ecc->sndwrite,0);
|
||||
|
||||
ms_filter_unlink(ecc->sndread,0,ecc->det,0);
|
||||
ms_filter_unlink(ecc->det,0,ecc->rec,0);
|
||||
|
|
@ -63,6 +69,7 @@ static void ecc_deinit_filters(EcCalibrator *ecc){
|
|||
ms_filter_destroy(ecc->rec);
|
||||
ms_filter_destroy(ecc->play);
|
||||
ms_filter_destroy(ecc->gen);
|
||||
ms_filter_destroy(ecc->resampler);
|
||||
ms_filter_destroy(ecc->sndwrite);
|
||||
|
||||
ms_ticker_destroy(ecc->ticker);
|
||||
|
|
@ -138,6 +145,7 @@ static void * ecc_thread(void *p){
|
|||
ecc_init_filters(ecc);
|
||||
ecc_play_tones(ecc);
|
||||
ecc_deinit_filters(ecc);
|
||||
ms_thread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.linphone.core.LinphoneAddress;
|
|||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListener;
|
||||
|
|
@ -95,7 +96,7 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
|
|||
public void globalState(LinphoneCore lc, GlobalState state, String message) {}
|
||||
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from, String message) {}
|
||||
public void callState(LinphoneCore lc, LinphoneCall call, State cstate, String msg) {}
|
||||
|
||||
public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {}
|
||||
|
||||
|
||||
|
||||
|
|
@ -229,4 +230,6 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
|
|||
TutorialNotifier.notify(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.linphone.core.LinphoneAddress;
|
|||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListener;
|
||||
|
|
@ -73,7 +74,7 @@ public class TutorialChatRoom implements LinphoneCoreListener {
|
|||
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf,String url) {}
|
||||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {}
|
||||
public void callState(LinphoneCore lc, LinphoneCall call, State cstate, String msg){}
|
||||
|
||||
public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {}
|
||||
|
||||
|
||||
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from, String message) {
|
||||
|
|
@ -144,4 +145,5 @@ public class TutorialChatRoom implements LinphoneCoreListener {
|
|||
TutorialNotifier.notify(s);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.linphone.core.LinphoneAddress;
|
|||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListener;
|
||||
|
|
@ -67,7 +68,7 @@ public class TutorialHelloWorld implements LinphoneCoreListener {
|
|||
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf,String url) {}
|
||||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {}
|
||||
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from, String message) {}
|
||||
|
||||
public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {}
|
||||
/*
|
||||
* Call state notification listener
|
||||
*/
|
||||
|
|
@ -153,4 +154,5 @@ public class TutorialHelloWorld implements LinphoneCoreListener {
|
|||
TutorialNotifier.notify(s);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.linphone.core.LinphoneAddress;
|
|||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListener;
|
||||
|
|
@ -78,7 +79,7 @@ public class TutorialRegistration implements LinphoneCoreListener {
|
|||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {}
|
||||
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from, String message) {}
|
||||
public void callState(LinphoneCore lc, LinphoneCall call, State cstate, String msg) {}
|
||||
|
||||
public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Check tutorial was called with the right number of arguments
|
||||
|
|
@ -184,4 +185,6 @@ public class TutorialRegistration implements LinphoneCoreListener {
|
|||
TutorialNotifier.notify(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include "linphonecore.h"
|
||||
#include "linphonecore_utils.h"
|
||||
|
||||
#include "mediastreamer2/msjava.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
|
|
@ -100,7 +101,10 @@ public:
|
|||
callStateId = env->GetMethodID(listernerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
|
||||
callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
|
||||
callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
|
||||
|
||||
/*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
|
||||
ecCalibrationStatusId = env->GetMethodID(listernerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
|
||||
ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
|
||||
ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
|
||||
/*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
|
||||
newSubscriptionRequestId = env->GetMethodID(listernerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
|
||||
|
||||
|
|
@ -165,6 +169,10 @@ public:
|
|||
jmethodID callStateId;
|
||||
jmethodID callStateFromIntId;
|
||||
|
||||
jclass ecCalibratorStatusClass;
|
||||
jmethodID ecCalibrationStatusId;
|
||||
jmethodID ecCalibratorStatusFromIntId;
|
||||
|
||||
jclass proxyClass;
|
||||
jmethodID proxyCtrId;
|
||||
|
||||
|
|
@ -290,6 +298,26 @@ public:
|
|||
,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
|
||||
,message ? env->NewStringUTF(message) : NULL);
|
||||
}
|
||||
static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
|
||||
JNIEnv *env = 0;
|
||||
jint result = jvm->AttachCurrentThread(&env,NULL);
|
||||
if (result != 0) {
|
||||
ms_error("cannot attach VM\n");
|
||||
return;
|
||||
}
|
||||
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
|
||||
env->CallVoidMethod(lcData->listener
|
||||
,lcData->ecCalibrationStatusId
|
||||
,lcData->core
|
||||
,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
|
||||
,delay_ms
|
||||
,data ? data : NULL);
|
||||
if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
|
||||
//final state, releasing global ref
|
||||
env->DeleteGlobalRef((jobject)data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -627,6 +655,18 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(J
|
|||
return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
|
||||
|
||||
}
|
||||
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong lc
|
||||
,jobject data) {
|
||||
return linphone_core_start_echo_calibration((LinphoneCore*)lc
|
||||
, LinphoneCoreData::ecCalibrationStatus
|
||||
, data?env->NewGlobalRef(data):NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//ProxyConfig
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#else
|
||||
#include "linphone/linphonecore.h"
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _LsdPlayer LsdPlayer;
|
||||
typedef struct _LinphoneSoundDaemon LinphoneSoundDaemon;
|
||||
|
|
@ -65,5 +68,7 @@ typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibr
|
|||
* Start an echo calibration of the sound devices, in order to find adequate settings for the echo canceller automatically.
|
||||
**/
|
||||
int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb, void *cb_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ struct _EcCalibrator{
|
|||
ms_thread_t thread;
|
||||
MSSndCard *play_card,*capt_card;
|
||||
MSFilter *sndread,*det,*rec;
|
||||
MSFilter *play, *gen, *sndwrite;
|
||||
MSFilter *play, *gen, *sndwrite,*resampler;
|
||||
MSTicker *ticker;
|
||||
LinphoneEcCalibrationCallback cb;
|
||||
void *cb_data;
|
||||
|
|
|
|||
|
|
@ -179,6 +179,50 @@ public interface LinphoneCore {
|
|||
return mStringValue;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* EC Calibrator Status
|
||||
.
|
||||
*
|
||||
*/
|
||||
static public class EcCalibratorStatus {
|
||||
|
||||
static private Vector values = new Vector();
|
||||
/**
|
||||
* Calibration in progress
|
||||
*/
|
||||
static public EcCalibratorStatus InProgress = new EcCalibratorStatus(0,"InProgress");
|
||||
/**
|
||||
* Calibration done
|
||||
*/
|
||||
static public EcCalibratorStatus Done = new EcCalibratorStatus(1,"Done");
|
||||
/**
|
||||
* Calibration in progress
|
||||
*/
|
||||
static public EcCalibratorStatus Failed = new EcCalibratorStatus(2,"Failed");
|
||||
|
||||
private final int mValue;
|
||||
private final String mStringValue;
|
||||
|
||||
private EcCalibratorStatus(int value,String stringValue) {
|
||||
mValue = value;
|
||||
values.addElement(this);
|
||||
mStringValue=stringValue;
|
||||
}
|
||||
public static EcCalibratorStatus fromInt(int value) {
|
||||
|
||||
for (int i=0; i<values.size();i++) {
|
||||
EcCalibratorStatus status = (EcCalibratorStatus) values.elementAt(i);
|
||||
if (status.mValue == value) return status;
|
||||
}
|
||||
throw new RuntimeException("status not found ["+value+"]");
|
||||
}
|
||||
public String toString() {
|
||||
return mStringValue;
|
||||
}
|
||||
public int value(){
|
||||
return mValue;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* clear all added proxy configs
|
||||
*/
|
||||
|
|
@ -497,4 +541,11 @@ public interface LinphoneCore {
|
|||
* @return true if enable
|
||||
*/
|
||||
boolean isKeepAliveEnabled();
|
||||
/**
|
||||
* Start an echo calibration of the sound devices, in order to find adequate settings for the echo canceler automatically.
|
||||
* status is notified to {@link LinphoneCoreListener#ecCalibrationStatus(EcCalibratorStatus, int, Object)}
|
||||
* @param User object
|
||||
* @throws LinphoneCoreException if operation is still in progress;
|
||||
**/
|
||||
void startEchoCalibration(Object data) throws LinphoneCoreException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,5 +78,14 @@ public interface LinphoneCoreListener {
|
|||
* @param message incoming message
|
||||
*/
|
||||
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);
|
||||
/**
|
||||
* Invoked when echo cancalation calibration is completed
|
||||
* @param lc LinphoneCore
|
||||
* @param status
|
||||
* @param delay_ms echo delay
|
||||
* @param data
|
||||
*/
|
||||
void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 434b627405d46c50cb109c001e44891551d0efab
|
||||
Subproject commit a4f5a5bcf16ec4deec210bbd021952495a14d055
|
||||
Loading…
Add table
Reference in a new issue