Make webrtc compile on android in chromium

Message:
There probably is a better way, this cl is trying to seperate android
specific calls into android files, particular SetAndroidObject, by doing
this, webrtc can be built inside Chromium on android. Currently, Chromium
manages its own jvm, capturer and renderer, all webrtc code that manages
jvm, captuer and renderer should not be compiled. 

Description:
By re-organize android specific code, this cl will make webrtc build
in Chromium on android.

BUG=
TEST=
Review URL: https://webrtc-codereview.appspot.com/668007

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2516 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
leozwang@webrtc.org 2012-07-13 22:00:43 +00:00
parent 6c08f26c4e
commit 7760963d04
9 changed files with 34 additions and 40 deletions

View File

@ -16,6 +16,10 @@
namespace webrtc {
#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
WebRtc_Word32 SetCaptureAndroidVM(void* javaVM, void* javaContext);
#endif
class VideoCaptureModule: public RefCountedModule {
public:
// Interface for receiving information about available camera devices.

View File

@ -18,6 +18,16 @@
namespace webrtc
{
#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
// TODO(leozwang) These SetAndroidVM apis will be refactored, thus we only
// keep and reference java vm.
WebRtc_Word32 SetCaptureAndroidVM(void* javaVM, void* javaContext) {
return videocapturemodule::VideoCaptureAndroid::SetAndroidObjects(
javaVM,
javaContext);
}
#endif
namespace videocapturemodule
{

View File

@ -10,9 +10,6 @@
#include "video_capture_factory.h"
#include "video_capture_impl.h"
#ifdef WEBRTC_ANDROID
#include "video_capture_android.h"
#endif
namespace webrtc
{
@ -32,12 +29,4 @@ VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo(
return videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(id);
}
#ifdef WEBRTC_ANDROID
WebRtc_Word32 VideoCaptureFactory::SetAndroidObjects(void* javaVM,
void* javaContext) {
return videocapturemodule::VideoCaptureAndroid::SetAndroidObjects(javaVM,
javaContext);
}
#endif
} // namespace webrtc

View File

@ -20,10 +20,6 @@
#include <stdlib.h>
#ifdef WEBRTC_ANDROID
#include "video_capture_android.h" // Need inclusion here to set Java environment.
#endif
namespace webrtc
{
namespace videocapturemodule

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 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
@ -24,6 +24,11 @@
#include "video_render_defines.h"
namespace webrtc {
#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
WebRtc_Word32 SetRenderAndroidVM(void* javaVM);
#endif
// Class definitions
class VideoRender: public Module
{
@ -273,8 +278,6 @@ public:
const bool enable,
const bool mirrorXAxis,
const bool mirrorYAxis) = 0;
static WebRtc_Word32 SetAndroidObjects(void* javaVM);
};
} //namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_INTERFACE_VIDEO_RENDER_H_

View File

@ -26,13 +26,16 @@
#endif
namespace webrtc {
JavaVM* VideoRenderAndroid::g_jvm = NULL;
WebRtc_Word32 VideoRenderAndroid::SetAndroidEnvVariables(void* javaVM) {
#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
WebRtc_Word32 SetRenderAndroidVM(void* javaVM) {
WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, -1, "%s", __FUNCTION__);
g_jvm = (JavaVM*) javaVM;
VideoRenderAndroid::g_jvm = (JavaVM*)javaVM;
return 0;
}
#endif
VideoRenderAndroid::VideoRenderAndroid(
const WebRtc_Word32 id,

View File

@ -38,8 +38,6 @@ class AndroidStream : public VideoRenderCallback {
class VideoRenderAndroid: IVideoRender {
public:
static WebRtc_Word32 SetAndroidEnvVariables(void* javaVM);
VideoRenderAndroid(const WebRtc_Word32 id,
const VideoRenderType videoRenderType,
void* window,
@ -118,6 +116,7 @@ class VideoRenderAndroid: IVideoRender {
const void* colorKey, const float left,
const float top, const float right,
const float bottom);
static JavaVM* g_jvm;
protected:
virtual AndroidStream* CreateAndroidRenderChannel(
@ -134,8 +133,6 @@ class VideoRenderAndroid: IVideoRender {
VideoRenderType _renderType;
jobject _ptrWindow;
static JavaVM* g_jvm;
private:
static bool JavaRenderThreadFun(void* obj);
bool JavaRenderThreadProcess();

View File

@ -24,7 +24,9 @@
#include "windows/video_render_windows_impl.h"
#define STANDARD_RENDERING kRenderWindows
#elif defined(MAC_IPHONE) // MAC_IPHONE should go before WEBRTC_MAC_INTEL because WEBRTC_MAC_INTEL gets defined if MAC_IPHONE is defined
// MAC_IPHONE should go before WEBRTC_MAC_INTEL because WEBRTC_MAC_INTEL
// gets defined if MAC_IPHONE is defined
#elif defined(MAC_IPHONE)
#if defined(IPHONE_GLES_RENDERING)
#define STANDARD_RENDERING kRenderiPhone
#include "iPhone/video_render_iphone_impl.h"
@ -69,7 +71,6 @@ VideoRender::CreateVideoRender(const WebRtc_Word32 id,
const bool fullscreen,
const VideoRenderType videoRenderType/*=kRenderDefault*/)
{
VideoRenderType resultVideoRenderType = videoRenderType;
if (videoRenderType == kRenderDefault)
{
@ -88,15 +89,6 @@ void VideoRender::DestroyVideoRender(
}
}
WebRtc_Word32 VideoRender::SetAndroidObjects(void *javaVM)
{
#ifdef WEBRTC_ANDROID
return VideoRenderAndroid::SetAndroidEnvVariables(javaVM);
#else
return -1;
#endif
}
ModuleVideoRenderImpl::ModuleVideoRenderImpl(
const WebRtc_Word32 id,
const VideoRenderType videoRenderType,

View File

@ -210,15 +210,15 @@ int VideoEngine::SetAndroidObjects(void* javaVM, void* javaContext) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, g_vie_active_instance_counter,
"SetAndroidObjects()");
#ifdef WEBRTC_ANDROID
if (VideoCaptureFactory::SetAndroidObjects(javaVM, javaContext) != 0) {
#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
if (SetCaptureAndroidVM(javaVM, javaContext) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter,
"Could not set capture module Android objects");
"Could not set capture Android VM");
return -1;
}
if (VideoRender::SetAndroidObjects(javaVM) != 0) {
if (SetRenderAndroidVM(javaVM) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter,
"Could not set render module Android objects");
"Could not set render Android VM");
return -1;
}
return 0;