My code
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Sip
#VersionCode: 2
#VersionName: 1.01
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
Sub Process_Globals
Dim Sip As Sip
Dim CurrentCall As SipAudioCall
End Sub
Sub Globals
Dim mute As ToggleButton
Dim btnAnswer As Button
Dim btnMakeCall As Button
Dim btnEndCall As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
If Sip.IsInitialized = False Then
'Check if SIP and VOIP are supported.
If Sip.IsSipSupported = False OR Sip.IsVoipSupported = False Then
Log("Not supported.")
ToastMessageShow("SIP not supported.", True)
Else
'Register with the VOIP service
Sip.Initialize2("SIP", "101@192.168.2.238", "101ohbe")
Sip.Register
End If
End If
Activity.LoadLayout("1")
End Sub
Sub SIP_Registering
Log("Registering")
End Sub
Sub SIP_RegistrationFailed (ErrorCode As Int, ErrorMessage As String)
Log("Failed, ErrorCode=" & ErrorCode & ", Message=" & ErrorMessage)
ToastMessageShow("Registration failed.", True)
End Sub
Sub SIP_RegistrationDone (ExpiryTime As Long)
Log("RegistrationDone, ExpiryTime=" & ExpiryTime)
ToastMessageShow("SIP registered sucessfully", True)
btnMakeCall.Enabled = True
End Sub
Sub SIP_CallEstablished
'Check that we are not already in a call.
'Seems like this event can be raised by the SIP service multiple times.
If CurrentCall.IsInCall Then Return
Log("CallEstablished")
CurrentCall.StartAudio 'Start the audio
CurrentCall.SpeakerMode = True
ToastMessageShow("Call established", True)
End Sub
Sub SIP_Calling
Log("Calling")
End Sub
Sub SIP_CallEnded
Log("CallEnded")
If CurrentCall.IsInitialized Then CurrentCall.EndCall
End Sub
'Incoming call
Sub SIP_CallRinging (IncomingCall As SipAudioCall)
Log("CallRinging")
ToastMessageShow("Ringing from: " & IncomingCall.PeerUri, True)
CurrentCall = IncomingCall
End Sub
'Answers an incoming call
Sub btnAnswer_Click
If CurrentCall.IsInitialized AND CurrentCall.IsInCall = False Then CurrentCall.AnswerCall(30)
End Sub
Sub SIP_CallError (ErrorCode As Int, ErrorMessage As String)
Log("CallError, ErrorCode=" & ErrorCode & ", ErrorMessage=" & ErrorMessage)
End Sub
Sub Activity_Pause(UserClosed As Boolean)
If UserClosed Then
Sip.Close
End If
End Sub
Sub Activity_Resume
End Sub
Sub mute_CheckedChange(Checked As Boolean)
If CurrentCall.IsInitialized Then
Log(CurrentCall.IsMuted)
If CurrentCall.IsMuted <> Checked Then CurrentCall.ToggleMute
End If
End Sub
Sub btnMakeCall_Click
'Makes a call.
'The audio will start after the CallEstablished event is raised.
CurrentCall = Sip.MakeCall("sip:
8355@ideasip.com", 30)
End Sub
Sub btnEndCall_Click
If CurrentCall.IsInitialized Then CurrentCall.EndCall
End Sub