Removing unnecessary parameters from initializeAndroidGlobals.

The "initialize audio/video" parameters are no longer needed, but
at the same time were required to be true, causing a lot of confusion.
This CL removes them, but leaves the old method signature around,
marked "deprecated".

BUG=webrtc:3416
TBR=solenberg@webrtc.org

Review-Url: https://codereview.webrtc.org/2800353002
Cr-Commit-Position: refs/heads/master@{#17626}
This commit is contained in:
deadbeef
2017-04-10 15:08:02 -07:00
committed by Commit bot
parent 6799553a2c
commit b4fc73a3ab
12 changed files with 27 additions and 50 deletions

View File

@ -471,10 +471,8 @@ public class PeerConnectionClient {
}); });
// Create peer connection factory. // Create peer connection factory.
if (!PeerConnectionFactory.initializeAndroidGlobals( PeerConnectionFactory.initializeAndroidGlobals(
context, true, true, peerConnectionParameters.videoCodecHwAcceleration)) { context, peerConnectionParameters.videoCodecHwAcceleration);
events.onPeerConnectionError("Failed to initializeAndroidGlobals");
}
if (options != null) { if (options != null) {
Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMask); Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMask);
} }

View File

@ -2,4 +2,5 @@ include_rules = [
# Allow include of Chrome base/android to allow inclusion of headers needed # Allow include of Chrome base/android to allow inclusion of headers needed
# for accessing the JVM and Application context in gtest. # for accessing the JVM and Application context in gtest.
"+base/android", "+base/android",
"+webrtc/modules/utility/include/jvm_android.h",
] ]

View File

@ -25,7 +25,7 @@ RTC_POP_IGNORING_WUNDEF()
#include "webrtc/base/checks.h" #include "webrtc/base/checks.h"
#include "webrtc/base/ssladapter.h" #include "webrtc/base/ssladapter.h"
#include "webrtc/voice_engine/include/voe_base.h" #include "webrtc/modules/utility/include/jvm_android.h"
namespace webrtc { namespace webrtc {
@ -45,7 +45,7 @@ void EnsureInitializedOnce() {
RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()"; RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
webrtc::VoiceEngine::SetAndroidObjects(jvm, context); webrtc::JVM::Initialize(jvm, context);
} }
} // anonymous namespace } // anonymous namespace

View File

@ -50,16 +50,18 @@ public class PeerConnectionFactory {
public boolean disableNetworkMonitor; public boolean disableNetworkMonitor;
} }
// |context| is an android.content.Context object, but we keep it untyped here // Must be called at least once before creating a PeerConnectionFactory
// to allow building on non-Android platforms. // (for example, at application startup time).
// Callers may specify either |initializeAudio| or |initializeVideo| as false public static native void initializeAndroidGlobals(
// to skip initializing the respective engine (and avoid the need for the android.content.Context context, boolean videoHwAcceleration);
// respective permissions).
// |renderEGLContext| can be provided to suport HW video decoding to // Older signature of initializeAndroidGlobals. The extra parameters are now meaningless.
// texture and will be used to create a shared EGL context on video @Deprecated
// decoding thread. public static boolean initializeAndroidGlobals(android.content.Context context,
public static native boolean initializeAndroidGlobals(Object context, boolean initializeAudio, boolean initializeAudio, boolean initializeVideo, boolean videoHwAcceleration) {
boolean initializeVideo, boolean videoHwAcceleration); initializeAndroidGlobals(context, videoHwAcceleration);
return true;
}
// Field trial initialization. Must be called before PeerConnectionFactory // Field trial initialization. Must be called before PeerConnectionFactory
// is created. // is created.
@ -90,6 +92,8 @@ public class PeerConnectionFactory {
this(null); this(null);
} }
// Note: initializeAndroidGlobals must be called at least once before
// constructing a PeerConnectionFactory.
public PeerConnectionFactory(Options options) { public PeerConnectionFactory(Options options) {
nativeFactory = nativeCreatePeerConnectionFactory(options); nativeFactory = nativeCreatePeerConnectionFactory(options);
if (nativeFactory == 0) { if (nativeFactory == 0) {

View File

@ -326,8 +326,7 @@ class CameraVideoCapturerTestFixtures {
private TestObjectFactory testObjectFactory; private TestObjectFactory testObjectFactory;
CameraVideoCapturerTestFixtures(TestObjectFactory testObjectFactory) { CameraVideoCapturerTestFixtures(TestObjectFactory testObjectFactory) {
PeerConnectionFactory.initializeAndroidGlobals( PeerConnectionFactory.initializeAndroidGlobals(testObjectFactory.getAppContext(), true);
testObjectFactory.getAppContext(), true, true, true);
this.peerConnectionFactory = new PeerConnectionFactory(null /* options */); this.peerConnectionFactory = new PeerConnectionFactory(null /* options */);
this.testObjectFactory = testObjectFactory; this.testObjectFactory = testObjectFactory;

View File

@ -103,8 +103,8 @@ public class EglRendererTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
PeerConnectionFactory.initializeAndroidGlobals(InstrumentationRegistry.getTargetContext(), PeerConnectionFactory.initializeAndroidGlobals(
true /* initializeAudio */, true /* initializeVideo */, true /* videoHwAcceleration */); InstrumentationRegistry.getTargetContext(), true /* videoHwAcceleration */);
eglRenderer = new EglRenderer("TestRenderer: "); eglRenderer = new EglRenderer("TestRenderer: ");
eglRenderer.init(null /* sharedContext */, EglBase.CONFIG_RGBA, new GlRectDrawer()); eglRenderer.init(null /* sharedContext */, EglBase.CONFIG_RGBA, new GlRectDrawer());
oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES); oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);

View File

@ -48,8 +48,7 @@ public class PeerConnectionTest {
@Before @Before
public void setUp() { public void setUp() {
assertTrue(PeerConnectionFactory.initializeAndroidGlobals( PeerConnectionFactory.initializeAndroidGlobals(InstrumentationRegistry.getContext(), true);
InstrumentationRegistry.getContext(), true, true, true));
} }
private static class ObserverExpectations private static class ObserverExpectations

View File

@ -26,7 +26,6 @@ public class WebRtcJniBootTest {
@SmallTest @SmallTest
public void testJniLoadsWithoutError() throws InterruptedException { public void testJniLoadsWithoutError() throws InterruptedException {
PeerConnectionFactory.initializeAndroidGlobals(InstrumentationRegistry.getTargetContext(), PeerConnectionFactory.initializeAndroidGlobals(InstrumentationRegistry.getTargetContext(),
true /* initializeAudio */, true /* initializeVideo */,
false /* videoCodecHwAcceleration */); false /* videoCodecHwAcceleration */);
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();

View File

@ -2,7 +2,7 @@ include_rules = [
"+third_party/libyuv", "+third_party/libyuv",
"+webrtc/common_video/h264/h264_bitstream_parser.h", "+webrtc/common_video/h264/h264_bitstream_parser.h",
"+webrtc/common_video/libyuv/include/webrtc_libyuv.h", "+webrtc/common_video/libyuv/include/webrtc_libyuv.h",
"+webrtc/modules/utility/include/jvm_android.h",
"+webrtc/modules/video_coding/utility/vp8_header_parser.h", "+webrtc/modules/video_coding/utility/vp8_header_parser.h",
"+webrtc/pc", "+webrtc/pc",
"+webrtc/voice_engine/include/voe_base.h",
] ]

View File

@ -63,6 +63,7 @@
#include "webrtc/media/base/videocapturer.h" #include "webrtc/media/base/videocapturer.h"
#include "webrtc/media/engine/webrtcvideodecoderfactory.h" #include "webrtc/media/engine/webrtcvideodecoderfactory.h"
#include "webrtc/media/engine/webrtcvideoencoderfactory.h" #include "webrtc/media/engine/webrtcvideoencoderfactory.h"
#include "webrtc/modules/utility/include/jvm_android.h"
#include "webrtc/system_wrappers/include/field_trial.h" #include "webrtc/system_wrappers/include/field_trial.h"
#include "webrtc/pc/webrtcsdp.h" #include "webrtc/pc/webrtcsdp.h"
#include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h" #include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h"
@ -1131,25 +1132,19 @@ JOW(jlong, PeerConnectionFactory_nativeCreateObserver)(
return (jlong)new PCOJava(jni, j_observer); return (jlong)new PCOJava(jni, j_observer);
} }
JOW(jboolean, PeerConnectionFactory_initializeAndroidGlobals) JOW(void, PeerConnectionFactory_initializeAndroidGlobals)
(JNIEnv* jni, (JNIEnv* jni,
jclass, jclass,
jobject context, jobject context,
jboolean initialize_audio,
jboolean initialize_video,
jboolean video_hw_acceleration) { jboolean video_hw_acceleration) {
bool failure = false;
video_hw_acceleration_enabled = video_hw_acceleration; video_hw_acceleration_enabled = video_hw_acceleration;
AndroidNetworkMonitor::SetAndroidContext(jni, context); AndroidNetworkMonitor::SetAndroidContext(jni, context);
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(), context);
if (initialize_audio)
failure |= webrtc::VoiceEngine::SetAndroidObjects(GetJVM(), context);
factory_static_initialized = true; factory_static_initialized = true;
} }
return !failure;
} }
JOW(void, PeerConnectionFactory_initializeFieldTrials)( JOW(void, PeerConnectionFactory_initializeFieldTrials)(

View File

@ -85,10 +85,6 @@ class WEBRTC_DLLEXPORT VoiceEngine {
// receives callbacks for generated trace messages. // receives callbacks for generated trace messages.
static int SetTraceCallback(TraceCallback* callback); static int SetTraceCallback(TraceCallback* callback);
#if !defined(WEBRTC_CHROMIUM_BUILD)
static int SetAndroidObjects(void* javaVM, void* context);
#endif
static std::string GetVersionString(); static std::string GetVersionString();
protected: protected:

View File

@ -12,7 +12,6 @@
#include "webrtc/modules/audio_device/android/audio_device_template.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_record_jni.h"
#include "webrtc/modules/audio_device/android/audio_track_jni.h" #include "webrtc/modules/audio_device/android/audio_track_jni.h"
#include "webrtc/modules/utility/include/jvm_android.h"
#endif #endif
#include "webrtc/base/checks.h" #include "webrtc/base/checks.h"
@ -129,19 +128,6 @@ bool VoiceEngine::Delete(VoiceEngine*& voiceEngine) {
return true; return true;
} }
#if !defined(WEBRTC_CHROMIUM_BUILD)
// TODO(henrika): change types to JavaVM* and jobject instead of void*.
int VoiceEngine::SetAndroidObjects(void* javaVM, void* context) {
#ifdef WEBRTC_ANDROID
webrtc::JVM::Initialize(reinterpret_cast<JavaVM*>(javaVM),
reinterpret_cast<jobject>(context));
return 0;
#else
return -1;
#endif
}
#endif
std::string VoiceEngine::GetVersionString() { std::string VoiceEngine::GetVersionString() {
std::string version = "VoiceEngine 4.1.0"; std::string version = "VoiceEngine 4.1.0";
#ifdef WEBRTC_EXTERNAL_TRANSPORT #ifdef WEBRTC_EXTERNAL_TRANSPORT