Hi folks!

I am programming a tactical radio application that communicates via LAN. It is basically a voice communication application in which you can set a frequency and only participants who have set the same frequency, can hear and speak to this frequency. Also you can set multiple radios in my application, so that you can listen and talk to multiple frequencies. You hear every frequency you have set, but can only speak on one frequency set as active.

The microphone packages are sent by a qudpsocket to the Broadcast Address, so every participant receives every voice package. This means I have to append the frequency to every voice package sent, so that every receiving radio can filter the incoming datagrams and only playback those with the correct frequencies.

I wrote a line like QString("frequency:100000") to the socket, when the transmission starts, but when more people talk the packages get mixed up. Thats why I need to add a string to every single audio package sent. Though I don't know how, because "QAudioInput::start(socket);" takes care of all the recording and sending via udp.


I hope this states my problem sufficiently and would appreciate any advice.


Qt Code:
  1. #include ...
  2.  
  3. class Audio_receive : public QObject
  4. {
  5. Q_OBJECT
  6.  
  7. private:
  8. Widget_radio* parent;
  9. QAudioOutput*output;
  10. QUdpSocket* socket;
  11. QIODevice* device;
  12. QTimer* timer;
  13. public:
  14. Audio_receive(Widget_radio* parent);
  15. ~Audio_receive();
  16. private slots :
  17. void receive();
  18. void updateRx();
  19. };
  20.  
  21. #include ...
  22.  
  23. Audio_send::Audio_send()
  24. {
  25. QAudioFormat format;
  26. format.setCodec("audio/PCM");
  27. format.setSampleRate(16000); //128000
  28. format.setSampleSize(16);
  29. format.setChannelCount(1);
  30. format.setByteOrder(QAudioFormat::LittleEndian);
  31. format.setSampleType(QAudioFormat::UnSignedInt);
  32. input = new QAudioInput(format);
  33.  
  34. QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
  35. if (!info.isFormatSupported(format))
  36. format = info.nearestFormat(format);
  37.  
  38. socket = new QUdpSocket();
  39. socket->connectToHost(QHostAddress::LocalHost, Config_manager::getInstance()->getPort());
  40. }
  41.  
  42. Audio_send::~Audio_send()
  43. {
  44.  
  45. }
  46.  
  47. void Audio_send::transmit(bool state)
  48. {
  49. if (state)
  50. {
  51. // Frequency Header
  52. //QByteArray datagram("frequency:100000");
  53. //socket->write(datagram);
  54. input->start(socket);
  55. }
  56. else
  57. input->stop();
  58. }
To copy to clipboard, switch view to plain text mode