diff --git a/webrtc/api/portallocatorfactory.cc b/webrtc/api/portallocatorfactory.cc deleted file mode 100644 index 33186003af..0000000000 --- a/webrtc/api/portallocatorfactory.cc +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 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. - */ -// TODO(deadbeef): Remove this file once chromium build files no longer -// reference it. - -#include "webrtc/api/portallocatorfactory.h" diff --git a/webrtc/api/portallocatorfactory.h b/webrtc/api/portallocatorfactory.h deleted file mode 100644 index cefd750c0b..0000000000 --- a/webrtc/api/portallocatorfactory.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 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. - */ -// TODO(deadbeef): Remove this file once chromium build files no longer -// reference it. - -#ifndef WEBRTC_API_PORTALLOCATORFACTORY_H_ -#define WEBRTC_API_PORTALLOCATORFACTORY_H_ - -#endif // WEBRTC_API_PORTALLOCATORFACTORY_H_ diff --git a/webrtc/api/remoteaudiotrack.cc b/webrtc/api/remoteaudiotrack.cc deleted file mode 100644 index 47de1b4dc8..0000000000 --- a/webrtc/api/remoteaudiotrack.cc +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2015 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. - */ - -// TODO(tommi): Delete this file when removed from build files in Chromium. diff --git a/webrtc/api/remoteaudiotrack.h b/webrtc/api/remoteaudiotrack.h deleted file mode 100644 index 47de1b4dc8..0000000000 --- a/webrtc/api/remoteaudiotrack.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2015 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. - */ - -// TODO(tommi): Delete this file when removed from build files in Chromium. diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/debugUtility.h b/webrtc/modules/audio_coding/codecs/isac/main/test/debugUtility.h deleted file mode 100644 index d708ad1fea..0000000000 --- a/webrtc/modules/audio_coding/codecs/isac/main/test/debugUtility.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_TEST_DEBUGUTILITY_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_TEST_DEBUGUTILITY_H_ - -#include -#include -#include "utility.h" - -typedef struct -{ - FILE* res0to4FilePtr; - FILE* res4to8FilePtr; - FILE* res8to12FilePtr; - FILE* res8to16FilePtr; - - FILE* res0to4DecFilePtr; - FILE* res4to8DecFilePtr; - FILE* res8to12DecFilePtr; - FILE* res8to16DecFilePtr; - - FILE* in0to4FilePtr; - FILE* in4to8FilePtr; - FILE* in8to12FilePtr; - FILE* in8to16FilePtr; - - FILE* out0to4FilePtr; - FILE* out4to8FilePtr; - FILE* out8to12FilePtr; - FILE* out8to16FilePtr; - - FILE* fftFilePtr; - FILE* fftDecFilePtr; - - FILE* arrivalTime; - - float lastArrivalTime; - - int prevPacketLost; - int currPacketLost; - int nextPacketLost; - - //double residualSignal4kHZ[240]; - int packetLossPercent; - - int maxPayloadLB; - int maxPayloadUB; - int lbBytes; - int ubBytes; - - -}debugStruct; - - -#define PRINT_ENTROPY_INFO(obj) \ - do \ - { \ - printf("%10u, %u; ", \ - obj->bitstr_obj.streamval, obj->bitstr_obj.stream_index); \ - } while(0) - -int setupDebugStruct(debugStruct* str); - -#endif \ No newline at end of file diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c b/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c index 1a1697fdae..5d7a92a942 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c +++ b/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c @@ -29,7 +29,6 @@ #include "isac.h" #include "utility.h" #include "webrtc/base/format_macros.h" -//#include "commonDefs.h" /* max number of samples per frame (= 60 ms frame) */ #define MAX_FRAMESAMPLES_SWB 1920 @@ -41,13 +40,6 @@ #define FS_SWB 32000 #define FS_WB 16000 -//#define CHANGE_OUTPUT_NAME - -#ifdef HAVE_DEBUG_INFO -#include "debugUtility.h" -debugStruct debugInfo; -#endif - unsigned long framecnt = 0; int main(int argc, char* argv[]) { @@ -69,7 +61,6 @@ int main(int argc, char* argv[]) { int16_t codingMode = 1; int16_t shortdata[FRAMESAMPLES_SWB_10ms]; int16_t decoded[MAX_FRAMESAMPLES_SWB]; - // uint16_t streamdata[1000]; int16_t speechType[1]; int16_t payloadLimit; int32_t rateLimit; @@ -257,18 +248,6 @@ int main(int argc, char* argv[]) { } WebRtcIsac_DecoderInit(ISAC_main_inst); - // { - // int32_t b1, b2; - // FILE* fileID = fopen("GetBNTest.txt", "w"); - // b2 = 32100; - // while (b2 <= 52000) { - // WebRtcIsac_Control(ISAC_main_inst, b2, frameSize); - // WebRtcIsac_GetUplinkBw(ISAC_main_inst, &b1); - // fprintf(fileID, "%5d %5d\n", b2, b1); - // b2 += 10; - // } - // } - if (codingMode == 1) { if (WebRtcIsac_Control(ISAC_main_inst, bottleneck, frameSize) < 0) { printf("cannot set bottleneck\n"); @@ -293,14 +272,6 @@ int main(int argc, char* argv[]) { } } - //===================================== - //#ifdef HAVE_DEBUG_INFO - // if(setupDebugStruct(&debugInfo) < 0) - // { - // exit(1); - // } - //#endif - while (endfile == 0) { fprintf(stderr, " \rframe = %7li", framecnt); @@ -445,13 +416,6 @@ int main(int argc, char* argv[]) { printf("Rate Limit.................. %d bits/sec \n", rateLimit); #ifdef WIN32 -#ifdef HAVE_DEBUG_INFO - rateLB = - ((double)debugInfo.lbBytes * 8. * (sampFreqKHz)) / (double)totalsmpls; - rateUB = - ((double)debugInfo.ubBytes * 8. * (sampFreqKHz)) / (double)totalsmpls; -#endif - fprintf(bitrateFile, "%d %10u %d %6.3f %6.3f %6.3f\n", sampFreqKHz, framecnt, bottleneck, rateLB, rateUB, rate); fclose(bitrateFile); @@ -465,18 +429,6 @@ int main(int argc, char* argv[]) { printf("Measured packet-loss........ %0.1f%% \n", 100.0f * (float)lostPacketCntr / (float)packetCntr); - // #ifdef HAVE_DEBUG_INFO - // printf("Measured lower-band bit-rate %0.3f kbps (%.0f%%)\n", - // rateLB, (double)(rateLB) * 100. /(double)(rate)); - // printf("Measured upper-band bit-rate %0.3f kbps (%.0f%%)\n", - // rateUB, (double)(rateUB) * 100. /(double)(rate)); - // - // printf("Maximum payload lower-band.. %d bytes (%0.3f kbps)\n", - // debugInfo.maxPayloadLB, debugInfo.maxPayloadLB * 8.0 / 0.03); - // printf("Maximum payload upper-band.. %d bytes (%0.3f kbps)\n", - // debugInfo.maxPayloadUB, debugInfo.maxPayloadUB * 8.0 / 0.03); - // #endif - printf("\n"); /* Runtime statistics */ @@ -511,68 +463,5 @@ int main(int argc, char* argv[]) { WebRtcIsac_Free(ISAC_main_inst); -#ifdef CHANGE_OUTPUT_NAME - { - char* p; - char myExt[50]; - char bitRateStr[10]; - char newOutName[500]; - strcpy(newOutName, outname); - - myExt[0] = '\0'; - p = strchr(newOutName, '.'); - if (p != NULL) { - strcpy(myExt, p); - *p = '_'; - p++; - *p = '\0'; - } else { - strcat(newOutName, "_"); - } - sprintf(bitRateStr, "%0.0fkbps", rate); - strcat(newOutName, bitRateStr); - strcat(newOutName, myExt); - rename(outname, newOutName); - } -#endif exit(0); } - -#ifdef HAVE_DEBUG_INFO -int setupDebugStruct(debugStruct* str) { - str->prevPacketLost = 0; - str->currPacketLost = 0; - - OPEN_FILE_WB(str->res0to4FilePtr, "Res0to4.dat"); - OPEN_FILE_WB(str->res4to8FilePtr, "Res4to8.dat"); - OPEN_FILE_WB(str->res8to12FilePtr, "Res8to12.dat"); - OPEN_FILE_WB(str->res8to16FilePtr, "Res8to16.dat"); - - OPEN_FILE_WB(str->res0to4DecFilePtr, "Res0to4Dec.dat"); - OPEN_FILE_WB(str->res4to8DecFilePtr, "Res4to8Dec.dat"); - OPEN_FILE_WB(str->res8to12DecFilePtr, "Res8to12Dec.dat"); - OPEN_FILE_WB(str->res8to16DecFilePtr, "Res8to16Dec.dat"); - - OPEN_FILE_WB(str->in0to4FilePtr, "in0to4.dat"); - OPEN_FILE_WB(str->in4to8FilePtr, "in4to8.dat"); - OPEN_FILE_WB(str->in8to12FilePtr, "in8to12.dat"); - OPEN_FILE_WB(str->in8to16FilePtr, "in8to16.dat"); - - OPEN_FILE_WB(str->out0to4FilePtr, "out0to4.dat"); - OPEN_FILE_WB(str->out4to8FilePtr, "out4to8.dat"); - OPEN_FILE_WB(str->out8to12FilePtr, "out8to12.dat"); - OPEN_FILE_WB(str->out8to16FilePtr, "out8to16.dat"); - OPEN_FILE_WB(str->fftFilePtr, "riFFT.dat"); - OPEN_FILE_WB(str->fftDecFilePtr, "riFFTDec.dat"); - - OPEN_FILE_WB(str->arrivalTime, NULL /*"ArivalTime.dat"*/); - str->lastArrivalTime = 0; - - str->maxPayloadLB = 0; - str->maxPayloadUB = 0; - str->lbBytes = 0; - str->ubBytes = 0; - - return 0; -}; -#endif diff --git a/webrtc/modules/audio_coding/test/TimedTrace.cc b/webrtc/modules/audio_coding/test/TimedTrace.cc deleted file mode 100644 index ff9b5eeb76..0000000000 --- a/webrtc/modules/audio_coding/test/TimedTrace.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. - */ - -#include "TimedTrace.h" -#include - -double TimedTrace::_timeEllapsedSec = 0; -FILE* TimedTrace::_timedTraceFile = NULL; - -TimedTrace::TimedTrace() { - -} - -TimedTrace::~TimedTrace() { - if (_timedTraceFile != NULL) { - fclose(_timedTraceFile); - } - _timedTraceFile = NULL; -} - -int16_t TimedTrace::SetUp(char* fileName) { - if (_timedTraceFile == NULL) { - _timedTraceFile = fopen(fileName, "w"); - } - if (_timedTraceFile == NULL) { - return -1; - } - return 0; -} - -void TimedTrace::SetTimeEllapsed(double timeEllapsedSec) { - _timeEllapsedSec = timeEllapsedSec; -} - -double TimedTrace::TimeEllapsed() { - return _timeEllapsedSec; -} - -void TimedTrace::Tick10Msec() { - _timeEllapsedSec += 0.010; -} - -void TimedTrace::TimedLogg(char* message) { - unsigned int minutes = (uint32_t) floor(_timeEllapsedSec / 60.0); - double seconds = _timeEllapsedSec - minutes * 60; - //char myFormat[100] = "%8.2f, %3u:%05.2f: %s\n"; - if (_timedTraceFile != NULL) { - fprintf(_timedTraceFile, "%8.2f, %3u:%05.2f: %s\n", _timeEllapsedSec, - minutes, seconds, message); - } -} diff --git a/webrtc/modules/audio_coding/test/TimedTrace.h b/webrtc/modules/audio_coding/test/TimedTrace.h deleted file mode 100644 index 0793eb0c0c..0000000000 --- a/webrtc/modules/audio_coding/test/TimedTrace.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_TEST_TIMEDTRACE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_TEST_TIMEDTRACE_H_ - -#include "webrtc/typedefs.h" - -#include -#include - -class TimedTrace { - public: - TimedTrace(); - ~TimedTrace(); - - void SetTimeEllapsed(double myTime); - double TimeEllapsed(); - void Tick10Msec(); - int16_t SetUp(char* fileName); - void TimedLogg(char* message); - - private: - static double _timeEllapsedSec; - static FILE* _timedTraceFile; - -}; - -#endif // WEBRTC_MODULES_AUDIO_CODING_TEST_TIMEDTRACE_H_ diff --git a/webrtc/modules/modules.gyp b/webrtc/modules/modules.gyp index 5e38028d1c..f47cf2c951 100644 --- a/webrtc/modules/modules.gyp +++ b/webrtc/modules/modules.gyp @@ -89,7 +89,6 @@ 'audio_coding/test/TestStereo.cc', 'audio_coding/test/TestVADDTX.cc', 'audio_coding/test/Tester.cc', - 'audio_coding/test/TimedTrace.cc', 'audio_coding/test/TwoWayCommunication.cc', 'audio_coding/test/iSACTest.cc', 'audio_coding/test/opus_test.cc', @@ -151,7 +150,7 @@ '<(DEPTH)/testing/gmock.gyp:gmock', '<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', - '<(webrtc_root)/base/base.gyp:rtc_base', + '<(webrtc_root)/base/base.gyp:rtc_base_approved', '<(webrtc_root)/common.gyp:webrtc_common', '<(webrtc_root)/common_audio/common_audio.gyp:common_audio', '<(webrtc_root)/common_video/common_video.gyp:common_video', diff --git a/webrtc/modules/video_coding/test/receiver_tests.h b/webrtc/modules/video_coding/test/receiver_tests.h index c2a8477872..e2429e75c6 100644 --- a/webrtc/modules/video_coding/test/receiver_tests.h +++ b/webrtc/modules/video_coding/test/receiver_tests.h @@ -19,7 +19,6 @@ #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" #include "webrtc/modules/video_coding/include/video_coding.h" #include "webrtc/modules/video_coding/test/test_util.h" -#include "webrtc/modules/video_coding/test/video_source.h" #include "webrtc/typedefs.h" class RtpDataCallback : public webrtc::NullRtpData { diff --git a/webrtc/modules/video_coding/test/video_source.h b/webrtc/modules/video_coding/test/video_source.h deleted file mode 100644 index 19d7f50b26..0000000000 --- a/webrtc/modules/video_coding/test/video_source.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#ifndef WEBRTC_MODULES_VIDEO_CODING_TEST_VIDEO_SOURCE_H_ -#define WEBRTC_MODULES_VIDEO_CODING_TEST_VIDEO_SOURCE_H_ - -#include - -#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" -#include "webrtc/typedefs.h" - -enum VideoSize { - kUndefined, - kSQCIF, // 128*96 = 12 288 - kQQVGA, // 160*120 = 19 200 - kQCIF, // 176*144 = 25 344 - kCGA, // 320*200 = 64 000 - kQVGA, // 320*240 = 76 800 - kSIF, // 352*240 = 84 480 - kWQVGA, // 400*240 = 96 000 - kCIF, // 352*288 = 101 376 - kW288p, // 512*288 = 147 456 (WCIF) - k448p, // 576*448 = 281 088 - kVGA, // 640*480 = 307 200 - k432p, // 720*432 = 311 040 - kW432p, // 768*432 = 331 776 - k4SIF, // 704*480 = 337 920 - kW448p, // 768*448 = 344 064 - kNTSC, // 720*480 = 345 600 - kFW448p, // 800*448 = 358 400 - kWVGA, // 800*480 = 384 000 - k4CIF, // 704*576 = 405 504 - kSVGA, // 800*600 = 480 000 - kW544p, // 960*544 = 522 240 - kW576p, // 1024*576 = 589 824 (W4CIF) - kHD, // 960*720 = 691 200 - kXGA, // 1024*768 = 786 432 - kWHD, // 1280*720 = 921 600 - kFullHD, // 1440*1080 = 1 555 200 - kWFullHD, // 1920*1080 = 2 073 600 - - kNumberOfVideoSizes -}; - -class VideoSource { - public: - VideoSource(); - VideoSource(std::string fileName, - VideoSize size, - float frameRate, - webrtc::VideoType type = webrtc::kI420); - VideoSource(std::string fileName, - uint16_t width, - uint16_t height, - float frameRate = 30, - webrtc::VideoType type = webrtc::kI420); - - std::string GetFileName() const { return _fileName; } - uint16_t GetWidth() const { return _width; } - uint16_t GetHeight() const { return _height; } - webrtc::VideoType GetType() const { return _type; } - float GetFrameRate() const { return _frameRate; } - int GetWidthHeight(VideoSize size); - - // Returns the filename with the path (including the leading slash) removed. - std::string GetName() const; - - size_t GetFrameLength() const; - - private: - std::string _fileName; - uint16_t _width; - uint16_t _height; - webrtc::VideoType _type; - float _frameRate; -}; - -#endif // WEBRTC_MODULES_VIDEO_CODING_TEST_VIDEO_SOURCE_H_ diff --git a/webrtc/voice_engine/test/android/android_test/.classpath b/webrtc/voice_engine/test/android/android_test/.classpath deleted file mode 100644 index 86a15c90b0..0000000000 --- a/webrtc/voice_engine/test/android/android_test/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/webrtc/voice_engine/test/android/android_test/.project b/webrtc/voice_engine/test/android/android_test/.project deleted file mode 100644 index 990e2f5074..0000000000 --- a/webrtc/voice_engine/test/android/android_test/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - AndroidTest - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/webrtc/voice_engine/test/android/android_test/AndroidManifest.xml b/webrtc/voice_engine/test/android/android_test/AndroidManifest.xml deleted file mode 100644 index a614f8dd13..0000000000 --- a/webrtc/voice_engine/test/android/android_test/AndroidManifest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/webrtc/voice_engine/test/android/android_test/default.properties b/webrtc/voice_engine/test/android/android_test/default.properties deleted file mode 100644 index 6ed608e0d4..0000000000 --- a/webrtc/voice_engine/test/android/android_test/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target, OpenSL ES requires API level 9 -target=android-9 diff --git a/webrtc/voice_engine/test/android/android_test/gen/org/webrtc/voiceengine/test/R.java b/webrtc/voice_engine/test/android/android_test/gen/org/webrtc/voiceengine/test/R.java deleted file mode 100644 index ec8f5b451a..0000000000 --- a/webrtc/voice_engine/test/android/android_test/gen/org/webrtc/voiceengine/test/R.java +++ /dev/null @@ -1,30 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package org.webrtc.voiceengine.test; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class id { - public static final int Button01=0x7f050002; - public static final int Button02=0x7f050005; - public static final int EditText01=0x7f050001; - public static final int Spinner01=0x7f050003; - public static final int Spinner02=0x7f050004; - public static final int TextView01=0x7f050000; - } - public static final class layout { - public static final int main=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } -} diff --git a/webrtc/voice_engine/test/android/android_test/jni/android_test.cc b/webrtc/voice_engine/test/android/android_test/jni/android_test.cc deleted file mode 100644 index 766b9e7a8e..0000000000 --- a/webrtc/voice_engine/test/android/android_test/jni/android_test.cc +++ /dev/null @@ -1,1331 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "webrtc/voice_engine/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h" - -#include "webrtc/base/platform_thread.h" - -#include "webrtc/voice_engine/include/voe_audio_processing.h" -#include "webrtc/voice_engine/include/voe_base.h" -#include "webrtc/voice_engine/include/voe_codec.h" -#include "webrtc/voice_engine/include/voe_file.h" -#include "webrtc/voice_engine/include/voe_hardware.h" -#include "webrtc/voice_engine/include/voe_network.h" -#include "webrtc/voice_engine/include/voe_rtp_rtcp.h" -#include "webrtc/voice_engine/include/voe_volume_control.h" - -#include "webrtc/voice_engine/test/auto_test/voe_test_interface.h" - -//#define INIT_FROM_THREAD -//#define START_CALL_FROM_THREAD - -#define WEBRTC_LOG_TAG "*WEBRTCN*" // As in WEBRTC Native... -#define VALIDATE_BASE_POINTER \ - if (!veData1.base) \ - { \ - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, \ - "Base pointer doesn't exist"); \ - return -1; \ - } -#define VALIDATE_CODEC_POINTER \ - if (!veData1.codec) \ - { \ - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, \ - "Codec pointer doesn't exist"); \ - return -1; \ - } -#define VALIDATE_FILE_POINTER \ - if (!veData1.file) \ - { \ - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, \ - "File pointer doesn't exist"); \ - return -1; \ - } -#define VALIDATE_NETWORK_POINTER \ - if (!veData1.netw) \ - { \ - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, \ - "Network pointer doesn't exist"); \ - return -1; \ - } -#define VALIDATE_APM_POINTER \ - if (!veData1.codec) \ - { \ - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, \ - "Apm pointer doesn't exist"); \ - return -1; \ - } -#define VALIDATE_VOLUME_POINTER \ - if (!veData1.volume) \ - { \ - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, \ - "Volume pointer doesn't exist"); \ - return -1; \ - } -#define VALIDATE_HARDWARE_POINTER \ - if (!veData1.hardware) \ - { \ - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, \ - "Hardware pointer doesn't exist"); \ - return -1; \ - } -#define VALIDATE_RTP_RTCP_POINTER \ - if (!veData1.rtp_rtcp) \ - { \ - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, \ - "RTP / RTCP pointer doesn't exist"); \ - return -1; \ - } - -// Register functions in JNI_OnLoad() -// How do we ensure that VoE is deleted? JNI_OnUnload? -// What happens if class is unloaded? When loaded again, NativeInit will be -// called again. Keep what we have? -// Should we do something in JNI_OnUnload? -// 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 -}; - -using namespace webrtc; - -class my_transportation; - -// VoiceEngine data struct -typedef struct -{ - // VoiceEngine - VoiceEngine* ve; - // Sub-APIs - VoEBase* base; - VoECodec* codec; - VoEFile* file; - VoENetwork* netw; - VoEAudioProcessing* apm; - VoEVolumeControl* volume; - VoEHardware* hardware; - VoERTP_RTCP* rtp_rtcp; - // Other - my_transportation* extTrans; - JavaVM* jvm; -} VoiceEngineData; - -// 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, size_t len) override; - int SendRTCPPacket(int channel, const void* data, size_t len) override; - - private: - VoENetwork * netw; -}; - -int my_transportation::SendPacket(int channel, const void *data, size_t len) -{ - netw->ReceivedRTPPacket(channel, data, len); - return len; -} - -int my_transportation::SendRTCPPacket(int channel, const void *data, size_t len) -{ - netw->ReceivedRTCPPacket(channel, data, len); - return len; -} - -//Global variables visible in this file -static VoiceEngineData veData1; -static VoiceEngineData veData2; - -// "Local" functions (i.e. not Java accessible) -static bool GetSubApis(VoiceEngineData &veData); -static bool ReleaseSubApis(VoiceEngineData &veData); - -class ThreadTest -{ -public: - ThreadTest(); - ~ThreadTest(); - int RunTest(); - int CloseTest(); -private: - static bool Run(void* ptr); - bool Process(); -private: - rtc::PlatformThread _thread; -}; - -ThreadTest::~ThreadTest() -{ - if (_thread) - _thread->Stop(); -} - -ThreadTest::ThreadTest() -{ - _thread(Run, this, "ThreadTest thread"); -} - -bool ThreadTest::Run(void* ptr) -{ - return static_cast (ptr)->Process(); -} - -bool ThreadTest::Process() -{ - // Attach this thread to JVM - /*JNIEnv* env = NULL; - jint res = veData1.jvm->AttachCurrentThread(&env, NULL); - char msg[32]; - sprintf(msg, "res=%d, env=%d", res, env); - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, msg);*/ - -#ifdef INIT_FROM_THREAD - VALIDATE_BASE_POINTER; - veData1.base->Init(); -#endif - -#ifdef START_CALL_FROM_THREAD - // receiving instance - veData2.ve = VoiceEngine::Create(); - GetSubApis(veData2); - veData2.base->Init(); - veData2.base->CreateChannel(); - if(veData2.base->SetLocalReceiver(0, 1234) < 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "set local receiver 2 failed"); - } - veData2.volume->SetSpeakerVolume(204); - veData2.base->StartReceive(0); - if(veData2.base->StartPlayout(0) < 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "start playout failed"); - } - - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "receiving instance started from thread"); - - // sending instance - veData1.ve = VoiceEngine::Create(); - GetSubApis(veData1); - veData1.base->Init(); - if(veData1.base->CreateChannel() < 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "create channel failed"); - } - if(veData1.base->SetLocalReceiver(0, 1256) < 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "set local receiver failed"); - } - if(veData1.base->SetSendDestination(0, 1234, "127.0.0.1") < 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "set send destination failed"); - } - if(veData1.base->StartSend(0) < 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "start send failed"); - } - - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "sending instance started from thread"); -#endif - - _thread->Stop(); - - //res = veData1.jvm->DetachCurrentThread(); - - return true; -} - -int ThreadTest::RunTest() -{ - if (_thread) - { - _thread->Start(); - } - return 0; -} - -int ThreadTest::CloseTest() -{ - VALIDATE_BASE_POINTER - - veData1.base->DeleteChannel(0); - veData2.base->DeleteChannel(0); - veData1.base->Terminate(); - veData2.base->Terminate(); - - // Release sub-APIs - ReleaseSubApis(veData1); - ReleaseSubApis(veData2); - - // Delete - VoiceEngine::Delete(veData1.ve); - VoiceEngine::Delete(veData2.ve); - veData2.ve = NULL; - veData2.ve = NULL; - - return 0; -} - -ThreadTest threadTest; - -////////////////////////////////////////////////////////////////// -// General functions -////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////// -// JNI_OnLoad -// -jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/) -{ - if (!vm) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "JNI_OnLoad did not receive a valid VM pointer"); - return -1; - } - - // Get JNI - JNIEnv* env; - if (JNI_OK != vm->GetEnv(reinterpret_cast (&env), - JNI_VERSION_1_4)) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "JNI_OnLoad could not get JNI env"); - return -1; - } - - // Get class to register the native functions with - // jclass regClass = env->FindClass("webrtc/android/AndroidTest"); - // if (!regClass) { - // return -1; // Exception thrown - // } - - // Register native functions - // JNINativeMethod methods[1]; - // methods[0].name = NULL; - // methods[0].signature = NULL; - // methods[0].fnPtr = NULL; - // if (JNI_OK != env->RegisterNatives(regClass, methods, 1)) - // { - // return -1; - // } - - // Init VoiceEngine data - memset(&veData1, 0, sizeof(veData1)); - memset(&veData2, 0, sizeof(veData2)); - - // Store the JVM - veData1.jvm = vm; - veData2.jvm = vm; - - return JNI_VERSION_1_4; -} - -///////////////////////////////////////////// -// Native initialization -// -JNIEXPORT jboolean JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_NativeInit( - JNIEnv * env, - jclass) -{ - // Look up and cache any interesting class, field and method IDs for - // any used java class here - - return true; -} - -///////////////////////////////////////////// -// Run auto standard test -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_RunAutoTest( - JNIEnv *env, - jobject context, - jint testType, - jint extendedSel) -{ - TestType tType(Invalid); - - switch (testType) - { - case 0: - return 0; - case 1: - tType = Standard; - break; - case 2: - tType = Extended; - break; - case 3: - tType = Stress; - break; - case 4: - tType = Unit; - break; - default: - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "RunAutoTest - Invalid TestType"); - return -1; - } - - // Set instance independent Java objects - VoiceEngine::SetAndroidObjects(veData1.jvm, env, context); - - // Call voe test interface function - // TODO(leozwang) add autotest setAndroidObjects(veData1.jvm, context); - // jint retVal = runAutoTest(tType); - - // Clear instance independent Java objects - VoiceEngine::SetAndroidObjects(NULL, NULL, NULL); - - return 0; -} - -////////////////////////////////////////////////////////////////// -// VoiceEngine API wrapper functions -////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////// -// Create VoiceEngine instance -// -JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Create( - JNIEnv *env, - jobject context) -{ - // Check if already created - if (veData1.ve) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "VoE already created"); - return false; - } - - // Set instance independent Java objects - VoiceEngine::SetAndroidObjects(veData1.jvm, env, context); - -#ifdef START_CALL_FROM_THREAD - threadTest.RunTest(); -#else - // Create - veData1.ve = VoiceEngine::Create(); - if (!veData1.ve) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Create VoE failed"); - return false; - } - - // Get sub-APIs - if (!GetSubApis(veData1)) - { - // If not OK, release all sub-APIs and delete VoE - ReleaseSubApis(veData1); - if (!VoiceEngine::Delete(veData1.ve)) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Delete VoE failed"); - } - return false; - } -#endif - - return true; -} - -///////////////////////////////////////////// -// Delete VoiceEngine instance -// -JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Delete( - JNIEnv *, - jobject) -{ -#ifdef START_CALL_FROM_THREAD - threadTest.CloseTest(); -#else - // Check if exists - if (!veData1.ve) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "VoE does not exist"); - return false; - } - - // Release sub-APIs - ReleaseSubApis(veData1); - - // Delete - if (!VoiceEngine::Delete(veData1.ve)) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Delete VoE failed"); - return false; - } - - veData1.ve = NULL; -#endif - - // Clear instance independent Java objects - VoiceEngine::SetAndroidObjects(NULL, NULL, NULL); - - return true; -} - -///////////////////////////////////////////// -// [Base] Initialize VoiceEngine -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Init( - JNIEnv *, - jobject, - jboolean enableTrace, - jboolean useExtTrans) -{ - VALIDATE_BASE_POINTER; - - if (enableTrace) - { - if (0 != VoiceEngine::SetTraceFile("/sdcard/trace.txt")) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not enable trace"); - } - if (0 != VoiceEngine::SetTraceFilter(kTraceAll)) - { - __android_log_write(ANDROID_LOG_WARN, WEBRTC_LOG_TAG, - "Could not set trace filter"); - } - } - - if (useExtTrans) - { - VALIDATE_NETWORK_POINTER; - veData1.extTrans = new my_transportation(veData1.netw); - } - - int retVal = 0; -#ifdef INIT_FROM_THREAD - threadTest.RunTest(); - usleep(200000); -#else - retVal = veData1.base->Init(); -#endif - return retVal; -} - -///////////////////////////////////////////// -// [Base] Terminate VoiceEngine -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Terminate( - JNIEnv *, - jobject) -{ - VALIDATE_BASE_POINTER; - - jint retVal = veData1.base->Terminate(); - - delete veData1.extTrans; - veData1.extTrans = NULL; - - return retVal; -} - -///////////////////////////////////////////// -// [Base] Create channel -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_CreateChannel( - JNIEnv *, - jobject) -{ - VALIDATE_BASE_POINTER; - jint channel = veData1.base->CreateChannel(); - - if (veData1.extTrans) - { - VALIDATE_NETWORK_POINTER; - __android_log_print(ANDROID_LOG_DEBUG, WEBRTC_LOG_TAG, - "Enabling external transport on channel %d", - channel); - if (veData1.netw->RegisterExternalTransport(channel, *veData1.extTrans) - < 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not set external transport"); - return -1; - } - } - - return channel; -} - -///////////////////////////////////////////// -// [Base] Delete channel -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_DeleteChannel( - JNIEnv *, - jobject, - jint channel) -{ - VALIDATE_BASE_POINTER; - return veData1.base->DeleteChannel(channel); -} - -///////////////////////////////////////////// -// [Base] SetLocalReceiver -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_SetLocalReceiver( - JNIEnv *, - jobject, - jint channel, - jint port) -{ - VALIDATE_BASE_POINTER; - return veData1.base->SetLocalReceiver(channel, port); -} - -///////////////////////////////////////////// -// [Base] SetSendDestination -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_SetSendDestination( - JNIEnv *env, - jobject, - jint channel, - jint port, - jstring ipaddr) -{ - VALIDATE_BASE_POINTER; - - const char* ipaddrNative = env->GetStringUTFChars(ipaddr, NULL); - if (!ipaddrNative) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not get UTF string"); - return -1; - } - - jint retVal = veData1.base->SetSendDestination(channel, port, ipaddrNative); - - env->ReleaseStringUTFChars(ipaddr, ipaddrNative); - - return retVal; -} - -///////////////////////////////////////////// -// [Base] StartListen -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartListen( - JNIEnv *, - jobject, - jint channel) -{ - VALIDATE_BASE_POINTER; - int retVal = veData1.base->StartReceive(channel); - - return retVal; -} - -///////////////////////////////////////////// -// [Base] Start playout -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_StartPlayout( - JNIEnv *, - jobject, - jint channel) -{ - VALIDATE_BASE_POINTER; - int retVal = veData1.base->StartPlayout(channel); - - return retVal; -} - -///////////////////////////////////////////// -// [Base] Start send -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartSend( - JNIEnv *, - jobject, - jint channel) -{ - /* int dscp(0), serviceType(-1), overrideDscp(0), res(0); - bool gqosEnabled(false), useSetSockOpt(false); - - if (veData1.netw->SetSendTOS(channel, 13, useSetSockOpt) != 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Failed to set TOS"); - return -1; - } - - res = veData1.netw->GetSendTOS(channel, dscp, useSetSockOpt); - if (res != 0 || dscp != 13 || useSetSockOpt != true) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Failed to get TOS"); - return -1; - } */ - - /* if (veData1.rtp_rtcp->SetREDStatus(channel, 1) != 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Failed to enable RED"); - return -1; - } */ - - VALIDATE_BASE_POINTER; - int retVal = veData1.base->StartSend(channel); - - return retVal; -} - -///////////////////////////////////////////// -// [Base] Stop listen -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopListen( - JNIEnv *, - jobject, - jint channel) -{ - VALIDATE_BASE_POINTER; - return veData1.base->StopReceive(channel); -} - -///////////////////////////////////////////// -// [Base] Stop playout -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopPlayout( - JNIEnv *, - jobject, - jint channel) -{ - VALIDATE_BASE_POINTER; - return veData1.base->StopPlayout(channel); -} - -///////////////////////////////////////////// -// [Base] Stop send -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopSend( - JNIEnv *, - jobject, - jint channel) -{ - /* if (veData1.rtp_rtcp->SetREDStatus(channel, 0) != 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Failed to disable RED"); - return -1; - } */ - - VALIDATE_BASE_POINTER; - return veData1.base->StopSend(channel); -} - -///////////////////////////////////////////// -// [codec] Number of codecs -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_NumOfCodecs( - JNIEnv *, - jobject) -{ - VALIDATE_CODEC_POINTER; - return veData1.codec->NumOfCodecs(); -} - -///////////////////////////////////////////// -// [codec] Set send codec -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_SetSendCodec( - JNIEnv *, - jobject, - jint channel, - jint index) -{ - VALIDATE_CODEC_POINTER; - - CodecInst codec; - - if (veData1.codec->GetCodec(index, codec) != 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Failed to get codec"); - return -1; - } - - return veData1.codec->SetSendCodec(channel, codec); -} - -///////////////////////////////////////////// -// [codec] Set VAD status -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_SetVADStatus( - JNIEnv *, - jobject, - jint channel, - jboolean enable, - jint mode) -{ - VALIDATE_CODEC_POINTER; - - VadModes VADmode = kVadConventional; - - switch (mode) - { - case 0: - break; // already set - case 1: - VADmode = kVadAggressiveLow; - break; - case 2: - VADmode = kVadAggressiveMid; - break; - case 3: - VADmode = kVadAggressiveHigh; - break; - default: - VADmode = (VadModes) 17; // force error - break; - } - - return veData1.codec->SetVADStatus(channel, enable, VADmode); -} - -///////////////////////////////////////////// -// [apm] SetNSStatus -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetNSStatus( - JNIEnv *, - jobject, - jboolean enable, - jint mode) -{ - VALIDATE_APM_POINTER; - - NsModes NSmode = kNsDefault; - - switch (mode) - { - case 0: - NSmode = kNsUnchanged; - break; - case 1: - break; // already set - case 2: - NSmode = kNsConference; - break; - case 3: - NSmode = kNsLowSuppression; - break; - case 4: - NSmode = kNsModerateSuppression; - break; - case 5: - NSmode = kNsHighSuppression; - break; - case 6: - NSmode = kNsVeryHighSuppression; - break; - default: - NSmode = (NsModes) 17; // force error - break; - } - - return veData1.apm->SetNsStatus(enable, NSmode); -} - -///////////////////////////////////////////// -// [apm] SetAGCStatus -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_SetAGCStatus( - JNIEnv *, - jobject, - jboolean enable, - jint mode) -{ - VALIDATE_APM_POINTER; - - AgcModes AGCmode = kAgcDefault; - - switch (mode) - { - case 0: - AGCmode = kAgcUnchanged; - break; - case 1: - break; // already set - case 2: - AGCmode = kAgcAdaptiveAnalog; - break; - case 3: - AGCmode = kAgcAdaptiveDigital; - break; - case 4: - AGCmode = kAgcFixedDigital; - break; - default: - AGCmode = (AgcModes) 17; // force error - break; - } - - /* AgcConfig agcConfig; - agcConfig.targetLeveldBOv = 3; - agcConfig.digitalCompressionGaindB = 50; - agcConfig.limiterEnable = 0; - - if (veData1.apm->SetAGCConfig(agcConfig) != 0) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Failed to set AGC config"); - return -1; - } */ - - return veData1.apm->SetAgcStatus(enable, AGCmode); -} - -///////////////////////////////////////////// -// [apm] SetECStatus -// -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetECStatus( - JNIEnv *, - jobject, - jboolean enable, - jint mode) -{ - VALIDATE_APM_POINTER; - - EcModes ECmode = kEcDefault; - - switch (mode) - { - case 0: - ECmode = kEcDefault; - break; - case 1: - break; // already set - case 2: - ECmode = kEcConference; - break; - case 3: - ECmode = kEcAec; - break; - case 4: - ECmode = kEcAecm; - break; - default: - ECmode = (EcModes) 17; // force error - break; - } - - return veData1.apm->SetEcStatus(enable, ECmode); -} - -///////////////////////////////////////////// -// [File] Start play file locally -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_StartPlayingFileLocally( - JNIEnv * env, - jobject, - jint channel, - jstring fileName, - jboolean loop) -{ - VALIDATE_FILE_POINTER; - - const char* fileNameNative = env->GetStringUTFChars(fileName, NULL); - if (!fileNameNative) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not get UTF string"); - return -1; - } - - jint retVal = veData1.file->StartPlayingFileLocally(channel, - fileNameNative, loop); - - env->ReleaseStringUTFChars(fileName, fileNameNative); - - return retVal; -} - -///////////////////////////////////////////// -// [File] Stop play file locally -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_StopPlayingFileLocally( - JNIEnv *, - jobject, - jint channel) -{ - VALIDATE_FILE_POINTER; - return veData1.file->StopPlayingFileLocally(channel); -} - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StartRecordingPlayout - * Signature: (ILjava/lang/String;Z)I - */ -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_StartRecordingPlayout( - JNIEnv * env, - jobject, - jint channel, - jstring fileName, - jboolean) -{ - VALIDATE_FILE_POINTER; - - const char* fileNameNative = env->GetStringUTFChars(fileName, NULL); - if (!fileNameNative) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not get UTF string"); - return -1; - } - - jint retVal = veData1.file->StartRecordingPlayout(channel, fileNameNative, - 0); - - env->ReleaseStringUTFChars(fileName, fileNameNative); - - return retVal; -} - -///////////////////////////////////////////// -// [File] Stop Recording Playout -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_StopRecordingPlayout( - JNIEnv *, - jobject, - jint channel) -{ - VALIDATE_FILE_POINTER; - return veData1.file->StopRecordingPlayout(channel); -} - -///////////////////////////////////////////// -// [File] Start playing file as microphone -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_StartPlayingFileAsMicrophone( - JNIEnv *env, - jobject, - jint channel, - jstring fileName, - jboolean loop) -{ - VALIDATE_FILE_POINTER; - - const char* fileNameNative = env->GetStringUTFChars(fileName, NULL); - if (!fileNameNative) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not get UTF string"); - return -1; - } - - jint retVal = veData1.file->StartPlayingFileAsMicrophone(channel, - fileNameNative, - loop); - - env->ReleaseStringUTFChars(fileName, fileNameNative); - - return retVal; -} - -///////////////////////////////////////////// -// [File] Stop playing file as microphone -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_StopPlayingFileAsMicrophone( - JNIEnv *, - jobject, - jint channel) -{ - VALIDATE_FILE_POINTER; - return veData1.file->StopPlayingFileAsMicrophone(channel); -} - -///////////////////////////////////////////// -// [Volume] Set speaker volume -// -JNIEXPORT jint JNICALL -Java_org_webrtc_voiceengine_test_AndroidTest_SetSpeakerVolume( - JNIEnv *, - jobject, - jint level) -{ - VALIDATE_VOLUME_POINTER; - if (veData1.volume->SetSpeakerVolume(level) != 0) - { - return -1; - } - - unsigned int storedVolume = 0; - if (veData1.volume->GetSpeakerVolume(storedVolume) != 0) - { - return -1; - } - - if (storedVolume != level) - { - return -1; - } - - return 0; -} - -////////////////////////////////////////////////////////////////// -// "Local" functions (i.e. not Java accessible) -////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////// -// Get all sub-APIs -// -bool GetSubApis(VoiceEngineData &veData) -{ - bool getOK = true; - - // Base - veData.base = VoEBase::GetInterface(veData.ve); - if (!veData.base) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Get base sub-API failed"); - getOK = false; - } - - // Codec - veData.codec = VoECodec::GetInterface(veData.ve); - if (!veData.codec) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Get codec sub-API failed"); - getOK = false; - } - - // File - veData.file = VoEFile::GetInterface(veData.ve); - if (!veData.file) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Get file sub-API failed"); - getOK = false; - } - - // Network - veData.netw = VoENetwork::GetInterface(veData.ve); - if (!veData.netw) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Get network sub-API failed"); - getOK = false; - } - - // AudioProcessing module - veData.apm = VoEAudioProcessing::GetInterface(veData.ve); - if (!veData.apm) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Get apm sub-API failed"); - getOK = false; - } - - // Volume - veData.volume = VoEVolumeControl::GetInterface(veData.ve); - if (!veData.volume) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Get volume sub-API failed"); - getOK = false; - } - - // Hardware - veData.hardware = VoEHardware::GetInterface(veData.ve); - if (!veData.hardware) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Get hardware sub-API failed"); - getOK = false; - } - - // RTP / RTCP - veData.rtp_rtcp = VoERTP_RTCP::GetInterface(veData.ve); - if (!veData.rtp_rtcp) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Get rtp_rtcp sub-API failed"); - getOK = false; - } - - return getOK; -} - -///////////////////////////////////////////// -// Release all sub-APIs -// -bool ReleaseSubApis(VoiceEngineData &veData) -{ - bool releaseOK = true; - - // Base - if (veData.base) - { - if (0 != veData.base->Release()) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release base sub-API failed"); - releaseOK = false; - } - else - { - veData.base = NULL; - } - } - - // Codec - if (veData.codec) - { - if (0 != veData.codec->Release()) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release codec sub-API failed"); - releaseOK = false; - } - else - { - veData.codec = NULL; - } - } - - // File - if (veData.file) - { - if (0 != veData.file->Release()) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release file sub-API failed"); - releaseOK = false; - } - else - { - veData.file = NULL; - } - } - - // Network - if (veData.netw) - { - if (0 != veData.netw->Release()) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release network sub-API failed"); - releaseOK = false; - } - else - { - veData.netw = NULL; - } - } - - // apm - if (veData.apm) - { - if (0 != veData.apm->Release()) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release apm sub-API failed"); - releaseOK = false; - } - else - { - veData.apm = NULL; - } - } - - // Volume - if (veData.volume) - { - if (0 != veData.volume->Release()) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release volume sub-API failed"); - releaseOK = false; - } - else - { - veData.volume = NULL; - } - } - - // Hardware - if (veData.hardware) - { - if (0 != veData.hardware->Release()) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release hardware sub-API failed"); - releaseOK = false; - } - else - { - veData.hardware = NULL; - } - } - - // RTP RTCP - if (veData.rtp_rtcp) - { - if (0 != veData.rtp_rtcp->Release()) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release rtp_rtcp sub-API failed"); - releaseOK = false; - } - else - { - veData.rtp_rtcp = NULL; - } - } - - return releaseOK; -} diff --git a/webrtc/voice_engine/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h b/webrtc/voice_engine/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h deleted file mode 100644 index 34d408a95f..0000000000 --- a/webrtc/voice_engine/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h +++ /dev/null @@ -1,245 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_webrtc_voiceengine_test_AndroidTest */ - -#ifndef _Included_org_webrtc_voiceengine_test_AndroidTest -#define _Included_org_webrtc_voiceengine_test_AndroidTest -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: NativeInit - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_NativeInit - (JNIEnv *, jclass); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: RunAutoTest - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_RunAutoTest - (JNIEnv *, jobject, jint, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: Create - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Create - (JNIEnv *, jobject); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: Delete - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Delete - (JNIEnv *, jobject); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: Init - * Signature: (IIIZZ)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Init - (JNIEnv *, jobject, jboolean, jboolean); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: Terminate - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_Terminate - (JNIEnv *, jobject); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: CreateChannel - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_CreateChannel - (JNIEnv *, jobject); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: DeleteChannel - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_DeleteChannel - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: SetLocalReceiver - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetLocalReceiver - (JNIEnv *, jobject, jint, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: SetSendDestination - * Signature: (IILjava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetSendDestination - (JNIEnv *, jobject, jint, jint, jstring); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StartListen - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartListen - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StartPlayout - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartPlayout - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StartSend - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartSend - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StopListen - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopListen - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StopPlayout - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopPlayout - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StopSend - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopSend - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StartPlayingFileLocally - * Signature: (ILjava/lang/String;Z)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartPlayingFileLocally - (JNIEnv *, jobject, jint, jstring, jboolean); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StopPlayingFileLocally - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopPlayingFileLocally - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StartRecordingPlayout - * Signature: (ILjava/lang/String;Z)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartRecordingPlayout - (JNIEnv *, jobject, jint, jstring, jboolean); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StopRecordingPlayout - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopRecordingPlayout - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StartPlayingFileAsMicrophone - * Signature: (ILjava/lang/String;Z)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartPlayingFileAsMicrophone - (JNIEnv *, jobject, jint, jstring, jboolean); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: StopPlayingFileAsMicrophone - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopPlayingFileAsMicrophone - (JNIEnv *, jobject, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: NumOfCodecs - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_NumOfCodecs - (JNIEnv *, jobject); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: SetSendCodec - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetSendCodec - (JNIEnv *, jobject, jint, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: SetVADStatus - * Signature: (IZI)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetVADStatus - (JNIEnv *, jobject, jint, jboolean, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: SetNSStatus - * Signature: (ZI)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetNSStatus - (JNIEnv *, jobject, jboolean, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: SetAGCStatus - * Signature: (ZI)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetAGCStatus - (JNIEnv *, jobject, jboolean, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: SetECStatus - * Signature: (ZI)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetECStatus - (JNIEnv *, jobject, jboolean, jint); - -/* - * Class: org_webrtc_voiceengine_test_AndroidTest - * Method: SetSpeakerVolume - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_SetSpeakerVolume - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/webrtc/voice_engine/test/android/android_test/res/drawable/icon.png b/webrtc/voice_engine/test/android/android_test/res/drawable/icon.png deleted file mode 100644 index a07c69fa5a..0000000000 Binary files a/webrtc/voice_engine/test/android/android_test/res/drawable/icon.png and /dev/null differ diff --git a/webrtc/voice_engine/test/android/android_test/res/layout/main.xml b/webrtc/voice_engine/test/android/android_test/res/layout/main.xml deleted file mode 100644 index 4165a07c39..0000000000 --- a/webrtc/voice_engine/test/android/android_test/res/layout/main.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/webrtc/voice_engine/test/android/android_test/res/values/strings.xml b/webrtc/voice_engine/test/android/android_test/res/values/strings.xml deleted file mode 100644 index 29ec4ee930..0000000000 --- a/webrtc/voice_engine/test/android/android_test/res/values/strings.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - WebRtc VoE - diff --git a/webrtc/voice_engine/test/android/android_test/src/org/webrtc/voiceengine/test/AndroidTest.java b/webrtc/voice_engine/test/android/android_test/src/org/webrtc/voiceengine/test/AndroidTest.java deleted file mode 100644 index 71b22b0d6d..0000000000 --- a/webrtc/voice_engine/test/android/android_test/src/org/webrtc/voiceengine/test/AndroidTest.java +++ /dev/null @@ -1,1190 +0,0 @@ -/* - * 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. - */ - -/* - * VoiceEngine Android test application. It starts either auto test or acts like - * a GUI test. - */ - -package org.webrtc.voiceengine.test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; - -import android.app.Activity; -import android.content.Context; -import android.media.AudioFormat; -import android.media.AudioManager; -import android.media.AudioRecord; -import android.media.AudioTrack; -import android.media.MediaRecorder; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Spinner; -import android.widget.TextView; - -public class AndroidTest extends Activity { - private byte[] _playBuffer = null; - private short[] _circBuffer = new short[8000]; // can hold 50 frames - - private int _recIndex = 0; - private int _playIndex = 0; - // private int _streamVolume = 4; - private int _maxVolume = 0; // Android max level (commonly 5) - // VoE level (0-255), corresponds to level 4 out of 5 - private int _volumeLevel = 204; - - private Thread _playThread; - private Thread _recThread; - private Thread _autotestThread; - - private static AudioTrack _at; - private static AudioRecord _ar; - - private File _fr = null; - private FileInputStream _in = null; - - private boolean _isRunningPlay = false; - private boolean _isRunningRec = false; - private boolean _settingSet = true; - private boolean _isCallActive = false; - private boolean _runAutotest = false; // ENABLE AUTOTEST HERE! - - private int _channel = -1; - private int _codecIndex = 0; - private int _ecIndex = 0; - private int _nsIndex = 0; - private int _agcIndex = 0; - private int _vadIndex = 0; - private int _audioIndex = 3; - private int _settingMenu = 0; - private int _receivePort = 1234; - private int _destinationPort = 1234; - private String _destinationIP = "127.0.0.1"; - - // "Build" settings - private final boolean _playFromFile = false; - // Set to true to send data to native code and back - private final boolean _runThroughNativeLayer = true; - private final boolean enableSend = true; - private final boolean enableReceive = true; - private final boolean useNativeThread = false; - - /** Called when the activity is first created. */ - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - TextView tv = (TextView) findViewById(R.id.TextView01); - tv.setText(""); - - final EditText ed = (EditText) findViewById(R.id.EditText01); - ed.setWidth(200); - ed.setText(_destinationIP); - - final Button buttonStart = (Button) findViewById(R.id.Button01); - buttonStart.setWidth(200); - if (_runAutotest) { - buttonStart.setText("Run test"); - } else { - buttonStart.setText("Start Call"); - } - // button.layout(50, 50, 100, 40); - buttonStart.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - - if (_runAutotest) { - startAutoTest(); - } else { - if (_isCallActive) { - - if (stopCall() != -1) { - _isCallActive = false; - buttonStart.setText("Start Call"); - } - } else { - - _destinationIP = ed.getText().toString(); - if (startCall() != -1) { - _isCallActive = true; - buttonStart.setText("Stop Call"); - } - } - } - - // displayTextFromFile(); - // recordAudioToFile(); - // if(!_playFromFile) - // { - // recAudioInThread(); - // } - // playAudioInThread(); - } - }); - - final Button buttonStop = (Button) findViewById(R.id.Button02); - buttonStop.setWidth(200); - buttonStop.setText("Close app"); - buttonStop.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - - if (!_runAutotest) { - ShutdownVoE(); - } - - // This call terminates and should close the activity - finish(); - - // playAudioFromFile(); - // if(!_playFromFile) - // { - // stopRecAudio(); - // } - // stopPlayAudio(); - } - }); - - - String ap1[] = {"EC off", "AECM"}; - final ArrayAdapter adapterAp1 = new ArrayAdapter( - this, - android.R.layout.simple_spinner_dropdown_item, - ap1); - String ap2[] = - {"NS off", "NS low", "NS moderate", "NS high", - "NS very high"}; - final ArrayAdapter adapterAp2 = new ArrayAdapter( - this, - android.R.layout.simple_spinner_dropdown_item, - ap2); - String ap3[] = {"AGC off", "AGC adaptive", "AGC fixed"}; - final ArrayAdapter adapterAp3 = new ArrayAdapter( - this, - android.R.layout.simple_spinner_dropdown_item, - ap3); - String ap4[] = - {"VAD off", "VAD conventional", "VAD high rate", - "VAD mid rate", "VAD low rate"}; - final ArrayAdapter adapterAp4 = new ArrayAdapter( - this, - android.R.layout.simple_spinner_dropdown_item, - ap4); - String codecs[] = {"iSAC", "PCMU", "PCMA", "iLBC"}; - final ArrayAdapter adapterCodecs = new ArrayAdapter( - this, - android.R.layout.simple_spinner_dropdown_item, - codecs); - - final Spinner spinnerSettings1 = (Spinner) findViewById(R.id.Spinner01); - final Spinner spinnerSettings2 = (Spinner) findViewById(R.id.Spinner02); - spinnerSettings1.setMinimumWidth(200); - String settings[] = - {"Codec", "Echo Control", "Noise Suppression", - "Automatic Gain Control", - "Voice Activity Detection"}; - ArrayAdapter adapterSettings1 = new ArrayAdapter( - this, - android.R.layout.simple_spinner_dropdown_item, - settings); - spinnerSettings1.setAdapter(adapterSettings1); - spinnerSettings1.setOnItemSelectedListener( - new AdapterView.OnItemSelectedListener() { - public void onItemSelected(AdapterView adapterView, View view, - int position, long id) { - - _settingMenu = position; - _settingSet = false; - if (position == 0) { - spinnerSettings2.setAdapter(adapterCodecs); - spinnerSettings2.setSelection(_codecIndex); - } - if (position == 1) { - spinnerSettings2.setAdapter(adapterAp1); - spinnerSettings2.setSelection(_ecIndex); - } - if (position == 2) { - spinnerSettings2.setAdapter(adapterAp2); - spinnerSettings2.setSelection(_nsIndex); - } - if (position == 3) { - spinnerSettings2.setAdapter(adapterAp3); - spinnerSettings2.setSelection(_agcIndex); - } - if (position == 4) { - spinnerSettings2.setAdapter(adapterAp4); - spinnerSettings2.setSelection(_vadIndex); - } - } - - public void onNothingSelected(AdapterView adapterView) { - WebrtcLog("No setting1 selected"); - } - }); - - spinnerSettings2.setMinimumWidth(200); - ArrayAdapter adapterSettings2 = new ArrayAdapter( - this, - android.R.layout.simple_spinner_dropdown_item, - codecs); - spinnerSettings2.setAdapter(adapterSettings2); - spinnerSettings2.setOnItemSelectedListener( - new AdapterView.OnItemSelectedListener() { - public void onItemSelected(AdapterView adapterView, View view, - int position, long id) { - - // avoid unintentional setting - if (_settingSet == false) { - _settingSet = true; - return; - } - - // Change volume - if (_settingMenu == 0) { - WebrtcLog("Selected audio " + position); - setAudioProperties(position); - spinnerSettings2.setSelection(_audioIndex); - } - - // Change codec - if (_settingMenu == 1) { - _codecIndex = position; - WebrtcLog("Selected codec " + position); - if (0 != SetSendCodec(_channel, _codecIndex)) { - WebrtcLog("VoE set send codec failed"); - } - } - - // Change EC - if (_settingMenu == 2) { - boolean enable = true; - int ECmode = 5; // AECM - int AESmode = 0; - - _ecIndex = position; - WebrtcLog("Selected EC " + position); - - if (position == 0) { - enable = false; - } - if (position > 1) { - ECmode = 4; // AES - AESmode = position - 1; - } - - if (0 != SetECStatus(enable, ECmode)) { - WebrtcLog("VoE set EC status failed"); - } - } - - // Change NS - if (_settingMenu == 3) { - boolean enable = true; - - _nsIndex = position; - WebrtcLog("Selected NS " + position); - - if (position == 0) { - enable = false; - } - if (0 != SetNSStatus(enable, position + 2)) { - WebrtcLog("VoE set NS status failed"); - } - } - - // Change AGC - if (_settingMenu == 4) { - boolean enable = true; - - _agcIndex = position; - WebrtcLog("Selected AGC " + position); - - if (position == 0) { - enable = false; - position = 1; // default - } - if (0 != SetAGCStatus(enable, position + 2)) { - WebrtcLog("VoE set AGC status failed"); - } - } - - // Change VAD - if (_settingMenu == 5) { - boolean enable = true; - - _vadIndex = position; - WebrtcLog("Selected VAD " + position); - - if (position == 0) { - enable = false; - position++; - } - if (0 != SetVADStatus(_channel, enable, position - 1)) { - WebrtcLog("VoE set VAD status failed"); - } - } - } - - public void onNothingSelected(AdapterView adapterView) { - } - }); - - // Setup VoiceEngine - if (!_runAutotest && !useNativeThread) SetupVoE(); - - // Suggest to use the voice call audio stream for hardware volume - // controls - setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); - - // Get max Android volume and adjust default volume to map exactly to an - // Android level - AudioManager am = - (AudioManager) getSystemService(Context.AUDIO_SERVICE); - _maxVolume = am.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL); - if (_maxVolume <= 0) { - WebrtcLog("Could not get max volume!"); - } else { - int androidVolumeLevel = (_volumeLevel * _maxVolume) / 255; - _volumeLevel = (androidVolumeLevel * 255) / _maxVolume; - } - - WebrtcLog("Started Webrtc Android Test"); - } - - // Will be called when activity is shutdown. - // NOTE: Activity may be killed without this function being called, - // but then we should not need to clean up. - protected void onDestroy() { - super.onDestroy(); - // ShutdownVoE(); - } - - private void SetupVoE() { - // Create VoiceEngine - Create(); // Error logging is done in native API wrapper - - // Initialize - if (0 != Init(false, false)) { - WebrtcLog("VoE init failed"); - } - - // Create channel - _channel = CreateChannel(); - if (0 != _channel) { - WebrtcLog("VoE create channel failed"); - } - - } - - private void ShutdownVoE() { - // Delete channel - if (0 != DeleteChannel(_channel)) { - WebrtcLog("VoE delete channel failed"); - } - - // Terminate - if (0 != Terminate()) { - WebrtcLog("VoE terminate failed"); - } - - // Delete VoiceEngine - Delete(); // Error logging is done in native API wrapper - } - - int startCall() { - - if (useNativeThread == true) { - - Create(); - return 0; - } - - if (enableReceive == true) { - // Set local receiver - if (0 != SetLocalReceiver(_channel, _receivePort)) { - WebrtcLog("VoE set local receiver failed"); - } - - if (0 != StartListen(_channel)) { - WebrtcLog("VoE start listen failed"); - return -1; - } - - // Route audio to earpiece - if (0 != SetLoudspeakerStatus(false)) { - WebrtcLog("VoE set louspeaker status failed"); - return -1; - } - - /* - * WebrtcLog("VoE start record now"); if (0 != - * StartRecordingPlayout(_channel, "/sdcard/singleUserDemoOut.pcm", - * false)) { WebrtcLog("VoE Recording Playout failed"); } - * WebrtcLog("VoE start Recording Playout end"); - */ - // Start playout - if (0 != StartPlayout(_channel)) { - WebrtcLog("VoE start playout failed"); - return -1; - } - - // Start playout file - // if (0 != StartPlayingFileLocally(_channel, - // "/sdcard/singleUserDemo.pcm", true)) { - // WebrtcLog("VoE start playout file failed"); - // return -1; - // } - } - - if (enableSend == true) { - if (0 != SetSendDestination(_channel, _destinationPort, - _destinationIP)) { - WebrtcLog("VoE set send destination failed"); - return -1; - } - - if (0 != SetSendCodec(_channel, _codecIndex)) { - WebrtcLog("VoE set send codec failed"); - return -1; - } - - /* - * if (0 != StartPlayingFileAsMicrophone(_channel, - * "/sdcard/singleUserDemo.pcm", true)) { - * WebrtcLog("VoE start playing file as microphone failed"); } - */ - if (0 != StartSend(_channel)) { - WebrtcLog("VoE start send failed"); - return -1; - } - - // if (0 != StartPlayingFileAsMicrophone(_channel, - // "/sdcard/singleUserDemo.pcm", true)) { - // WebrtcLog("VoE start playing file as microphone failed"); - // return -1; - // } - } - - return 0; - } - - int stopCall() { - - if (useNativeThread == true) { - - Delete(); - return 0; - } - - if (enableSend == true) { - // Stop playing file as microphone - /* - * if (0 != StopPlayingFileAsMicrophone(_channel)) { - * WebrtcLog("VoE stop playing file as microphone failed"); return - * -1; } - */ - // Stop send - if (0 != StopSend(_channel)) { - WebrtcLog("VoE stop send failed"); - return -1; - } - } - - if (enableReceive == true) { - // if (0 != StopRecordingPlayout(_channel)) { - // WebrtcLog("VoE stop Recording Playout failed"); - // } - // WebrtcLog("VoE stop Recording Playout ended"); - - // Stop listen - if (0 != StopListen(_channel)) { - WebrtcLog("VoE stop listen failed"); - return -1; - } - - // Stop playout file - // if (0 != StopPlayingFileLocally(_channel)) { - // WebrtcLog("VoE stop playout file failed"); - // return -1; - // } - - // Stop playout - if (0 != StopPlayout(_channel)) { - WebrtcLog("VoE stop playout failed"); - return -1; - } - - // Route audio to loudspeaker - if (0 != SetLoudspeakerStatus(true)) { - WebrtcLog("VoE set louspeaker status failed"); - return -1; - } - } - - return 0; - } - - int startAutoTest() { - - _autotestThread = new Thread(_autotestProc); - _autotestThread.start(); - - return 0; - } - - private Runnable _autotestProc = new Runnable() { - public void run() { - // TODO(xians): choose test from GUI - // 1 = standard, not used - // 2 = extended, 2 = base - RunAutoTest(1, 2); - } - }; - - int setAudioProperties(int val) { - - // AudioManager am = (AudioManager) - // getSystemService(Context.AUDIO_SERVICE); - - if (val == 0) { - // _streamVolume = - // am.getStreamVolume(AudioManager.STREAM_VOICE_CALL); - // am.setStreamVolume(AudioManager.STREAM_VOICE_CALL, - // (_streamVolume+1), 0); - - int androidVolumeLevel = (_volumeLevel * _maxVolume) / 255; - if (androidVolumeLevel < _maxVolume) { - _volumeLevel = ((androidVolumeLevel + 1) * 255) / _maxVolume; - if (0 != SetSpeakerVolume(_volumeLevel)) { - WebrtcLog("VoE set speaker volume failed"); - } - } - } else if (val == 1) { - // _streamVolume = - // am.getStreamVolume(AudioManager.STREAM_VOICE_CALL); - // am.setStreamVolume(AudioManager.STREAM_VOICE_CALL, - // (_streamVolume-1), 0); - - int androidVolumeLevel = (_volumeLevel * _maxVolume) / 255; - if (androidVolumeLevel > 0) { - _volumeLevel = ((androidVolumeLevel - 1) * 255) / _maxVolume; - if (0 != SetSpeakerVolume(_volumeLevel)) { - WebrtcLog("VoE set speaker volume failed"); - } - } - } else if (val == 2) { - // route audio to back speaker - if (0 != SetLoudspeakerStatus(true)) { - WebrtcLog("VoE set loudspeaker status failed"); - } - _audioIndex = 2; - } else if (val == 3) { - // route audio to earpiece - if (0 != SetLoudspeakerStatus(false)) { - WebrtcLog("VoE set loudspeaker status failed"); - } - _audioIndex = 3; - } - - return 0; - } - - int displayTextFromFile() { - - TextView tv = (TextView) findViewById(R.id.TextView01); - FileReader fr = null; - char[] fileBuffer = new char[64]; - - try { - fr = new FileReader("/sdcard/test.txt"); - } catch (FileNotFoundException e) { - e.printStackTrace(); - tv.setText("File not found!"); - } - - try { - fr.read(fileBuffer); - } catch (IOException e) { - e.printStackTrace(); - } - - String readString = new String(fileBuffer); - tv.setText(readString); - // setContentView(tv); - - return 0; - } - - int recordAudioToFile() { - File fr = null; - // final to be reachable within onPeriodicNotification - byte[] recBuffer = new byte[320]; - - int recBufSize = - AudioRecord.getMinBufferSize(16000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT); - AudioRecord rec = - new AudioRecord(MediaRecorder.AudioSource.MIC, 16000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT, - recBufSize); - - fr = new File("/sdcard/record.pcm"); - FileOutputStream out = null; - try { - out = new FileOutputStream(fr); - } catch (FileNotFoundException e1) { - e1.printStackTrace(); - } - - // start recording - try { - rec.startRecording(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - - for (int i = 0; i < 550; i++) { - // note, there is a short version of write as well! - int wrBytes = rec.read(recBuffer, 0, 320); - - try { - out.write(recBuffer); - } catch (IOException e) { - e.printStackTrace(); - } - } - - // stop playout - try { - rec.stop(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - - return 0; - } - - int playAudioFromFile() { - - File fr = null; - // final to be reachable within onPeriodicNotification - // final byte[] playBuffer = new byte [320000]; - // final to be reachable within onPeriodicNotification - final byte[] playBuffer = new byte[320]; - - final int playBufSize = - AudioTrack.getMinBufferSize(16000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT); - // final int playBufSize = 1920; // 100 ms buffer - // byte[] playBuffer = new byte [playBufSize]; - final AudioTrack play = - new AudioTrack(AudioManager.STREAM_VOICE_CALL, 16000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT, - playBufSize, AudioTrack.MODE_STREAM); - - // implementation of the playpos callback functions - play.setPlaybackPositionUpdateListener( - new AudioTrack.OnPlaybackPositionUpdateListener() { - - int count = 0; - - public void onPeriodicNotification(AudioTrack track) { - // int wrBytes = play.write(playBuffer, count, 320); - count += 320; - } - - public void onMarkerReached(AudioTrack track) { - - } - }); - - // set the notification period = 160 samples - // int ret = play.setPositionNotificationPeriod(160); - - fr = new File("/sdcard/record.pcm"); - FileInputStream in = null; - try { - in = new FileInputStream(fr); - } catch (FileNotFoundException e1) { - e1.printStackTrace(); - } - - // try { - // in.read(playBuffer); - // } catch (IOException e) { - // e.printStackTrace(); - // } - - // play all at once - // int wrBytes = play.write(playBuffer, 0, 320000); - - - // start playout - try { - play.play(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - - // returns the number of samples that has been written - // int headPos = play.getPlaybackHeadPosition(); - - // play with multiple writes - for (int i = 0; i < 500; i++) { - try { - in.read(playBuffer); - } catch (IOException e) { - e.printStackTrace(); - } - - - // note, there is a short version of write as well! - int wrBytes = play.write(playBuffer, 0, 320); - - Log.d("testWrite", "wrote"); - } - - // stop playout - try { - play.stop(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - - return 0; - } - - int playAudioInThread() { - - if (_isRunningPlay) { - return 0; - } - - // File fr = null; - // final byte[] playBuffer = new byte[320]; - if (_playFromFile) { - _playBuffer = new byte[320]; - } else { - // reset index - _playIndex = 0; - } - // within - // onPeriodicNotification - - // Log some info (static) - WebrtcLog("Creating AudioTrack object"); - final int minPlayBufSize = - AudioTrack.getMinBufferSize(16000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT); - WebrtcLog("Min play buf size = " + minPlayBufSize); - WebrtcLog("Min volume = " + AudioTrack.getMinVolume()); - WebrtcLog("Max volume = " + AudioTrack.getMaxVolume()); - WebrtcLog("Native sample rate = " - + AudioTrack.getNativeOutputSampleRate( - AudioManager.STREAM_VOICE_CALL)); - - final int playBufSize = minPlayBufSize; // 3200; // 100 ms buffer - // byte[] playBuffer = new byte [playBufSize]; - try { - _at = new AudioTrack( - AudioManager.STREAM_VOICE_CALL, - 16000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT, - playBufSize, AudioTrack.MODE_STREAM); - } catch (Exception e) { - WebrtcLog(e.getMessage()); - } - - // Log some info (non-static) - WebrtcLog("Notification marker pos = " - + _at.getNotificationMarkerPosition()); - WebrtcLog("Play head pos = " + _at.getPlaybackHeadPosition()); - WebrtcLog("Pos notification dt = " - + _at.getPositionNotificationPeriod()); - WebrtcLog("Playback rate = " + _at.getPlaybackRate()); - WebrtcLog("Sample rate = " + _at.getSampleRate()); - - // implementation of the playpos callback functions - // _at.setPlaybackPositionUpdateListener( - // new AudioTrack.OnPlaybackPositionUpdateListener() { - // - // int count = 3200; - // - // public void onPeriodicNotification(AudioTrack track) { - // // int wrBytes = play.write(playBuffer, count, 320); - // count += 320; - // } - // - // public void onMarkerReached(AudioTrack track) { - // } - // }); - - // set the notification period = 160 samples - // int ret = _at.setPositionNotificationPeriod(160); - - if (_playFromFile) { - _fr = new File("/sdcard/singleUserDemo.pcm"); - try { - _in = new FileInputStream(_fr); - } catch (FileNotFoundException e1) { - e1.printStackTrace(); - } - } - - // try { - // in.read(playBuffer); - // } catch (IOException e) { - // e.printStackTrace(); - // } - - _isRunningPlay = true; - - // buffer = new byte[3200]; - _playThread = new Thread(_playProc); - // ar.startRecording(); - // bytesRead = 3200; - // recording = true; - _playThread.start(); - - return 0; - } - - int stopPlayAudio() { - if (!_isRunningPlay) { - return 0; - } - - _isRunningPlay = false; - - return 0; - } - - private Runnable _playProc = new Runnable() { - public void run() { - - // set high thread priority - android.os.Process.setThreadPriority( - android.os.Process.THREAD_PRIORITY_URGENT_AUDIO); - - // play all at once - // int wrBytes = play.write(playBuffer, 0, 320000); - - // fill the buffer - // play.write(playBuffer, 0, 3200); - - // play.flush(); - - // start playout - try { - _at.play(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - - // play with multiple writes - int i = 0; - for (; i < 3000 && _isRunningPlay; i++) { - - if (_playFromFile) { - try { - _in.read(_playBuffer); - } catch (IOException e) { - e.printStackTrace(); - } - - int wrBytes = _at.write(_playBuffer, 0 /* i * 320 */, 320); - } else { - int wrSamples = - _at.write(_circBuffer, _playIndex * 160, - 160); - - // WebrtcLog("Played 10 ms from buffer, _playIndex = " + - // _playIndex); - // WebrtcLog("Diff = " + (_recIndex - _playIndex)); - - if (_playIndex == 49) { - _playIndex = 0; - } else { - _playIndex += 1; - } - } - - // WebrtcLog("Wrote 10 ms to buffer, head = " - // + _at.getPlaybackHeadPosition()); - } - - // stop playout - try { - _at.stop(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - - // returns the number of samples that has been written - WebrtcLog("Test stopped, i = " + i + ", head = " - + _at.getPlaybackHeadPosition()); - int headPos = _at.getPlaybackHeadPosition(); - - // flush the buffers - _at.flush(); - - // release the object - _at.release(); - _at = null; - - // try { - // Thread.sleep() must be within a try - catch block - // Thread.sleep(3000); - // }catch (Exception e){ - // System.out.println(e.getMessage()); - // } - - _isRunningPlay = false; - - } - }; - - int recAudioInThread() { - - if (_isRunningRec) { - return 0; - } - - // within - // onPeriodicNotification - - // reset index - _recIndex = 20; - - // Log some info (static) - WebrtcLog("Creating AudioRecord object"); - final int minRecBufSize = AudioRecord.getMinBufferSize(16000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT); - WebrtcLog("Min rec buf size = " + minRecBufSize); - // WebrtcLog("Min volume = " + AudioTrack.getMinVolume()); - // WebrtcLog("Max volume = " + AudioTrack.getMaxVolume()); - // WebrtcLog("Native sample rate = " - // + AudioRecord - // .getNativeInputSampleRate(AudioManager.STREAM_VOICE_CALL)); - - final int recBufSize = minRecBufSize; // 3200; // 100 ms buffer - try { - _ar = new AudioRecord( - MediaRecorder.AudioSource.MIC, - 16000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT, - recBufSize); - } catch (Exception e) { - WebrtcLog(e.getMessage()); - } - - // Log some info (non-static) - WebrtcLog("Notification marker pos = " - + _ar.getNotificationMarkerPosition()); - // WebrtcLog("Play head pos = " + _ar.getRecordHeadPosition()); - WebrtcLog("Pos notification dt rec= " - + _ar.getPositionNotificationPeriod()); - // WebrtcLog("Playback rate = " + _ar.getRecordRate()); - // WebrtcLog("Playback rate = " + _ar.getPlaybackRate()); - WebrtcLog("Sample rate = " + _ar.getSampleRate()); - // WebrtcLog("Playback rate = " + _ar.getPlaybackRate()); - // WebrtcLog("Playback rate = " + _ar.getPlaybackRate()); - - _isRunningRec = true; - - _recThread = new Thread(_recProc); - - _recThread.start(); - - return 0; - } - - int stopRecAudio() { - if (!_isRunningRec) { - return 0; - } - - _isRunningRec = false; - - return 0; - } - - private Runnable _recProc = new Runnable() { - public void run() { - - // set high thread priority - android.os.Process.setThreadPriority( - android.os.Process.THREAD_PRIORITY_URGENT_AUDIO); - - // start recording - try { - _ar.startRecording(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - - // keep recording to circular buffer - // for a while - int i = 0; - int rdSamples = 0; - short[] tempBuffer = new short[160]; // Only used for native case - - for (; i < 3000 && _isRunningRec; i++) { - if (_runThroughNativeLayer) { - rdSamples = _ar.read(tempBuffer, 0, 160); - // audioLoop(tempBuffer, 160); // Insert into native layer - } else { - rdSamples = _ar.read(_circBuffer, _recIndex * 160, 160); - - // WebrtcLog("Recorded 10 ms to buffer, _recIndex = " + - // _recIndex); - // WebrtcLog("rdSamples = " + rdSamples); - - if (_recIndex == 49) { - _recIndex = 0; - } else { - _recIndex += 1; - } - } - } - - // stop recording - try { - _ar.stop(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - - // release the object - _ar.release(); - _ar = null; - - // try { - // Thread.sleep() must be within a try - catch block - // Thread.sleep(3000); - // }catch (Exception e){ - // System.out.println(e.getMessage()); - // } - - _isRunningRec = false; - - // returns the number of samples that has been written - // WebrtcLog("Test stopped, i = " + i + ", head = " - // + _at.getPlaybackHeadPosition()); - // int headPos = _at.getPlaybackHeadPosition(); - } - }; - - private void WebrtcLog(String msg) { - Log.d("*Webrtc*", msg); - } - - // //////////////// Native function prototypes //////////////////// - - private native static boolean NativeInit(); - - private native int RunAutoTest(int testType, int extendedSel); - - private native boolean Create(); - - private native boolean Delete(); - - private native int Init(boolean enableTrace, boolean useExtTrans); - - private native int Terminate(); - - private native int CreateChannel(); - - private native int DeleteChannel(int channel); - - private native int SetLocalReceiver(int channel, int port); - - private native int SetSendDestination(int channel, int port, - String ipaddr); - - private native int StartListen(int channel); - - private native int StartPlayout(int channel); - - private native int StartSend(int channel); - - private native int StopListen(int channel); - - private native int StopPlayout(int channel); - - private native int StopSend(int channel); - - private native int StartPlayingFileLocally(int channel, String fileName, - boolean loop); - - private native int StopPlayingFileLocally(int channel); - - private native int StartRecordingPlayout(int channel, String fileName, - boolean loop); - - private native int StopRecordingPlayout(int channel); - - private native int StartPlayingFileAsMicrophone(int channel, - String fileName, boolean loop); - - private native int StopPlayingFileAsMicrophone(int channel); - - private native int NumOfCodecs(); - - private native int SetSendCodec(int channel, int index); - - private native int SetVADStatus(int channel, boolean enable, int mode); - - private native int SetNSStatus(boolean enable, int mode); - - private native int SetAGCStatus(boolean enable, int mode); - - private native int SetECStatus(boolean enable, int mode); - - private native int SetSpeakerVolume(int volume); - - private native int SetLoudspeakerStatus(boolean enable); - - /* - * this is used to load the 'webrtc-voice-demo-jni' - * library on application startup. - * The library has already been unpacked into - * /data/data/webrtc.android.AndroidTest/lib/libwebrtc-voice-demo-jni.so - * at installation time by the package manager. - */ - static { - Log.d("*Webrtc*", "Loading webrtc-voice-demo-jni..."); - System.loadLibrary("webrtc-voice-demo-jni"); - - Log.d("*Webrtc*", "Calling native init..."); - if (!NativeInit()) { - Log.e("*Webrtc*", "Native init failed"); - throw new RuntimeException("Native init failed"); - } else { - Log.d("*Webrtc*", "Native init successful"); - } - } -}