I want to write an online voice chat program used QTcpSocket
I refer to examples of code input / output audio in the QT example, but I had trouble reading the code, I do not understand in the QT example, which part is input / output ....
similar to the code below I have found it is written win32API :

Qt Code:
  1. #include <windows.h>
  2. #include <mmsystem.h>
  3. #include <iostream>
  4. #include <stdio.h>
  5.  
  6. using namespace std;
  7.  
  8. #pragma comment(lib, "winmm.lib")
  9.  
  10. int main()
  11. {
  12. const int NUMPTS = 441000;
  13. int sampleRate = 44100;
  14. short int waveIn[NUMPTS];
  15. HWAVEIN hWaveIn;
  16. WAVEHDR WaveInHdr;
  17. MMRESULT result;
  18. HWAVEOUT hWaveOut;
  19. WAVEFORMATEX pFormat;
  20. pFormat.wFormatTag = WAVE_FORMAT_PCM;
  21. pFormat.nChannels = 1;
  22. pFormat.nSamplesPerSec = sampleRate;
  23. pFormat.nAvgBytesPerSec = 2 * sampleRate;
  24. pFormat.nBlockAlign = 2;
  25. pFormat.wBitsPerSample = 16;
  26. pFormat.cbSize = 0;
  27. result = waveInOpen(&hWaveIn, WAVE_MAPPER, &pFormat, 0, 0, WAVE_FORMAT_DIRECT);
  28. if(result)
  29. {
  30. char fault[256];
  31. waveInGetErrorTextA(result, fault, 256);
  32. MessageBoxA(NULL, fault, "open error.", MB_OK | MB_ICONEXCLAMATION);
  33. return 1;
  34. }
  35. WaveInHdr.lpData = (LPSTR)waveIn;
  36. WaveInHdr.dwBufferLength = 2 * NUMPTS;
  37. WaveInHdr.dwBytesRecorded = 0;
  38. WaveInHdr.dwUser = 0;
  39. WaveInHdr.dwFlags = 0;
  40. WaveInHdr.dwLoops = 0;
  41. waveInPrepareHeader(hWaveIn, &WaveInHdr, sizeof(WAVEHDR));
  42. result = waveInAddBuffer(hWaveIn, &WaveInHdr, sizeof(WAVEHDR));
  43. if(result)
  44. {
  45. MessageBoxA(NULL, "add error", NULL, MB_OK | MB_ICONEXCLAMATION);
  46. return 1;
  47. }
  48. result = waveInStart(hWaveIn);
  49. if(result)
  50. {
  51. MessageBoxA(NULL, "start error", NULL, MB_OK | MB_ICONEXCLAMATION);
  52. return 1;
  53. }
  54. cout << "Recording..." << endl;
  55. Sleep((NUMPTS/sampleRate) * 1000);
  56. cout << "Playing..." << endl;
  57. if(waveOutOpen(&hWaveOut, WAVE_MAPPER, &pFormat, 0, 0, WAVE_FORMAT_DIRECT))
  58. {
  59. MessageBoxA(NULL, "outopen error", NULL, MB_OK | MB_ICONEXCLAMATION );
  60. }
  61. waveOutWrite(hWaveOut, &WaveInHdr, sizeof(WaveInHdr));
  62. Sleep((NUMPTS/sampleRate) * 1000);
  63. waveOutUnprepareHeader(hWaveOut, &WaveInHdr, sizeof(WAVEHDR));
  64. waveInUnprepareHeader(hWaveIn, &WaveInHdr, sizeof(WAVEHDR));
  65. waveInClose(hWaveIn);
  66. waveOutClose(hWaveOut);
  67. return 0;
  68. }
To copy to clipboard, switch view to plain text mode 

I need a similar code is written with QT. or can anyone give me demo code simple voice chat with QT.