Commit 9154626c authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added missing methods on factory for Java wrapper

parent abe68907
......@@ -361,4 +361,12 @@ void *linphone_factory_get_user_data(const LinphoneFactory *factory) {
void linphone_factory_set_user_data(LinphoneFactory *factory, void *data) {
factory->user_data = data;
}
void linphone_factory_log_collection_path(LinphoneFactory *factory, const char *path) {
linphone_core_set_log_collection_path(path);
}
void linphone_factory_enable_log_collection(LinphoneFactory *factory, LinphoneLogCollectionState state) {
linphone_core_enable_log_collection(state);
}
\ No newline at end of file
......@@ -338,6 +338,20 @@ LINPHONE_PUBLIC void *linphone_factory_get_user_data(const LinphoneFactory *fact
*/
LINPHONE_PUBLIC void linphone_factory_set_user_data(LinphoneFactory *factory, void *data);
/**
* Sets the log collection path
* @param[in] factory the LinphoneFactory
* @param[in] the path of the logs
*/
LINPHONE_PUBLIC void linphone_factory_log_collection_path(LinphoneFactory *factory, const char *path);
/**
* Enables or disables log collection
* @param[in] factory the LinphoneFactory
* @param[in] the policy for log collection
*/
LINPHONE_PUBLIC void linphone_factory_enable_log_collection(LinphoneFactory *factory, LinphoneLogCollectionState state);
/**
* @}
*/
......
......@@ -94,6 +94,8 @@ public {{#isLinphoneFactory}}abstract class{{/isLinphoneFactory}}{{#isNotLinphon
}
abstract public OpenH264DownloadHelper createOpenH264DownloadHelper(Context context);
abstract public void setDebugMode(boolean enable, String tag);
{{/isLinphoneFactory}}
{{#isLinphoneCore}}
/**
......@@ -162,6 +164,9 @@ class {{classImplName}} {{#isLinphoneFactory}}extends{{/isLinphoneFactory}}{{#is
}
return new OpenH264DownloadHelper(context);
}
@Override
public native void setDebugMode(boolean enable, String tag);
{{/isLinphoneFactory}}
{{#methods}}
......
......@@ -69,6 +69,68 @@ static jlong GetObjectNativePtr(JNIEnv *env, jobject object) {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void linphone_android_log_handler(int prio, char *str) {
char *current;
char *next;
if (strlen(str) < 512) {
__android_log_write(prio, LogDomain, str);
} else {
current = str;
while ((next = strchr(current, '\n')) != NULL) {
*next = '\0';
if (next != str && next[-1] == '\r')
next[-1] = '\0';
__android_log_write(prio, LogDomain, current);
current = next + 1;
}
__android_log_write(prio, LogDomain, current);
}
}
static void linphone_android_ortp_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) {
char* str = bctbx_strdup_vprintf(fmt, args);
const char *levname = "undef";
if (str == NULL) return;
int prio;
switch(lev) {
case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; levname="debug"; break;
case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; levname="message"; break;
case ORTP_WARNING: prio = ANDROID_LOG_WARN; levname="warning"; break;
case ORTP_ERROR: prio = ANDROID_LOG_ERROR; levname="error"; break;
case ORTP_FATAL: prio = ANDROID_LOG_FATAL; levname="fatal"; break;
default: prio = ANDROID_LOG_DEFAULT; break;
}
if (handler_obj) {
JNIEnv *env = ms_get_jni_env();
jstring jdomain = env->NewStringUTF(LogDomain);
jstring jlevname = env->NewStringUTF(levname);
jstring jstr = env->NewStringUTF(str);
env->CallVoidMethod(handler_obj, loghandler_id, jdomain, (jint)lev, jlevname, jstr, NULL);
if (jdomain) env->DeleteLocalRef(jdomain);
if (jlevname) env->DeleteLocalRef(jlevname);
if (jstr) env->DeleteLocalRef(jstr);
} else {
linphone_android_log_handler(prio, str);
}
bctbx_free(str);
}
void Java_org_linphone_core_FactoryImpl_setDebugMode(JNIEnv* env, jobject thiz, jboolean isDebug, jstring jdebugTag) {
if (isDebug) {
LogDomain = GetStringUTFChars(env, jdebugTag);
linphone_core_enable_logs_with_cb(linphone_android_ortp_log_handler);
} else {
linphone_core_disable_logs();
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class LinphoneJavaBindings {
public:
LinphoneJavaBindings(JNIEnv *env) {
......
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