Hello everyone.
I'm trying to wrap the library.
Here is the wrapper code
The wrapper compiles fine, but when I use it in an application I get an error:
main$ResumableSub_Activity_Createresume (java line: 398)
java.lang.NoClassDefFoundError: mylip.MyLipPhone$LinphoneMiniManager
at mylip.MyLipPhone.initialize(MyLipPhone.java:81)
at b4a.example.main$ResumableSub_Activity_Create.resume(main.java:398)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:215)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.keywords.Common$15.run(Common.java:1804)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I am not a strong programmer, so I ask for your tips
I'm trying to wrap the library.
Here is the wrapper code
wrapper:
public class MyLipPhone {
private BA ba;
private String event;
Context ctx = null;
public static MyLipPhone mInstance;
public LinphoneCore mLinphoneCore;
public static Context mContext;
public void initialize(BA ba, String event) {
this.ba = ba;
this.event = event;
mContext = ba.context;
BA.Log("1");
LinphoneMiniManager mLinphoneManager = new LinphoneMiniManager(mContext);
BA.Log("2");
mLinphoneCore = mLinphoneManager.getLc();
mInstance = this;
//setObject((LinphoneCore) mLinphoneManager);
}
class LinphoneMiniManager implements LinphoneCoreListener {
//class LinphoneMiniManager {
public LinphoneMiniManager mInstance;
public Context mContext;
public LinphoneCore mCore;
public LinphoneCoreFactory mFactory;
//public static LinphonePreferences mPrefs;
public Timer mTimer;
public SurfaceView mCaptureView;
//public CallbackContext mCallbackContext;
//public CallbackContext mLoginCallbackContext;
public LinphoneMiniManager(Context c) {
BA.Log("2");
mContext = c;
LinphoneCoreFactory.instance().setDebugMode(true, "Linphone Mini");
//mPrefs = LinphonePreferences.instance();
BA.Log("3");
////////////////////////////////////////////////////////////////////////////////////////
BA.Log("mCore");
try {
mCore = LinphoneCoreFactory.instance().createLinphoneCore((LinphoneCoreListener) mInstance, mContext);
} catch (LinphoneCoreException e) {
// TODO Автоматически созданный блок catch
e.printStackTrace();
}
BA.Log("mCore 2");
//mCore = LinphoneCoreFactory.instance().createLinphoneCore(this, basePath + "/.linphonerc", basePath + "/linphonerc", null, mContext);
/*
setUserAgent();
//setFrontCamAsDefault();
startIterate();
mInstance = this;
mCore.setNetworkReachable(true); // Let's assume it's true
mCore.addListener((LinphoneCoreListener)mContext);
mCaptureView = new SurfaceView(mContext);
mCore.setContext(mContext);
int availableCores = Runtime.getRuntime().availableProcessors();
BA.Log("MediaStreamer : " + availableCores + " cores detected and configured");
mCore.setCpuCount(availableCores);
int migrationResult = getLc().migrateToMultiTransport();
BA.Log( "Migration to multi transport result = " + migrationResult);
mCore.setNetworkReachable(true);
// echo cancellation
boolean isEchoCancellation = true;
mCore.enableEchoCancellation(isEchoCancellation);
// adaptive rate control
boolean isAdaptiveRateControl = true;
mCore.enableAdaptiveRateControl(isAdaptiveRateControl);
// audio bit rate setting
//LinphoneUtils.getConfig(mServiceContext).setInt("audio", "codec_bitrate_limit", 128);
mCore.setPreferredVideoSizeByName("720p");
mCore.setUploadBandwidth(1536);
mCore.setDownloadBandwidth(1536);
mCore.setVideoPolicy(mCore.getVideoAutoInitiatePolicy(), true);
mCore.setVideoPolicy(true, mCore.getVideoAutoAcceptPolicy());
mCore.enableVideo(true, true);
setCodecMime();
*/
}
public LinphoneCore getLc(){
return mCore;
}
private void copyAssetsFromPackage(String basePath) throws IOException {
String package_name = mContext.getPackageName();
Resources resources = mContext.getResources();
//copyIfNotExist(mContext, resources.getIdentifier("oldphone_mono", "raw", package_name), basePath + "/oldphone_mono.wav");
//copyIfNotExist(mContext, resources.getIdentifier("ringback", "raw", package_name), basePath + "/ringback.wav");
//copyIfNotExist(mContext, resources.getIdentifier("toy_mono", "raw", package_name), basePath + "/toy_mono.wav");
copyIfNotExist(mContext, resources.getIdentifier("linphonerc_default", "raw", package_name), basePath + "/.linphonerc");
copyFromPackage(mContext, resources.getIdentifier("linphonerc_factory", "raw", package_name), new File(basePath + "/linphonerc").getName());
copyIfNotExist(mContext, resources.getIdentifier("lpconfig", "raw", package_name), basePath + "/lpconfig.xsd");
//copyIfNotExist(mContext, resources.getIdentifier("rootca", "raw", package_name), basePath + "/rootca.pem");
//copyIfNotExist(mContext, resources.getIdentifier("vcard_grammar", "raw", package_name), basePath + "/vcard_grammar.pem");
//copyIfNotExist(mContext, resources.getIdentifier("cpim_grammar", "raw", package_name), basePath + "/cpim_grammar.pem");
}
public void copyIfNotExist(Context context, int ressourceId, String target) throws IOException {
File lFileToCopy = new File(target);
if (!lFileToCopy.exists()) {
copyFromPackage(context, ressourceId, lFileToCopy.getName());
}
}
public void copyFromPackage(Context context, int ressourceId, String target) throws IOException {
FileOutputStream lOutputStream = context.openFileOutput (target, 0);
InputStream lInputStream = context.getResources().openRawResource(ressourceId);
int readByte;
byte[] buff = new byte[8048];
while (( readByte = lInputStream.read(buff)) != -1) {
lOutputStream.write(buff,0, readByte);
}
lOutputStream.flush();
lOutputStream.close();
lInputStream.close();
}
private void setUserAgent() {
try {
String versionName = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName;
if (versionName == null) {
versionName = String.valueOf(mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode);
}
mCore.setUserAgent("LinphoneMiniAndroid", versionName);
} catch (NameNotFoundException e) {
}
}
private void startIterate() {
TimerTask lTask = new TimerTask() {
@Override
public void run() {
mCore.iterate();
}
};
mTimer = new Timer("LinphoneMini scheduler");
mTimer.schedule(lTask, 0, 20);
}
private void setCodecMime()
{
for (final PayloadType pt : mCore.getVideoCodecs())
{
BA.Log("setCodecMime = " + pt.getMime());
if (!pt.getMime().equals("VP8"))
{
try
{
BA.Log("disable codec " + pt.getMime());
mCore.enablePayloadType(pt, false);
}
catch (LinphoneCoreException e)
{
BA.Log(e.toString() );
}
}
}
}
}
}
The wrapper compiles fine, but when I use it in an application I get an error:
main$ResumableSub_Activity_Createresume (java line: 398)
java.lang.NoClassDefFoundError: mylip.MyLipPhone$LinphoneMiniManager
at mylip.MyLipPhone.initialize(MyLipPhone.java:81)
at b4a.example.main$ResumableSub_Activity_Create.resume(main.java:398)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:215)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.keywords.Common$15.run(Common.java:1804)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I am not a strong programmer, so I ask for your tips