2014-12-11 19:07:21 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ThreadQueue.h"
|
2014-12-16 18:27:02 -05:00
|
|
|
#include "CubicSDRDefs.h"
|
|
|
|
#include "liquid/liquid.h"
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-22 19:43:56 -05:00
|
|
|
#include <atomic>
|
2014-12-23 23:37:18 -05:00
|
|
|
#include <mutex>
|
2014-12-22 19:43:56 -05:00
|
|
|
|
2015-07-29 18:34:58 -04:00
|
|
|
#include "IOThread.h"
|
2015-01-01 18:08:54 -05:00
|
|
|
|
2014-12-11 19:07:21 -05:00
|
|
|
class DemodulatorThread;
|
|
|
|
|
|
|
|
|
2014-12-21 16:08:32 -05:00
|
|
|
class DemodulatorThreadControlCommand {
|
|
|
|
public:
|
|
|
|
enum DemodulatorThreadControlCommandEnum {
|
2015-01-03 17:07:39 -05:00
|
|
|
DEMOD_THREAD_CMD_CTL_NULL, DEMOD_THREAD_CMD_CTL_SQUELCH_ON, DEMOD_THREAD_CMD_CTL_SQUELCH_OFF, DEMOD_THREAD_CMD_CTL_TYPE
|
2014-12-21 16:08:32 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
DemodulatorThreadControlCommand() :
|
2015-11-17 18:57:42 -05:00
|
|
|
cmd(DEMOD_THREAD_CMD_CTL_NULL), demodType("") {
|
2014-12-21 16:08:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorThreadControlCommandEnum cmd;
|
2015-11-17 18:57:42 -05:00
|
|
|
std::string demodType;
|
2014-12-21 16:08:32 -05:00
|
|
|
};
|
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
class DemodulatorThreadIQData: public ReferenceCounter {
|
2014-12-11 19:07:21 -05:00
|
|
|
public:
|
2015-01-04 17:11:20 -05:00
|
|
|
long long frequency;
|
2015-01-11 17:08:16 -05:00
|
|
|
long long sampleRate;
|
2014-12-26 16:15:35 -05:00
|
|
|
std::vector<liquid_float_complex> data;
|
2016-06-02 17:56:31 -04:00
|
|
|
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
DemodulatorThreadIQData() :
|
2015-01-11 17:08:16 -05:00
|
|
|
frequency(0), sampleRate(0) {
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
}
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2015-09-09 23:46:23 -04:00
|
|
|
DemodulatorThreadIQData & operator=(const DemodulatorThreadIQData &other) {
|
|
|
|
frequency = other.frequency;
|
|
|
|
sampleRate = other.sampleRate;
|
|
|
|
data.assign(other.data.begin(), other.data.end());
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
~DemodulatorThreadIQData() {
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
}
|
2014-12-11 19:07:21 -05:00
|
|
|
};
|
|
|
|
|
2015-11-17 19:32:47 -05:00
|
|
|
class Modem;
|
|
|
|
class ModemKit;
|
2015-11-16 23:49:54 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
class DemodulatorThreadPostIQData: public ReferenceCounter {
|
2014-12-16 18:27:02 -05:00
|
|
|
public:
|
2014-12-24 01:28:33 -05:00
|
|
|
std::vector<liquid_float_complex> data;
|
2015-01-11 17:08:16 -05:00
|
|
|
long long sampleRate;
|
2015-11-29 13:35:12 -05:00
|
|
|
std::string modemName;
|
2015-11-17 20:20:12 -05:00
|
|
|
std::string modemType;
|
2015-11-17 19:32:47 -05:00
|
|
|
Modem *modem;
|
|
|
|
ModemKit *modemKit;
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
DemodulatorThreadPostIQData() :
|
2015-11-17 19:32:47 -05:00
|
|
|
sampleRate(0), modem(nullptr), modemKit(nullptr) {
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
}
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
~DemodulatorThreadPostIQData() {
|
2016-06-01 13:46:45 -04:00
|
|
|
std::lock_guard < std::recursive_mutex > lock(m_mutex);
|
2014-12-24 01:28:33 -05:00
|
|
|
}
|
2014-12-16 18:27:02 -05:00
|
|
|
};
|
|
|
|
|
2015-11-16 23:49:54 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
class DemodulatorThreadAudioData: public ReferenceCounter {
|
2014-12-11 19:07:21 -05:00
|
|
|
public:
|
2015-01-04 17:11:20 -05:00
|
|
|
long long frequency;
|
2014-12-24 01:28:33 -05:00
|
|
|
unsigned int sampleRate;
|
|
|
|
unsigned char channels;
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
std::vector<float> *data;
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
DemodulatorThreadAudioData() :
|
|
|
|
frequency(0), sampleRate(0), channels(0), data(NULL) {
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
}
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2015-01-04 17:11:20 -05:00
|
|
|
DemodulatorThreadAudioData(long long frequency, unsigned int sampleRate, std::vector<float> *data) :
|
2014-12-24 01:28:33 -05:00
|
|
|
frequency(frequency), sampleRate(sampleRate), channels(1), data(data) {
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
}
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
~DemodulatorThreadAudioData() {
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-12-24 01:28:33 -05:00
|
|
|
}
|
2014-12-11 19:07:21 -05:00
|
|
|
};
|
|
|
|
|
2014-12-22 23:27:52 -05:00
|
|
|
typedef ThreadQueue<DemodulatorThreadIQData *> DemodulatorThreadInputQueue;
|
2014-12-23 01:12:14 -05:00
|
|
|
typedef ThreadQueue<DemodulatorThreadPostIQData *> DemodulatorThreadPostInputQueue;
|
2014-12-21 16:08:32 -05:00
|
|
|
typedef ThreadQueue<DemodulatorThreadControlCommand> DemodulatorThreadControlCommandQueue;
|