mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-26 12:27:51 +02:00
compression
This commit is contained in:
@ -19,6 +19,10 @@ endif ()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(sdrpp_server_source PRIVATE wsock32 ws2_32)
|
||||
|
||||
# ZSTD
|
||||
find_package(zstd CONFIG REQUIRED)
|
||||
target_link_libraries(sdrpp_server_source PRIVATE zstd::libzstd_shared)
|
||||
endif()
|
||||
|
||||
# Install directives
|
||||
|
@ -194,11 +194,18 @@ private:
|
||||
config.conf["servers"][_this->devConfName]["sampleType"] = _this->sampleTypeList.key(_this->sampleTypeId);
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Compression", &_this->compression)) {
|
||||
_this->client->setCompression(_this->compression);
|
||||
|
||||
bool dummy = false;
|
||||
// Save config
|
||||
config.acquire();
|
||||
config.conf["servers"][_this->devConfName]["compression"] = _this->compression;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
bool dummy = true;
|
||||
style::beginDisabled();
|
||||
ImGui::Checkbox("Compression", &dummy);
|
||||
dummy = true;
|
||||
ImGui::Checkbox("Full IQ", &dummy);
|
||||
style::endDisabled();
|
||||
|
||||
@ -237,9 +244,13 @@ private:
|
||||
std::string key = config.conf["servers"][devConfName]["sampleType"];
|
||||
if (sampleTypeList.keyExists(key)) { sampleTypeId = sampleTypeList.keyId(key); }
|
||||
}
|
||||
if (config.conf["servers"][devConfName].contains("compression")) {
|
||||
compression = config.conf["servers"][devConfName]["compression"];
|
||||
}
|
||||
|
||||
// Set settings
|
||||
client->setSampleType(sampleTypeList[sampleTypeId]);
|
||||
client->setCompression(compression);
|
||||
}
|
||||
|
||||
std::string name;
|
||||
@ -261,6 +272,7 @@ private:
|
||||
|
||||
OptionList<std::string, dsp::PCMType> sampleTypeList;
|
||||
int sampleTypeId;
|
||||
bool compression = false;
|
||||
|
||||
server::Client client;
|
||||
};
|
||||
|
@ -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)]);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <dsp/compression.h>
|
||||
#include <dsp/sink.h>
|
||||
#include <dsp/link.h>
|
||||
#include <zstd.h>
|
||||
|
||||
#define RFSPACE_MAX_SIZE 8192
|
||||
#define RFSPACE_HEARTBEAT_INTERVAL_MS 1000
|
||||
@ -85,6 +86,7 @@ namespace server {
|
||||
double getSampleRate();
|
||||
|
||||
void setSampleType(dsp::PCMType type);
|
||||
void setCompression(bool enabled);
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
@ -133,6 +135,8 @@ namespace server {
|
||||
SmGui::DrawList dl;
|
||||
std::mutex dlMtx;
|
||||
|
||||
ZSTD_DCtx* dctx;
|
||||
|
||||
double currentSampleRate = 1000000.0;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user