1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Server: added BFM demod plugin

This commit is contained in:
f4exb 2018-05-28 11:52:24 +02:00
parent 7feec443a7
commit a8966789c0
4 changed files with 97 additions and 1 deletions

View File

@ -20,7 +20,9 @@
#include <QtPlugin>
#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)
{

View File

@ -1,4 +1,5 @@
project(demod)
add_subdirectory(demodam)
add_subdirectory(demodbfm)
add_subdirectory(demodnfm)

View File

@ -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)

View File

@ -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: