Subversion Repositories tpanel

Rev

Rev 474 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 474 Rev 477
Line 25... Line 25...
25
#include <QAbstractSocket>
25
#include <QAbstractSocket>
26
#include <QAudioSink>
26
#include <QAudioSink>
27
#include <QUdpSocket>
27
#include <QUdpSocket>
28
#include <QScopedPointer>
28
#include <QScopedPointer>
29
 
29
 
-
 
30
#include "taudioconvert.h"
-
 
31
 
30
typedef struct INTERCOM_t
32
typedef struct INTERCOM_t
31
{
33
{
32
    std::string ip;         // IP address of panel to connect to
34
    std::string ip;         // IP address of panel to connect to
33
    long rxPort{0};          // Network port number for receiver
35
    long rxPort{0};          // Network port number for receiver
34
    long txPort{0};          // Network port number for transmitter
36
    long txPort{0};          // Network port number for transmitter
Line 38... Line 40...
38
class QAudioSource;
40
class QAudioSource;
39
class QBuffer;
41
class QBuffer;
40
class QTimer;
42
class QTimer;
41
class QTimerEvent;
43
class QTimerEvent;
42
 
44
 
43
class TMicrophone : public QIODevice
45
class TMicrophone : public QIODevice, public TAudioConvert
44
{
46
{
45
    public:
47
    public:
46
        TMicrophone();
48
        TMicrophone();
47
        ~TMicrophone();
49
        ~TMicrophone();
48
 
50
 
Line 52... Line 54...
52
        qint64 readData(char *data, qint64 maxlen) override;
54
        qint64 readData(char *data, qint64 maxlen) override;
53
        qint64 writeData(const char *data, qint64 len) override;
55
        qint64 writeData(const char *data, qint64 len) override;
54
        qint64 bytesAvailable() const override;
56
        qint64 bytesAvailable() const override;
55
        qint64 size() const override { return mBuffer.size(); }
57
        qint64 size() const override { return mBuffer.size(); }
56
 
58
 
57
    protected:
-
 
58
        int8_t uLawEncode(int16_t number);
-
 
59
 
-
 
60
    private:
59
    private:
61
        qint64 mPos{0};
60
        qint64 mPos{0};
62
        QByteArray mBuffer;
61
        QByteArray mBuffer;
63
};
62
};
64
 
63
 
65
class TQIntercom : public QObject
64
class TQIntercom : public QObject, public TAudioConvert
66
{
65
{
67
    Q_OBJECT
66
    Q_OBJECT
68
 
67
 
69
    public:
68
    public:
70
        TQIntercom(QObject *parent);
69
        TQIntercom(QObject *parent);
Line 90... Line 89...
90
        void socketErrorMessages(QAbstractSocket::SocketError socketError, const std::string& msg);
89
        void socketErrorMessages(QAbstractSocket::SocketError socketError, const std::string& msg);
91
        void onReadPendingDatagrams();
90
        void onReadPendingDatagrams();
92
        void onRecordPermissionGranted();
91
        void onRecordPermissionGranted();
93
        void onMicStateChanged(QAudio::State state);
92
        void onMicStateChanged(QAudio::State state);
94
 
93
 
95
        int16_t uLawDecode(int8_t number);
-
 
96
        int8_t uLawEncode(int16_t number);
-
 
97
        qreal convertVolume(int volume);
94
        qreal convertVolume(int volume);
98
 
95
 
99
    private:
96
    private:
100
        typedef struct _HEADER_t
97
        typedef struct _HEADER_t
101
        {
98
        {