Change folder name from Android to android
Review URL: http://webrtc-codereview.appspot.com/107001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@357 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
74a49a833e
commit
c5597353c6
@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="org.webrtc.capturemoduleandroidtest"
|
|
||||||
android:versionCode="1"
|
|
||||||
android:versionName="1.0">
|
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
|
|
||||||
<activity android:label="@string/app_name" android:name="VideoCaptureModuleTest" android:configChanges="orientation|keyboardHidden" android:launchMode="singleTask" android:multiprocess="false">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<uses-feature android:required="true" android:name="android.hardware.camera"></uses-feature>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-sdk android:targetSdkVersion="7" android:minSdkVersion="7"></uses-sdk>
|
|
||||||
</manifest>
|
|
@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h> // memset
|
|
||||||
#include <android/log.h>
|
|
||||||
|
|
||||||
#include "org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest.h"
|
|
||||||
#include "../../../interface/video_capture.h"
|
|
||||||
#include "../../../../../video_render/main/interface/video_render.h"
|
|
||||||
#include "../../testAPI/testPlatformDependent.h"
|
|
||||||
#include "../../testAPI/testPlatformDependent.h"
|
|
||||||
#ifdef RENDER_PREVIEW
|
|
||||||
#include "../../testAPI/Renderer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace webrtc;
|
|
||||||
#define WEBRTC_LOG_TAG "*WEBRTCN*" // As in WEBRTC Native...
|
|
||||||
// ADM data struct
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
// Other
|
|
||||||
JavaVM* jvm;
|
|
||||||
Renderer* renderer;
|
|
||||||
VideoCaptureModule* _videoCapture;
|
|
||||||
VideoCaptureModule::DeviceInfo*_captureInfo;
|
|
||||||
} JniData;
|
|
||||||
|
|
||||||
// Global variables visible in this file
|
|
||||||
static JniData jniData;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
// General functions
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
|
||||||
// JNI_OnLoad
|
|
||||||
//
|
|
||||||
jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
|
|
||||||
{
|
|
||||||
__android_log_write(ANDROID_LOG_DEBUG, WEBRTC_LOG_TAG, "JNI_OnLoad");
|
|
||||||
if (!vm)
|
|
||||||
{
|
|
||||||
__android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
|
|
||||||
"JNI_OnLoad did not receive a valid VM pointer");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get JNI
|
|
||||||
JNIEnv* env;
|
|
||||||
if (JNI_OK != vm->GetEnv(reinterpret_cast<void**> (&env), JNI_VERSION_1_4))
|
|
||||||
{
|
|
||||||
__android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
|
|
||||||
"JNI_OnLoad could not get JNI env");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init JniData data
|
|
||||||
memset(&jniData, 0, sizeof(jniData));
|
|
||||||
|
|
||||||
// Store the JVM
|
|
||||||
jniData.jvm = vm;
|
|
||||||
|
|
||||||
return JNI_VERSION_1_4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
|
||||||
// Run Test
|
|
||||||
//
|
|
||||||
JNIEXPORT jint JNICALL Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_RunTest(
|
|
||||||
JNIEnv * env,
|
|
||||||
jobject context,
|
|
||||||
jobject surface)
|
|
||||||
{
|
|
||||||
__android_log_write(ANDROID_LOG_DEBUG, WEBRTC_LOG_TAG, "Run test");
|
|
||||||
// Set instance independent Java objects
|
|
||||||
VideoCaptureModule::SetAndroidObjects(jniData.jvm, context);
|
|
||||||
|
|
||||||
// Start test
|
|
||||||
__android_log_write(ANDROID_LOG_DEBUG, WEBRTC_LOG_TAG,
|
|
||||||
"Create testPlatformDependent");
|
|
||||||
testPlatformDependent testPlatformDependent;
|
|
||||||
testPlatformDependent.SetRenderer(jniData.renderer);
|
|
||||||
testPlatformDependent.DoTest();
|
|
||||||
|
|
||||||
// Clear instance independent Java objects
|
|
||||||
VideoCaptureModule::SetAndroidObjects(NULL, NULL);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_RenderInit(
|
|
||||||
JNIEnv * env,
|
|
||||||
jobject context,
|
|
||||||
jobject surface)
|
|
||||||
{
|
|
||||||
VideoRender::SetAndroidObjects(jniData.jvm);
|
|
||||||
#ifdef RENDER_PREVIEW
|
|
||||||
Renderer::SetRenderWindow(surface);
|
|
||||||
jniData.renderer=new Renderer(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_StartCapture(
|
|
||||||
JNIEnv * env,
|
|
||||||
jobject context)
|
|
||||||
{
|
|
||||||
if (!jniData._captureInfo)
|
|
||||||
{
|
|
||||||
VideoCaptureModule::SetAndroidObjects(jniData.jvm, context);
|
|
||||||
jniData._captureInfo = VideoCaptureModule::CreateDeviceInfo(5);
|
|
||||||
WebRtc_UWord8 id[256];
|
|
||||||
WebRtc_UWord8 name[256];
|
|
||||||
jniData._captureInfo->GetDeviceName(0, name, 256, id, 256);
|
|
||||||
jniData._videoCapture = VideoCaptureModule::Create(0, id);
|
|
||||||
VideoCaptureCapability capability;
|
|
||||||
|
|
||||||
jniData._captureInfo->GetCapability(id, 0, capability);
|
|
||||||
capability.width = 176;
|
|
||||||
capability.height = 144;
|
|
||||||
capability.maxFPS = 15;
|
|
||||||
|
|
||||||
jniData._videoCapture->StartCapture(capability);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_StopCapture(
|
|
||||||
JNIEnv * env,
|
|
||||||
jobject context)
|
|
||||||
{
|
|
||||||
if (jniData._videoCapture)
|
|
||||||
{
|
|
||||||
jniData._videoCapture->StopCapture();
|
|
||||||
VideoCaptureModule::DestroyDeviceInfo(jniData._captureInfo);
|
|
||||||
VideoCaptureModule::Destroy(jniData._videoCapture);
|
|
||||||
jniData._videoCapture = NULL;
|
|
||||||
jniData._captureInfo = NULL;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
>
|
|
||||||
<Button android:text="@string/run_button" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
|
|
||||||
<Button android:text="@string/run_button2" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
|
|
||||||
<Button android:text="@string/run_button3" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
|
|
||||||
<Button android:text="@string/run_button4" android:id="@+id/Button04" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/renderView"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_weight="1">
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,58 +0,0 @@
|
|||||||
package org.webrtc.capturemoduleandroidtest;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.webrtc.videoengine.CaptureCapabilityAndroid;
|
|
||||||
import org.webrtc.videoengine.VideoCaptureAndroid;
|
|
||||||
import org.webrtc.videoengine.VideoCaptureDeviceInfoAndroid;
|
|
||||||
|
|
||||||
public class VideoCaptureJavaTest {
|
|
||||||
void DoTest(Context context)
|
|
||||||
{
|
|
||||||
VideoCaptureDeviceInfoAndroid videoCaptureDeviceInfo=VideoCaptureDeviceInfoAndroid.CreateVideoCaptureDeviceInfoAndroid(5,context);
|
|
||||||
for(int i=0; i<videoCaptureDeviceInfo.NumberOfDevices();i++)
|
|
||||||
{
|
|
||||||
String deviceUniqueId=videoCaptureDeviceInfo.GetDeviceUniqueName(i);
|
|
||||||
VideoCaptureAndroid videoCapture=videoCaptureDeviceInfo.AllocateCamera(i,0,deviceUniqueId);
|
|
||||||
|
|
||||||
CaptureCapabilityAndroid capArray[] =videoCaptureDeviceInfo.GetCapabilityArray(deviceUniqueId);
|
|
||||||
for(CaptureCapabilityAndroid cap: capArray)
|
|
||||||
{
|
|
||||||
Log.d("*WEBRTC*", "Capability widht" + cap.width + " height " +cap.height+ " frameRate " +cap.maxFPS);
|
|
||||||
int result=videoCapture.StartCapture(cap.width, cap.height, cap.maxFPS);
|
|
||||||
try{
|
|
||||||
Thread.sleep(2000);//sleep for 2000 ms
|
|
||||||
}
|
|
||||||
catch(InterruptedException ie){
|
|
||||||
//If this thread was interrupted by another thread
|
|
||||||
}
|
|
||||||
result+=videoCapture.StopCapture();
|
|
||||||
Log.d("*WEBRTC*", "Start stop result " + result);
|
|
||||||
}
|
|
||||||
VideoCaptureAndroid.DeleteVideoCaptureAndroid(videoCapture);
|
|
||||||
videoCapture=null;
|
|
||||||
}
|
|
||||||
Log.d("*WEBRTC*", "Test complete");
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoCaptureDeviceInfoAndroid _videoCaptureDeviceInfo;
|
|
||||||
VideoCaptureAndroid _videoCapture;
|
|
||||||
void StartCapture(Context context)
|
|
||||||
{
|
|
||||||
_videoCaptureDeviceInfo= VideoCaptureDeviceInfoAndroid.CreateVideoCaptureDeviceInfoAndroid(5,context);
|
|
||||||
String deviceUniqueId=_videoCaptureDeviceInfo.GetDeviceUniqueName(0);
|
|
||||||
_videoCapture=_videoCaptureDeviceInfo.AllocateCamera(5,0,deviceUniqueId);
|
|
||||||
_videoCapture.StartCapture(176,144,15);
|
|
||||||
|
|
||||||
}
|
|
||||||
void StopCapture()
|
|
||||||
{
|
|
||||||
_videoCapture.StopCapture();
|
|
||||||
VideoCaptureAndroid.DeleteVideoCaptureAndroid(_videoCapture);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
package org.webrtc.capturemoduleandroidtest;
|
|
||||||
|
|
||||||
import javax.microedition.khronos.egl.EGLConfig;
|
|
||||||
import javax.microedition.khronos.opengles.GL10;
|
|
||||||
|
|
||||||
import org.webrtc.capturemoduleandroidtest.R;
|
|
||||||
import org.webrtc.videoengine.ViERenderer;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.opengl.GLSurfaceView;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.SurfaceHolder;
|
|
||||||
import android.view.SurfaceView;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
public class VideoCaptureModuleTest extends Activity implements OnClickListener {
|
|
||||||
private final int _useOpenGL=1; // Set to 1 if OpenGL shall be used. 0 Otherwise
|
|
||||||
private Thread _testThread;
|
|
||||||
private SurfaceView _view=null;
|
|
||||||
private VideoCaptureModuleTest _thisPointer;
|
|
||||||
private VideoCaptureJavaTest _videoCaptureJavaTest;
|
|
||||||
/** Called when the activity is first created. */
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.main);
|
|
||||||
|
|
||||||
|
|
||||||
final Button buttonStartCP = (Button) findViewById(R.id.Button01);
|
|
||||||
buttonStartCP.setOnClickListener(this);
|
|
||||||
final Button buttonStartJava = (Button) findViewById(R.id.Button02);
|
|
||||||
buttonStartJava.setOnClickListener(this);
|
|
||||||
final Button buttonStartCPP = (Button) findViewById(R.id.Button03);
|
|
||||||
buttonStartCPP.setOnClickListener(this);
|
|
||||||
final Button buttonStopCPP = (Button) findViewById(R.id.Button04);
|
|
||||||
buttonStopCPP.setOnClickListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Runnable _testProc = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
// TODO: choose test from GUI
|
|
||||||
// Select test here, 0 for API test, 1-> for Func tests
|
|
||||||
RunTest(_view);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
super.onStart();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onRestart()
|
|
||||||
{
|
|
||||||
super.onRestart();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause()
|
|
||||||
{
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
super.onStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function used to call test
|
|
||||||
private native int RunTest(Object view);
|
|
||||||
private native int RenderInit(Object view);
|
|
||||||
|
|
||||||
private native int StartCapture();
|
|
||||||
private native int StopCapture();
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
|
||||||
Log.d("*WEBRTC*", "Loading ModuleVideoCaptureModuleAndroidTest...");
|
|
||||||
System.loadLibrary("ModuleVideoCaptureModuleAndroidTestJniAPI");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick(View v) {
|
|
||||||
LinearLayout renderLayout=(LinearLayout) findViewById(R.id.renderView); //get the handle to the layout
|
|
||||||
switch(v.getId())
|
|
||||||
{
|
|
||||||
case R.id.Button01:
|
|
||||||
renderLayout.removeAllViews();
|
|
||||||
_view=ViERenderer.CreateLocalRenderer(this);
|
|
||||||
if(_useOpenGL==1)
|
|
||||||
{
|
|
||||||
_view= ViERenderer.CreateRenderer(this, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_view= new SurfaceView(this);
|
|
||||||
}
|
|
||||||
renderLayout.addView(_view); // add the surfaceview to the layout, the surfaceview will be the same size as the layout (container)
|
|
||||||
RenderInit(_view);
|
|
||||||
_testThread = new Thread(_testProc);
|
|
||||||
_testThread.start();
|
|
||||||
break;
|
|
||||||
case R.id.Button02:
|
|
||||||
_view=ViERenderer.CreateLocalRenderer(this);
|
|
||||||
renderLayout.removeAllViews();
|
|
||||||
if(_videoCaptureJavaTest==null)
|
|
||||||
{
|
|
||||||
_videoCaptureJavaTest=new VideoCaptureJavaTest();
|
|
||||||
_videoCaptureJavaTest.StartCapture(this);
|
|
||||||
renderLayout.addView(_view); // add the surfaceview to the layout, the surfaceview will be the same size as the layout (container)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_videoCaptureJavaTest.StopCapture();
|
|
||||||
_videoCaptureJavaTest=null;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.Button03:
|
|
||||||
_view=ViERenderer.CreateLocalRenderer(this);
|
|
||||||
renderLayout.removeAllViews();
|
|
||||||
StartCapture();
|
|
||||||
renderLayout.addView(_view); // add the surfaceview to the layout, the surfaceview will be the same size as the layout (container)
|
|
||||||
break;
|
|
||||||
case R.id.Button04:
|
|
||||||
renderLayout.removeAllViews();
|
|
||||||
StopCapture();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="org.webrtc.capturemoduleandroidtest"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0">
|
||||||
|
<application android:icon="@drawable/icon"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:debuggable="true">
|
||||||
|
<activity android:label="@string/app_name"
|
||||||
|
android:name="VideoCaptureModuleTest"
|
||||||
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:multiprocess="false">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<uses-feature android:required="true"
|
||||||
|
android:name="android.hardware.camera">
|
||||||
|
</uses-feature>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA">
|
||||||
|
</uses-permission>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-sdk android:targetSdkVersion="7"
|
||||||
|
android:minSdkVersion="7">
|
||||||
|
</uses-sdk>
|
||||||
|
</manifest>
|
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h> // memset
|
||||||
|
#include <android/log.h>
|
||||||
|
|
||||||
|
#include "org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest.h"
|
||||||
|
#include "../../../interface/video_capture.h"
|
||||||
|
#include "../../../../../video_render/main/interface/video_render.h"
|
||||||
|
#include "../../testAPI/testPlatformDependent.h"
|
||||||
|
#include "../../testAPI/testPlatformDependent.h"
|
||||||
|
#ifdef RENDER_PREVIEW
|
||||||
|
#include "../../testAPI/Renderer.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace webrtc;
|
||||||
|
#define WEBRTC_LOG_TAG "*WEBRTCN*" // As in WEBRTC Native...
|
||||||
|
// ADM data struct
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// Other
|
||||||
|
JavaVM* jvm;
|
||||||
|
Renderer* renderer;
|
||||||
|
VideoCaptureModule* _videoCapture;
|
||||||
|
VideoCaptureModule::DeviceInfo*_captureInfo;
|
||||||
|
} JniData;
|
||||||
|
|
||||||
|
// Global variables visible in this file
|
||||||
|
static JniData jniData;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
// General functions
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// JNI_OnLoad
|
||||||
|
//
|
||||||
|
jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
|
||||||
|
{
|
||||||
|
__android_log_write(ANDROID_LOG_DEBUG, WEBRTC_LOG_TAG, "JNI_OnLoad");
|
||||||
|
if (!vm)
|
||||||
|
{
|
||||||
|
__android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
|
||||||
|
"JNI_OnLoad did not receive a valid VM pointer");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get JNI
|
||||||
|
JNIEnv* env;
|
||||||
|
if (JNI_OK != vm->GetEnv(reinterpret_cast<void**> (&env), JNI_VERSION_1_4))
|
||||||
|
{
|
||||||
|
__android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
|
||||||
|
"JNI_OnLoad could not get JNI env");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init JniData data
|
||||||
|
memset(&jniData, 0, sizeof(jniData));
|
||||||
|
|
||||||
|
// Store the JVM
|
||||||
|
jniData.jvm = vm;
|
||||||
|
|
||||||
|
return JNI_VERSION_1_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// Run Test
|
||||||
|
//
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_RunTest(
|
||||||
|
JNIEnv * env,
|
||||||
|
jobject context,
|
||||||
|
jobject surface)
|
||||||
|
{
|
||||||
|
__android_log_write(ANDROID_LOG_DEBUG, WEBRTC_LOG_TAG, "Run test");
|
||||||
|
// Set instance independent Java objects
|
||||||
|
VideoCaptureModule::SetAndroidObjects(jniData.jvm, context);
|
||||||
|
|
||||||
|
// Start test
|
||||||
|
__android_log_write(ANDROID_LOG_DEBUG, WEBRTC_LOG_TAG,
|
||||||
|
"Create testPlatformDependent");
|
||||||
|
testPlatformDependent testPlatformDependent;
|
||||||
|
testPlatformDependent.SetRenderer(jniData.renderer);
|
||||||
|
testPlatformDependent.DoTest();
|
||||||
|
|
||||||
|
// Clear instance independent Java objects
|
||||||
|
VideoCaptureModule::SetAndroidObjects(NULL, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_RenderInit(
|
||||||
|
JNIEnv * env,
|
||||||
|
jobject context,
|
||||||
|
jobject surface)
|
||||||
|
{
|
||||||
|
VideoRender::SetAndroidObjects(jniData.jvm);
|
||||||
|
#ifdef RENDER_PREVIEW
|
||||||
|
Renderer::SetRenderWindow(surface);
|
||||||
|
jniData.renderer=new Renderer(true);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_StartCapture(
|
||||||
|
JNIEnv * env,
|
||||||
|
jobject context)
|
||||||
|
{
|
||||||
|
if (!jniData._captureInfo) {
|
||||||
|
VideoCaptureModule::SetAndroidObjects(jniData.jvm, context);
|
||||||
|
jniData._captureInfo = VideoCaptureModule::CreateDeviceInfo(5);
|
||||||
|
WebRtc_UWord8 id[256];
|
||||||
|
WebRtc_UWord8 name[256];
|
||||||
|
jniData._captureInfo->GetDeviceName(0, name, 256, id, 256);
|
||||||
|
jniData._videoCapture = VideoCaptureModule::Create(0, id);
|
||||||
|
VideoCaptureCapability capability;
|
||||||
|
|
||||||
|
jniData._captureInfo->GetCapability(id, 0, capability);
|
||||||
|
capability.width = 176;
|
||||||
|
capability.height = 144;
|
||||||
|
capability.maxFPS = 15;
|
||||||
|
|
||||||
|
jniData._videoCapture->StartCapture(capability);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_StopCapture(
|
||||||
|
JNIEnv * env,
|
||||||
|
jobject context)
|
||||||
|
{
|
||||||
|
if (jniData._videoCapture) {
|
||||||
|
jniData._videoCapture->StopCapture();
|
||||||
|
VideoCaptureModule::DestroyDeviceInfo(jniData._captureInfo);
|
||||||
|
VideoCaptureModule::Destroy(jniData._videoCapture);
|
||||||
|
jniData._videoCapture = NULL;
|
||||||
|
jniData._captureInfo = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
<Button android:text="@string/run_button"
|
||||||
|
android:id="@+id/Button01"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
</Button>
|
||||||
|
<Button android:text="@string/run_button2"
|
||||||
|
android:id="@+id/Button02"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
</Button>
|
||||||
|
<Button android:text="@string/run_button3"
|
||||||
|
android:id="@+id/Button03"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
</Button>
|
||||||
|
<Button android:text="@string/run_button4"
|
||||||
|
android:id="@+id/Button04"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
</Button>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/renderView"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="1">
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,61 @@
|
|||||||
|
package org.webrtc.capturemoduleandroidtest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.webrtc.videoengine.CaptureCapabilityAndroid;
|
||||||
|
import org.webrtc.videoengine.VideoCaptureAndroid;
|
||||||
|
import org.webrtc.videoengine.VideoCaptureDeviceInfoAndroid;
|
||||||
|
|
||||||
|
public class VideoCaptureJavaTest {
|
||||||
|
void DoTest(Context context)
|
||||||
|
{
|
||||||
|
VideoCaptureDeviceInfoAndroid videoCaptureDeviceInfo =
|
||||||
|
VideoCaptureDeviceInfoAndroid.CreateVideoCaptureDeviceInfoAndroid(
|
||||||
|
5,context);
|
||||||
|
for(int i = 0; i < videoCaptureDeviceInfo.NumberOfDevices(); i++) {
|
||||||
|
String deviceUniqueId=videoCaptureDeviceInfo.GetDeviceUniqueName(i);
|
||||||
|
VideoCaptureAndroid videoCapture =
|
||||||
|
videoCaptureDeviceInfo.AllocateCamera(i,0,deviceUniqueId);
|
||||||
|
|
||||||
|
CaptureCapabilityAndroid capArray[] =
|
||||||
|
videoCaptureDeviceInfo.GetCapabilityArray(deviceUniqueId);
|
||||||
|
for(CaptureCapabilityAndroid cap: capArray) {
|
||||||
|
Log.d("*WEBRTC*", "Capability widht" + cap.width +
|
||||||
|
" height " +cap.height+ " frameRate " +cap.maxFPS);
|
||||||
|
int result=videoCapture.StartCapture(cap.width,
|
||||||
|
cap.height,
|
||||||
|
cap.maxFPS);
|
||||||
|
try{
|
||||||
|
Thread.sleep(2000);//sleep for 2000 ms
|
||||||
|
}
|
||||||
|
catch(InterruptedException ie){
|
||||||
|
//If this thread was interrupted by another thread
|
||||||
|
}
|
||||||
|
result+=videoCapture.StopCapture();
|
||||||
|
Log.d("*WEBRTC*", "Start stop result " + result);
|
||||||
|
}
|
||||||
|
VideoCaptureAndroid.DeleteVideoCaptureAndroid(videoCapture);
|
||||||
|
videoCapture=null;
|
||||||
|
}
|
||||||
|
Log.d("*WEBRTC*", "Test complete");
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoCaptureDeviceInfoAndroid _videoCaptureDeviceInfo;
|
||||||
|
VideoCaptureAndroid _videoCapture;
|
||||||
|
void StartCapture(Context context) {
|
||||||
|
_videoCaptureDeviceInfo =
|
||||||
|
VideoCaptureDeviceInfoAndroid.CreateVideoCaptureDeviceInfoAndroid(
|
||||||
|
5,context);
|
||||||
|
String deviceUniqueId=_videoCaptureDeviceInfo.GetDeviceUniqueName(0);
|
||||||
|
_videoCapture=_videoCaptureDeviceInfo.AllocateCamera(5,0,deviceUniqueId);
|
||||||
|
_videoCapture.StartCapture(176,144,15);
|
||||||
|
}
|
||||||
|
void StopCapture() {
|
||||||
|
_videoCapture.StopCapture();
|
||||||
|
VideoCaptureAndroid.DeleteVideoCaptureAndroid(_videoCapture);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,142 @@
|
|||||||
|
package org.webrtc.capturemoduleandroidtest;
|
||||||
|
|
||||||
|
import javax.microedition.khronos.egl.EGLConfig;
|
||||||
|
import javax.microedition.khronos.opengles.GL10;
|
||||||
|
|
||||||
|
import org.webrtc.capturemoduleandroidtest.R;
|
||||||
|
import org.webrtc.videoengine.ViERenderer;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.opengl.GLSurfaceView;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.SurfaceHolder;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
public class VideoCaptureModuleTest
|
||||||
|
extends Activity implements OnClickListener {
|
||||||
|
// Set to 1 if OpenGL shall be used. 0 Otherwise
|
||||||
|
private final int _useOpenGL=1;
|
||||||
|
private Thread _testThread;
|
||||||
|
private SurfaceView _view=null;
|
||||||
|
private VideoCaptureModuleTest _thisPointer;
|
||||||
|
private VideoCaptureJavaTest _videoCaptureJavaTest;
|
||||||
|
/** Called when the activity is first created. */
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
|
final Button buttonStartCP = (Button) findViewById(R.id.Button01);
|
||||||
|
buttonStartCP.setOnClickListener(this);
|
||||||
|
final Button buttonStartJava = (Button) findViewById(R.id.Button02);
|
||||||
|
buttonStartJava.setOnClickListener(this);
|
||||||
|
final Button buttonStartCPP = (Button) findViewById(R.id.Button03);
|
||||||
|
buttonStartCPP.setOnClickListener(this);
|
||||||
|
final Button buttonStopCPP = (Button) findViewById(R.id.Button04);
|
||||||
|
buttonStopCPP.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Runnable _testProc = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
// TODO: choose test from GUI
|
||||||
|
// Select test here, 0 for API test, 1-> for Func tests
|
||||||
|
RunTest(_view);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
super.onStart();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onRestart()
|
||||||
|
{
|
||||||
|
super.onRestart();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onPause()
|
||||||
|
{
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function used to call test
|
||||||
|
private native int RunTest(Object view);
|
||||||
|
private native int RenderInit(Object view);
|
||||||
|
|
||||||
|
private native int StartCapture();
|
||||||
|
private native int StopCapture();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Log.d("*WEBRTC*",
|
||||||
|
"Loading ModuleVideoCaptureModuleAndroidTest...");
|
||||||
|
System.loadLibrary(
|
||||||
|
"ModuleVideoCaptureModuleAndroidTestJniAPI");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClick(View v) {
|
||||||
|
//get the handle to the layout
|
||||||
|
LinearLayout renderLayout=(LinearLayout) findViewById(R.id.renderView);
|
||||||
|
switch(v.getId())
|
||||||
|
{
|
||||||
|
case R.id.Button01:
|
||||||
|
renderLayout.removeAllViews();
|
||||||
|
_view=ViERenderer.CreateLocalRenderer(this);
|
||||||
|
if(_useOpenGL==1)
|
||||||
|
{
|
||||||
|
_view= ViERenderer.CreateRenderer(this, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_view= new SurfaceView(this);
|
||||||
|
}
|
||||||
|
// add the surfaceview to the layout,
|
||||||
|
// the surfaceview will be the same size as the layout (container)
|
||||||
|
renderLayout.addView(_view);
|
||||||
|
RenderInit(_view);
|
||||||
|
_testThread = new Thread(_testProc);
|
||||||
|
_testThread.start();
|
||||||
|
break;
|
||||||
|
case R.id.Button02:
|
||||||
|
_view=ViERenderer.CreateLocalRenderer(this);
|
||||||
|
renderLayout.removeAllViews();
|
||||||
|
if(_videoCaptureJavaTest==null)
|
||||||
|
{
|
||||||
|
_videoCaptureJavaTest=new VideoCaptureJavaTest();
|
||||||
|
_videoCaptureJavaTest.StartCapture(this);
|
||||||
|
// add the surfaceview to the layout,
|
||||||
|
// the surfaceview will be the same size as the layout (container)
|
||||||
|
renderLayout.addView(_view);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_videoCaptureJavaTest.StopCapture();
|
||||||
|
_videoCaptureJavaTest=null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.Button03:
|
||||||
|
_view=ViERenderer.CreateLocalRenderer(this);
|
||||||
|
renderLayout.removeAllViews();
|
||||||
|
StartCapture();
|
||||||
|
// add the surfaceview to the layout,
|
||||||
|
// the surfaceview will be the same size as the layout (container)
|
||||||
|
renderLayout.addView(_view);
|
||||||
|
break;
|
||||||
|
case R.id.Button04:
|
||||||
|
renderLayout.removeAllViews();
|
||||||
|
StopCapture();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user