And also revert https://codereview.webrtc.org/2888093005/ (Chromium roll) which has a dependency on 2889183002

BUG=webrtc:7707

Review-Url: https://codereview.webrtc.org/2897423002
Cr-Commit-Position: refs/heads/master@{#18263}
This commit is contained in:
lliuu
2017-05-24 16:45:57 -07:00
committed by Commit bot
parent b8c926b141
commit 548cdce7bc
18 changed files with 67 additions and 202 deletions

37
DEPS
View File

@ -2,7 +2,7 @@
vars = { vars = {
'chromium_git': 'https://chromium.googlesource.com', 'chromium_git': 'https://chromium.googlesource.com',
'chromium_revision': 'c1878a272a87bd797949717bebdfdbc1e6f0c143', 'chromium_revision': 'b4155a0bbd8b968baa44f8c9656e86e351b4e50a',
'boringssl_git': 'https://boringssl.googlesource.com', 'boringssl_git': 'https://boringssl.googlesource.com',
# Three lines of non-changing comments so that # Three lines of non-changing comments so that
# the commit queue can handle CLs rolling swarming_client # the commit queue can handle CLs rolling swarming_client
@ -15,7 +15,7 @@ vars = {
# Three lines of non-changing comments so that # Three lines of non-changing comments so that
# the commit queue can handle CLs rolling BoringSSL # the commit queue can handle CLs rolling BoringSSL
# and whatever else without interference from each other. # and whatever else without interference from each other.
'boringssl_revision': '467d3220f86c2fd26107783f1e3762ba5ecad9da', 'boringssl_revision': '1e5cb820de99c754b57ab4321e1456ac6bdc1a78',
# Three lines of non-changing comments so that # Three lines of non-changing comments so that
# the commit queue can handle CLs rolling lss # the commit queue can handle CLs rolling lss
# and whatever else without interference from each other. # and whatever else without interference from each other.
@ -23,26 +23,25 @@ vars = {
# Three lines of non-changing comments so that # Three lines of non-changing comments so that
# the commit queue can handle CLs rolling catapult # the commit queue can handle CLs rolling catapult
# and whatever else without interference from each other. # and whatever else without interference from each other.
'catapult_revision': '6bd7ec034804d7ece286366393fab685e91595c1', 'catapult_revision': '9e7bc18ce70595be32d8534b4309aff83ac78434',
# Three lines of non-changing comments so that # Three lines of non-changing comments so that
# the commit queue can handle CLs rolling libFuzzer # the commit queue can handle CLs rolling libFuzzer
# and whatever else without interference from each other. # and whatever else without interference from each other.
'libfuzzer_revision': '16f5f743c188c836d32cdaf349d5d3effb8a3518', 'libfuzzer_revision': '16f5f743c188c836d32cdaf349d5d3effb8a3518',
} }
deps = { deps = {
# TODO(kjellander): Move this to be Android-only once the libevent dependency # TODO(kjellander): Move this to be Android-only once the libevent dependency
# in base/third_party/libevent is solved. # in base/third_party/libevent is solved.
'src/base': 'src/base':
Var('chromium_git') + '/chromium/src/base' + '@' + 'b05612a7f430f5cd0573b35a151a0cd013b20ded', Var('chromium_git') + '/chromium/src/base' + '@' + '4545fc1f631d4259ee10a9b2972160831cd08a53',
'src/build': 'src/build':
Var('chromium_git') + '/chromium/src/build' + '@' + '4763c94e5e5696e8db6a755c163ff251de728348', Var('chromium_git') + '/chromium/src/build' + '@' + 'f671d3baeb64d9dba628ad582e867cf1aebc0207',
'src/buildtools': 'src/buildtools':
Var('chromium_git') + '/chromium/buildtools.git' + '@' + '98f00fa10dbad2cdbb2e297a66c3d6d5bc3994f3', Var('chromium_git') + '/chromium/buildtools.git' + '@' + '98f00fa10dbad2cdbb2e297a66c3d6d5bc3994f3',
'src/testing': 'src/testing':
Var('chromium_git') + '/chromium/src/testing' + '@' + '5fef37b05e0b251bfa7bd428405a4db9c5957139', Var('chromium_git') + '/chromium/src/testing' + '@' + 'dbbebc0d545834b83dbacf6b20188c7ed2ba45fe',
'src/third_party': 'src/third_party':
Var('chromium_git') + '/chromium/src/third_party' + '@' + '9577054f45a7102b259c16560ea22191893b9bb6', Var('chromium_git') + '/chromium/src/third_party' + '@' + '744b88f9a83ead5dd946581462acd3c8b289113a',
'src/third_party/boringssl/src': 'src/third_party/boringssl/src':
Var('boringssl_git') + '/boringssl.git' + '@' + Var('boringssl_revision'), Var('boringssl_git') + '/boringssl.git' + '@' + Var('boringssl_revision'),
'src/third_party/catapult': 'src/third_party/catapult':
@ -52,20 +51,18 @@ deps = {
'src/third_party/ffmpeg': 'src/third_party/ffmpeg':
Var('chromium_git') + '/chromium/third_party/ffmpeg.git' + '@' + '28a5cdde5c32bcf66715343c10f74e85713f7aaf', Var('chromium_git') + '/chromium/third_party/ffmpeg.git' + '@' + '28a5cdde5c32bcf66715343c10f74e85713f7aaf',
'src/third_party/googletest/src': 'src/third_party/googletest/src':
Var('chromium_git') + '/external/github.com/google/googletest.git' + '@' + '42bc671f47b122fad36db5eccbc06868afdf7862', Var('chromium_git') + '/external/github.com/google/googletest.git' + '@' + '8c7f93fedaca1b0158e67af0f5dd63a044066eab',
'src/third_party/jsoncpp/source': 'src/third_party/jsoncpp/source':
Var('chromium_git') + '/external/github.com/open-source-parsers/jsoncpp.git' + '@' + 'f572e8e42e22cfcf5ab0aea26574f408943edfa4', # from svn 248 Var('chromium_git') + '/external/github.com/open-source-parsers/jsoncpp.git' + '@' + 'f572e8e42e22cfcf5ab0aea26574f408943edfa4', # from svn 248
# Used for building libFuzzers (only supports Linux). # Used for building libFuzzers (only supports Linux).
'src/third_party/libFuzzer/src': 'src/third_party/libFuzzer/src':
Var('chromium_git') + '/chromium/llvm-project/llvm/lib/Fuzzer.git' + '@' + Var('libfuzzer_revision'), Var('chromium_git') + '/chromium/llvm-project/llvm/lib/Fuzzer.git' + '@' + Var('libfuzzer_revision'),
'src/third_party/libjpeg_turbo': 'src/third_party/libjpeg_turbo':
Var('chromium_git') + '/chromium/deps/libjpeg_turbo.git' + '@' + 'a1750dbc79a8792dde3d3f7d7d8ac28ba01ac9dd', Var('chromium_git') + '/chromium/deps/libjpeg_turbo.git' + '@' + 'a1750dbc79a8792dde3d3f7d7d8ac28ba01ac9dd',
'src/third_party/libsrtp': 'src/third_party/libsrtp':
Var('chromium_git') + '/chromium/deps/libsrtp.git' + '@' + 'ccf84786f8ef803cb9c75e919e5a3976b9f5a672', Var('chromium_git') + '/chromium/deps/libsrtp.git' + '@' + 'ccf84786f8ef803cb9c75e919e5a3976b9f5a672',
'src/third_party/libvpx/source/libvpx': 'src/third_party/libvpx/source/libvpx':
Var('chromium_git') + '/webm/libvpx.git' + '@' + 'b3bf91bdc60220c004a22d21c867cc392e684b81', Var('chromium_git') + '/webm/libvpx.git' + '@' + 'ac8f58f6ab73fea7948f40eaf608f832964d8a58',
'src/third_party/libyuv': 'src/third_party/libyuv':
Var('chromium_git') + '/libyuv/libyuv.git' + '@' + '945ea1b7463004581502ebbcfc5a0b2f54ff6867', Var('chromium_git') + '/libyuv/libyuv.git' + '@' + '945ea1b7463004581502ebbcfc5a0b2f54ff6867',
'src/third_party/openh264/src': 'src/third_party/openh264/src':
@ -77,21 +74,19 @@ deps = {
'src/third_party/yasm/source/patched-yasm': 'src/third_party/yasm/source/patched-yasm':
Var('chromium_git') + '/chromium/deps/yasm/patched-yasm.git' + '@' + '7da28c6c7c6a1387217352ce02b31754deb54d2a', Var('chromium_git') + '/chromium/deps/yasm/patched-yasm.git' + '@' + '7da28c6c7c6a1387217352ce02b31754deb54d2a',
'src/tools': 'src/tools':
Var('chromium_git') + '/chromium/src/tools' + '@' + '352772c07f1ab117bbb228ec8e857870cb123e0f', Var('chromium_git') + '/chromium/src/tools' + '@' + 'e095601b862720c85a699c2ce05e78a1b890df35',
'src/tools/gyp': 'src/tools/gyp':
Var('chromium_git') + '/external/gyp.git' + '@' + 'eb296f67da078ec01f5e3a9ea9cdc6d26d680161', Var('chromium_git') + '/external/gyp.git' + '@' + 'eb296f67da078ec01f5e3a9ea9cdc6d26d680161',
'src/tools/swarming_client': 'src/tools/swarming_client':
Var('chromium_git') + '/external/swarming.client.git' + '@' + Var('swarming_revision'), Var('chromium_git') + '/external/swarming.client.git' + '@' + Var('swarming_revision'),
# WebRTC-only dependencies (not present in Chromium). # WebRTC-only dependencies (not present in Chromium).
'src/third_party/gflags': 'src/third_party/gflags':
Var('chromium_git') + '/external/webrtc/deps/third_party/gflags' + '@' + '892576179b45861b53e04a112996a738309cf364', Var('chromium_git') + '/external/webrtc/deps/third_party/gflags' + '@' + '892576179b45861b53e04a112996a738309cf364',
'src/third_party/gflags/src': 'src/third_party/gflags/src':
Var('chromium_git') + '/external/github.com/gflags/gflags' + '@' + '03bebcb065c83beff83d50ae025a55a4bf94dfca', Var('chromium_git') + '/external/github.com/gflags/gflags' + '@' + '03bebcb065c83beff83d50ae025a55a4bf94dfca',
'src/third_party/gtest-parallel': 'src/third_party/gtest-parallel':
Var('chromium_git') + '/external/github.com/google/gtest-parallel' + '@' + '21b383f81a2214307a5cece839206418a2ba820b', Var('chromium_git') + '/external/github.com/google/gtest-parallel' + '@' + 'c95bf7d82c30e57560be91890aa968d9bc4cedae',
} }
deps_os = { deps_os = {
'android': { 'android': {
'src/third_party/android_tools': 'src/third_party/android_tools':
@ -99,7 +94,7 @@ deps_os = {
'src/third_party/ced/src': 'src/third_party/ced/src':
Var('chromium_git') + '/external/github.com/google/compact_enc_det.git' + '@' + 'e21eb6aed10b9f6e2727f136c52420033214d458', Var('chromium_git') + '/external/github.com/google/compact_enc_det.git' + '@' + 'e21eb6aed10b9f6e2727f136c52420033214d458',
'src/third_party/icu': 'src/third_party/icu':
Var('chromium_git') + '/chromium/deps/icu.git' + '@' + 'c844075aa0f1758d04f9192825f1b1e7e607992e', Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '87232d8d763692d4b8303f0194472a82c829a6a9',
'src/third_party/jsr-305/src': 'src/third_party/jsr-305/src':
Var('chromium_git') + '/external/jsr-305.git' + '@' + '642c508235471f7220af6d5df2d3210e3bfc0919', Var('chromium_git') + '/external/jsr-305.git' + '@' + '642c508235471f7220af6d5df2d3210e3bfc0919',
'src/third_party/junit/src': 'src/third_party/junit/src':
@ -114,7 +109,6 @@ deps_os = {
Var('chromium_git') + '/external/robolectric.git' + '@' + '2a0b6ba221c14f3371813a676ce06143353e448d', Var('chromium_git') + '/external/robolectric.git' + '@' + '2a0b6ba221c14f3371813a676ce06143353e448d',
'src/third_party/ub-uiautomator/lib': 'src/third_party/ub-uiautomator/lib':
Var('chromium_git') + '/chromium/third_party/ub-uiautomator.git' + '@' + '00270549ce3161ae72ceb24712618ea28b4f9434', Var('chromium_git') + '/chromium/third_party/ub-uiautomator.git' + '@' + '00270549ce3161ae72ceb24712618ea28b4f9434',
# Gradle 3.5.0. Used for testing Android Studio project generation for WebRTC. # Gradle 3.5.0. Used for testing Android Studio project generation for WebRTC.
'src/webrtc/examples/androidtests/third_party/gradle': 'src/webrtc/examples/androidtests/third_party/gradle':
Var('chromium_git') + '/external/github.com/gradle/gradle.git' + '@' + Var('chromium_git') + '/external/github.com/gradle/gradle.git' + '@' +
@ -122,7 +116,7 @@ deps_os = {
}, },
'ios': { 'ios': {
'src/ios': 'src/ios':
Var('chromium_git') + '/chromium/src/ios' + '@' + 'ecec75065b2b62f57b9ba0c14cac5dc8a51ad515', Var('chromium_git') + '/chromium/src/ios' + '@' + '411732c0b91e4116dc6123c20042891ed4619e55',
}, },
'unix': { 'unix': {
'src/third_party/lss': 'src/third_party/lss':
@ -132,13 +126,11 @@ deps_os = {
# Dependencies used by libjpeg-turbo # Dependencies used by libjpeg-turbo
'src/third_party/yasm/binaries': 'src/third_party/yasm/binaries':
Var('chromium_git') + '/chromium/deps/yasm/binaries.git' + '@' + '52f9b3f4b0aa06da24ef8b123058bb61ee468881', Var('chromium_git') + '/chromium/deps/yasm/binaries.git' + '@' + '52f9b3f4b0aa06da24ef8b123058bb61ee468881',
# WebRTC-only dependency (not present in Chromium). # WebRTC-only dependency (not present in Chromium).
'src/third_party/winsdk_samples': 'src/third_party/winsdk_samples':
Var('chromium_git') + '/external/webrtc/deps/third_party/winsdk_samples_v71' + '@' + '2d31a1cbecc86359e6ec041fb9ff6c082babd073', Var('chromium_git') + '/external/webrtc/deps/third_party/winsdk_samples_v71' + '@' + '2d31a1cbecc86359e6ec041fb9ff6c082babd073',
}, },
} }
pre_deps_hooks = [ pre_deps_hooks = [
{ {
# Remove any symlinks from before 177567c518b121731e507e9b9c4049c4dc96e4c8. # Remove any symlinks from before 177567c518b121731e507e9b9c4049c4dc96e4c8.
@ -148,7 +140,6 @@ pre_deps_hooks = [
'action': ['python', 'src/cleanup_links.py'], 'action': ['python', 'src/cleanup_links.py'],
}, },
] ]
hooks = [ hooks = [
{ {
# Check for legacy named top-level dir (named 'trunk'). # Check for legacy named top-level dir (named 'trunk').
@ -526,11 +517,9 @@ hooks = [
'src/resources'], 'src/resources'],
}, },
] ]
recursedeps = [ recursedeps = [
# buildtools provides clang_format, libc++, and libc++abi. # buildtools provides clang_format, libc++, and libc++abi.
'src/buildtools', 'src/buildtools',
# android_tools manages the NDK. # android_tools manages the NDK.
'src/third_party/android_tools', 'src/third_party/android_tools',
] ]

View File

@ -83,10 +83,11 @@ AudioManager::AudioManager()
j_native_registration_ = j_environment_->RegisterNatives( j_native_registration_ = j_environment_->RegisterNatives(
"org/webrtc/voiceengine/WebRtcAudioManager", native_methods, "org/webrtc/voiceengine/WebRtcAudioManager", native_methods,
arraysize(native_methods)); arraysize(native_methods));
j_audio_manager_.reset( j_audio_manager_.reset(new JavaAudioManager(
new JavaAudioManager(j_native_registration_.get(), j_native_registration_.get(),
j_native_registration_->NewObject( j_native_registration_->NewObject(
"<init>", "(J)V", PointerTojlong(this)))); "<init>", "(Landroid/content/Context;J)V",
JVM::GetInstance()->context(), PointerTojlong(this))));
} }
AudioManager::~AudioManager() { AudioManager::~AudioManager() {

View File

@ -90,10 +90,11 @@ AudioRecordJni::AudioRecordJni(AudioManager* audio_manager)
j_native_registration_ = j_environment_->RegisterNatives( j_native_registration_ = j_environment_->RegisterNatives(
"org/webrtc/voiceengine/WebRtcAudioRecord", native_methods, "org/webrtc/voiceengine/WebRtcAudioRecord", native_methods,
arraysize(native_methods)); arraysize(native_methods));
j_audio_record_.reset( j_audio_record_.reset(new JavaAudioRecord(
new JavaAudioRecord(j_native_registration_.get(), j_native_registration_.get(),
j_native_registration_->NewObject( j_native_registration_->NewObject(
"<init>", "(J)V", PointerTojlong(this)))); "<init>", "(Landroid/content/Context;J)V",
JVM::GetInstance()->context(), PointerTojlong(this))));
// Detach from this thread since we want to use the checker to verify calls // Detach from this thread since we want to use the checker to verify calls
// from the Java based audio thread. // from the Java based audio thread.
thread_checker_java_.DetachFromThread(); thread_checker_java_.DetachFromThread();

View File

@ -89,10 +89,11 @@ AudioTrackJni::AudioTrackJni(AudioManager* audio_manager)
j_native_registration_ = j_environment_->RegisterNatives( j_native_registration_ = j_environment_->RegisterNatives(
"org/webrtc/voiceengine/WebRtcAudioTrack", native_methods, "org/webrtc/voiceengine/WebRtcAudioTrack", native_methods,
arraysize(native_methods)); arraysize(native_methods));
j_audio_track_.reset( j_audio_track_.reset(new JavaAudioTrack(
new JavaAudioTrack(j_native_registration_.get(), j_native_registration_.get(),
j_native_registration_->NewObject( j_native_registration_->NewObject(
"<init>", "(J)V", PointerTojlong(this)))); "<init>", "(Landroid/content/Context;J)V",
JVM::GetInstance()->context(), PointerTojlong(this))));
// Detach from this thread since we want to use the checker to verify calls // Detach from this thread since we want to use the checker to verify calls
// from the Java based audio thread. // from the Java based audio thread.
thread_checker_java_.DetachFromThread(); thread_checker_java_.DetachFromThread();

View File

@ -17,6 +17,7 @@
// Note: this dependency is dangerous since it reaches into Chromium's base. // Note: this dependency is dangerous since it reaches into Chromium's base.
// There's a risk of e.g. macro clashes. This file may only be used in tests. // There's a risk of e.g. macro clashes. This file may only be used in tests.
RTC_PUSH_IGNORING_WUNDEF() RTC_PUSH_IGNORING_WUNDEF()
#include "base/android/context_utils.h"
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
RTC_POP_IGNORING_WUNDEF() RTC_POP_IGNORING_WUNDEF()
#include "webrtc/base/checks.h" #include "webrtc/base/checks.h"
@ -34,9 +35,10 @@ void EnsureInitializedOnce() {
JNIEnv* jni = ::base::android::AttachCurrentThread(); JNIEnv* jni = ::base::android::AttachCurrentThread();
JavaVM* jvm = NULL; JavaVM* jvm = NULL;
RTC_CHECK_EQ(0, jni->GetJavaVM(&jvm)); RTC_CHECK_EQ(0, jni->GetJavaVM(&jvm));
jobject context = ::base::android::GetApplicationContext().obj();
// Initialize the Java environment (currently only used by the audio manager). // Initialize the Java environment (currently only used by the audio manager).
webrtc::JVM::Initialize(jvm); webrtc::JVM::Initialize(jvm, context);
} }
void EnsureInitialized() { void EnsureInitialized() {

View File

@ -20,7 +20,6 @@ import android.media.AudioTrack;
import android.os.Build; import android.os.Build;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import org.webrtc.ContextUtils;
import org.webrtc.Logging; import org.webrtc.Logging;
// WebRtcAudioManager handles tasks that uses android.media.AudioManager. // WebRtcAudioManager handles tasks that uses android.media.AudioManager.
@ -136,6 +135,7 @@ public class WebRtcAudioManager {
} }
private final long nativeAudioManager; private final long nativeAudioManager;
private final Context context;
private final AudioManager audioManager; private final AudioManager audioManager;
private boolean initialized = false; private boolean initialized = false;
@ -156,11 +156,11 @@ public class WebRtcAudioManager {
private final VolumeLogger volumeLogger; private final VolumeLogger volumeLogger;
WebRtcAudioManager(long nativeAudioManager) { WebRtcAudioManager(Context context, long nativeAudioManager) {
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo()); Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo());
this.context = context;
this.nativeAudioManager = nativeAudioManager; this.nativeAudioManager = nativeAudioManager;
audioManager = audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
(AudioManager) ContextUtils.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
if (DEBUG) { if (DEBUG) {
WebRtcAudioUtils.logDeviceInfo(TAG); WebRtcAudioUtils.logDeviceInfo(TAG);
} }
@ -224,14 +224,12 @@ public class WebRtcAudioManager {
// Gets the current earpiece state. // Gets the current earpiece state.
private boolean hasEarpiece() { private boolean hasEarpiece() {
return ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature( return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
PackageManager.FEATURE_TELEPHONY);
} }
// Returns true if low-latency audio output is supported. // Returns true if low-latency audio output is supported.
private boolean isLowLatencyOutputSupported() { private boolean isLowLatencyOutputSupported() {
return ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature( return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
PackageManager.FEATURE_AUDIO_LOW_LATENCY);
} }
// Returns true if low-latency audio input is supported. // Returns true if low-latency audio input is supported.
@ -250,8 +248,7 @@ public class WebRtcAudioManager {
@TargetApi(23) @TargetApi(23)
private boolean isProAudioSupported() { private boolean isProAudioSupported() {
return WebRtcAudioUtils.runningOnMarshmallowOrHigher() return WebRtcAudioUtils.runningOnMarshmallowOrHigher()
&& ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature( && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_PRO);
PackageManager.FEATURE_AUDIO_PRO);
} }
// Returns the native output sample rate for this device's output stream. // Returns the native output sample rate for this device's output stream.

View File

@ -19,7 +19,6 @@ import android.os.Process;
import java.lang.System; import java.lang.System;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.webrtc.ContextUtils;
import org.webrtc.Logging; import org.webrtc.Logging;
import org.webrtc.ThreadUtils; import org.webrtc.ThreadUtils;
@ -48,6 +47,7 @@ public class WebRtcAudioRecord {
private static final long AUDIO_RECORD_THREAD_JOIN_TIMEOUT_MS = 2000; private static final long AUDIO_RECORD_THREAD_JOIN_TIMEOUT_MS = 2000;
private final long nativeAudioRecord; private final long nativeAudioRecord;
private final Context context;
private WebRtcAudioEffects effects = null; private WebRtcAudioEffects effects = null;
@ -139,8 +139,9 @@ public class WebRtcAudioRecord {
} }
} }
WebRtcAudioRecord(long nativeAudioRecord) { WebRtcAudioRecord(Context context, long nativeAudioRecord) {
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo()); Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo());
this.context = context;
this.nativeAudioRecord = nativeAudioRecord; this.nativeAudioRecord = nativeAudioRecord;
if (DEBUG) { if (DEBUG) {
WebRtcAudioUtils.logDeviceInfo(TAG); WebRtcAudioUtils.logDeviceInfo(TAG);
@ -168,8 +169,7 @@ public class WebRtcAudioRecord {
private int initRecording(int sampleRate, int channels) { private int initRecording(int sampleRate, int channels) {
Logging.d(TAG, "initRecording(sampleRate=" + sampleRate + ", channels=" + channels + ")"); Logging.d(TAG, "initRecording(sampleRate=" + sampleRate + ", channels=" + channels + ")");
if (!WebRtcAudioUtils.hasPermission( if (!WebRtcAudioUtils.hasPermission(context, android.Manifest.permission.RECORD_AUDIO)) {
ContextUtils.getApplicationContext(), android.Manifest.permission.RECORD_AUDIO)) {
reportWebRtcAudioRecordInitError("RECORD_AUDIO permission is missing"); reportWebRtcAudioRecordInitError("RECORD_AUDIO permission is missing");
return -1; return -1;
} }

View File

@ -19,7 +19,6 @@ import android.media.AudioTrack;
import android.os.Process; import android.os.Process;
import java.lang.Thread; import java.lang.Thread;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.webrtc.ContextUtils;
import org.webrtc.Logging; import org.webrtc.Logging;
public class WebRtcAudioTrack { public class WebRtcAudioTrack {
@ -37,6 +36,7 @@ public class WebRtcAudioTrack {
// Average number of callbacks per second. // Average number of callbacks per second.
private static final int BUFFERS_PER_SECOND = 1000 / CALLBACK_BUFFER_SIZE_MS; private static final int BUFFERS_PER_SECOND = 1000 / CALLBACK_BUFFER_SIZE_MS;
private final Context context;
private final long nativeAudioTrack; private final long nativeAudioTrack;
private final AudioManager audioManager; private final AudioManager audioManager;
@ -165,11 +165,11 @@ public class WebRtcAudioTrack {
} }
} }
WebRtcAudioTrack(long nativeAudioTrack) { WebRtcAudioTrack(Context context, long nativeAudioTrack) {
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo()); Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo());
this.context = context;
this.nativeAudioTrack = nativeAudioTrack; this.nativeAudioTrack = nativeAudioTrack;
audioManager = audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
(AudioManager) ContextUtils.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
if (DEBUG) { if (DEBUG) {
WebRtcAudioUtils.logDeviceInfo(TAG); WebRtcAudioUtils.logDeviceInfo(TAG);
} }

View File

@ -118,7 +118,8 @@ class JNIEnvironment {
// JNIEnv* jni = ::base::android::AttachCurrentThread(); // JNIEnv* jni = ::base::android::AttachCurrentThread();
// JavaVM* jvm = NULL; // JavaVM* jvm = NULL;
// jni->GetJavaVM(&jvm); // jni->GetJavaVM(&jvm);
// webrtc::JVM::Initialize(jvm); // jobject context = ::base::android::GetApplicationContext();
// webrtc::JVM::Initialize(jvm, context);
// //
// // Header (.h) file of example class called User. // // Header (.h) file of example class called User.
// std::unique_ptr<JNIEnvironment> env; // std::unique_ptr<JNIEnvironment> env;
@ -144,12 +145,9 @@ class JNIEnvironment {
// JVM::Uninitialize(); // JVM::Uninitialize();
class JVM { class JVM {
public: public:
// Stores global handles to the Java VM interface. // Stores global handles to the Java VM interface and the application context.
// Should be called once on a thread that is attached to the JVM. // Should be called once on a thread that is attached to the JVM.
static void Initialize(JavaVM* jvm); static void Initialize(JavaVM* jvm, jobject context);
// TODO(sakal): Remove once downstream dependencies have been updated.
// Deprecated old signature with Android context.
static void Initialize(JavaVM* jvm, jobject context) { Initialize(jvm); }
// Clears handles stored in Initialize(). Must be called on same thread as // Clears handles stored in Initialize(). Must be called on same thread as
// Initialize(). // Initialize().
static void Uninitialize(); static void Uninitialize();
@ -170,9 +168,10 @@ class JVM {
// TODO(henrika): can we make these private? // TODO(henrika): can we make these private?
JavaVM* jvm() const { return jvm_; } JavaVM* jvm() const { return jvm_; }
jobject context() const { return context_; }
protected: protected:
JVM(JavaVM* jvm); JVM(JavaVM* jvm, jobject context);
~JVM(); ~JVM();
private: private:
@ -180,6 +179,7 @@ class JVM {
rtc::ThreadChecker thread_checker_; rtc::ThreadChecker thread_checker_;
JavaVM* const jvm_; JavaVM* const jvm_;
jobject context_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -217,10 +217,10 @@ std::string JNIEnvironment::JavaToStdString(const jstring& j_string) {
} }
// static // static
void JVM::Initialize(JavaVM* jvm) { void JVM::Initialize(JavaVM* jvm, jobject context) {
ALOGD("JVM::Initialize%s", GetThreadInfo().c_str()); ALOGD("JVM::Initialize%s", GetThreadInfo().c_str());
RTC_CHECK(!g_jvm); RTC_CHECK(!g_jvm);
g_jvm = new JVM(jvm); g_jvm = new JVM(jvm, context);
} }
// static // static
@ -237,9 +237,11 @@ JVM* JVM::GetInstance() {
return g_jvm; return g_jvm;
} }
JVM::JVM(JavaVM* jvm) : jvm_(jvm) { JVM::JVM(JavaVM* jvm, jobject context)
: jvm_(jvm) {
ALOGD("JVM::JVM%s", GetThreadInfo().c_str()); ALOGD("JVM::JVM%s", GetThreadInfo().c_str());
RTC_CHECK(jni()) << "AttachCurrentThread() must be called on this thread."; RTC_CHECK(jni()) << "AttachCurrentThread() must be called on this thread.";
context_ = NewGlobalRef(jni(), context);
LoadClasses(jni()); LoadClasses(jni());
} }
@ -247,6 +249,7 @@ JVM::~JVM() {
ALOGD("JVM::~JVM%s", GetThreadInfo().c_str()); ALOGD("JVM::~JVM%s", GetThreadInfo().c_str());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.CalledOnValidThread());
FreeClassReferences(jni()); FreeClassReferences(jni());
DeleteGlobalRef(jni(), context_);
} }
std::unique_ptr<JNIEnvironment> JVM::environment() { std::unique_ptr<JNIEnvironment> JVM::environment() {

View File

@ -19,6 +19,7 @@
// Since we use Chromes build system for creating the gtest binary, this should // Since we use Chromes build system for creating the gtest binary, this should
// be fine. // be fine.
RTC_PUSH_IGNORING_WUNDEF() RTC_PUSH_IGNORING_WUNDEF()
#include "base/android/context_utils.h"
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
RTC_POP_IGNORING_WUNDEF() RTC_POP_IGNORING_WUNDEF()
@ -40,10 +41,11 @@ void EnsureInitializedOnce() {
JNIEnv* jni = ::base::android::AttachCurrentThread(); JNIEnv* jni = ::base::android::AttachCurrentThread();
JavaVM* jvm = NULL; JavaVM* jvm = NULL;
RTC_CHECK_EQ(0, jni->GetJavaVM(&jvm)); RTC_CHECK_EQ(0, jni->GetJavaVM(&jvm));
jobject context = ::base::android::GetApplicationContext().obj();
RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()"; RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
webrtc::JVM::Initialize(jvm); webrtc::JVM::Initialize(jvm, context);
} }
} // anonymous namespace } // anonymous namespace

View File

@ -10,7 +10,6 @@
package org.webrtc; package org.webrtc;
import android.content.Context;
import java.util.List; import java.util.List;
/** /**
@ -31,7 +30,6 @@ public class PeerConnectionFactory {
private static final String TAG = "PeerConnectionFactory"; private static final String TAG = "PeerConnectionFactory";
private final long nativeFactory; private final long nativeFactory;
private static Context applicationContext;
private static Thread networkThread; private static Thread networkThread;
private static Thread workerThread; private static Thread workerThread;
private static Thread signalingThread; private static Thread signalingThread;
@ -54,19 +52,14 @@ public class PeerConnectionFactory {
// Must be called at least once before creating a PeerConnectionFactory // Must be called at least once before creating a PeerConnectionFactory
// (for example, at application startup time). // (for example, at application startup time).
public static native void nativeInitializeAndroidGlobals( public static native void initializeAndroidGlobals(
Context context, boolean videoHwAcceleration); android.content.Context context, boolean videoHwAcceleration);
public static void initializeAndroidGlobals(Context context, boolean videoHwAcceleration) {
ContextUtils.initialize(context);
nativeInitializeAndroidGlobals(context, videoHwAcceleration);
}
// Older signature of initializeAndroidGlobals. The extra parameters are now meaningless. // Older signature of initializeAndroidGlobals. The extra parameters are now meaningless.
@Deprecated @Deprecated
public static boolean initializeAndroidGlobals(Object context, boolean initializeAudio, public static boolean initializeAndroidGlobals(Object context, boolean initializeAudio,
boolean initializeVideo, boolean videoHwAcceleration) { boolean initializeVideo, boolean videoHwAcceleration) {
initializeAndroidGlobals((Context) context, videoHwAcceleration); initializeAndroidGlobals((android.content.Context) context, videoHwAcceleration);
return true; return true;
} }

View File

@ -1139,7 +1139,7 @@ JOW(jlong, PeerConnectionFactory_nativeCreateObserver)(
return (jlong)new PCOJava(jni, j_observer); return (jlong)new PCOJava(jni, j_observer);
} }
JOW(void, PeerConnectionFactory_nativeInitializeAndroidGlobals) JOW(void, PeerConnectionFactory_initializeAndroidGlobals)
(JNIEnv* jni, (JNIEnv* jni,
jclass, jclass,
jobject context, jobject context,
@ -1149,7 +1149,7 @@ JOW(void, PeerConnectionFactory_nativeInitializeAndroidGlobals)
if (!factory_static_initialized) { if (!factory_static_initialized) {
RTC_DCHECK(j_application_context == nullptr); RTC_DCHECK(j_application_context == nullptr);
j_application_context = NewGlobalRef(jni, context); j_application_context = NewGlobalRef(jni, context);
webrtc::JVM::Initialize(GetJVM()); webrtc::JVM::Initialize(GetJVM(), context);
factory_static_initialized = true; factory_static_initialized = true;
} }
} }

View File

@ -532,17 +532,3 @@ rtc_source_set("audio_codec_mocks") {
"//testing/gmock", "//testing/gmock",
] ]
} }
if (!build_with_chromium && is_android) {
android_library("native_test_java") {
testonly = true
java_files = [
"android/org/webrtc/native_test/RTCNativeUnitTest.java",
"android/org/webrtc/native_test/RTCNativeUnitTestActivity.java",
]
deps = [
"//testing/android/native_test:native_test_java",
"//webrtc/base:base_java",
]
}
}

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.webrtc.native_test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:label="NativeTests"
android:name="org.chromium.base.BaseChromiumApplication">
<uses-library android:name="android.test.runner"/>
<activity android:name=".RTCNativeUnitTestActivity"
android:label="NativeTest"
android:configChanges="orientation|keyboardHidden"
android:process=":test_process">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<instrumentation android:name="org.chromium.native_test.NativeTestInstrumentationTestRunner"
android:targetPackage="org.webrtc.native_test"
android:label="Instrumentation entry point for org.webrtc.native_test"/>
</manifest>

View File

@ -1,26 +0,0 @@
/*
* Copyright 2017 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.
*/
package org.webrtc.native_test;
import android.app.Activity;
import org.chromium.native_test.NativeUnitTest;
import org.webrtc.ContextUtils;
/**
* Native unit test that calls ContextUtils.initialize for WebRTC.
*/
public class RTCNativeUnitTest extends NativeUnitTest {
@Override
public void preCreate(Activity activity) {
super.preCreate(activity);
ContextUtils.initialize(activity.getApplicationContext());
}
}

View File

@ -1,34 +0,0 @@
/*
* Copyright 2017 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.
*/
package org.webrtc.native_test;
import android.app.Activity;
import android.os.Bundle;
/**
* Activity that uses RTCNativeUnitTest to run the tests.
*/
public class RTCNativeUnitTestActivity extends Activity {
private RTCNativeUnitTest mTest = new RTCNativeUnitTest();
@Override
public void onCreate(Bundle savedInstanceState) {
mTest.preCreate(this);
super.onCreate(savedInstanceState);
mTest.postCreate(this);
}
@Override
public void onStart() {
super.onStart();
mTest.postStart(this, false);
}
}

View File

@ -266,10 +266,6 @@ template("rtc_test") {
if (defined(invoker.public_configs)) { if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs public_configs += invoker.public_configs
} }
if (!build_with_chromium && is_android) {
android_manifest = "//webrtc/test/android/AndroidManifest.xml"
deps += [ "//webrtc/test:native_test_java" ]
}
} }
} }