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

📄 u_vcnettalk_main.pas

📁 Voice Commnucation Components for Delphi
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  //
  saveControlPosition(self, f_ini);
end;

// --  --
procedure Tc_form_vcNetTalkMain.c_timer_updateTimer(Sender: TObject);

  // --  --
  function getIpStatus(ip: unavclInOutIpPipe; rec: TunavclWaveInDevice; wave: tunavclWaveRiff; play: TunavclwaveOutDevice): string;
  begin
    if (0 <> ip.getErrorCode()) then
      result := 'Error code: ' + int2Str(ip.getErrorCode())
    else
      if (not ip.active) then
	result := 'Not active'
      else
	result := 'Packets: in ' + int2Str(ip.inPacketsCount, 10, 3) + ', out ' + int2Str(ip.outPacketsCount, 10, 3) +
		  ' / Rec: ' + int2Str(rec.device.outBytes shr 10, 10, 3) + ' KB' +
		  ' / WAVe: ' + int2Str(wave.device.outBytes shr 10, 10, 3) + ' KB' +
		  ' / Play: ' + int2Str(play.device.inBytes shr 10, 10, 3) + ' KB';
  end;

  // --  --
  procedure deviceInfo(isServer: bool; index: unsigned; device: unavclInOutPipe);
  var
    lb: tCheckListBox;
    st: tStaticText;
  begin
    if (isServer) then begin
      lb := c_checkListBox_server;
      st := c_staticText_deviceInfoServer;
    end
    else begin
      lb := c_checkListBox_client;
      st := c_staticText_deviceInfoClient;
    end;
    //
    lb.Checked[index] := device.active;
    //
    if (int(index) = lb.ItemIndex) then
      if (device is unavclInOutWavePipe) then
	st.Caption := 'Src: ' + unavclInOutWavePipe(device).device.srcFormatInfo + #13#10 +
		      'Dst: ' + unavclInOutWavePipe(device).device.dstFormatInfo
      else
	if (device is unavclInOutIpPipe) then
	  st.Caption := 'Sent: ' + int2Str(device.inBytes shr 10, 10, 3) + ' KB'#13#10 +
			'Received: ' + int2Str(device.outBytes shr 10, 10, 3) + ' KB';
  end;

begin
  if (not (csDestroying in componentState)) then begin
    c_statusBar_main.panels[0].text := 'Mem: ' + int2Str(ams() shr 10, 10, 3) + ' KB';
    //
    c_label_statusSrv.caption := getIpStatus(ipServer, waveIn_server, riff_server, waveOut_server);
    c_label_statusClient.caption := getIpStatus(ipClient, waveIn_client, riff_client, waveOut_client);
    //
    c_pb_volumeInClient.position := waveGetLogVolume(mixer_client.mixer.getVolume());
    c_pb_volumeInServer.position := waveGetLogVolume(mixer_server.mixer.getVolume());
    c_pb_volumeOutClient.position := waveGetLogVolume(waveOut_client.waveOutDevice.getVolume());
    c_pb_volumeOutServer.position := waveGetLogVolume(waveOut_server.waveOutDevice.getVolume());

    //
    deviceInfo(true, 0, waveIn_server);
    deviceInfo(true, 1, riff_server);
    deviceInfo(true, 2, resampler_server);
    deviceInfo(true, 3, mixer_server);
    deviceInfo(true, 4, codecIn_server);
    deviceInfo(true, 5, ipServer);
    deviceInfo(true, 6, codecOut_server);
    deviceInfo(true, 7, waveOut_server);

    //
    deviceInfo(false, 0, waveIn_client);
    deviceInfo(false, 1, riff_client);
    deviceInfo(false, 2, resampler_client);
    deviceInfo(false, 3, mixer_client);
    deviceInfo(false, 4, codecIn_client);
    deviceInfo(false, 5, ipClient);
    deviceInfo(false, 6, codecOut_client);
    deviceInfo(false, 7, waveOut_client);

    // bottom info panel
    inc(f_hintColorCount);
    inc(f_hintTextCount, 3);
    c_panel_info.Font.Color := hintColors[(f_hintColorCount shr 3) and $07];
    c_panel_info.Caption := hintStrings[(f_hintTextCount shr 5) and $0F];

    //
    reEnable();
    reEnable(false);
  end;
end;

// --  --
procedure Tc_form_vcNetTalkMain.reEnable(server: bool);
var
  isActive: bool;
begin
  if not (csDestroying in componentState) then begin
    //
    if (server) then begin
      isActive := ipServer.active;
      a_srvStart.enabled := not isActive;
      a_srvStop.enabled := isActive;
      c_button_formatChooseServer.enabled := not isActive;
    end
    else begin
      isActive := ipClient.active;
      a_clientStart.enabled := not isActive;
      a_clientStop.enabled := isActive;
      c_button_formatChooseClient.enabled := not isActive;
    end;
  end;
end;

