mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2026-04-18 22:32:44 +00:00
compression
This commit is contained in:
@@ -26,7 +26,11 @@ namespace server {
|
||||
s_cmd_hdr = (CommandHeader*)s_pkt_data;
|
||||
s_cmd_data = &sbuffer[sizeof(PacketHeader) + sizeof(CommandHeader)];
|
||||
|
||||
// Initialize decompressor
|
||||
dctx = ZSTD_createDCtx();
|
||||
|
||||
// Initialize DSP
|
||||
decompIn.setBufferSize((sizeof(dsp::complex_t) * STREAM_BUFFER_SIZE) + 8);
|
||||
decomp.init(&decompIn);
|
||||
link.init(&decomp.out, output);
|
||||
decomp.start();
|
||||
@@ -43,6 +47,7 @@ namespace server {
|
||||
|
||||
ClientClass::~ClientClass() {
|
||||
close();
|
||||
ZSTD_freeDCtx(dctx);
|
||||
delete[] rbuffer;
|
||||
delete[] sbuffer;
|
||||
}
|
||||
@@ -108,6 +113,11 @@ namespace server {
|
||||
sendCommand(COMMAND_SET_SAMPLE_TYPE, 1);
|
||||
}
|
||||
|
||||
void ClientClass::setCompression(bool enabled) {
|
||||
s_cmd_data[0] = enabled;
|
||||
sendCommand(COMMAND_SET_COMPRESSION, 1);
|
||||
}
|
||||
|
||||
void ClientClass::start() {
|
||||
if (!client || !client->isOpen()) { return; }
|
||||
sendCommand(COMMAND_START, 0);
|
||||
@@ -189,6 +199,10 @@ namespace server {
|
||||
memcpy(_this->decompIn.writeBuf, &buf[sizeof(PacketHeader)], _this->r_pkt_hdr->size - sizeof(PacketHeader));
|
||||
_this->decompIn.swap(_this->r_pkt_hdr->size - sizeof(PacketHeader));
|
||||
}
|
||||
else if (_this->r_pkt_hdr->type == PACKET_TYPE_BASEBAND_COMPRESSED) {
|
||||
size_t outCount = ZSTD_decompressDCtx(_this->dctx, _this->decompIn.writeBuf, STREAM_BUFFER_SIZE, _this->r_pkt_data, _this->r_pkt_hdr->size - sizeof(PacketHeader));
|
||||
if (outCount) { _this->decompIn.swap(outCount); };
|
||||
}
|
||||
else if (_this->r_pkt_hdr->type == PACKET_TYPE_ERROR) {
|
||||
spdlog::error("SDR++ Server Error: {0}", buf[sizeof(PacketHeader)]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user