refactor java code in test app

Review URL: http://webrtc-codereview.appspot.com/24011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@53 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
leozwang@google.com
2011-06-07 17:52:00 +00:00
parent 40cd79e63c
commit ed7f027037
3 changed files with 958 additions and 944 deletions

View File

@ -1,19 +1,17 @@
/* /*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* *
* Use of this source code is governed by a BSD-style license * 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 * that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found * tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
/* package org.webrtc.videoengineapp;
* TODO, refactoring
*/ public interface IViEAndroidCallback {
public int UpdateStats(int frameRateI, int bitRateI,
package org.webrtc.videoengineapp; int packetLoss, int frameRateO,
int bitRateO);
public interface IViEAndroidCallback { }
public int UpdateStats(int frameRateI, int bitRateI, int packetLoss, int frameRateO, int bitRateO);
}

View File

@ -1,150 +1,138 @@
/* /*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* *
* Use of this source code is governed by a BSD-style license * 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 * that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found * tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
/*
* TODO, refactoring package org.webrtc.videoengineapp;
*/
import android.app.Activity;
/////////////////////////////////////////////// import android.content.Context;
//VideoEngine Java API class import android.util.Log;
//for Android import android.view.SurfaceHolder;
/////////////////////////////////////////////// import android.view.SurfaceView;
package org.webrtc.videoengineapp;
public class ViEAndroidJavaAPI {
import android.app.Activity;
import android.content.Context; public ViEAndroidJavaAPI(Context context) {
import android.util.Log; Log.d("*WEBRTCJ*", "Loading ViEAndroidJavaAPI...");
import android.view.SurfaceHolder; System.loadLibrary("webrtc-video-demo-jni");
import android.view.SurfaceView;
Log.d("*WEBRTCJ*", "Calling native init...");
public class ViEAndroidJavaAPI { if (!NativeInit(context)) {
Log.e("*WEBRTCJ*", "Native init failed");
public ViEAndroidJavaAPI(Context context) { throw new RuntimeException("Native init failed");
Log.d("*WEBRTCJ*", "Loading ViEAndroidJavaAPI..."); }
System.loadLibrary("ViEAndroidJavaAPI"); else {
Log.d("*WEBRTCJ*", "Native init successful");
Log.d("*WEBRTCJ*", "Calling native init..."); }
if (!NativeInit(context)) { String a = "";
Log.e("*WEBRTCJ*", "Native init failed"); a.getBytes();
throw new RuntimeException("Native init failed"); }
} else {
Log.d("*WEBRTCJ*", "Native init successful"); // API Native
} private native boolean NativeInit(Context context);
String a = "";
a.getBytes(); // Video Engine API
} // Initialization and Termination functions
public native int GetVideoEngine();
// ####################API Native############################## public native int Init(boolean enableTrace);
private native boolean NativeInit(Context context); public native int Terminate();
// #################### Video Engine API ##############################
// Initialization and Termination functions public native int StartSend(int channel);
public native int GetVideoEngine(); public native int StopRender(int channel);
public native int Init(boolean enableTrace); public native int StopSend(int channel);
public native int Terminate(); public native int StartReceive(int channel);
public native int StopReceive(int channel);
// Channel functions
public native int StartSend(int channel); public native int CreateChannel(int voiceChannel);
// Receiver & Destination functions
public native int StopRender(int channel); public native int SetLocalReceiver(int channel, int port);
public native int SetSendDestination(int channel, int port, byte ipadr[]);
public native int StopSend(int channel); // Codec
public native int SetReceiveCodec(int channel, int codecNum,
public native int StartReceive(int channel); int intbitRate, int width,
int height, int frameRate);
public native int StopReceive(int channel); public native int SetSendCodec(int channel, int codecNum,
int intbitRate, int width,
// Channel functions int height, int frameRate);
public native int CreateChannel(int voiceChannel); // Rendering
public native int AddRemoteRenderer(int channel, Object glSurface);
// Receiver & Destination functions public native int RemoveRemoteRenderer(int channel);
public native int SetLocalReceiver(int channel, int port); public native int StartRender(int channel);
public native int SetSendDestination(int channel, int port, // Capture
byte ipadr[]); public native int StartCamera(int channel, int cameraNum);
public native int StopCamera(int cameraId);
// Codec public native int GetCameraOrientation(int cameraNum);
public native int SetReceiveCodec(int channel, int codecNum, public native int SetRotation(int cameraId,int degrees);
int intbitRate, int width, int height, int frameRate);
// NACK
public native int SetSendCodec(int channel, int codecNum, public native int EnableNACK(int channel, boolean enable);
int intbitRate, int width, int height, int frameRate);
//PLI for H.264
// Rendering public native int EnablePLI(int channel, boolean enable);
public native int AddRemoteRenderer(int channel,
Object glSurface); // Enable stats callback
public native int SetCallback(int channel, IViEAndroidCallback callback);
public native int RemoveRemoteRenderer(int channel);
// Voice Engine API
public native int StartRender(int channel); // Create and Delete functions
public native boolean VoE_Create(Activity context);
// Capture public native boolean VoE_Delete();
public native int StartCamera(int channel, int cameraNum);
public native int StopCamera(int cameraId); // Initialization and Termination functions
public native int GetCameraOrientation(int cameraNum); public native int VoE_Authenticate(String key);
public native int SetRotation(int cameraId,int degrees); public native int VoE_Init(boolean enableTrace);
public native int VoE_Terminate();
// NACK
public native int EnableNACK(int channel, boolean enable); // Channel functions
public native int VoE_CreateChannel();
//PLI for H.264 public native int VoE_DeleteChannel(int channel);
public native int EnablePLI(int channel, boolean enable);
// Receiver & Destination functions
// Enable stats callback public native int VoE_SetLocalReceiver(int channel, int port);
public native int SetCallback(int channel, IViEAndroidCallback callback); public native int VoE_SetSendDestination(int channel, int port,
String ipaddr);
// #################### Voice Engine API ##############################
// Create and Delete functions // Media functions
public native boolean VoE_Create(Activity context); public native int VoE_StartListen(int channel);
public native boolean VoE_Delete(); public native int VoE_StartPlayout(int channel);
public native int VoE_StartSend(int channel);
// Initialization and Termination functions public native int VoE_StopListen(int channel);
public native int VoE_Authenticate(String key); public native int VoE_StopPlayout(int channel);
public native int VoE_Init(int month, int day, int year, boolean enableTrace, boolean useExtTrans); public native int VoE_StopSend(int channel);
public native int VoE_Terminate();
// Volume
// Channel functions public native int VoE_SetSpeakerVolume(int volume);
public native int VoE_CreateChannel();
public native int VoE_DeleteChannel(int channel); // Hardware
public native int VoE_SetLoudspeakerStatus(boolean enable);
// Receiver & Destination functions
public native int VoE_SetLocalReceiver(int channel, int port); // Playout file locally
public native int VoE_SetSendDestination(int channel, int port, String ipaddr); public native int VoE_StartPlayingFileLocally(int channel,
String fileName,
// Media functions boolean loop);
public native int VoE_StartListen(int channel); public native int VoE_StopPlayingFileLocally(int channel);
public native int VoE_StartPlayout(int channel);
public native int VoE_StartSend(int channel); // Play file as microphone
public native int VoE_StopListen(int channel); public native int VoE_StartPlayingFileAsMicrophone(int channel,
public native int VoE_StopPlayout(int channel); String fileName,
public native int VoE_StopSend(int channel); boolean loop);
public native int VoE_StopPlayingFileAsMicrophone(int channel);
// Volume
public native int VoE_SetSpeakerVolume(int volume); // Codec-setting functions
public native int VoE_NumOfCodecs();
// Hardware public native int VoE_SetSendCodec(int channel, int index);
public native int VoE_SetLoudspeakerStatus(boolean enable);
//VE funtions
// Playout file locally public native int VoE_SetECStatus(boolean enable, int mode,
public native int VoE_StartPlayingFileLocally(int channel, String fileName, boolean loop); int AESmode, int AESattenuation);
public native int VoE_StopPlayingFileLocally(int channel); public native int VoE_SetAGCStatus(boolean enable, int mode);
public native int VoE_SetNSStatus(boolean enable, int mode);
// Play file as microphone }
public native int VoE_StartPlayingFileAsMicrophone(int channel, String fileName, boolean loop);
public native int VoE_StopPlayingFileAsMicrophone(int channel);
// Codec-setting functions
public native int VoE_NumOfCodecs();
public native int VoE_SetSendCodec(int channel, int index);
//VE funtions
public native int VoE_SetECStatus(boolean enable, int mode, int AESmode, int AESattenuation);
public native int VoE_SetAGCStatus(boolean enable, int mode);
public native int VoE_SetNSStatus(boolean enable, int mode);
}