From 412889a2a97ec72ebc72ee17184e84fe396efcfc Mon Sep 17 00:00:00 2001 From: "leozwang@google.com" Date: Fri, 19 Aug 2011 15:34:34 +0000 Subject: [PATCH] Some cleanup in test app This CL is to keep track of work and demonstrate a way to do ndk build in case it's needed. But ndk-build doesn't work yet because of many reasons, issues will be addressed in future if it's needed. Some minor changes in source files to make them pass compiler. Review URL: http://webrtc-codereview.appspot.com/107004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@405 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../android/android_test/default.properties | 4 +- .../test/android/android_test/jni/Android.mk | 144 ++++++++++++++---- .../android/android_test/jni/Application.mk | 3 + .../android/android_test/jni/android_test.cc | 119 +++++++++------ .../org_webrtc_voiceengine_test_AndroidTest.h | 10 +- .../webrtc/voiceengine/test/AndroidTest.java | 5 +- 6 files changed, 196 insertions(+), 89 deletions(-) create mode 100644 src/voice_engine/main/test/android/android_test/jni/Application.mk diff --git a/src/voice_engine/main/test/android/android_test/default.properties b/src/voice_engine/main/test/android/android_test/default.properties index 19ddebd416..6ed608e0d4 100644 --- a/src/voice_engine/main/test/android/android_test/default.properties +++ b/src/voice_engine/main/test/android/android_test/default.properties @@ -7,5 +7,5 @@ # "build.properties", and override values to adapt the script to your # project structure. -# Project target. -target=android-3 +# Project target, OpenSL ES requires API level 9 +target=android-9 diff --git a/src/voice_engine/main/test/android/android_test/jni/Android.mk b/src/voice_engine/main/test/android/android_test/jni/Android.mk index 48707fb845..b8e4830a8f 100644 --- a/src/voice_engine/main/test/android/android_test/jni/Android.mk +++ b/src/voice_engine/main/test/android/android_test/jni/Android.mk @@ -1,29 +1,115 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -# Android makefile for webrtc VoiceEngine Java API wrapper -# This setup assumes two libs built outside Android makefile structure. - -LOCAL_PATH := $(call my-dir) - -WEBRTC_INTERFACES_PATH := $(LOCAL_PATH)/../../../../../../../../build/interface -WEBRTC_LIBS_PATH := $(LOCAL_PATH)/../../../../../../../../build/libraries -WEBRTC_AUTO_TEST_PATH := $(LOCAL_PATH)/../../../auto_test - -include $(CLEAR_VARS) - -LOCAL_MODULE := android_test -LOCAL_SRC_FILES := android_test.cc -LOCAL_CFLAGS := -DWEBRTC_TARGET_PC # For typedefs.h -LOCAL_C_INCLUDES := $(WEBRTC_INTERFACES_PATH) $(WEBRTC_AUTO_TEST_PATH) -LOCAL_LDLIBS := \ - $(WEBRTC_LIBS_PATH)/VoiceEngine_android_gcc.a \ - $(WEBRTC_AUTO_TEST_PATH)/auto_test_android_gcc.a \ - -llog -lgcc - -include $(BUILD_SHARED_LIBRARY) +# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +MY_WEBRTC_ROOT_PATH := $(call my-dir) + +MY_WEBRTC_SRC_PATH := ../../../../../../.. + +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/common_audio/resampler/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/common_audio/signal_processing_library/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/common_audio/vad/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/NetEQ/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/codecs/CNG/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/codecs/G711/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/codecs/G722/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/codecs/PCM16B/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/codecs/iLBC/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/codecs/iSAC/fix/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/codecs/iSAC/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_coding/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_conference_mixer/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_device/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_processing/aec/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_processing/aecm/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_processing/agc/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_processing/main/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_processing/ns/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/audio_processing/utility/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/media_file/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/rtp_rtcp/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/udp_transport/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/modules/utility/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/system_wrappers/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/$(MY_WEBRTC_SRC_PATH)/src/voice_engine/main/source/Android.mk + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_ARM_MODE := arm +LOCAL_MODULE := libwebrtc_audio_preprocessing +LOCAL_MODULE_TAGS := optional + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libwebrtc_spl \ + libwebrtc_resampler \ + libwebrtc_apm \ + libwebrtc_apm_utility \ + libwebrtc_vad \ + libwebrtc_ns \ + libwebrtc_agc \ + libwebrtc_aec \ + libwebrtc_aecm \ + libwebrtc_system_wrappers \ + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + libdl \ + libstlport + +LOCAL_PRELINK_MODULE := false + +ifndef NDK_ROOT +include external/stlport/libstlport.mk +endif +include $(BUILD_SHARED_LIBRARY) + +### + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_ARM_MODE := arm +LOCAL_MODULE := libwebrtc +LOCAL_MODULE_TAGS := optional + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libwebrtc_system_wrappers \ + libwebrtc_audio_device \ + libwebrtc_pcm16b \ + libwebrtc_cng \ + libwebrtc_audio_coding \ + libwebrtc_rtp_rtcp \ + libwebrtc_media_file \ + libwebrtc_udp_transport \ + libwebrtc_utility \ + libwebrtc_neteq \ + libwebrtc_audio_conference_mixer \ + libwebrtc_isac \ + libwebrtc_ilbc \ + libwebrtc_isacfix \ + libwebrtc_g722 \ + libwebrtc_g711 \ + libwebrtc_voe_core + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + libdl \ + libstlport \ + libjpeg \ + libGLESv2 \ + libOpenSLES \ + libwebrtc_audio_preprocessing + +LOCAL_PRELINK_MODULE := false + +ifndef NDK_ROOT +include external/stlport/libstlport.mk +endif +include $(BUILD_SHARED_LIBRARY) diff --git a/src/voice_engine/main/test/android/android_test/jni/Application.mk b/src/voice_engine/main/test/android/android_test/jni/Application.mk new file mode 100644 index 0000000000..09c9c16908 --- /dev/null +++ b/src/voice_engine/main/test/android/android_test/jni/Application.mk @@ -0,0 +1,3 @@ +# Build both ARMv5TE and ARMv7-A machine code. +APP_ABI := armeabi armeabi-v7a x86 +APP_STL := stlport_static diff --git a/src/voice_engine/main/test/android/android_test/jni/android_test.cc b/src/voice_engine/main/test/android/android_test/jni/android_test.cc index 2742b14982..8c5fdff50e 100644 --- a/src/voice_engine/main/test/android/android_test/jni/android_test.cc +++ b/src/voice_engine/main/test/android/android_test/jni/android_test.cc @@ -106,8 +106,47 @@ // General design: create a class or keep global struct with "C" functions? // Otherwise make sure symbols are as unique as possible. +// TestType enumerator +enum TestType +{ + Invalid = -1, + Standard = 0, + Extended = 1, + Stress = 2, + Unit = 3, + CPU = 4 +}; + +// ExtendedSelection enumerator +enum ExtendedSelection +{ + XSEL_Invalid = -1, + XSEL_None = 0, + XSEL_All, + XSEL_Base, + XSEL_CallReport, + XSEL_Codec, + XSEL_DTMF, + XSEL_Encryption, + XSEL_ExternalMedia, + XSEL_File, + XSEL_Hardware, + XSEL_NetEqStats, + XSEL_Network, + XSEL_PTT, + XSEL_RTP_RTCP, + XSEL_VideoSync, + XSEL_VideoSyncExtended, + XSEL_VolumeControl, + XSEL_VQE, + XSEL_APM, + XSEL_VQMon +}; + using namespace webrtc; +class my_transportation; + // VoiceEngine data struct typedef struct { @@ -128,7 +167,33 @@ typedef struct JavaVM* jvm; } VoiceEngineData; -// Global variables visible in this file +// my_transportation is used when useExtTrans is enabled +class my_transportation : public Transport +{ + public: + my_transportation(VoENetwork * network) : + netw(network) { + } + + int SendPacket(int channel,const void *data,int len); + int SendRTCPPacket(int channel, const void *data, int len); + private: + VoENetwork * netw; +}; + +int my_transportation::SendPacket(int channel,const void *data,int len) +{ + netw->ReceivedRTPPacket(channel, data, len); + return len; +} + +int my_transportation::SendRTCPPacket(int channel, const void *data, int len) +{ + netw->ReceivedRTCPPacket(channel, data, len); + return len; +} + +//Global variables visible in this file static VoiceEngineData veData1; static VoiceEngineData veData2; @@ -136,9 +201,6 @@ static VoiceEngineData veData2; static bool GetSubApis(VoiceEngineData &veData); static bool ReleaseSubApis(VoiceEngineData &veData); -char nikkey[64] = - "123456781234567812345678123456781234567812345678123456781234567"; - class ThreadTest { public: @@ -189,14 +251,14 @@ bool ThreadTest::Process() #ifdef INIT_FROM_THREAD VALIDATE_BASE_POINTER; - veData1.base->Init(0, 0, 0); + veData1.base->Init(); #endif #ifdef START_CALL_FROM_THREAD // receiving instance veData2.ve = VoiceEngine::Create(); GetSubApis(veData2); - veData2.base->Init(0, 0, 0); + veData2.base->Init(); veData2.base->CreateChannel(); if(veData2.base->SetLocalReceiver(0, 1234) < 0) { @@ -218,7 +280,7 @@ bool ThreadTest::Process() // sending instance veData1.ve = VoiceEngine::Create(); GetSubApis(veData1); - veData1.base->Init(0, 0, 0); + veData1.base->Init(); if(veData1.base->CreateChannel() < 0) { __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, @@ -458,13 +520,13 @@ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_RunAutoTest( VoiceEngine::SetAndroidObjects(veData1.jvm, env, context); // Call voe test interface function - //setAndroidObjects(veData1.jvm, context); - jint retVal = runAutoTest(tType, xsel); + // TODO(leozwang) add autotest setAndroidObjects(veData1.jvm, context); + // jint retVal = runAutoTest(tType, xsel); // Clear instance independent Java objects VoiceEngine::SetAndroidObjects(NULL, NULL, NULL); - return retVal; + return 0; } ////////////////////////////////////////////////////////////////// @@ -556,38 +618,12 @@ JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Delete( return true; } -///////////////////////////////////////////// -// [Base] Authenticate -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Authenticate( - JNIEnv *env, - jobject, - jstring key) -{ - const char* keyNative = env->GetStringUTFChars(key, NULL); - if (!keyNative) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not get UTF string"); - return -1; - } - - jint retVal = veData1.base->Authenticate(keyNative, strlen(keyNative)); - - env->ReleaseStringUTFChars(key, keyNative); - - return retVal; -} - ///////////////////////////////////////////// // [Base] Initialize VoiceEngine // JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Init( JNIEnv *, jobject, - jint month, - jint day, - jint year, jboolean enableTrace, jboolean useExtTrans) { @@ -600,13 +636,6 @@ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Init( __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, "Could not enable trace"); } - if (0 - != VoiceEngine::SetEncryptedTraceFile( - "/sdcard/trace_debug.txt")) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not enable debug trace"); - } if (0 != VoiceEngine::SetTraceFilter(kTraceAll)) { __android_log_write(ANDROID_LOG_WARN, WEBRTC_LOG_TAG, @@ -625,7 +654,7 @@ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Init( threadTest.RunTest(); usleep(200000); #else - retVal = veData1.base->Init(month, day, year); + retVal = veData1.base->Init(); #endif return retVal; } @@ -635,7 +664,7 @@ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Init( // JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Terminate( JNIEnv *, - jobj ect) + jobject) { VALIDATE_BASE_POINTER; diff --git a/src/voice_engine/main/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h b/src/voice_engine/main/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h index 22bb35a4c4..60fe83926b 100644 --- a/src/voice_engine/main/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h +++ b/src/voice_engine/main/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h @@ -39,21 +39,13 @@ JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Create JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Delete (JNIEnv *, jobject); -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: Authenticate - * Signature: (Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Authenticate - (JNIEnv *, jobject, jstring); - /* * Class: org_webrtc_voiceengine_test_AndroidTest * Method: Init * Signature: (IIIZZ)I */ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Init - (JNIEnv *, jobject, jint, jint, jint, jboolean, jboolean); + (JNIEnv *, jobject, jboolean, jboolean); /* * Class: org_webrtc_voiceengine_test_AndroidTest diff --git a/src/voice_engine/main/test/android/android_test/src/org/webrtc/voiceengine/test/AndroidTest.java b/src/voice_engine/main/test/android/android_test/src/org/webrtc/voiceengine/test/AndroidTest.java index ef5a8c95c6..b8e0e4c0de 100644 --- a/src/voice_engine/main/test/android/android_test/src/org/webrtc/voiceengine/test/AndroidTest.java +++ b/src/voice_engine/main/test/android/android_test/src/org/webrtc/voiceengine/test/AndroidTest.java @@ -1128,10 +1128,7 @@ public class AndroidTest extends Activity { private native boolean Delete(); - private native int Authenticate(String key); - - private native int Init(int month, int day, int year, - boolean enableTrace, boolean useExtTrans); + private native int Init(boolean enableTrace, boolean useExtTrans); private native int Terminate();