diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp index 1c97f0f0a4..29f2900c44 100755 --- a/talk/libjingle.gyp +++ b/talk/libjingle.gyp @@ -144,10 +144,10 @@ 'app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java', 'app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java', 'app/webrtc/java/src/org/webrtc/VideoCapturerAndroid.java', - '<(webrtc_modules_dir)/audio_device/android/java/src/org/webrtc/voiceengine/AudioManagerAndroid.java', '<(webrtc_modules_dir)/video_render/android/java/src/org/webrtc/videoengine/ViEAndroidGLES20.java', '<(webrtc_modules_dir)/video_render/android/java/src/org/webrtc/videoengine/ViERenderer.java', '<(webrtc_modules_dir)/video_render/android/java/src/org/webrtc/videoengine/ViESurfaceRenderer.java', + '<(webrtc_modules_dir)/audio_device/android/java/src/org/webrtc/voiceengine/BuildInfo.java', '<(webrtc_modules_dir)/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java', '<(webrtc_modules_dir)/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java', '<(webrtc_modules_dir)/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java', diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index 893dd9f39a..2c1fafbaef 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -55,9 +55,6 @@ config("common_inherited_config") { "WEBRTC_LINUX", "WEBRTC_ANDROID", ] - if (rtc_enable_android_opensl) { - defines += [ "WEBRTC_ANDROID_OPENSLES" ] - } } } diff --git a/webrtc/build/common.gypi b/webrtc/build/common.gypi index 2d7d9854dd..e1ef419bf2 100644 --- a/webrtc/build/common.gypi +++ b/webrtc/build/common.gypi @@ -363,11 +363,6 @@ 'WEBRTC_ANDROID', ], 'conditions': [ - ['enable_android_opensl==1', { - 'defines': [ - 'WEBRTC_ANDROID_OPENSLES', - ], - }], ['clang!=1', { # The Android NDK doesn't provide optimized versions of these # functions. Ensure they are disabled for all compilers. @@ -431,13 +426,6 @@ 'WEBRTC_LINUX', 'WEBRTC_ANDROID', ], - 'conditions': [ - ['enable_android_opensl==1', { - 'defines': [ - 'WEBRTC_ANDROID_OPENSLES', - ], - }] - ], }], ['os_posix==1', { # For access to standard POSIXish features, use WEBRTC_POSIX instead diff --git a/webrtc/examples/android/opensl_loopback/AndroidManifest.xml b/webrtc/examples/android/opensl_loopback/AndroidManifest.xml deleted file mode 100644 index 3d32a7afcd..0000000000 --- a/webrtc/examples/android/opensl_loopback/AndroidManifest.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/webrtc/examples/android/opensl_loopback/README b/webrtc/examples/android/opensl_loopback/README deleted file mode 100644 index 59f6de9dbb..0000000000 --- a/webrtc/examples/android/opensl_loopback/README +++ /dev/null @@ -1,23 +0,0 @@ -This directory contains an app for measuring the total delay from the native -OpenSL implementation. Note that it just loops audio back from mic to speakers. - -Prerequisites: -- Make sure gclient is checking out tools necessary to target Android: your - .gclient file should contain a line like: - target_os = ['android'] - Make sure to re-run gclient sync after adding this to download the tools. -- Env vars need to be set up to target Android; easiest way to do this is to run - (from the libjingle trunk directory): - . ./build/android/envsetup.sh - Note that this clobbers any previously-set $GYP_DEFINES so it must be done - before the next item. -- Set up webrtc-related GYP variables: - export GYP_DEFINES="$GYP_DEFINES java_home= - enable_android_opensl=1" -- Finally, run "gclient runhooks" to generate Android-targeting .ninja files. - -Example of building & using the app: - -cd /trunk -ninja -C out/Debug OpenSlDemo -adb install -r out/Debug/OpenSlDemo-debug.apk \ No newline at end of file diff --git a/webrtc/examples/android/opensl_loopback/build.xml b/webrtc/examples/android/opensl_loopback/build.xml deleted file mode 100644 index b6e033a6a8..0000000000 --- a/webrtc/examples/android/opensl_loopback/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/webrtc/examples/android/opensl_loopback/fake_audio_device_buffer.cc b/webrtc/examples/android/opensl_loopback/fake_audio_device_buffer.cc deleted file mode 100644 index 116521e695..0000000000 --- a/webrtc/examples/android/opensl_loopback/fake_audio_device_buffer.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2013 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 "webrtc/examples/android/opensl_loopback/fake_audio_device_buffer.h" - -#include - -#include "webrtc/modules/audio_device/android/opensles_common.h" -#include "webrtc/modules/audio_device/android/audio_common.h" - -namespace webrtc { - -FakeAudioDeviceBuffer::FakeAudioDeviceBuffer() - : fifo_(kNumBuffers), - next_available_buffer_(0), - record_channels_(0), - play_channels_(0) { - buf_.reset(new rtc::scoped_ptr[kNumBuffers]); - for (int i = 0; i < kNumBuffers; ++i) { - buf_[i].reset(new int8_t[buffer_size_bytes()]); - } -} - -int32_t FakeAudioDeviceBuffer::SetRecordingSampleRate(uint32_t fsHz) { - assert(static_cast(fsHz) == sample_rate()); - return 0; -} - -int32_t FakeAudioDeviceBuffer::SetPlayoutSampleRate(uint32_t fsHz) { - assert(static_cast(fsHz) == sample_rate()); - return 0; -} - -int32_t FakeAudioDeviceBuffer::SetRecordingChannels(uint8_t channels) { - assert(channels > 0); - record_channels_ = channels; - assert((play_channels_ == 0) || - (record_channels_ == play_channels_)); - return 0; -} - -int32_t FakeAudioDeviceBuffer::SetPlayoutChannels(uint8_t channels) { - assert(channels > 0); - play_channels_ = channels; - assert((record_channels_ == 0) || - (record_channels_ == play_channels_)); - return 0; -} - -int32_t FakeAudioDeviceBuffer::SetRecordedBuffer(const void* audioBuffer, - uint32_t nSamples) { - assert(audioBuffer); - assert(fifo_.size() < fifo_.capacity()); - assert(nSamples == kDefaultBufSizeInSamples); - int8_t* buffer = buf_[next_available_buffer_].get(); - next_available_buffer_ = (next_available_buffer_ + 1) % kNumBuffers; - memcpy(buffer, audioBuffer, nSamples * sizeof(int16_t)); - fifo_.Push(buffer); - return 0; -} - -int32_t FakeAudioDeviceBuffer::RequestPlayoutData(uint32_t nSamples) { - assert(nSamples == kDefaultBufSizeInSamples); - return 0; -} - -int32_t FakeAudioDeviceBuffer::GetPlayoutData(void* audioBuffer) { - assert(audioBuffer); - if (fifo_.size() < 1) { - // Playout silence until there is data available. - memset(audioBuffer, 0, buffer_size_bytes()); - return buffer_size_samples(); - } - int8_t* buffer = fifo_.Pop(); - memcpy(audioBuffer, buffer, buffer_size_bytes()); - return buffer_size_samples(); -} - -int FakeAudioDeviceBuffer::sample_rate() const { - return audio_manager_.low_latency_supported() ? - audio_manager_.native_output_sample_rate() : kDefaultSampleRate; -} - -int FakeAudioDeviceBuffer::buffer_size_samples() const { - return sample_rate() * 10 / 1000; -} - -int FakeAudioDeviceBuffer::buffer_size_bytes() const { - return buffer_size_samples() * kNumChannels * sizeof(int16_t); -} - - -void FakeAudioDeviceBuffer::ClearBuffer() { - while (fifo_.size() != 0) { - fifo_.Pop(); - } - next_available_buffer_ = 0; -} - -} // namespace webrtc diff --git a/webrtc/examples/android/opensl_loopback/fake_audio_device_buffer.h b/webrtc/examples/android/opensl_loopback/fake_audio_device_buffer.h deleted file mode 100644 index f5442ee00b..0000000000 --- a/webrtc/examples/android/opensl_loopback/fake_audio_device_buffer.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013 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_EXAMPLES_ANDROID_OPENSL_LOOPBACK_FAKE_AUDIO_DEVICE_BUFFER_H_ -#define WEBRTC_EXAMPLES_ANDROID_OPENSL_LOOPBACK_FAKE_AUDIO_DEVICE_BUFFER_H_ - -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/modules/audio_device/android/audio_manager_jni.h" -#include "webrtc/modules/audio_device/android/single_rw_fifo.h" -#include "webrtc/modules/audio_device/audio_device_buffer.h" - -namespace webrtc { - -// Fake AudioDeviceBuffer implementation that returns audio data that is pushed -// to it. It implements all APIs used by the OpenSL implementation. -class FakeAudioDeviceBuffer : public AudioDeviceBuffer { - public: - FakeAudioDeviceBuffer(); - virtual ~FakeAudioDeviceBuffer() {} - - virtual int32_t SetRecordingSampleRate(uint32_t fsHz); - virtual int32_t SetPlayoutSampleRate(uint32_t fsHz); - virtual int32_t SetRecordingChannels(uint8_t channels); - virtual int32_t SetPlayoutChannels(uint8_t channels); - virtual int32_t SetRecordedBuffer(const void* audioBuffer, - uint32_t nSamples); - virtual void SetVQEData(int playDelayMS, - int recDelayMS, - int clockDrift) {} - virtual int32_t DeliverRecordedData() { return 0; } - virtual int32_t RequestPlayoutData(uint32_t nSamples); - virtual int32_t GetPlayoutData(void* audioBuffer); - - void ClearBuffer(); - - private: - enum { - // Each buffer contains 10 ms of data since that is what OpenSlesInput - // delivers. Keep 7 buffers which would cover 70 ms of data. These buffers - // are needed because of jitter between OpenSl recording and playing. - kNumBuffers = 7, - }; - int sample_rate() const; - int buffer_size_samples() const; - int buffer_size_bytes() const; - - // Java API handle - AudioManagerJni audio_manager_; - - SingleRwFifo fifo_; - rtc::scoped_ptr[]> buf_; - int next_available_buffer_; - - uint8_t record_channels_; - uint8_t play_channels_; -}; - -} // namespace webrtc - -#endif // WEBRTC_EXAMPLES_ANDROID_OPENSL_LOOPBACK_FAKE_AUDIO_DEVICE_BUFFER_H_ diff --git a/webrtc/examples/android/opensl_loopback/jni/opensl_runner.cc b/webrtc/examples/android/opensl_loopback/jni/opensl_runner.cc deleted file mode 100644 index 3b201a7cdf..0000000000 --- a/webrtc/examples/android/opensl_loopback/jni/opensl_runner.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2013 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 "webrtc/base/scoped_ptr.h" -#include "webrtc/examples/android/opensl_loopback/fake_audio_device_buffer.h" -#include "webrtc/modules/audio_device/android/audio_device_template.h" -#include "webrtc/modules/audio_device/android/audio_record_jni.h" -#include "webrtc/modules/audio_device/android/audio_track_jni.h" -#include "webrtc/modules/audio_device/android/opensles_input.h" -#include "webrtc/modules/audio_device/android/opensles_output.h" - -// Java globals -static JavaVM* g_vm = NULL; -static jclass g_osr = NULL; - -namespace webrtc { - -template -class OpenSlRunnerTemplate { - public: - OpenSlRunnerTemplate() - : output_(NULL), // TODO(henrika): inject proper audio manager. - input_(&output_, NULL) { - output_.AttachAudioBuffer(&audio_buffer_); - if (output_.Init() != 0) { - assert(false); - } - if (output_.InitPlayout() != 0) { - assert(false); - } - input_.AttachAudioBuffer(&audio_buffer_); - if (input_.Init() != 0) { - assert(false); - } - if (input_.InitRecording() != 0) { - assert(false); - } - } - - ~OpenSlRunnerTemplate() {} - - void StartPlayRecord() { - output_.StartPlayout(); - input_.StartRecording(); - } - - void StopPlayRecord() { - // There are large enough buffers to compensate for recording and playing - // jitter such that the timing of stopping playing or recording should not - // result in over or underrun. - input_.StopRecording(); - output_.StopPlayout(); - audio_buffer_.ClearBuffer(); - } - - private: - OutputType output_; - InputType input_; - FakeAudioDeviceBuffer audio_buffer_; -}; - -class OpenSlRunner - : public OpenSlRunnerTemplate { - public: - // Global class implementing native code. - static OpenSlRunner* g_runner; - - - OpenSlRunner() {} - virtual ~OpenSlRunner() {} - - static JNIEXPORT void JNICALL RegisterApplicationContext( - JNIEnv* env, - jobject obj, - jobject context) { - assert(!g_runner); // Should only be called once. - OpenSlesInput::SetAndroidAudioDeviceObjects(g_vm, context); - OpenSlesOutput::SetAndroidAudioDeviceObjects(g_vm, context); - g_runner = new OpenSlRunner(); - } - - static JNIEXPORT void JNICALL Start(JNIEnv * env, jobject) { - g_runner->StartPlayRecord(); - } - - static JNIEXPORT void JNICALL Stop(JNIEnv * env, jobject) { - g_runner->StopPlayRecord(); - } -}; - -OpenSlRunner* OpenSlRunner::g_runner = NULL; - -} // namespace webrtc - -jint JNI_OnLoad(JavaVM* vm, void* reserved) { - // Only called once. - assert(!g_vm); - JNIEnv* env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { - return -1; - } - - jclass local_osr = env->FindClass("org/webrtc/app/OpenSlRunner"); - assert(local_osr != NULL); - g_osr = static_cast(env->NewGlobalRef(local_osr)); - JNINativeMethod nativeFunctions[] = { - {"RegisterApplicationContext", "(Landroid/content/Context;)V", - reinterpret_cast( - &webrtc::OpenSlRunner::RegisterApplicationContext)}, - {"Start", "()V", reinterpret_cast(&webrtc::OpenSlRunner::Start)}, - {"Stop", "()V", reinterpret_cast(&webrtc::OpenSlRunner::Stop)} - }; - int ret_val = env->RegisterNatives(g_osr, nativeFunctions, 3); - if (ret_val != 0) { - assert(false); - } - g_vm = vm; - return JNI_VERSION_1_6; -} diff --git a/webrtc/examples/android/opensl_loopback/project.properties b/webrtc/examples/android/opensl_loopback/project.properties deleted file mode 100644 index a6ca533fe3..0000000000 --- a/webrtc/examples/android/opensl_loopback/project.properties +++ /dev/null @@ -1,16 +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 edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-22 - -java.compilerargs=-Xlint:all -Werror diff --git a/webrtc/examples/android/opensl_loopback/res/drawable/logo.png b/webrtc/examples/android/opensl_loopback/res/drawable/logo.png deleted file mode 100644 index a07c69fa5a..0000000000 Binary files a/webrtc/examples/android/opensl_loopback/res/drawable/logo.png and /dev/null differ diff --git a/webrtc/examples/android/opensl_loopback/res/layout/open_sl_demo.xml b/webrtc/examples/android/opensl_loopback/res/layout/open_sl_demo.xml deleted file mode 100644 index 1efad73366..0000000000 --- a/webrtc/examples/android/opensl_loopback/res/layout/open_sl_demo.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - -