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

@ -8,12 +8,10 @@
* 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; package org.webrtc.videoengineapp;
public interface IViEAndroidCallback { public interface IViEAndroidCallback {
public int UpdateStats(int frameRateI, int bitRateI, int packetLoss, int frameRateO, int bitRateO); public int UpdateStats(int frameRateI, int bitRateI,
int packetLoss, int frameRateO,
int bitRateO);
} }

View File

@ -7,14 +7,7 @@
* 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
*/
///////////////////////////////////////////////
//VideoEngine Java API class
//for Android
///////////////////////////////////////////////
package org.webrtc.videoengineapp; package org.webrtc.videoengineapp;
import android.app.Activity; import android.app.Activity;
@ -27,23 +20,24 @@ public class ViEAndroidJavaAPI {
public ViEAndroidJavaAPI(Context context) { public ViEAndroidJavaAPI(Context context) {
Log.d("*WEBRTCJ*", "Loading ViEAndroidJavaAPI..."); Log.d("*WEBRTCJ*", "Loading ViEAndroidJavaAPI...");
System.loadLibrary("ViEAndroidJavaAPI"); System.loadLibrary("webrtc-video-demo-jni");
Log.d("*WEBRTCJ*", "Calling native init..."); Log.d("*WEBRTCJ*", "Calling native init...");
if (!NativeInit(context)) { if (!NativeInit(context)) {
Log.e("*WEBRTCJ*", "Native init failed"); Log.e("*WEBRTCJ*", "Native init failed");
throw new RuntimeException("Native init failed"); throw new RuntimeException("Native init failed");
} else { }
else {
Log.d("*WEBRTCJ*", "Native init successful"); Log.d("*WEBRTCJ*", "Native init successful");
} }
String a = ""; String a = "";
a.getBytes(); a.getBytes();
} }
// ####################API Native############################## // API Native
private native boolean NativeInit(Context context); private native boolean NativeInit(Context context);
// #################### Video Engine API ############################## // Video Engine API
// Initialization and Termination functions // Initialization and Termination functions
public native int GetVideoEngine(); public native int GetVideoEngine();
public native int Init(boolean enableTrace); public native int Init(boolean enableTrace);
@ -51,37 +45,25 @@ public class ViEAndroidJavaAPI {
public native int StartSend(int channel); public native int StartSend(int channel);
public native int StopRender(int channel); public native int StopRender(int channel);
public native int StopSend(int channel); public native int StopSend(int channel);
public native int StartReceive(int channel); public native int StartReceive(int channel);
public native int StopReceive(int channel); public native int StopReceive(int channel);
// Channel functions // Channel functions
public native int CreateChannel(int voiceChannel); public native int CreateChannel(int voiceChannel);
// Receiver & Destination functions // Receiver & Destination functions
public native int SetLocalReceiver(int channel, int port); public native int SetLocalReceiver(int channel, int port);
public native int SetSendDestination(int channel, int port, byte ipadr[]);
public native int SetSendDestination(int channel, int port,
byte ipadr[]);
// Codec // Codec
public native int SetReceiveCodec(int channel, int codecNum, public native int SetReceiveCodec(int channel, int codecNum,
int intbitRate, int width, int height, int frameRate); int intbitRate, int width,
int height, int frameRate);
public native int SetSendCodec(int channel, int codecNum, public native int SetSendCodec(int channel, int codecNum,
int intbitRate, int width, int height, int frameRate); int intbitRate, int width,
int height, int frameRate);
// Rendering // Rendering
public native int AddRemoteRenderer(int channel, public native int AddRemoteRenderer(int channel, Object glSurface);
Object glSurface);
public native int RemoveRemoteRenderer(int channel); public native int RemoveRemoteRenderer(int channel);
public native int StartRender(int channel); public native int StartRender(int channel);
// Capture // Capture
@ -99,14 +81,14 @@ public class ViEAndroidJavaAPI {
// Enable stats callback // Enable stats callback
public native int SetCallback(int channel, IViEAndroidCallback callback); public native int SetCallback(int channel, IViEAndroidCallback callback);
// #################### Voice Engine API ############################## // Voice Engine API
// Create and Delete functions // Create and Delete functions
public native boolean VoE_Create(Activity context); public native boolean VoE_Create(Activity context);
public native boolean VoE_Delete(); public native boolean VoE_Delete();
// Initialization and Termination functions // Initialization and Termination functions
public native int VoE_Authenticate(String key); public native int VoE_Authenticate(String key);
public native int VoE_Init(int month, int day, int year, boolean enableTrace, boolean useExtTrans); public native int VoE_Init(boolean enableTrace);
public native int VoE_Terminate(); public native int VoE_Terminate();
// Channel functions // Channel functions
@ -115,7 +97,8 @@ public class ViEAndroidJavaAPI {
// Receiver & Destination functions // Receiver & Destination functions
public native int VoE_SetLocalReceiver(int channel, int port); public native int VoE_SetLocalReceiver(int channel, int port);
public native int VoE_SetSendDestination(int channel, int port, String ipaddr); public native int VoE_SetSendDestination(int channel, int port,
String ipaddr);
// Media functions // Media functions
public native int VoE_StartListen(int channel); public native int VoE_StartListen(int channel);
@ -132,11 +115,15 @@ public class ViEAndroidJavaAPI {
public native int VoE_SetLoudspeakerStatus(boolean enable); public native int VoE_SetLoudspeakerStatus(boolean enable);
// Playout file locally // Playout file locally
public native int VoE_StartPlayingFileLocally(int channel, String fileName, boolean loop); public native int VoE_StartPlayingFileLocally(int channel,
String fileName,
boolean loop);
public native int VoE_StopPlayingFileLocally(int channel); public native int VoE_StopPlayingFileLocally(int channel);
// Play file as microphone // Play file as microphone
public native int VoE_StartPlayingFileAsMicrophone(int channel, String fileName, boolean loop); public native int VoE_StartPlayingFileAsMicrophone(int channel,
String fileName,
boolean loop);
public native int VoE_StopPlayingFileAsMicrophone(int channel); public native int VoE_StopPlayingFileAsMicrophone(int channel);
// Codec-setting functions // Codec-setting functions
@ -144,7 +131,8 @@ public class ViEAndroidJavaAPI {
public native int VoE_SetSendCodec(int channel, int index); public native int VoE_SetSendCodec(int channel, int index);
//VE funtions //VE funtions
public native int VoE_SetECStatus(boolean enable, int mode, int AESmode, int AESattenuation); 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_SetAGCStatus(boolean enable, int mode);
public native int VoE_SetNSStatus(boolean enable, int mode); public native int VoE_SetNSStatus(boolean enable, int mode);
} }