mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 12:51:49 -05:00
SDRDaemon: anonymize protected block
This commit is contained in:
parent
6341bddef3
commit
1590db3ce2
@ -82,7 +82,8 @@ DaemonSink::~DaemonSink()
|
|||||||
void DaemonSink::setTxDelay(int txDelay, int nbBlocksFEC)
|
void DaemonSink::setTxDelay(int txDelay, int nbBlocksFEC)
|
||||||
{
|
{
|
||||||
double txDelayRatio = txDelay / 100.0;
|
double txDelayRatio = txDelay / 100.0;
|
||||||
double delay = m_sampleRate == 0 ? 1.0 : (127*SDRDaemonSamplesPerBlock*txDelayRatio) / m_sampleRate;
|
int samplesPerBlock = SDRDaemonNbBytesPerBlock / sizeof(Sample);
|
||||||
|
double delay = m_sampleRate == 0 ? 1.0 : (127*samplesPerBlock*txDelayRatio) / m_sampleRate;
|
||||||
delay /= 128 + nbBlocksFEC;
|
delay /= 128 + nbBlocksFEC;
|
||||||
m_txDelay = roundf(delay*1e6); // microseconds
|
m_txDelay = roundf(delay*1e6); // microseconds
|
||||||
qDebug() << "DaemonSink::setTxDelay:"
|
qDebug() << "DaemonSink::setTxDelay:"
|
||||||
@ -152,10 +153,11 @@ void DaemonSink::feed(const SampleVector::const_iterator& begin, const SampleVec
|
|||||||
m_txBlockIndex = 1; // next Tx block with data
|
m_txBlockIndex = 1; // next Tx block with data
|
||||||
} // block zero
|
} // block zero
|
||||||
|
|
||||||
// TODO: handle different sample sizes...
|
// handle different sample sizes...
|
||||||
if (m_sampleIndex + inRemainingSamples < SDRDaemonSamplesPerBlock) // there is still room in the current super block
|
int samplesPerBlock = SDRDaemonNbBytesPerBlock / sizeof(Sample);
|
||||||
|
if (m_sampleIndex + inRemainingSamples < samplesPerBlock) // there is still room in the current super block
|
||||||
{
|
{
|
||||||
memcpy((void *) &m_superBlock.m_protectedBlock.m_samples[m_sampleIndex],
|
memcpy((void *) &m_superBlock.m_protectedBlock.buf[m_sampleIndex*sizeof(Sample)],
|
||||||
(const void *) &(*(begin+inSamplesIndex)),
|
(const void *) &(*(begin+inSamplesIndex)),
|
||||||
inRemainingSamples * sizeof(Sample));
|
inRemainingSamples * sizeof(Sample));
|
||||||
m_sampleIndex += inRemainingSamples;
|
m_sampleIndex += inRemainingSamples;
|
||||||
@ -163,10 +165,10 @@ void DaemonSink::feed(const SampleVector::const_iterator& begin, const SampleVec
|
|||||||
}
|
}
|
||||||
else // complete super block and initiate the next if not end of frame
|
else // complete super block and initiate the next if not end of frame
|
||||||
{
|
{
|
||||||
memcpy((void *) &m_superBlock.m_protectedBlock.m_samples[m_sampleIndex],
|
memcpy((void *) &m_superBlock.m_protectedBlock.buf[m_sampleIndex*sizeof(Sample)],
|
||||||
(const void *) &(*(begin+inSamplesIndex)),
|
(const void *) &(*(begin+inSamplesIndex)),
|
||||||
(SDRDaemonSamplesPerBlock - m_sampleIndex) * sizeof(Sample));
|
(samplesPerBlock - m_sampleIndex) * sizeof(Sample));
|
||||||
it += SDRDaemonSamplesPerBlock - m_sampleIndex;
|
it += samplesPerBlock - m_sampleIndex;
|
||||||
m_sampleIndex = 0;
|
m_sampleIndex = 0;
|
||||||
|
|
||||||
m_superBlock.m_header.m_frameIndex = m_frameCount;
|
m_superBlock.m_header.m_frameIndex = m_frameCount;
|
||||||
|
@ -287,7 +287,8 @@ void DaemonSinkGUI::on_nbFECBlocks_valueChanged(int value)
|
|||||||
void DaemonSinkGUI::updateTxDelayTime()
|
void DaemonSinkGUI::updateTxDelayTime()
|
||||||
{
|
{
|
||||||
double txDelayRatio = m_settings.m_txDelay / 100.0;
|
double txDelayRatio = m_settings.m_txDelay / 100.0;
|
||||||
double delay = m_sampleRate == 0 ? 0.0 : (127*SDRDaemonSamplesPerBlock*txDelayRatio) / m_sampleRate;
|
int samplesPerBlock = SDRDaemonNbBytesPerBlock / sizeof(Sample);
|
||||||
|
double delay = m_sampleRate == 0 ? 0.0 : (127*samplesPerBlock*txDelayRatio) / m_sampleRate;
|
||||||
delay /= 128 + m_settings.m_nbFECBlocks;
|
delay /= 128 + m_settings.m_nbFECBlocks;
|
||||||
ui->txDelayTime->setText(tr("%1µs").arg(QString::number(delay*1e6, 'f', 0)));
|
ui->txDelayTime->setText(tr("%1µs").arg(QString::number(delay*1e6, 'f', 0)));
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ DaemonSrc::DaemonSrc(DeviceSinkAPI *deviceAPI) :
|
|||||||
m_deviceAPI(deviceAPI),
|
m_deviceAPI(deviceAPI),
|
||||||
m_sourceThread(0),
|
m_sourceThread(0),
|
||||||
m_running(false),
|
m_running(false),
|
||||||
|
m_dataReadQueue(SDR_TX_SAMP_SZ <= 16 ? 4 : 8),
|
||||||
m_nbCorrectableErrors(0),
|
m_nbCorrectableErrors(0),
|
||||||
m_nbUncorrectableErrors(0)
|
m_nbUncorrectableErrors(0)
|
||||||
{
|
{
|
||||||
|
@ -147,10 +147,11 @@ void SDRDaemonChannelSink::feed(const SampleVector::const_iterator& begin, const
|
|||||||
m_txBlockIndex = 1; // next Tx block with data
|
m_txBlockIndex = 1; // next Tx block with data
|
||||||
} // block zero
|
} // block zero
|
||||||
|
|
||||||
// TODO: handle different sample sizes...
|
// handle different sample sizes...
|
||||||
if (m_sampleIndex + inRemainingSamples < SDRDaemonSamplesPerBlock) // there is still room in the current super block
|
int samplesPerBlock = SDRDaemonNbBytesPerBlock / sizeof(Sample);
|
||||||
|
if (m_sampleIndex + inRemainingSamples < samplesPerBlock) // there is still room in the current super block
|
||||||
{
|
{
|
||||||
memcpy((void *) &m_superBlock.m_protectedBlock.m_samples[m_sampleIndex],
|
memcpy((void *) &m_superBlock.m_protectedBlock.buf[m_sampleIndex*sizeof(Sample)],
|
||||||
(const void *) &(*(begin+inSamplesIndex)),
|
(const void *) &(*(begin+inSamplesIndex)),
|
||||||
inRemainingSamples * sizeof(Sample));
|
inRemainingSamples * sizeof(Sample));
|
||||||
m_sampleIndex += inRemainingSamples;
|
m_sampleIndex += inRemainingSamples;
|
||||||
@ -158,10 +159,10 @@ void SDRDaemonChannelSink::feed(const SampleVector::const_iterator& begin, const
|
|||||||
}
|
}
|
||||||
else // complete super block and initiate the next if not end of frame
|
else // complete super block and initiate the next if not end of frame
|
||||||
{
|
{
|
||||||
memcpy((void *) &m_superBlock.m_protectedBlock.m_samples[m_sampleIndex],
|
memcpy((void *) &m_superBlock.m_protectedBlock.buf[m_sampleIndex*sizeof(Sample)],
|
||||||
(const void *) &(*(begin+inSamplesIndex)),
|
(const void *) &(*(begin+inSamplesIndex)),
|
||||||
(SDRDaemonSamplesPerBlock - m_sampleIndex) * sizeof(Sample));
|
(samplesPerBlock - m_sampleIndex) * sizeof(Sample));
|
||||||
it += SDRDaemonSamplesPerBlock - m_sampleIndex;
|
it += samplesPerBlock - m_sampleIndex;
|
||||||
m_sampleIndex = 0;
|
m_sampleIndex = 0;
|
||||||
|
|
||||||
m_superBlock.m_header.m_frameIndex = m_frameCount;
|
m_superBlock.m_header.m_frameIndex = m_frameCount;
|
||||||
|
@ -50,6 +50,7 @@ SDRDaemonChannelSource::SDRDaemonChannelSource(DeviceSinkAPI *deviceAPI) :
|
|||||||
m_deviceAPI(deviceAPI),
|
m_deviceAPI(deviceAPI),
|
||||||
m_sourceThread(0),
|
m_sourceThread(0),
|
||||||
m_running(false),
|
m_running(false),
|
||||||
|
m_dataReadQueue(SDR_TX_SAMP_SZ <= 16 ? 4 : 8),
|
||||||
m_nbCorrectableErrors(0),
|
m_nbCorrectableErrors(0),
|
||||||
m_nbUncorrectableErrors(0)
|
m_nbUncorrectableErrors(0)
|
||||||
{
|
{
|
||||||
|
@ -83,14 +83,14 @@ struct SDRDaemonHeader
|
|||||||
|
|
||||||
static const int SDRDaemonUdpSize = UDPSINKFEC_UDPSIZE;
|
static const int SDRDaemonUdpSize = UDPSINKFEC_UDPSIZE;
|
||||||
static const int SDRDaemonNbOrginalBlocks = UDPSINKFEC_NBORIGINALBLOCKS;
|
static const int SDRDaemonNbOrginalBlocks = UDPSINKFEC_NBORIGINALBLOCKS;
|
||||||
static const int SDRDaemonSamplesPerBlock = (UDPSINKFEC_UDPSIZE - sizeof(SDRDaemonHeader)) / sizeof(Sample);
|
static const int SDRDaemonNbBytesPerBlock = UDPSINKFEC_UDPSIZE - sizeof(SDRDaemonHeader);
|
||||||
|
|
||||||
struct SDRDaemonProtectedBlock
|
struct SDRDaemonProtectedBlock
|
||||||
{
|
{
|
||||||
Sample m_samples[SDRDaemonSamplesPerBlock];
|
uint8_t buf[SDRDaemonNbBytesPerBlock];
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
std::fill(m_samples, m_samples+SDRDaemonSamplesPerBlock, Sample{0,0});
|
std::fill(buf, buf+SDRDaemonNbBytesPerBlock, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
|
|
||||||
const uint32_t SDRDaemonDataReadQueue::MinimumMaxSize = 10;
|
const uint32_t SDRDaemonDataReadQueue::MinimumMaxSize = 10;
|
||||||
|
|
||||||
SDRDaemonDataReadQueue::SDRDaemonDataReadQueue() :
|
SDRDaemonDataReadQueue::SDRDaemonDataReadQueue(uint32_t sampleSize) :
|
||||||
|
m_sampleSize(sampleSize),
|
||||||
m_dataBlock(0),
|
m_dataBlock(0),
|
||||||
m_maxSize(MinimumMaxSize),
|
m_maxSize(MinimumMaxSize),
|
||||||
m_blockIndex(1),
|
m_blockIndex(1),
|
||||||
@ -95,7 +96,7 @@ void SDRDaemonDataReadQueue::readSample(Sample& s)
|
|||||||
qDebug("SDRDaemonDataReadQueue::readSample: initial pop new block: queue size: %u", length());
|
qDebug("SDRDaemonDataReadQueue::readSample: initial pop new block: queue size: %u", length());
|
||||||
m_blockIndex = 1;
|
m_blockIndex = 1;
|
||||||
m_dataBlock = m_dataReadQueue.takeFirst();
|
m_dataBlock = m_dataReadQueue.takeFirst();
|
||||||
s = m_dataBlock->m_superBlocks[m_blockIndex].m_protectedBlock.m_samples[m_sampleIndex];
|
convertDataToSample(s, m_blockIndex, m_sampleIndex);
|
||||||
m_sampleIndex++;
|
m_sampleIndex++;
|
||||||
m_sampleCount++;
|
m_sampleCount++;
|
||||||
}
|
}
|
||||||
@ -107,9 +108,11 @@ void SDRDaemonDataReadQueue::readSample(Sample& s)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_sampleIndex < SDRDaemonSamplesPerBlock)
|
uint32_t samplesPerBlock = SDRDaemonNbBytesPerBlock / m_sampleSize;
|
||||||
|
|
||||||
|
if (m_sampleIndex < samplesPerBlock)
|
||||||
{
|
{
|
||||||
s = m_dataBlock->m_superBlocks[m_blockIndex].m_protectedBlock.m_samples[m_sampleIndex];
|
convertDataToSample(s, m_blockIndex, m_sampleIndex);
|
||||||
m_sampleIndex++;
|
m_sampleIndex++;
|
||||||
m_sampleCount++;
|
m_sampleCount++;
|
||||||
}
|
}
|
||||||
@ -120,7 +123,7 @@ void SDRDaemonDataReadQueue::readSample(Sample& s)
|
|||||||
|
|
||||||
if (m_blockIndex < SDRDaemonNbOrginalBlocks)
|
if (m_blockIndex < SDRDaemonNbOrginalBlocks)
|
||||||
{
|
{
|
||||||
s = m_dataBlock->m_superBlocks[m_blockIndex].m_protectedBlock.m_samples[m_sampleIndex];
|
convertDataToSample(s, m_blockIndex, m_sampleIndex);
|
||||||
m_sampleIndex++;
|
m_sampleIndex++;
|
||||||
m_sampleCount++;
|
m_sampleCount++;
|
||||||
}
|
}
|
||||||
@ -141,7 +144,7 @@ void SDRDaemonDataReadQueue::readSample(Sample& s)
|
|||||||
//qDebug("SDRDaemonDataReadQueue::readSample: pop new block: queue size: %u", length());
|
//qDebug("SDRDaemonDataReadQueue::readSample: pop new block: queue size: %u", length());
|
||||||
m_blockIndex = 1;
|
m_blockIndex = 1;
|
||||||
m_dataBlock = m_dataReadQueue.takeFirst();
|
m_dataBlock = m_dataReadQueue.takeFirst();
|
||||||
s = m_dataBlock->m_superBlocks[m_blockIndex].m_protectedBlock.m_samples[m_sampleIndex];
|
convertDataToSample(s, m_blockIndex, m_sampleIndex);
|
||||||
m_sampleIndex++;
|
m_sampleIndex++;
|
||||||
m_sampleCount++;
|
m_sampleCount++;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class Sample;
|
|||||||
class SDRDaemonDataReadQueue
|
class SDRDaemonDataReadQueue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SDRDaemonDataReadQueue();
|
SDRDaemonDataReadQueue(uint32_t sampleSize);
|
||||||
~SDRDaemonDataReadQueue();
|
~SDRDaemonDataReadQueue();
|
||||||
|
|
||||||
void push(SDRDaemonDataBlock* dataBlock); //!< push block on the queue
|
void push(SDRDaemonDataBlock* dataBlock); //!< push block on the queue
|
||||||
@ -45,6 +45,7 @@ public:
|
|||||||
static const uint32_t MinimumMaxSize;
|
static const uint32_t MinimumMaxSize;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
uint32_t m_sampleSize;
|
||||||
QQueue<SDRDaemonDataBlock*> m_dataReadQueue;
|
QQueue<SDRDaemonDataBlock*> m_dataReadQueue;
|
||||||
SDRDaemonDataBlock *m_dataBlock;
|
SDRDaemonDataBlock *m_dataBlock;
|
||||||
uint32_t m_maxSize;
|
uint32_t m_maxSize;
|
||||||
@ -52,6 +53,32 @@ private:
|
|||||||
uint32_t m_sampleIndex;
|
uint32_t m_sampleIndex;
|
||||||
uint32_t m_sampleCount; //!< use a counter capped below 2^31 as it is going to be converted to an int in the web interface
|
uint32_t m_sampleCount; //!< use a counter capped below 2^31 as it is going to be converted to an int in the web interface
|
||||||
bool m_full; //!< full condition was hit
|
bool m_full; //!< full condition was hit
|
||||||
|
|
||||||
|
inline void convertDataToSample(Sample& s, uint32_t blockIndex, uint32_t sampleIndex)
|
||||||
|
{
|
||||||
|
if (sizeof(Sample) == m_sampleSize)
|
||||||
|
{
|
||||||
|
s = *((Sample*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*m_sampleSize]));
|
||||||
|
}
|
||||||
|
else if ((sizeof(Sample) == 4) && (m_sampleSize == 8))
|
||||||
|
{
|
||||||
|
int32_t rp = *( (int32_t*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*m_sampleSize]) );
|
||||||
|
int32_t ip = *( (int32_t*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*m_sampleSize+4]) );
|
||||||
|
s.setReal(rp>>8);
|
||||||
|
s.setImag(ip>>8);
|
||||||
|
}
|
||||||
|
else if ((sizeof(Sample) == 8) && (m_sampleSize == 4))
|
||||||
|
{
|
||||||
|
int32_t rp = *( (int16_t*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*m_sampleSize]) );
|
||||||
|
int32_t ip = *( (int16_t*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*m_sampleSize+2]) );
|
||||||
|
s.setReal(rp<<8);
|
||||||
|
s.setImag(ip<<8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = Sample{0, 0};
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user