B4A Library SIP Linphone 4.3 wrapper for B4A

Hello everyone

I present you the SIP Linphone library wrapper
This is an implementation of a fairly old version of Linphone 4.3
Almost all classes and methods that are present in Linphone are implemented
I will be glad if someone tests it This is my first library for B4A, besides,
I am not a professional programmer and I started working with Java not so long ago,
but I will gladly accept comments on possible errors and will try to fix them.

The archive with the library and an example of use are attached

I spent quite a lot of time, so if someone wants to thank me, I will not refuse
4100119094185464
yoomoney.ru

And I apologize, English is not my native language, I am from Russia

MyPJSIP.rar - https://disk.yandex.ru/d/IITkrcdI66KBRw

BAlinphone.rar - https://disk.yandex.ru/d/9POjQQ3CUGqhQw
 

f0raster0

Well-Known Member
Licensed User
Longtime User
I'm getting this error

B4X:
B4A Version: 13.10
Parsing code.    (0.00s)
    Java Version: 19
Building folders structure.    (0.02s)
Compiling code.    (0.01s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Compiling resources    (0.08s)
Linking resources    (0.31s)
    build tools: 34.0.0, android jar: android-34
Compiling generated Java code.    Error
Cannot find: C:\Program Files\Anywhere Software\B4A\libraries\linphone43.jar
1744666783294.png
 

Semendey

Member
I'm getting this error

B4X:
B4A Version: 13.10
Parsing code.    (0.00s)
    Java Version: 19
Building folders structure.    (0.02s)
Compiling code.    (0.01s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Compiling resources    (0.08s)
Linking resources    (0.31s)
    build tools: 34.0.0, android jar: android-34
Compiling generated Java code.    Error
Cannot find: C:\Program Files\Anywhere Software\B4A\libraries\linphone43.jar
View attachment 163416
Sorry. Forgot to add linphone43.jar to the archive.
Here is a link to the full one.
Download again.

 

Semendey

Member
Colleagues.
I noticed one feature when using with Android 14
The Linphone 4.3 library in the default configuration settings contains the following parameters:

register_only_when_network_is_up=1
auto_net_state_mon=1

which, as I understand it, tell the kernel Linphone to register only when there is a network connection and monitor the network status

But as we know, Android 14 has certain limitations on network monitoring,
and the Linphone 4.3 library itself is quite old,
which most likely cannot work with the network status according to the new rules.

Because of this, there are interruptions in registration on SIP servers.

Can anyone else verify my assumptions?

Be careful when developing for Android 14
 

Semendey

Member
Colleagues.
I noticed one feature when using with Android 14
The Linphone 4.3 library in the default configuration settings contains the following parameters:

register_only_when_network_is_up=1
auto_net_state_mon=1

which, as I understand it, tell the kernel Linphone to register only when there is a network connection and monitor the network status

But as we know, Android 14 has certain limitations on network monitoring,
and the Linphone 4.3 library itself is quite old,
which most likely cannot work with the network status according to the new rules.

Because of this, there are interruptions in registration on SIP servers.

Can anyone else verify my assumptions?

Be careful when developing for Android 14


It is possible to bypass this behavior:
1. You need to disable network monitoring

XXX.SetConfig("sip","register_only_when_network_is_up","0")
XXX.SetConfig("sip","auto_net_state_mon","0")

2. Set your reconnection timer
 

alimanam3386

Active Member
Licensed User
Longtime User
Thank you for your fantastic job , One question how we can get who is calling ? ( when you make a video or audio call the receiver how can knows who is calling )
 

Semendey

Member
Thank you for your fantastic job , One question how we can get who is calling ? ( when you make a video or audio call the receiver how can knows who is calling )
All the best
I am still working on the library and making edits
Please download the new version


You can read the caller's name like this:

kod:
Dim currentCall As LinphoneCall
    currentCall.initialize()
    currentCall =  Mysip.CurrentCall
    If currentCall <> Null Then
        Log(currentCall.RemoteAddress) ' "My" <sip:Foulless@iptel.org>
    End If
 
Last edited:

alimanam3386

Active Member
Licensed User
Longtime User
All the best
I am still working on the library and making edits
Please download the new version


You can read the caller's name like this:

kod:
Dim currentCall As LinphoneCall
    currentCall.initialize()
    currentCall =  Mysip.CurrentCall
    If currentCall <> Null Then
        Log(currentCall.RemoteAddress) ' "My" <sip:Foulless@iptel.org>
    End If

thank you, it's works now. one thing I can see in it is two times shows the incoming call in log.


B4X:
Sub CallIncoming()
    AceptButton.Enabled = True
    EndButton.Enabled = True
    
    Dim currentCall As LinphoneCall
    currentCall.initialize()
    currentCall =  linphone.Mysip.CurrentCall
    If currentCall <> Null Then
        Log(ExtractUsername(currentCall.RemoteAddress) & " calling ...") ' "My" <sip:Foulless@iptel.org>
        'MsgboxAsync(ExtractUsername(currentCall.RemoteAddress) & " calling ..." , "Call")
    End If
    
End Sub

Sub ExtractUsername(inputString As String) As String
    
    Dim colonIndex As Int = inputString.IndexOf(":")
    Dim atIndex As Int = inputString.IndexOf("@")
    If colonIndex = -1 Or atIndex = -1 Then
        Return "Invalid input format"
    End If
    Dim username As String = inputString.SubString2(colonIndex + 1, atIndex)
    Return username
End Sub
 

Attachments

  • 1.png
    1.png
    30.7 KB · Views: 90

Semendey

Member
thank you, it's works now. one thing I can see in it is two times shows the incoming call in log.


B4X:
Sub CallIncoming()
    AceptButton.Enabled = True
    EndButton.Enabled = True
   
    Dim currentCall As LinphoneCall
    currentCall.initialize()
    currentCall =  linphone.Mysip.CurrentCall
    If currentCall <> Null Then
        Log(ExtractUsername(currentCall.RemoteAddress) & " calling ...") ' "My" <sip:Foulless@iptel.org>
        'MsgboxAsync(ExtractUsername(currentCall.RemoteAddress) & " calling ..." , "Call")
    End If
   
End Sub

Sub ExtractUsername(inputString As String) As String
   
    Dim colonIndex As Int = inputString.IndexOf(":")
    Dim atIndex As Int = inputString.IndexOf("@")
    If colonIndex = -1 Or atIndex = -1 Then
        Return "Invalid input format"
    End If
    Dim username As String = inputString.SubString2(colonIndex + 1, atIndex)
    Return username
End Sub

I also observe a similar picture
But there is no way to influence this Events are generated by the Core Linphone

I can assume that events are read from SIP messages, and they can be repeated

You can enter a local variable of the incoming call and set it at the first event, and reset it when the call ends
 
Top