⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.frm

📁 VaxSIPUserAgentSDK
💻 FRM
📖 第 1 页 / 共 4 页
字号:
    ToURI = "sip:" + EditTransferPhoneNo.Text + "@" + EditSIPProxy.Text
    
    LineNo = ListLines.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 CheckStartConf_Click()
    
    BusyCount = 0
    
    For LineNo = 0 To 6
        If VaxSIPUserAgentOCX.IsLineBusy(LineNo) = True Then
            BusyCount = BusyCount + 1
        End If
    Next LineNo
    
    If BusyCount < 2 And CheckStartConf.Value Then
        CheckStartConf.Value = False
        MsgBox ("Dial/receive more than one calls and then click start conference check box.")
    End If
    
End Sub

Private Sub CheckStartRecording_Click()

    If CheckStartRecording.Value = 1 Then
        Result = VaxSIPUserAgentOCX.StartRecording(ListLines.ListIndex, 2, True)
        If Result = False Then
            ErrorMessages
        End If
    Else
        Result = VaxSIPUserAgentOCX.StopRecording(ListLines.ListIndex)
    End If
    
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, True, 7)
        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
            
       ComboAudioIn.Clear
       ComboAudioOut.Clear
       
       BtnOnline.Caption = "Online"
                     
       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, 7)
    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
        
    If CheckEchoCancel.Value Then
        VaxSIPUserAgentOCX.EnableEchoNoiseCancellation
    Else
        VaxSIPUserAgentOCX.DisableEchoNoiseCancellation
    End If
        
    VaxSIPUserAgentOCX.DeselectAllVoiceCodec
        
    If CheckGSM610.Value Then
        VaxSIPUserAgentOCX.SelectVoiceCodec (0)
    End If
        
    If CheckiLBC.Value Then
        VaxSIPUserAgentOCX.SelectVoiceCodec (1)
    End If
        
    If CheckG711A.Value Then
        VaxSIPUserAgentOCX.SelectVoiceCodec (2)
    End If
        
    If CheckG711U.Value Then
        VaxSIPUserAgentOCX.SelectVoiceCodec (3)
    End If

    VaxSIPUserAgentOCX.EnableKeepAlive (10)
        
    BtnOnline.Caption = "Offline"
        
    UpdateSoundDevices
               
    TimerTick.Enabled = True
    TimerProgressBar.Enabled = True
               
                    
End Sub

Private Sub VaxSIPUserAgentOCX_OnCallTransferAccepted(ByVal LineNo As Long)
    AddToStatusLog ("Line-" + Trim(Str(LineNo + 1)) + ": Transfer accepted.")
End Sub

Private Sub VaxSIPUserAgentOCX_OnConnecting(ByVal LineNo As Long)
    AddToStatusLog ("Line-" + Trim(Str(LineNo + 1)) + ": Connecting.")
End Sub

Private Sub VaxSIPUserAgentOCX_OnDisconnectCall(ByVal LineNo As Long)
    AddToStatusLog ("Line-" + Trim(Str(LineNo + 1)) + ": Hung up.")
End Sub

Private Sub VaxSIPUserAgentOCX_OnDTMFDigit(ByVal LineNo As Long, ByVal Digit As String)
    AddToStatusLog ("Line-" + Trim(Str(LineNo + 1)) + ": Key-pressed: " + Digit)
End Sub

Private Sub VaxSIPUserAgentOCX_OnFailToConnect(ByVal LineNo As Long)
    AddToStatusLog ("Line-" + Trim(Str(LineNo + 1)) + ": Fail to connect.")
End Sub

Private Sub VaxSIPUserAgentOCX_OnFailToRegister()
    AddToStatusLog ("Fail to register.")
End Sub

Private Function FindCallIdFromList(ByVal CallId As String) As Boolean
    
    Dim Result As Boolean
    
    Result = False
    
    For ListIndex = 0 To (ListIncomingCallIds.ListCount - 1)
       
        If UCase(ListIncomingCallIds.List(ListIndex)) = UCase(CallId) Then
          Result = True
          Exit For
        End If
    
    Next ListIndex
    
    FindCallIdFromList = Result
    
End Function

Private Sub VaxSIPUserAgentOCX_OnGeneralFailureResponse(ByVal LineNo As Long, ByVal StatusCode As Long, ByVal ReasonPhrase As String)
    AddToStatusLog ("Line-" + Trim(Str(LineNo + 1)) + " Response: " + ReasonPhrase)
End Sub

Private Sub VaxSIPUserAgentOCX_OnIncomingCall(ByVal CallId As String, ByVal DisplayName As String, ByVal UserName As String, ByVal FromURI As String, ByVal ToURI As String)
    
    If FindCallIdFromList(CallId) = False Then
        ListIncomingCallIds.AddItem (CallId)
        
        If Len(DisplayName) <> 0 Then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -