From a8966789c00d82a07c5d1f95e3fd4d67999d2620 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 28 May 2018 11:52:24 +0200 Subject: [PATCH] Server: added BFM demod plugin --- plugins/channelrx/demodbfm/bfmplugin.cpp | 12 ++++- pluginssrv/channelrx/CMakeLists.txt | 1 + pluginssrv/channelrx/demodbfm/CMakeLists.txt | 55 ++++++++++++++++++++ swagger/sdrangel/examples/rx_test.py | 30 +++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 pluginssrv/channelrx/demodbfm/CMakeLists.txt diff --git a/plugins/channelrx/demodbfm/bfmplugin.cpp b/plugins/channelrx/demodbfm/bfmplugin.cpp index 55ffb78dc..1d08ffad4 100644 --- a/plugins/channelrx/demodbfm/bfmplugin.cpp +++ b/plugins/channelrx/demodbfm/bfmplugin.cpp @@ -20,7 +20,9 @@ #include #include "plugin/pluginapi.h" +#ifndef SERVER_MODE #include "bfmdemodgui.h" +#endif #include "bfmdemod.h" const PluginDescriptor BFMPlugin::m_pluginDescriptor = { @@ -51,11 +53,19 @@ void BFMPlugin::initPlugin(PluginAPI* pluginAPI) m_pluginAPI->registerRxChannel(BFMDemod::m_channelIdURI, BFMDemod::m_channelId, this); } +#ifdef SERVER_MODE +PluginInstanceGUI* BFMPlugin::createRxChannelGUI( + DeviceUISet *deviceUISet __attribute__((unused)), + BasebandSampleSink *rxChannel __attribute__((unused))) +{ + return 0; +} +#else PluginInstanceGUI* BFMPlugin::createRxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel) { return BFMDemodGUI::create(m_pluginAPI, deviceUISet, rxChannel); } - +#endif BasebandSampleSink* BFMPlugin::createRxChannelBS(DeviceSourceAPI *deviceAPI) { diff --git a/pluginssrv/channelrx/CMakeLists.txt b/pluginssrv/channelrx/CMakeLists.txt index 5e24cddff..25438c882 100644 --- a/pluginssrv/channelrx/CMakeLists.txt +++ b/pluginssrv/channelrx/CMakeLists.txt @@ -1,4 +1,5 @@ project(demod) add_subdirectory(demodam) +add_subdirectory(demodbfm) add_subdirectory(demodnfm) diff --git a/pluginssrv/channelrx/demodbfm/CMakeLists.txt b/pluginssrv/channelrx/demodbfm/CMakeLists.txt new file mode 100644 index 000000000..dffd1854a --- /dev/null +++ b/pluginssrv/channelrx/demodbfm/CMakeLists.txt @@ -0,0 +1,55 @@ +project(bfm) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +set(PLUGIN_PREFIX "../../../plugins/channelrx/demodbfm") + +set(bfm_SOURCES + ${PLUGIN_PREFIX}/bfmdemod.cpp + ${PLUGIN_PREFIX}/bfmdemodsettings.cpp + ${PLUGIN_PREFIX}/bfmplugin.cpp + ${PLUGIN_PREFIX}/rdsdemod.cpp + ${PLUGIN_PREFIX}/rdsdecoder.cpp + ${PLUGIN_PREFIX}/rdsparser.cpp + ${PLUGIN_PREFIX}/rdstmc.cpp +) + +set(bfm_HEADERS + ${PLUGIN_PREFIX}/bfmdemod.h + ${PLUGIN_PREFIX}/bfmdemodsettings.h + ${PLUGIN_PREFIX}/bfmplugin.h + ${PLUGIN_PREFIX}/rdsdemod.h + ${PLUGIN_PREFIX}/rdsdecoder.h + ${PLUGIN_PREFIX}/rdsparser.h + ${PLUGIN_PREFIX}/rdstmc.h +) + +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set_source_files_properties(rdstmc.cpp PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments) +endif() + +include_directories( + . + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client +) + +#include(${QT_USE_FILE}) +add_definitions(${QT_DEFINITIONS}) +add_definitions(-DQT_PLUGIN) +add_definitions(-DQT_SHARED) + +add_library(demodbfmsrv SHARED + ${bfm_SOURCES} + ${bfm_HEADERS_MOC} + ${bfm_FORMS_HEADERS} +) + +target_link_libraries(demodbfmsrv + ${QT_LIBRARIES} + sdrbase + swagger +) + +qt5_use_modules(demodbfmsrv Core) + +install(TARGETS demodbfmsrv DESTINATION lib/pluginssrv/channelrx) diff --git a/swagger/sdrangel/examples/rx_test.py b/swagger/sdrangel/examples/rx_test.py index 238617a6f..e22791769 100755 --- a/swagger/sdrangel/examples/rx_test.py +++ b/swagger/sdrangel/examples/rx_test.py @@ -38,6 +38,12 @@ def getInputOptions(): parser.add_option("--stereo", dest="stereo", help="Broadcast FM stereo", metavar="BOOL", action="store_true", default=False) parser.add_option("--lsb-stereo", dest="lsb_stereo", help="Broadcast FM LSB stereo", metavar="BOOL", action="store_true", default=False) parser.add_option("--rds", dest="rds", help="Broadcast FM RDS", metavar="BOOL", action="store_true", default=False) + parser.add_option("--audio-name", dest="audio_name", help="Audio: audio device name", metavar="STRING", type="string") + parser.add_option("--audio-udp", dest="audio_udp", help="Audio: set copy to UDP", metavar="BOOL_INT", type="int") + parser.add_option("--audio-rtp", dest="audio_rtp", help="Audio: use RTP over UDP", metavar="BOOL_INT", type="int") + parser.add_option("--audio-address", dest="audio_address", help="Audio: UDP destination address", metavar="IP_ADDRESS", type="string") + parser.add_option("--audio-port", dest="audio_port", help="Audio: UDP destination port", metavar="IP_PORT", type="int") + parser.add_option("--audio-channels", dest="audio_channels", help="Audio: UDP mode (0: L only 1: R only 2: L+R mono 3: LR stereo)", metavar="ENUM_INT", type="int") (options, args) = parser.parse_args() @@ -77,6 +83,7 @@ def printResponse(response): def callAPI(url, method, params, json, text): request_method = requests_methods.get(method, None) if request_method is not None: + #print(base_url, url, json) r = request_method(url=base_url+url, params=params, json=json) if r.status_code / 100 == 2: print(text + " succeeded") @@ -87,6 +94,26 @@ def callAPI(url, method, params, json, text): printResponse(r) return None +# ====================================================================== +def setup_audio(options): + audio_dict = {} + if options.audio_name: # must not be None and reference a valid audio device + audio_dict["name"] = options.audio_name + if options.audio_udp: + audio_dict["copyToUDP"] = 0 if options.audio_udp == 0 else 1 + if options.audio_rtp: + audio_dict["udpUsesRTP"] = 0 if options.audio_rtp == 0 else 1 + if options.audio_address: + audio_dict["udpAddress"] = options.audio_address + if options.audio_port: + audio_dict["udpPort"] = options.audio_port + if options.audio_channels: + audio_dict["udpChannelMode"] = 0 if options.audio_channels < 0 else 3 if options.audio_channels > 3 else options.audio_channels + + r = callAPI('/audio/output/parameters', "PATCH", None, audio_dict, "setup audio {}".format(options.audio_name)) + if r is None: + exit(-1) + # ====================================================================== def setupDevice(deviceset_url, options): r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid, "tx": 0}, "setup device on Rx device set") @@ -284,6 +311,9 @@ def main(): base_url = "http://%s/sdrangel" % options.address deviceset_url = "/deviceset/%d" % options.device_index + if options.audio_name: + setup_audio(options) + if options.create: r = callAPI("/deviceset", "POST", {"tx": 0}, None, "Add Rx device set") if r is None: