Commit bcd3042a authored by Simon Morlat's avatar Simon Morlat

add new Factory object in java, so that filter enablement can be controlled...

add new Factory object in java, so that filter enablement can be controlled with the new way of doing it.
parent bc6574e8
/*
AndroidContext.java
Copyright (C) 2014 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.mediastream;
public class Factory{
private long mNativePtr;
private Factory(long nativePtr){
mNativePtr = nativePtr;
}
private native void enableFilterFromName(long nativePtr, String name, boolean enabled);
public void enableFilterFromName(String name, boolean enabled){
enableFilterFromName(mNativePtr, name, enabled);
}
private native boolean filterFromNameEnabled(long nativePtr, String name);
public boolean filterFromNameEnabled(String name){
return filterFromNameEnabled(mNativePtr, name);
}
};
......@@ -91,6 +91,7 @@ public class MediastreamerAndroidContext {
* @param name A name for the filter. refer to ms2 internals to get list of filters
* @param enable, true/false
* @throw MediastreamException if filter name is unknown
* @deprecated
* */
public static void enableFilterFromName(String name,boolean enable) throws MediastreamException {
if (getInstance().enableFilterFromNameImpl(name,enable) != 0)
......@@ -100,6 +101,7 @@ public class MediastreamerAndroidContext {
* Specifies if a filter is enabled or not.
* @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);
......
......@@ -569,7 +569,7 @@ static MSFilterDesc msandroid_sound_read_desc={
MSFilter *msandroid_sound_read_new(MSSndCard *card){
ms_debug("msandroid_sound_read_new");
MSFilter *f=ms_factory_new_from_desc(ms_snd_card_get_factory(card), &msandroid_sound_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_get_factory(card), &msandroid_sound_read_desc);
msandroid_sound_read_data *data=new msandroid_sound_read_data();
data->builtin_aec = card->capabilities & MS_SND_CARD_CAP_BUILTIN_ECHO_CANCELLER;
if (card->data != NULL) {
......@@ -895,7 +895,7 @@ static MSFilterDesc msandroid_sound_write_desc={
MSFilter *msandroid_sound_write_new(MSSndCard *card){
ms_debug("msandroid_sound_write_new");
MSFilter *f=ms_filter_new_from_desc(ms_snd_card_get_factory(card), &msandroid_sound_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_get_factory(card), &msandroid_sound_write_desc);
msandroid_sound_write_data *data = new msandroid_sound_write_data();
if (card->data != NULL) {
SoundDeviceDescription *d = (SoundDeviceDescription *)card->data;
......
......@@ -869,18 +869,51 @@ MSOfferAnswerContext * ms_factory_create_offer_answer_context(MSFactory *f, cons
#include "sys/system_properties.h"
#include <jni.h>
JNIEXPORT jint JNICALL Java_org_linphone_mediastream_Factory_enableFilterFromName(JNIEnv* env, jobject obj, long factoryPtr, jstring jname, jboolean enable) {
MSFactory *factory = (MSFactory *) factoryPtr;
const char *mime = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : NULL;
int result = ms_factory_enable_filter_from_name(factory, mime, enable);
(*env)->ReleaseStringUTFChars(env, jname, mime);
return result;
}
JNIEXPORT jboolean JNICALL Java_org_linphone_mediastream_Factory_filterFromNameEnabled(JNIEnv* env, jobject obj, long factoryPtr, jstring jname) {
const char *mime = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : NULL;
MSFactory *factory = (MSFactory *) factoryPtr;
jboolean result = ms_factory_filter_from_name_enabled(factory, mime);
(*env)->ReleaseStringUTFChars(env, jname, mime);
return result;
}
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#else
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
JNIEXPORT jint JNICALL Java_org_linphone_mediastream_MediastreamerAndroidContext_enableFilterFromNameImpl(JNIEnv* env, jobject obj, jstring jname, jboolean enable) {
if (ms_factory_get_fallback() == NULL) {
ms_error("Java_org_linphone_mediastream_MediastreamerAndroidContext_enableFilterFromNameImpl(): no fallback factory. Use Factory.enableFilterFromName()");
return -1;
}
const char *mime = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : NULL;
int result = ms_factory_enable_filter_from_name(ms_factory_get_fallback(),mime,enable);
(*env)->ReleaseStringUTFChars(env, jname, mime);
return result;
}
JNIEXPORT jboolean JNICALL Java_org_linphone_mediastream_MediastreamerAndroidContext_filterFromNameEnabledImpl(JNIEnv* env, jobject obj, jstring jname) {
if (ms_factory_get_fallback() == NULL) {
ms_error("Java_org_linphone_mediastream_MediastreamerAndroidContext_filterFromNameEnabledImpl(): no fallback factory. Use Factory.filterFromNameEnabled()");
return FALSE;
}
const char *mime = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : NULL;
jboolean result = ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),mime);
(*env)->ReleaseStringUTFChars(env, jname, mime);
return result;
}
#endif
......
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