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

📄 mainunit.pas

📁 VaxSIPUserAgentSDK
💻 PAS
📖 第 1 页 / 共 3 页
字号:
        break;
      end;

   end;

   Result := RetValue;

end;

procedure TMainForm.UpdateListAudioIn();
var
DeviceId : Integer;
begin
     ListAudioIn.Clear();
     ListAudioIn.Items.Add('Default Device');

     for DeviceId := 0 to VaxSIPUserAgentOCX.GetAudioInDevTotal() - 1 do
     Begin
        ListAudioIn.Items.Add(VaxSIPUserAgentOCX.GetAudioInDevName(DeviceId));
     end;

     ListAudioIn.ItemIndex := 0;
end;

procedure TMainForm.UpdateListAudioOut();
var
DeviceId : Integer;
begin
     ListAudioOut.Clear();
     ListAudioOut.Items.Add('Default Device');

     for DeviceId := 0 to VaxSIPUserAgentOCX.GetAudioOutDevTotal() - 1 do
     Begin
        ListAudioOut.Items.Add(VaxSIPUserAgentOCX.GetAudioOutDevName(DeviceId));
     end;

     ListAudioOut.ItemIndex := 0;
end;

function TMainForm.GetSelectedAudioIn() : Integer;
begin
  Result := ListAudioIn.ItemIndex - 1;
end;

function TMainForm.GetSelectedAudioOut() : Integer;
begin
  Result := ListAudioOut.ItemIndex - 1;
end;

procedure TMainForm.FillComboBoxes();
var
LineNo : Integer;
begin

  ComboBoxDial.Clear();
  ComboBoxRecord.Clear();
  ComboBoxIncomingCall.Clear();
  ComboBoxPlayWave.Clear();
  ComboBoxTransferCall.Clear();

  for LineNo := 1 to StrToInt(EditTotalLines.Text) do
  begin

    ComboBoxDial.AddItem('Line-' + IntToStr(LineNo), nil);
    ComboBoxRecord.AddItem('Line-' + IntToStr(LineNo), nil);
    ComboBoxIncomingCall.AddItem('Line-' + IntToStr(LineNo), nil);
    ComboBoxPlayWave.AddItem('Line-' + IntToStr(LineNo), nil);
    ComboBoxTransferCall.AddItem('Line-' + IntToStr(LineNo), nil);

  end;

  ComboBoxDial.ItemIndex := 0;
  ComboBoxRecord.ItemIndex := 0;
  ComboBoxIncomingCall.ItemIndex := 0;
  ComboBoxPlayWave.ItemIndex := 0;
  ComboBoxTransferCall.ItemIndex := 0;

end;

procedure TMainForm.BtnInitClick(Sender: TObject);
begin

   if BtnInit.Caption = 'Offline' then
   begin
       BtnInit.Caption := 'Online';
       VaxSIPUserAgentOCX.UnInitialize();
       EditTotalLines.Enabled := True;

       TimerTick.Enabled := False;
       TimerProgress.Enabled := False;

       SpkProgBar.Position := 0;
       MicProgBar.Position := 0;

       ListAudioOut.Clear();
       ListAudioIn.Clear();
       ListViewLineStatus.Clear();
       
       exit;
   end;

   If EditLoginId.Text = '' Then
   begin
        application.MessageBox('Please enter the SIP proxy Login Id.', 'VaxVoIP SDK', MB_ICONEXCLAMATION);
        exit;
   end;

   If EditSIPProxy.Text = '' Then
   Begin
        application.MessageBox('Please enter the SIP proxy address or URI.', 'VaxVoIP SDK', MB_ICONEXCLAMATION);
        exit;
   end;

   VaxSIPUserAgentOCX.SetLicenceKey('TRIAL-LICENSE-KEY');

   if InitVaxObject() = False then exit;

   if OpenLines() = False then exit;

   if CheckBoxRegisterToProxy.Checked = True then
   begin

    If False = VaxSIPUserAgentOCX.RegisterToProxy(3600) Then
    begin
     ErrorMessages();
     exit;
    end;

    AddToStatusLog('Registering to SIP Proxy.');
  end;

  CheckEchoCancel.Checked := True;
  CheckGSM610.Checked     := True;
  CheckiLBC.Checked       := True;
  CheckG711A.Checked      := True;
  CheckG711U.Checked      := True;

  VaxSIPUserAgentOCX.EnableKeepAlive(10);

  BtnInit.Caption := 'Offline';
  ListViewLineStatus.Items.Clear();

  UpdateListAudioIn();
  UpdateListAudioOut();
  FillComboBoxes();

  EditTotalLines.Enabled := False;
  TimerTick.Enabled := True;
  TimerProgress.Enabled := True;