// --  --
procedure Tc_form_vcNetTalkMain.clientAction(doOpen: bool);
begin
  if (doOpen) then begin
    ipClient.port := c_edit_clientSrvPort.text;
    ipClient.host := c_edit_clientSrvHost.text;
    //
    riff_client.fileName := c_edit_waveNameClient.Text;
  end;
  //
  waveIn_client.active := doOpen and c_checkBox_useWaveInClient.checked;
  riff_client.active := doOpen and c_checkBox_mixWaveClient.checked;
  //
  mixer_client.active := doOpen;
  ipClient.active := doOpen;
end;

// --  --
procedure Tc_form_vcNetTalkMain.serverAction(doOpen: bool);
begin
  if (doOpen) then begin
    ipServer.port := c_edit_serverPort.text;
    //
    riff_server.fileName := c_edit_waveNameServer.Text;
  end;
  //
  waveIn_server.active := doOpen and c_checkBox_useWaveInServer.checked;
  riff_server.active := doOpen and c_checkBox_mixWaveServer.checked;
  //
  mixer_server.active := doOpen;
  ipServer.active := doOpen;
end;

// --  --
procedure Tc_form_vcNetTalkMain.a_clientStartExecute(Sender: TObject);
begin
  clientAction();
end;

// --  --
procedure Tc_form_vcNetTalkMain.a_clientStopExecute(Sender: TObject);
begin
  clientAction(false);
end;

// --  --
procedure Tc_form_vcNetTalkMain.a_srvStartExecute(Sender: TObject);
begin
  serverAction();
end;

// --  --
procedure Tc_form_vcNetTalkMain.a_srvStopExecute(Sender: TObject);
begin
  serverAction(false);
end;

// --  --
procedure Tc_form_vcNetTalkMain.c_panel_infoClick(Sender: TObject);
begin
  shellExecute(0, 'open', 'http://www.lakeofsoft.com/vc', nil, nil, SW_SHOWNORMAL);
end;

// --  --
procedure Tc_form_vcNetTalkMain.c_button_chooseWaveServerClick(Sender: TObject);
begin
  chooseFile(c_checkBox_mixWaveServer, c_edit_waveNameServer);
end;

// --  --
procedure Tc_form_vcNetTalkMain.c_button_chooseWaveClientClick(Sender: TObject);
begin
  chooseFile(c_checkBox_mixWaveClient, c_edit_waveNameClient);
end;

// --  --
procedure Tc_form_vcNetTalkMain.chooseFile(cb: tCheckBox; edit: tEdit);
begin
  if (c_openDialog_wave.execute()) then begin
    cb.checked := true;
    edit.Text := c_openDialog_wave.fileName;
  end;
end;

// --  --
procedure Tc_form_vcNetTalkMain.c_button_formatChooseClientClick(Sender: TObject);
begin
  if (S_OK = c_form_common_audioConfig.doConfig(waveIn_client, waveOut_client, codecIn_client, nil, f_ini, 'wave.format.client')) then
    updateFormat(false);
end;

// --  --
procedure Tc_form_vcNetTalkMain.c_button_formatChooseServerClick(Sender: TObject);
begin
  if (S_OK = c_form_common_audioConfig.doConfig(waveIn_server, waveOut_server, codecIn_server, nil, f_ini, 'wave.format.server')) then
    updateFormat();
end;

// --  --
procedure Tc_form_vcNetTalkMain.updateFormatInfo(isServer: bool);
begin
  if (isServer) then
    c_static_formatInfoServer.caption := codecIn_server.device.dstFormatInfo
  else
    c_static_formatInfoClient.caption := codecIn_client.device.dstFormatInfo;
end;

// --  --
procedure Tc_form_vcNetTalkMain.updateFormat(isServer: bool);
begin
  if (isServer) then begin
    mixer_server.pcmFormat := codecIn_server.pcmFormat;
    waveIn_server.pcmFormat := codecIn_server.pcmFormat;
    resampler_server.dstFormat := codecIn_server.pcmFormat;
  end
  else begin
    mixer_client.pcmFormat := codecIn_client.pcmFormat;
    waveIn_client.pcmFormat := codecIn_client.pcmFormat;
    resampler_client.dstFormat := codecIn_client.pcmFormat;
  end;
  //
  updateFormatInfo(isServer);
end;

// --  --
procedure Tc_form_vcNetTalkMain.c_comboBox_socketTypeClientChange(Sender: TObject);
begin
  if (0 = c_comboBox_socketTypeClient.ItemIndex) then
    ipClient.proto := unapt_UDP
  else
    ipClient.proto := unapt_TCP;
end;

// --  --
procedure Tc_form_vcNetTalkMain.c_comboBox_socketTypeServerChange(Sender: TObject);
begin
  if (0 = c_comboBox_socketTypeServer.ItemIndex) then
    ipServer.proto := unapt_UDP
  else
    ipServer.proto := unapt_TCP;
end;

// --  --
procedure Tc_form_vcNetTalkMain.ipClientClientDisconnect(sender: TObject; connectionId: Cardinal; connected: LongBool);
begin
  clientAction(false);
end;

end.

⌨️ 快捷键说明

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