SDRPlusPlus/core/src/module.h

86 lines
3.2 KiB
C
Raw Normal View History

2020-08-07 14:29:06 +02:00
#pragma once
#include <string>
#include <map>
#include <filesystem>
#include <stdint.h>
#include <imgui.h>
#include <spdlog/spdlog.h>
2020-08-11 18:33:42 +02:00
#include <dsp/types.h>
#include <dsp/stream.h>
2020-08-12 16:43:44 +02:00
#include <waterfall.h>
#include <json.hpp>
2020-08-07 14:29:06 +02:00
#ifdef _WIN32
#include <Windows.h>
#define MOD_EXPORT extern "C" \
__declspec(dllexport)
#else
2020-08-11 18:33:42 +02:00
#include <dlfcn.h>
2020-08-07 14:29:06 +02:00
#define MOD_EXPORT extern "C"
#endif
namespace mod {
struct API_t {
2020-08-11 18:33:42 +02:00
dsp::stream<dsp::complex_t>* (*registerVFO)(std::string name, int reference, float offset, float bandwidth, float sampleRate, int blockSize);
void (*setVFOOffset)(std::string name, float offset);
void (*setVFOCenterOffset)(std::string name, float offset);
void (*setVFOBandwidth)(std::string name, float bandwidth);
void (*setVFOSampleRate)(std::string name, float sampleRate, float bandwidth);
int (*getVFOOutputBlockSize)(std::string name);
void (*setVFOReference)(std::string name, int ref);
void (*removeVFO)(std::string name);
2020-08-16 03:39:05 +02:00
2020-08-12 16:43:44 +02:00
std::string (*getSelectedVFOName)(void);
void (*bindVolumeVariable)(float* vol);
void (*unbindVolumeVariable)(void);
2020-08-07 14:29:06 +02:00
2020-08-16 03:39:05 +02:00
float (*registerMonoStream)(dsp::stream<float>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, float sampleRate), void* ctx);
float (*registerStereoStream)(dsp::stream<dsp::StereoFloat_t>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, float sampleRate), void* ctx);
void (*startStream)(std::string name);
void (*stopStream)(std::string name);
void (*removeStream)(std::string name);
dsp::stream<float>* (*bindToStreamMono)(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, float sampleRate, int blockSize), void* ctx);
dsp::stream<dsp::StereoFloat_t>* (*bindToStreamStereo)(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, float sampleRate, int blockSize), void* ctx);
void (*setBlockSize)(std::string name, int blockSize);
void (*unbindFromStreamMono)(std::string name, dsp::stream<float>* stream);
void (*unbindFromStreamStereo)(std::string name, dsp::stream<dsp::StereoFloat_t>* stream);
2020-08-18 00:56:51 +02:00
std::vector<std::string> (*getStreamNameList)(void);
2020-08-16 03:39:05 +02:00
2020-08-11 18:33:42 +02:00
enum {
REF_LOWER,
REF_CENTER,
REF_UPPER,
_REF_COUNT
};
};
enum {
EVENT_STREAM_PARAM_CHANGED,
2020-08-12 16:43:44 +02:00
EVENT_SELECTED_VFO_CHANGED,
2020-08-11 18:33:42 +02:00
_EVENT_COUNT
2020-08-07 14:29:06 +02:00
};
struct Module_t {
#ifdef _WIN32
HINSTANCE inst;
#else
void* inst;
#endif
void* (*_INIT_)(API_t*, ImGuiContext*, std::string);
void (*_DRAW_MENU_)(void*);
2020-08-12 16:43:44 +02:00
void (*_NEW_FRAME_)(void*);
2020-08-11 18:33:42 +02:00
void (*_HANDLE_EVENT_)(void*, int);
2020-08-07 14:29:06 +02:00
void (*_STOP_)(void*);
void* ctx;
};
2020-08-12 16:43:44 +02:00
void initAPI(ImGui::WaterFall* wtf);
2020-08-07 14:29:06 +02:00
void loadModule(std::string path, std::string name);
2020-08-11 18:33:42 +02:00
void broadcastEvent(int eventId);
2020-08-12 16:43:44 +02:00
void loadFromList(std::string path);
2020-08-07 14:29:06 +02:00
extern std::map<std::string, Module_t> modules;
extern std::vector<std::string> moduleNames;
2020-08-11 18:33:42 +02:00
};
extern mod::API_t* API;