end;

procedure TMainForm.BtnDial1Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '1';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '1');
end;

procedure TMainForm.BtnDial2Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '2';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '2');
end;

procedure TMainForm.BtnDial3Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '3';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '3');
end;

procedure TMainForm.BtnDial4Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '4';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '4');
end;

procedure TMainForm.BtnDial5Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '5';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '5');
end;

procedure TMainForm.BtnDial6Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '6';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '6');
end;

procedure TMainForm.BtnDial7Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '7';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '7');
end;

procedure TMainForm.BtnDial8Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '8';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '8');
end;

procedure TMainForm.BtnDial9Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '9';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '9');
end;

procedure TMainForm.BtnDialStarClick(Sender: TObject);
begin
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '*');
end;

procedure TMainForm.BtnDial0Click(Sender: TObject);
begin
  EditPhoneNo.Text := EditPhoneNo.Text + '0';
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '0');
end;

procedure TMainForm.BtnDialNoClick(Sender: TObject);
begin
  VaxSIPUserAgentOCX.DigitDTMF(ComboBoxDial.ItemIndex, '#');
end;

procedure TMainForm.BtnDialClick(Sender: TObject);
var
ToURI  : string;
begin

  If EditPhoneNo.Text = '' Then
  Begin
    application.MessageBox('Please enter a phone number.', 'VaxVoIP SDK', MB_ICONEXCLAMATION);
    Exit;
  End;

  {*******************************************************
         Constructing SIP To URI for IP Telephony:
                  sip:PhoneNumber@SIP Proxy
  ********************************************************}

  ToURI := 'sip:' + EditPhoneNo.Text + '@' + EditSIPProxy.Text;

  If VaxSIPUserAgentOCX.Connect(ComboBoxDial.ItemIndex, ToURI, GetSelectedAudioIn(), GetSelectedAudioOut()) = False Then
      ErrorMessages()
  Else
      AddToStatusLog('Line-' + IntToStr(ComboBoxDial.ItemIndex + 1) + ': Dialing.');
end;

procedure TMainForm.BtnHangUpClick(Sender: TObject);
begin

   If VaxSIPUserAgentOCX.Disconnect(ComboBoxDial.ItemIndex) = False Then
       ErrorMessages();
end;

procedure TMainForm.BtnHoldClick(Sender: TObject);
begin

  If VaxSIPUserAgentOCX.HoldLine(ComboBoxDial.ItemIndex) = False Then
       ErrorMessages();
end;

procedure TMainForm.BtnUnholdClick(Sender: TObject);
begin
  If VaxSIPUserAgentOCX.UnHoldLine(ComboBoxDial.ItemIndex) = False Then
       ErrorMessages();
end;

procedure TMainForm.BtnAcceptCallClick(Sender: TObject);
var
CallId : String;
LineNo : Integer;
begin

  if ListBoxIncomingCall.ItemIndex = -1 Then
     exit;

  CallId := ListBoxIcomingCallId.Items.Strings[ListBoxIncomingCall.ItemIndex];
  LineNo := ComboBoxIncomingCall.ItemIndex;

  if VaxSIPUserAgentOCX.AcceptCall(LineNo, CallId, GetSelectedAudioIn(), GetSelectedAudioOut()) = False Then
  begin
    ErrorMessages();
    exit;
  end;

  PlaySound(nil, 0, 0);

  ListBoxIcomingCallId.Items.Delete(ListBoxIncomingCall.ItemIndex);
  ListBoxIncomingCall.Items.Delete(ListBoxIncomingCall.ItemIndex);

  if (ListBoxIncomingCall.ItemIndex = -1) and (ListBoxIncomingCall.Items.Count > 0) Then
    ListBoxIncomingCall.ItemIndex := 0;

