diff --git a/doc/img/RemoteSink.png b/doc/img/RemoteSink.png index 4b3ce531a..20e8c5d7d 100644 Binary files a/doc/img/RemoteSink.png and b/doc/img/RemoteSink.png differ diff --git a/doc/img/RemoteSink.xcf b/doc/img/RemoteSink.xcf index 8ca49d85f..259e69f8f 100644 Binary files a/doc/img/RemoteSink.xcf and b/doc/img/RemoteSink.xcf differ diff --git a/plugins/channelrx/remotesink/readme.md b/plugins/channelrx/remotesink/readme.md index 6fcd797a7..aa7509aa7 100644 --- a/plugins/channelrx/remotesink/readme.md +++ b/plugins/channelrx/remotesink/readme.md @@ -56,17 +56,6 @@ When the return key is hit within the address (1) or port (2) the changes are ef This sets the number of FEC blocks per frame. A frame consists of 128 data blocks (1 meta data block followed by 127 I/Q data blocks) and a variable number of FEC blocks used to protect the UDP transmission with a Cauchy MDS block erasure correction. The two numbers next are the total number of blocks and the number of FEC blocks separated by a slash (/). -

10: Delay between UDP blocks transmission

+

10: Transmission sample size

-This sets the minimum delay between transmission of an UDP block (send datagram) and the next. This allows throttling of the UDP transmission that is otherwise uncontrolled and causes network congestion. - -The value is a percentage of the nominal time it takes to process a block of samples corresponding to one UDP block (512 bytes). This is calculated as follows: - - - Sample rate on the network: _SR_ - - Delay percentage: _d_ - - Number of FEC blocks: _F_ - - There are 127 blocks of I/Q data per frame (1 meta block for 128 blocks) and each I/Q data block of 512 bytes (128 samples) has a 8 bytes header (2 samples) thus there are 126 samples remaining effectively. This gives the constant 127*126 = 16002 samples per frame in the formula - -Formula: ((127 ✕ 126 ✕ _d_) / _SR_) / (128 + _F_) - -The percentage appears first at the right of the dial button and then the actual delay value in microseconds. \ No newline at end of file +Number of bytes per I or Q sample in transmission. diff --git a/plugins/channelrx/remotesink/remotesinksink.cpp b/plugins/channelrx/remotesink/remotesinksink.cpp index fd512049a..f13b9bf13 100644 --- a/plugins/channelrx/remotesink/remotesinksink.cpp +++ b/plugins/channelrx/remotesink/remotesinksink.cpp @@ -144,7 +144,7 @@ void RemoteSinkSink::feed(const SampleVector::const_iterator& begin, const Sampl } // block zero // handle different sample sizes... - int samplesPerBlock = RemoteNbBytesPerBlock / (SDR_RX_SAMP_SZ <= 16 ? 4 : 8); // two I or Q samples + int samplesPerBlock = RemoteNbBytesPerBlock / (2 * m_nbTxBytes); // two I or Q samples if (m_sampleIndex + inRemainingSamples < samplesPerBlock) // there is still room in the current super block { convertSampleToData(begin + inSamplesIndex, inRemainingSamples, false); diff --git a/plugins/channelrx/remotesink/remotesinksink.h b/plugins/channelrx/remotesink/remotesinksink.h index 7db48a3d5..cfe391f12 100644 --- a/plugins/channelrx/remotesink/remotesinksink.h +++ b/plugins/channelrx/remotesink/remotesinksink.h @@ -96,12 +96,12 @@ private: *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag; } } - else if (m_nbTxBytes == 1) // 16 -> 8 + else if (m_nbTxBytes == 1) // 16 or 24 -> 8 { for (int i = 0; i < nbSamples; i++) { - m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2] = (uint8_t) ((begin+i)->m_real / 256); - m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes] = (uint8_t) ((begin+i)->m_imag / 256); + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (int8_t) ((begin+i)->m_real / (1<<8)); + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (int8_t) ((begin+i)->m_imag / (1<<8)); } } } @@ -111,26 +111,32 @@ private: { for (int i = 0; i < nbSamples; i++) { - *((int32_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (begin+i)->m_real << 8; - *((int32_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag << 8; + *((int32_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (begin+i)->m_real * (1<<8); + *((int32_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag * (1<<8); } } else if (m_nbTxBytes == 2) // 24 -> 16 { for (int i = 0; i < nbSamples; i++) { - *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (begin+i)->m_real >> 8; - *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag >> 8; + *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (begin+i)->m_real / (1<<8); + *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag / (1<<8); } } - else if (m_nbTxBytes == 1) // 16 or 24 -> 8 + else if ((m_nbTxBytes == 1) && (sizeof(Sample) == 4)) // 16 -> 8 { for (int i = 0; i < nbSamples; i++) { - m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2] = - (uint8_t) (((begin+i)->m_real / (1<m_imag / (1<m_real / (1<<8)); + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (int8_t) ((begin+i)->m_imag / (1<<8)); + } + } + else if ((m_nbTxBytes == 1) && (sizeof(Sample) == 8)) // 24 -> 8 + { + for (int i = 0; i < nbSamples; i++) + { + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (int8_t) ((begin+i)->m_real / (1<<16)); + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (int8_t) ((begin+i)->m_imag / (1<<16)); } } } diff --git a/plugins/samplesink/remoteoutput/udpsinkfec.h b/plugins/samplesink/remoteoutput/udpsinkfec.h index c1b0084a0..06da1c87d 100644 --- a/plugins/samplesink/remoteoutput/udpsinkfec.h +++ b/plugins/samplesink/remoteoutput/udpsinkfec.h @@ -128,12 +128,12 @@ private: *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag; } } - else if (m_nbTxBytes == 1) // 16 -> 8 + else if (m_nbTxBytes == 1) // 16 or 24 -> 8 { for (int i = 0; i < nbSamples; i++) { - m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2] = (uint8_t) ((begin+i)->m_real / 256); - m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes] = (uint8_t) ((begin+i)->m_imag / 256); + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (int8_t) ((begin+i)->m_real / (1<<8)); + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (int8_t) ((begin+i)->m_imag / (1<<8)); } } } @@ -143,26 +143,32 @@ private: { for (int i = 0; i < nbSamples; i++) { - *((int32_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (begin+i)->m_real << 8; - *((int32_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag << 8; + *((int32_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (begin+i)->m_real * (1<<8); + *((int32_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag * (1<<8); } } else if (m_nbTxBytes == 2) // 24 -> 16 { for (int i = 0; i < nbSamples; i++) { - *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (begin+i)->m_real >> 8; - *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag >> 8; + *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (begin+i)->m_real / (1<<8); + *((int16_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (begin+i)->m_imag / (1<<8); } } - else if (m_nbTxBytes == 1) // 16 or 24 -> 8 + else if ((m_nbTxBytes == 1) && (sizeof(Sample) == 4)) // 16 -> 8 { for (int i = 0; i < nbSamples; i++) { - m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2] = - (uint8_t) (((begin+i)->m_real / (1<m_imag / (1<m_real / (1<<8)); + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (int8_t) ((begin+i)->m_imag / (1<<8)); + } + } + else if ((m_nbTxBytes == 1) && (sizeof(Sample) == 4)) // 24 -> 8 + { + for (int i = 0; i < nbSamples; i++) + { + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2]) = (int8_t) ((begin+i)->m_real / (1<<16)); + *((int8_t*) &m_superBlock.m_protectedBlock.buf[(m_sampleIndex+ i)*m_nbTxBytes*2 + m_nbTxBytes]) = (int8_t) ((begin+i)->m_imag / (1<<16)); } } } diff --git a/plugins/samplesource/remoteinput/remoteinputudphandler.cpp b/plugins/samplesource/remoteinput/remoteinputudphandler.cpp index cd1f9c300..1bdd14f77 100644 --- a/plugins/samplesource/remoteinput/remoteinputudphandler.cpp +++ b/plugins/samplesource/remoteinput/remoteinputudphandler.cpp @@ -340,13 +340,13 @@ void RemoteInputUDPHandler::tick() m_converterBuffer = new int32_t[m_readLengthSamples]; } - uint8_t *buf = m_remoteInputBuffer.readData(m_readLength); + int8_t *buf = (int8_t*) m_remoteInputBuffer.readData(m_readLength); for (int is = 0; is < m_readLengthSamples; is++) { - m_converterBuffer[is] = buf[2*is+1] << 8; // Q -> MSB + m_converterBuffer[is] = buf[2*is+1] * (1<<8); // Q -> MSB m_converterBuffer[is] <<= 16; - m_converterBuffer[is] += buf[2*is] << 8; // I -> LSB + m_converterBuffer[is] += buf[2*is] * (1<<8); // I -> LSB } } else if ((metaData.m_sampleBits == 8) && (SDR_RX_SAMP_SZ == 24)) // 8 -> 24 @@ -357,14 +357,12 @@ void RemoteInputUDPHandler::tick() m_converterBuffer = new int32_t[m_readLengthSamples*2]; } - uint8_t *buf = m_remoteInputBuffer.readData(m_readLength); + int8_t *buf = (int8_t*) m_remoteInputBuffer.readData(m_readLength); for (int is = 0; is < m_readLengthSamples; is++) { - m_converterBuffer[2*is] = buf[2*is]; // I - m_converterBuffer[2*is] <<= 16; - m_converterBuffer[2*is+1] = buf[2*is+1]; // Q - m_converterBuffer[2*is+1] <<= 16; + m_converterBuffer[2*is] = buf[2*is] * (1<<16); // I + m_converterBuffer[2*is+1] = buf[2*is+1] * (1<<16); // Q } m_sampleFifo->write(reinterpret_cast(m_converterBuffer), m_readLengthSamples*sizeof(Sample)); @@ -377,14 +375,12 @@ void RemoteInputUDPHandler::tick() m_converterBuffer = new int32_t[m_readLengthSamples*2]; } - uint8_t *buf = m_remoteInputBuffer.readData(m_readLength); + int16_t *buf = (int16_t*) m_remoteInputBuffer.readData(m_readLength); for (int is = 0; is < m_readLengthSamples; is++) { - m_converterBuffer[2*is] = ((int16_t*)buf)[2*is]; // I - m_converterBuffer[2*is] <<= 8; - m_converterBuffer[2*is+1] = ((int16_t*)buf)[2*is+1]; // Q - m_converterBuffer[2*is+1] <<= 8; + m_converterBuffer[2*is] = buf[2*is] * (1<<8); // I + m_converterBuffer[2*is+1] = buf[2*is+1] * (1<<8); // Q } m_sampleFifo->write(reinterpret_cast(m_converterBuffer), m_readLengthSamples*sizeof(Sample)); @@ -397,13 +393,13 @@ void RemoteInputUDPHandler::tick() m_converterBuffer = new int32_t[m_readLengthSamples]; } - uint8_t *buf = m_remoteInputBuffer.readData(m_readLength); + int32_t *buf = (int32_t*) m_remoteInputBuffer.readData(m_readLength); for (int is = 0; is < m_readLengthSamples; is++) { - m_converterBuffer[is] = ((int32_t *)buf)[2*is+1]>>8; // Q -> MSB + m_converterBuffer[is] = buf[2*is+1] / (1<<8); // Q -> MSB m_converterBuffer[is] <<= 16; - m_converterBuffer[is] += ((int32_t *)buf)[2*is]>>8; // I -> LSB + m_converterBuffer[is] += buf[2*is] / (1<<8); // I -> LSB } m_sampleFifo->write(reinterpret_cast(m_converterBuffer), m_readLengthSamples*sizeof(Sample)); diff --git a/sdrbase/channel/remotedatareadqueue.h b/sdrbase/channel/remotedatareadqueue.h index 6ad014c3c..c748fe2f9 100644 --- a/sdrbase/channel/remotedatareadqueue.h +++ b/sdrbase/channel/remotedatareadqueue.h @@ -70,24 +70,23 @@ private: { if (sampleSize == 2) // 8 -> 16 bits { - int8_t iu = m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]; - int8_t qu = m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+1]; - iconv = iu * (1 << 8); - qconv = qu * (1 << 8); + int8_t *buf = (int8_t*) m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf; + iconv = buf[sampleIndex*sampleSize] * (1<<8); + qconv = buf[sampleIndex*sampleSize+1] * (1<<8); s.setReal(iconv); s.setImag(qconv); } else if (sampleSize == 4) // just convert types (always 16 bits wide) { - iconv = ((int16_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]))[0]; - qconv = ((int16_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+2]))[0]; + iconv = *((int16_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize])); + qconv = *((int16_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+2])); s.setReal(iconv); s.setImag(qconv); } else if (sampleSize == 8) // just convert types (always 16 bits wide) { - iconv = ((int32_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]))[0]; - qconv = ((int32_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+4]))[0]; + iconv = *((int32_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize])); + qconv = *((int32_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+4])); s.setReal(iconv); s.setImag(qconv); } @@ -98,26 +97,33 @@ private: } else { - if (sampleSize == 2) // 8 -> 16 or 24 bits + if ((sampleSize == 2) && (sizeof(Sample) == 2)) // 8 -> 16 bits { - int8_t iu = m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]; - int8_t qu = m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+1]; - iconv = iu * (1 << sizeof(Sample)*2); - qconv = qu * (1 << sizeof(Sample)*2); + int8_t *buf = (int8_t*) m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf; + iconv = buf[sampleIndex*sampleSize] * (1<<8); + qconv = buf[sampleIndex*sampleSize+1] * (1<<8); + s.setReal(iconv); + s.setImag(qconv); + } + else if ((sampleSize == 2) && (sizeof(Sample) == 4)) // 8 -> 24 bits + { + int8_t *buf = (int8_t*) m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf; + iconv = buf[sampleIndex*sampleSize] * (1<<16); + qconv = buf[sampleIndex*sampleSize+1] * (1<<16); s.setReal(iconv); s.setImag(qconv); } else if (sampleSize == 4) // 16 -> 24 bits { - iconv = ((int16_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]))[0] << 8; - qconv = ((int16_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+2]))[0] << 8; + iconv = *((int16_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize])) * (1<<8); + qconv = *((int16_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+2])) * (1<<8); s.setReal(iconv); s.setImag(qconv); } else if (sampleSize == 8) // 24 -> 16 bits { - iconv = ((int32_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]))[0] >> 8; - qconv = ((int32_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+4]))[0] >> 8; + iconv = *((int32_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize])) / (1<<8); + qconv = *((int32_t*) &(m_dataFrame->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+4])) / (1<<8); s.setReal(iconv); s.setImag(qconv); }