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.
if (!PeerConnectionFactory.initializeAndroidGlobals(
context, true, true, peerConnectionParameters.videoCodecHwAcceleration)) {
events.onPeerConnectionError("Failed to initializeAndroidGlobals");
}
PeerConnectionFactory.initializeAndroidGlobals(
context, peerConnectionParameters.videoCodecHwAcceleration);
if (options != null) {
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
# for accessing the JVM and Application context in gtest.
"+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/ssladapter.h"
#include "webrtc/voice_engine/include/voe_base.h"
#include "webrtc/modules/utility/include/jvm_android.h"
namespace webrtc {
@ -45,7 +45,7 @@ void EnsureInitializedOnce() {
RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
webrtc::VoiceEngine::SetAndroidObjects(jvm, context);
webrtc::JVM::Initialize(jvm, context);
}
} // anonymous namespace

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@ include_rules = [
"+third_party/libyuv",
"+webrtc/common_video/h264/h264_bitstream_parser.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/pc",
"+webrtc/voice_engine/include/voe_base.h",
]

View File

@ -63,6 +63,7 @@
#include "webrtc/media/base/videocapturer.h"
#include "webrtc/media/engine/webrtcvideodecoderfactory.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/pc/webrtcsdp.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);
}
JOW(jboolean, PeerConnectionFactory_initializeAndroidGlobals)
JOW(void, PeerConnectionFactory_initializeAndroidGlobals)
(JNIEnv* jni,
jclass,
jobject context,
jboolean initialize_audio,
jboolean initialize_video,
jboolean video_hw_acceleration) {
bool failure = false;
video_hw_acceleration_enabled = video_hw_acceleration;
AndroidNetworkMonitor::SetAndroidContext(jni, context);
if (!factory_static_initialized) {
RTC_DCHECK(j_application_context == nullptr);
j_application_context = NewGlobalRef(jni, context);
if (initialize_audio)
failure |= webrtc::VoiceEngine::SetAndroidObjects(GetJVM(), context);
webrtc::JVM::Initialize(GetJVM(), context);
factory_static_initialized = true;
}
return !failure;
}
JOW(void, PeerConnectionFactory_initializeFieldTrials)(

View File

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

View File

@ -12,7 +12,6 @@
#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/utility/include/jvm_android.h"
#endif
#include "webrtc/base/checks.h"
@ -129,19 +128,6 @@ bool VoiceEngine::Delete(VoiceEngine*& voiceEngine) {
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 version = "VoiceEngine 4.1.0";
#ifdef WEBRTC_EXTERNAL_TRANSPORT