end;

procedure TMainForm.BtnRejectCallClick(Sender: TObject);
var
CallId : String;
begin

  if ListBoxIncomingCall.ItemIndex = -1 Then
     exit;

  CallId := ListBoxIcomingCallId.Items.Strings[ListBoxIncomingCall.ItemIndex];

  if VaxSIPUserAgentOCX.RejectCall(CallId) = False Then
  begin
    ErrorMessages();
    exit;
  end;

  PlaySound(nil, 0, 0);

  ListBoxIcomingCallId.Items.Delete(ListBoxIncomingCall.ItemIndex);
  ListBoxIncomingCall.Items.Delete(ListBoxIncomingCall.ItemIndex);

  if (ListBoxIncomingCall.ItemIndex = -1) and (ListBoxIncomingCall.Items.Count > 0) Then
    ListBoxIncomingCall.ItemIndex := 0;

end;

procedure TMainForm.BtnClearClick(Sender: TObject);
begin
  ListStatusLog.Items.Clear();
end;

procedure TMainForm.BtnSaveClick(Sender: TObject);
begin

  if VaxSIPUserAgentOCX.SaveRecordingToWaveFile(ComboBoxRecord.ItemIndex, EditRecordFileName.Text) = False then
    ErrorMessages()
  else
    application.MessageBox('Saved Successfully', 'VaxVoIP SDK', MB_ICONEXCLAMATION);

end;

procedure TMainForm.CheckBoxStartRecordingClick(Sender: TObject);
begin
  if CheckBoxStartRecording.Checked = True then
    VaxSIPUserAgentOCX.StartRecording(ComboBoxRecord.ItemIndex, 2, True)
  else
    VaxSIPUserAgentOCX.StopRecording(ComboBoxRecord.ItemIndex)
end;

procedure TMainForm.BtnResetBufferClick(Sender: TObject);
begin
  VaxSIPUserAgentOCX.ResetRecording(ComboBoxRecord.ItemIndex);
end;

procedure TMainForm.ComboBoxRecordChange(Sender: TObject);
begin
     CheckBoxStartRecording.Checked := VaxSIPUserAgentOCX.IsRecording(ComboBoxRecord.ItemIndex);
end;

procedure TMainForm.CheckBoxSpkMuteClick(Sender: TObject);
begin
  VaxSIPUserAgentOCX.MuteSpk(CheckBoxSpkMute.Checked);
end;

procedure TMainForm.CheckBoxMuteMicClick(Sender: TObject);
begin
  VaxSIPUserAgentOCX.MuteMic(CheckBoxMuteMic.Checked);
end;

procedure TMainForm.VaxSIPUserAgentOCXFailToRegister(Sender: TObject);
begin
  AddToStatusLog('Fail to register.');
end;

procedure TMainForm.VaxSIPUserAgentOCXFailToUnRegister(Sender: TObject);
begin
 AddToStatusLog('Fail to un-register.');
end;

procedure TMainForm.VaxSIPUserAgentOCXSuccessToUnRegister(Sender: TObject);
begin
  AddToStatusLog('Unregistered successfully.');
end;

procedure TMainForm.CheckEchoCancelClick(Sender: TObject);
begin

  If CheckEchoCancel.Checked = True Then
    VaxSIPUserAgentOCX.EnableEchoNoiseCancellation()
  Else
    VaxSIPUserAgentOCX.DisableEchoNoiseCancellation();
  
end;

procedure TMainForm.CheckMicBoostClick(Sender: TObject);
begin
  If CheckMicBoost.Checked = True Then
    VaxSIPUserAgentOCX.EnableMicBoost()
  Else
    VaxSIPUserAgentOCX.DisableMicBoost();
end;

procedure TMainForm.CheckDonotDisturbClick(Sender: TObject);
begin
   If CheckDonotDisturb.Checked = True Then
     VaxSIPUserAgentOCX.EnableDonotDisturb()
   Else
     VaxSIPUserAgentOCX.DisableDonotDisturb();
end;

procedure TMainForm.CheckGSM610Click(Sender: TObject);
begin

⌨️ 快捷键说明

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