Bug 1109248: Revert removal of SetAndroidObjects calls in webrtc.org r=jesup

This commit is contained in:
Gian-Carlo Pascutto 2015-01-29 18:33:36 -05:00
parent 1f481c70e6
commit 974d6435e4
6 changed files with 51 additions and 5 deletions

View File

@ -332,7 +332,6 @@ MediaConduitErrorCode WebrtcVideoConduit::Init(WebrtcVideoConduit *other)
MOZ_ASSERT(other->mVideoEngine);
mVideoEngine = other->mVideoEngine;
} else {
#ifdef MOZ_WIDGET_ANDROID
// get the JVM
JavaVM *jvm = jsjni_GetVM();

View File

@ -50,7 +50,7 @@ void JNICALL ProvideCameraFrame(
env->ReleaseByteArrayElements(javaCameraFrame, cameraFrame, JNI_ABORT);
}
int32_t SetCaptureAndroidVM(JavaVM* javaVM, jobject context) {
int32_t SetCaptureAndroidVM(JavaVM* javaVM) {
if (g_java_capturer_class)
return 0;
@ -58,12 +58,13 @@ int32_t SetCaptureAndroidVM(JavaVM* javaVM, jobject context) {
assert(!g_jvm);
g_jvm = javaVM;
AttachThreadScoped ats(g_jvm);
g_context = ats.env()->NewGlobalRef(context);
g_context = jsjni_GetGlobalContextRef();
videocapturemodule::DeviceInfoAndroid::Initialize(ats.env());
g_java_capturer_class =
jsjni_GetGlobalClassRef("org/webrtc/videoengine/VideoCaptureAndroid");
jsjni_GetGlobalClassRef("org/webrtc/videoengine/VideoCaptureAndroid");
assert(g_java_capturer_class);
JNINativeMethod native_methods[] = {
@ -82,7 +83,6 @@ int32_t SetCaptureAndroidVM(JavaVM* javaVM, jobject context) {
ats.env()->UnregisterNatives(g_java_capturer_class);
ats.env()->DeleteGlobalRef(g_java_capturer_class);
g_java_capturer_class = NULL;
ats.env()->DeleteGlobalRef(g_context);
g_context = NULL;
videocapturemodule::DeviceInfoAndroid::DeInitialize();
g_jvm = NULL;

View File

@ -14,8 +14,16 @@
#include "webrtc/modules/interface/module.h"
#include "webrtc/modules/video_capture/include/video_capture_defines.h"
#if defined(ANDROID) && !defined(WEBRTC_GONK)
#include <jni.h>
#endif
namespace webrtc {
#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(WEBRTC_GONK)
int32_t SetCaptureAndroidVM(JavaVM* javaVM);
#endif
class VideoCaptureModule: public RefCountedModule {
public:
// Interface for receiving information about available camera devices.

View File

@ -36,6 +36,10 @@ class VideoCaptureFactory {
static VideoCaptureModule::DeviceInfo* CreateDeviceInfo(
const int32_t id);
#ifdef WEBRTC_ANDROID
static int32_t SetAndroidObjects(void* javaVM, void* javaContext);
#endif
private:
~VideoCaptureFactory();
};

View File

@ -21,6 +21,10 @@
#include "webrtc/common_types.h"
#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(MOZ_WIDGET_GONK)
#include <jni.h>
#endif
namespace webrtc {
class Config;
@ -147,6 +151,11 @@ class WEBRTC_DLLEXPORT VideoEngine {
// user receives callbacks for generated trace messages.
static int SetTraceCallback(TraceCallback* callback);
#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(MOZ_WIDGET_GONK)
// Android specific.
static int SetAndroidObjects(JavaVM* java_vm);
#endif
protected:
VideoEngine() {}
virtual ~VideoEngine() {}

View File

@ -14,6 +14,11 @@
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_ANDROID
#include "webrtc/modules/video_capture/include/video_capture_factory.h"
#include "webrtc/modules/video_render/include/video_render.h"
#endif
namespace webrtc {
enum { kModuleId = 0 };
@ -134,4 +139,25 @@ int VideoEngine::SetTraceCallback(TraceCallback* callback) {
return Trace::SetTraceCallback(callback);
}
#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(WEBRTC_GONK)
int VideoEngine::SetAndroidObjects(JavaVM* javaVM) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, kModuleId,
"SetAndroidObjects()");
if (SetCaptureAndroidVM(javaVM) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, kModuleId,
"Could not set capture Android VM");
return -1;
}
#ifdef WEBRTC_INCLUDE_INTERNAL_VIDEO_RENDER
if (SetRenderAndroidVM(javaVM) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, kModuleId,
"Could not set render Android VM");
return -1;
}
#endif
return 0;
}
#endif
} // namespace webrtc