File: tciserver.h

package info (click to toggle)
wfview 2.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,256 kB
  • sloc: cpp: 43,386; ansic: 3,196; sh: 32; xml: 29; makefile: 11
file content (109 lines) | stat: -rw-r--r-- 2,195 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef TCISERVER_H
#define TCISERVER_H

#include <QObject>
#include <QtWebSockets/QtWebSockets>
#include <QtWebSockets/QWebSocketServer>

#include "audioconverter.h"
#include "cachingqueue.h"

/* Opus and Eigen */
#ifndef Q_OS_LINUX
#include "opus.h"
#include <Eigen/Eigen>
#else
#include "opus/opus.h"
#include <eigen3/Eigen/Eigen>
#endif

#define TCI_AUDIO_LENGTH 4096
struct tciCommandStruct
{
    const char *str;
    funcs func;
    valueType arg1;
    valueType arg2;
    valueType arg3;
};


class tciServer : public QObject
{
    Q_OBJECT

    static constexpr quint32 iqHeaderSize = 16u*sizeof(quint32);
    static constexpr quint32 iqBufferSize = 2048u;

    typedef enum
    {
        IqInt16 = 0,
        IqInt24,
        IqInt32,
        IqFloat32,
        IqFloat64
    }iqDataType;

    typedef enum
    {
        IqStream = 0,
        RxAudioStream,
        TxAudioStream,
        TxChrono,
    }streamType;

    typedef struct
    {
        quint32 receiver;
        quint32 sampleRate;
        quint32 format;
        quint32 codec;
        quint32 crc;
        quint32 length;
        quint32 type;
        quint32 reserv[9];
        float   data[TCI_AUDIO_LENGTH];
    }dataStream;

    struct connStatus {
        bool connected=true;
        bool rxaudio=false;
        bool txaudio=false;
    };


public:
    explicit tciServer(QObject *parent = nullptr);
    ~tciServer();

signals:
    void closed();
    void sendTCIAudio(QByteArray audio);

public slots:
    void receiveTCIAudio(audioPacket audio);
    void receiveRigCaps(rigCapabilities* caps);
    void init(quint16 port);


private slots:
    void onNewConnection();
    void processIncomingTextMessage(QString message);
    void processIncomingBinaryMessage(QByteArray message);
    void socketDisconnected();
    void receiveCache(cacheItem item);
    void setupTxPacket(int packetLen);

private:
    QWebSocketServer *server;
    QMap<QWebSocket *, connStatus> clients;
    cachingQueue *queue;
    QByteArray rxAudioData;
    QByteArray txAudioData;
    QByteArray txChrono;
    rigCapabilities* rigCaps = Q_NULLPTR;
    QString tciMode(modeInfo m);
    modeInfo rigMode(QString);
};

#endif // TCISERVER_H