Commit b2ae9095 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

Change adaptive_rate_algorithm API to not use enum

parent 75eee41a
......@@ -1965,7 +1965,7 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna
if (captcard && stream->max_rate>0) ms_snd_card_set_preferred_sample_rate(captcard, stream->max_rate);
audio_stream_enable_adaptive_bitrate_control(call->audiostream,use_arc);
media_stream_set_adaptive_bitrate_algorithm(&call->audiostream->ms,
linphone_core_get_adaptive_rate_algorithm(lc));
ms_qos_analyzer_algorithm_from_string(linphone_core_get_adaptive_rate_algorithm(lc)));
audio_stream_enable_adaptive_jittcomp(call->audiostream, linphone_core_audio_adaptive_jittcomp_enabled(lc));
if (!call->params->in_conference && call->params->record_file){
audio_stream_mixed_record_open(call->audiostream,call->params->record_file);
......@@ -2057,7 +2057,7 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna
video_stream_enable_adaptive_bitrate_control(call->videostream,
linphone_core_adaptive_rate_control_enabled(lc));
media_stream_set_adaptive_bitrate_algorithm(&call->videostream->ms,
linphone_core_get_adaptive_rate_algorithm(lc));
ms_qos_analyzer_algorithm_from_string(linphone_core_get_adaptive_rate_algorithm(lc)));
video_stream_enable_adaptive_jittcomp(call->videostream, linphone_core_video_adaptive_jittcomp_enabled(lc));
if (lc->video_conf.preview_vsize.width!=0)
video_stream_set_preview_size(call->videostream,lc->video_conf.preview_vsize);
......
......@@ -793,8 +793,8 @@ bool_t linphone_core_adaptive_rate_control_enabled(const LinphoneCore *lc){
* @ingroup media_parameters
*
**/
void linphone_core_set_adaptive_rate_algorithm(LinphoneCore *lc, MSQosAnalyzerAlgorithm algorithm){
lp_config_set_string(lc->config,"net","adaptive_rate_algorithm",ms_qos_analyzer_algorithm_to_string(algorithm));
void linphone_core_set_adaptive_rate_algorithm(LinphoneCore *lc, const char* algorithm){
lp_config_set_string(lc->config,"net","adaptive_rate_algorithm",algorithm);
}
/**
......@@ -804,16 +804,8 @@ void linphone_core_set_adaptive_rate_algorithm(LinphoneCore *lc, MSQosAnalyzerAl
*
* See linphone_core_set_adaptive_rate_algorithm().
**/
MSQosAnalyzerAlgorithm linphone_core_get_adaptive_rate_algorithm(const LinphoneCore *lc){
const char* alg = lp_config_get_string(lc->config, "net", "adaptive_rate_algorithm", NULL);
if (alg == NULL || strcmp(alg, "Simple")==0)
return MSQosAnalyzerAlgorithmSimple;
else if (strcmp(alg, "Stateful")==0)
return MSQosAnalyzerAlgorithmStateful;
ms_error("Invalid value for key net/adaptive_rate_control: %s", alg);
return MSQosAnalyzerAlgorithmSimple;
const char * linphone_core_get_adaptive_rate_algorithm(const LinphoneCore *lc){
return lp_config_get_string(lc->config, "net", "adaptive_rate_algorithm", NULL);
}
bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc){
......
......@@ -1878,8 +1878,8 @@ LINPHONE_PUBLIC int linphone_core_get_upload_bandwidth(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_enable_adaptive_rate_control(LinphoneCore *lc, bool_t enabled);
LINPHONE_PUBLIC bool_t linphone_core_adaptive_rate_control_enabled(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_set_adaptive_rate_algorithm(LinphoneCore *lc, MSQosAnalyzerAlgorithm algorithm);
LINPHONE_PUBLIC MSQosAnalyzerAlgorithm linphone_core_get_adaptive_rate_algorithm(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_set_adaptive_rate_algorithm(LinphoneCore *lc, const char *algorithm);
LINPHONE_PUBLIC const char* linphone_core_get_adaptive_rate_algorithm(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_set_download_ptime(LinphoneCore *lc, int ptime);
LINPHONE_PUBLIC int linphone_core_get_download_ptime(LinphoneCore *lc);
......
......@@ -1333,18 +1333,26 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isAdaptiveRateContro
) {
return (jboolean)linphone_core_adaptive_rate_control_enabled((LinphoneCore*)lc);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getAdaptiveRateAlgorithm(JNIEnv* env
extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getAdaptiveRateAlgorithm(JNIEnv* env
,jobject thiz
,jlong lc
) {
return (jint)linphone_core_get_adaptive_rate_algorithm((LinphoneCore*)lc);
const char* alg = linphone_core_get_adaptive_rate_algorithm((LinphoneCore*)lc);
if (alg) {
return env->NewStringUTF(alg);
} else {
return NULL;
}
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAdaptiveRateAlgorithm(JNIEnv* env
,jobject thiz
,jlong lc
,jint alg) {
linphone_core_set_adaptive_rate_algorithm((LinphoneCore*)lc,(MSQosAnalyzerAlgorithm)alg);
,jstring jalg) {
const char* alg = jalg?env->GetStringUTFChars(jalg, NULL):NULL;
linphone_core_set_adaptive_rate_algorithm((LinphoneCore*)lc,alg);
if (alg) env->ReleaseStringUTFChars(jalg, alg);
}
......
......@@ -310,11 +310,11 @@ public interface LinphoneCore {
values.addElement(this);
mStringValue=stringValue;
}
public static AdaptiveRateAlgorithm fromInt(int value) {
public static AdaptiveRateAlgorithm fromString(String value) {
for (int i=0; i<values.size();i++) {
AdaptiveRateAlgorithm alg = (AdaptiveRateAlgorithm) values.elementAt(i);
if (alg.mValue == value) return alg;
if (alg.mStringValue.equals(value)) return alg;
}
throw new RuntimeException("AdaptiveRateAlgorithm not found ["+value+"]");
}
......
......@@ -77,8 +77,8 @@ class LinphoneCoreImpl implements LinphoneCore {
private native boolean payloadTypeIsVbr(long nativePtr, long payloadType);
private native void enableAdaptiveRateControl(long nativePtr,boolean enable);
private native boolean isAdaptiveRateControlEnabled(long nativePtr);
private native int getAdaptiveRateAlgorithm(long nativePtr);
private native void setAdaptiveRateAlgorithm(long nativePtr, int alg);
private native String getAdaptiveRateAlgorithm(long nativePtr);
private native void setAdaptiveRateAlgorithm(long nativePtr, String alg);
private native void enableEchoCancellation(long nativePtr,boolean enable);
private native boolean isEchoCancellationEnabled(long nativePtr);
private native Object getCurrentCall(long nativePtr) ;
......@@ -1224,10 +1224,10 @@ class LinphoneCoreImpl implements LinphoneCore {
return isAdaptiveRateControlEnabled(nativePtr);
}
public synchronized AdaptiveRateAlgorithm getAdaptiveRateAlgorithm() {
return AdaptiveRateAlgorithm.fromInt(getAdaptiveRateAlgorithm(nativePtr));
return AdaptiveRateAlgorithm.fromString(getAdaptiveRateAlgorithm(nativePtr));
}
public synchronized void setAdaptiveRateAlgorithm(AdaptiveRateAlgorithm alg) {
setAdaptiveRateAlgorithm(nativePtr, alg.mValue);
setAdaptiveRateAlgorithm(nativePtr, alg.toString());
}
......
mediastreamer2 @ a87216d8
Subproject commit a762948dd3e9668d071658557418db571f71c0aa
Subproject commit a87216d8e30ec6723774b1236c1eba6525568925
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