mainform.frm
来自「VaxSIPUserAgentSDK」· FRM 代码 · 共 1,947 行 · 第 1/4 页
FRM
1,947 行
Private Sub BtnDialPad7_Click()
EditPhoneNo.Text = EditPhoneNo.Text + "7"
Result = VaxSIPUserAgentOCX.DigitDTMF(ComboDial.ListIndex, "7")
End Sub
Private Sub BtnDialPad8_Click()
EditPhoneNo.Text = EditPhoneNo.Text + "8"
Result = VaxSIPUserAgentOCX.DigitDTMF(ComboDial.ListIndex, "8")
End Sub
Private Sub BtnDialPad9_Click()
EditPhoneNo.Text = EditPhoneNo.Text + "9"
Result = VaxSIPUserAgentOCX.DigitDTMF(ComboDial.ListIndex, "9")
End Sub
Private Sub BtnDialPadStar_Click()
Result = VaxSIPUserAgentOCX.DigitDTMF(ComboDial.ListIndex, "*")
End Sub
Private Sub BtnDialPadNo_Click()
Result = VaxSIPUserAgentOCX.DigitDTMF(ComboDial.ListIndex, "#")
End Sub
Private Sub BtnHelpMore_Click()
HelpForm.Show vbModal
End Sub
Private Sub BtnPlayForward_Click()
LineNo = ComboPlayWave.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveSkipTo(LineNo, VaxSIPUserAgentOCX.PlayWavePosition(LineNo) + 2)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnPlayPause_Click()
LineNo = ComboPlayWave.ListIndex
Result = VaxSIPUserAgentOCX.PlayWavePause(LineNo)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnPlayRewind_Click()
LineNo = ComboPlayWave.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveSkipTo(LineNo, VaxSIPUserAgentOCX.PlayWavePosition(LineNo) - 2)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnPlayStop_Click()
LineNo = ComboPlayWave.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveStop(LineNo)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnSetPlayFile_Click()
LineNo = ComboPlayWave.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveOpen(LineNo, EditPlayFileName.Text)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnStartPlay_Click()
LineNo = ComboPlayWave.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveStart(LineNo, CheckPlayListen.Value)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnTransferCall_Click()
ToURI = "sip:" + EditTransferPhoneNo.Text + "@" + EditSIPProxy.Text
LineNo = ComboTransferCall.ListIndex
Result = VaxSIPUserAgentOCX.TransferCall(LineNo, ToURI)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub CheckAGC_Click()
If CheckAGC.Value = 1 Then
Result = VaxSIPUserAgentOCX.EnableAGC(8000)
If Result = False Then
ErrorMessages
End If
Else
VaxSIPUserAgentOCX.DisableAGC
End If
End Sub
Private Sub CheckMuteMic_Click()
Result = VaxSIPUserAgentOCX.MuteMic(CheckMuteMic.Value)
End Sub
Private Sub CheckPlayRingTone_Click()
If CheckPlayRingTone.Value <> 1 Then
Retval = PlaySound(ByVal 0&, 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT)
End If
End Sub
Private Sub CheckSpkMute_Click()
Dim Result
Result = VaxSIPUserAgentOCX.MuteSpk(CheckSpkMute.Value)
End Sub
Private Sub CheckStartRecording_Click()
If CheckStartRecording.Value = 1 Then
Result = VaxSIPUserAgentOCX.StartRecording(ComboRecord.ListIndex, 2, True)
If Result = False Then
ErrorMessages
End If
Else
Result = VaxSIPUserAgentOCX.StopRecording(ComboRecord.ListIndex)
End If
End Sub
Private Sub ComboRecord_Click()
If VaxSIPUserAgentOCX.IsRecording(ComboRecord.ListIndex) = True Then
CheckStartRecording.Value = 1
Else
CheckStartRecording.Value = 0
End If
End Sub
Private Sub Form_Load()
ListViewLineStatus.ColumnHeaders.Add 1, , "#", 70
ListViewLineStatus.ColumnHeaders.Add 2, , "Status", 505
ListViewLineStatus.ColumnHeaders.Add 3, , "Outbound", 770
ListViewLineStatus.ColumnHeaders.Add 4, , "Inbound", 770
End Sub
Private Sub Form_Unload(Cancel As Integer)
Retval = PlaySound(ByVal 0&, 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT)
End Sub
Private Sub SliderMicVol_Click()
' SetMicVolume method requires Volume value from 0 to 255 range '
' but the slider range is 0 to 10, so we multiply the slider value '
' to 25 to get the required value to pass to SetMicVolume method '
Dim Result
Result = VaxSIPUserAgentOCX.SetMicVolume(SliderMicVol.Value * 25)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub SliderSpkVol_Click()
' SetSpkVolume method requires Volume value from 0 to 255 range '
' but the slider range is 0 to 10, so we multiply the slider value '
' to 25 to get the required value to pass to SetSpkVolume method '
Dim Result
Result = VaxSIPUserAgentOCX.SetSpkVolume(SliderSpkVol.Value * 25)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub ErrorMessages()
Dim Error
Error = VaxSIPUserAgentOCX.GetVaxObjectError
If Error = 10 Then
MsgBox ("You are not Online, please click the 'Online' button first.")
End If
If Error = 11 Then
MsgBox ("Cann't open local communication port. Another softphone (x-Ten, x-lite or skype etc) is already running. Please close it first.")
End If
If Error = 12 Then
MsgBox ("License Key is not valid.")
End If
If Error = 13 Then
MsgBox ("Fail to initialize VaxVoIP task window.")
End If
If Error = 14 Then
MsgBox ("Cann't access Input/Mic device or device is already in use.")
End If
If Error = 15 Then
MsgBox ("Cann't access Output/Speaker device or device is already in use.")
End If
If Error = 16 Then
MsgBox ("Input/Mic device is not open.")
End If
If Error = 17 Then
MsgBox ("Output/Speaker device is not open.")
End If
If Error = 18 Then
MsgBox ("Your sound device does not support mic volume.")
End If
If Error = 19 Then
MsgBox ("Your sound device does not support speaker volume.")
End If
If Error = 20 Then
MsgBox ("Recording media initialization fail.")
End If
If Error = 21 Then
MsgBox ("Cann't open the wave file.")
End If
If Error = 22 Then
MsgBox ("Provided SIP URI is not valid.")
End If
If Error = 23 Then
MsgBox ("Codec is not supported.")
End If
If Error = 24 Then
MsgBox ("Error to create SDP (Session Description Protocol) request.")
End If
If Error = 25 Then
MsgBox ("Error to create CONNECTION request. Please check the provided SIP URI is valid.")
End If
If Error = 26 Then
MsgBox ("Error to create REGISTER request. Please check the provided SIP URI is valid.")
End If
If Error = 27 Then
MsgBox ("Error to create UN-REGISTER request. Please check the provided SIP URI is valid.")
End If
If Error = 28 Then
MsgBox ("Error to create DISCONNECT request.")
End If
If Error = 29 Then
MsgBox ("Line No is not valid.")
End If
If Error = 30 Then
MsgBox ("Line is already busy.")
End If
If Error = 31 Then
MsgBox ("Line is not open.")
End If
If Error = 32 Then
MsgBox ("Invalid Call-Id.")
End If
If Error = 33 Then
MsgBox ("Provided value is not valid.")
End If
If Error = 34 Then
MsgBox ("Selected line is not in voice session.")
End If
If Error = 35 Then
MsgBox ("Fail to read wave file.")
End If
If Error = 36 Then
MsgBox ("Fail to write wave file.")
End If
If Error = 37 Then
MsgBox ("Unsupported wave file format.")
End If
End Sub
Private Function InitVaxVoIPObject(ByVal MyIP As String, ByVal FromURI As String) As Boolean
Dim ListenPort As Integer
Dim Result As Boolean
Result = False
ListenPort = 5060
Do While ListenPort < 7000
Result = VaxSIPUserAgentOCX.Initialize(False, MyIP, ListenPort, FromURI, EditOutBoundProxy.Text, EditSIPProxy.Text, EditLoginId.Text, EditLoginPwd.Text, CheckEnableSoundDevice.Value, Int(EditTotalLines.Text))
If Result = False Then
If 11 <> VaxSIPUserAgentOCX.GetVaxObjectError() Then
ErrorMessages
Exit Do
End If
Else
Exit Do
End If
ListenPort = ListenPort + 1
Loop
If ListenPort >= 7000 Then
MsgBox ("Cann't open SIP communication port.")
Result = False
End If
InitVaxVoIPObject = Result
End Function
Private Function OpenLines(ByVal MyIP As String, ByVal TotalNoOfLine As Integer) As Boolean
Dim ListenPort As Integer
Dim Result As Boolean
Dim ErrorCount As Integer
Result = False
ListenPort = 7000
ErrorCount = 0
For LineNo = 0 To (TotalNoOfLine - 1)
Result = VaxSIPUserAgentOCX.OpenLine(LineNo, False, MyIP, ListenPort)
If Result = False Then
If 11 <> VaxSIPUserAgentOCX.GetVaxObjectError() Then
ErrorMessages
Exit For
Else
ErrorCount = ErrorCount + 1
LineNo = LineNo - 1
End If
End If
ListenPort = ListenPort + 2 ' It is importent to increament RTP Listen port by 2
If ErrorCount >= (TotalNoOfLine + 1000) Then ' If unable to open more than 1000 ports.
MsgBox ("Unable to open RTP communication port.")
Result = False
Exit For
End If
Next LineNo
OpenLines = Result
End Function
Private Sub BtnOnline_Click()
Dim MyIP
Dim FromURI
If BtnOnline.Caption = "Offline" Then
TimerTick.Enabled = False
TimerProgressBar.Enabled = False
SpkProgress.Value = 0
MicProgress.Value = 0
VaxSIPUserAgentOCX.UnInitialize
BtnOnline.Caption = "Online"
EditTotalLines.Enabled = True
ListAudioIn.Clear
ListAudioOut.Clear
ListViewLineStatus.ListItems.Clear
Exit Sub
End If
If EditLoginId.Text = "" Then
MsgBox ("Please enter the SIP proxy Login Id.")
Exit Sub
End If
If EditSIPProxy.Text = "" Then
MsgBox ("Please enter the SIP proxy address or URI.")
Exit Sub
End If
VaxSIPUserAgentOCX.SetLicenceKey ("TRIAL-LICENSE-KEY")
'****** Constructing SIP From URI for IP Telephony *******
If EditDisplayName = "" Then
FromURI = EditLoginId.Text + " <sip:" + EditLoginId.Text + "@" + EditSIPProxy.Text + ">"
Else
FromURI = EditDisplayName.Text + " <sip:" + EditLoginId.Text + "@" + EditSIPProxy.Text + ">"
End If
'********************************************************************
' Listen Port: default SIP port 5060.
' SIP Proxy: SIP Proxy IP or FQDN provided by your service provider.
' OutboundProxy: SIP outbound/NAT proxy IP or FQDN provided by your
' service provider to use SIP phone behind the NAT.
'
'*********************************************************************
MyIP = VaxSIPUserAgentOCX.GetMyIP()
Result = InitVaxVoIPObject(MyIP, FromURI)
If Result = False Then
Exit Sub
End If
Result = OpenLines(MyIP, Int(EditTotalLines.Text))
If Result = False Then
Exit Sub
End If
If CheckRegisterToProxy.Value = 1 Then
Result = VaxSIPUserAgentOCX.RegisterToProxy(3600)
If Result = False Then
ErrorMessages
Exit Sub
End If
AddToStatusLog ("Registering to SIP Proxy.")
End If
CheckEchoCancel.Value = 1
CheckGSM610.Value = 1
CheckiLBC.Value = 1
CheckG711A.Value = 1
CheckG711U.Value = 1
VaxSIPUserAgentOCX.EnableKeepAlive (10)
BtnOnline.Caption = "Offline"
EditTotalLines.Enabled = False
UpdateAudioIn
UpdateAudioOut
TimerTick.Enabled = True
TimerProgressBar.Enabled = True
FillComboBox
End Sub
Private Sub VaxSIPUserAgentOCX_OnCallTransferAccepted(ByVal LineNo As Long)
AddToStatusLog ("Line-" + Str(LineNo + 1) + ": Transfer accepted.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnConnecting(ByVal LineNo As Long)
AddToStatusLog ("Line-" + Str(LineNo + 1) + ": Connecting.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnDisconnectCall(ByVal LineNo As Long)
AddToStatusLog ("Line-" + Str(LineNo + 1) + ": Hung up.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnDTMFDigit(ByVal LineNo As Long, ByVal Digit As String)
AddToStatusLog ("Line-" + Str(LineNo + 1) + ": Key-pressed: " + Digit)
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?