From 6bc925ebab4f67c89f91d8ff1dde3b6bc7ac57c6 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Fri, 23 Apr 2021 14:01:56 +0100 Subject: [PATCH 1/2] Add support for displaying images broadcast in the DAB demodulator GUI --- plugins/channelrx/demoddab/dabdemod.cpp | 11 ++++++++ plugins/channelrx/demoddab/dabdemod.h | 23 ++++++++++++++++ plugins/channelrx/demoddab/dabdemodgui.cpp | 30 ++++++++++++++++++--- plugins/channelrx/demoddab/dabdemodgui.h | 1 + plugins/channelrx/demoddab/dabdemodgui.ui | 21 +++++++++++++++ plugins/channelrx/demoddab/dabdemodsink.cpp | 16 ++++++++--- plugins/channelrx/demoddab/dabdemodsink.h | 1 + 7 files changed, 95 insertions(+), 8 deletions(-) diff --git a/plugins/channelrx/demoddab/dabdemod.cpp b/plugins/channelrx/demoddab/dabdemod.cpp index c83df1d04..c0d6361bd 100644 --- a/plugins/channelrx/demoddab/dabdemod.cpp +++ b/plugins/channelrx/demoddab/dabdemod.cpp @@ -48,6 +48,7 @@ MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABProgramQuality, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABFIBQuality, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABSampleRate, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABData, Message) +MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABMOTData, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABReset, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABResetService, Message) @@ -232,6 +233,16 @@ bool DABDemod::handleMessage(const Message& cmd) return true; } + else if (MsgDABMOTData::match(cmd)) + { + MsgDABMOTData& report = (MsgDABMOTData&)cmd; + if (getMessageQueueToGUI()) + { + getMessageQueueToGUI()->push(new MsgDABMOTData(report)); + } + + return true; + } else if (MsgDABReset::match(cmd)) { MsgDABReset& report = (MsgDABReset&)cmd; diff --git a/plugins/channelrx/demoddab/dabdemod.h b/plugins/channelrx/demoddab/dabdemod.h index aa627e356..de8e50b89 100644 --- a/plugins/channelrx/demoddab/dabdemod.h +++ b/plugins/channelrx/demoddab/dabdemod.h @@ -250,6 +250,29 @@ public: { } }; + class MsgDABMOTData : public Message { + MESSAGE_CLASS_DECLARATION + + public: + const QString getFilename() const { return m_filename; } + int getContentSubType() const { return m_contentSubType; } + + static MsgDABMOTData* create(const QString& filename, int contentSubType) + { + return new MsgDABMOTData(filename, contentSubType); + } + + private: + QString m_filename; + int m_contentSubType; + + MsgDABMOTData(const QString& filename, int contentSubType) : + Message(), + m_filename(filename), + m_contentSubType(contentSubType) + { } + }; + class MsgDABReset : public Message { MESSAGE_CLASS_DECLARATION diff --git a/plugins/channelrx/demoddab/dabdemodgui.cpp b/plugins/channelrx/demoddab/dabdemodgui.cpp index c1b615f01..0452e9e66 100644 --- a/plugins/channelrx/demoddab/dabdemodgui.cpp +++ b/plugins/channelrx/demoddab/dabdemodgui.cpp @@ -180,6 +180,8 @@ void DABDemodGUI::on_programs_cellDoubleClicked(int row, int column) double frequencyInHz = ui->programs->item(row, PROGRAMS_COL_FREQUENCY)->data(Qt::UserRole).toDouble(); ChannelWebAPIUtils::setCenterFrequency(m_dabDemod->getDeviceSetIndex(), frequencyInHz-m_settings.m_inputFrequencyOffset); + clearProgram(); + applySettings(); } @@ -261,6 +263,16 @@ bool DABDemodGUI::handleMessage(const Message& message) ui->data->setText(report.getData()); return true; } + else if (DABDemod::MsgDABMOTData::match(message)) + { + DABDemod::MsgDABMOTData& report = (DABDemod::MsgDABMOTData&) message; + QPixmap pixmap(report.getFilename()); + ui->motImage->resize(ui->motImage->width(), pixmap.height()); + ui->motImage->setVisible(true); + ui->motImage->setPixmap(pixmap, pixmap.size()); + arrangeRollups(); + return true; + } return false; } @@ -452,6 +464,8 @@ DABDemodGUI::DABDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor())); connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); + ui->motImage->setVisible(false); + // Resize the table using dummy data resizeTable(); // Allow user to reorder columns @@ -557,11 +571,8 @@ void DABDemodGUI::enterEvent(QEvent*) m_channelMarker.setHighlighted(true); } -void DABDemodGUI::resetService() +void DABDemodGUI::clearProgram() { - // Reset DAB audio service, to avoid unpleasent noise when changing frequency - DABDemod::MsgDABResetService* message = DABDemod::MsgDABResetService::create(); - m_dabDemod->getInputMessageQueue()->push(message); // Clear current program ui->program->setText("-"); ui->ensemble->setText("-"); @@ -571,6 +582,17 @@ void DABDemodGUI::resetService() ui->bitrate->setText("-"); ui->sampleRate->setText("-"); ui->data->setText(""); + ui->motImage->setPixmap(QPixmap()); + ui->motImage->setVisible(false); + arrangeRollups(); +} + +void DABDemodGUI::resetService() +{ + // Reset DAB audio service, to avoid unpleasent noise when changing frequency + DABDemod::MsgDABResetService* message = DABDemod::MsgDABResetService::create(); + m_dabDemod->getInputMessageQueue()->push(message); + clearProgram(); } void DABDemodGUI::on_channel_currentIndexChanged(int index) diff --git a/plugins/channelrx/demoddab/dabdemodgui.h b/plugins/channelrx/demoddab/dabdemodgui.h index c714e9e7b..44a09933f 100644 --- a/plugins/channelrx/demoddab/dabdemodgui.h +++ b/plugins/channelrx/demoddab/dabdemodgui.h @@ -85,6 +85,7 @@ private: void leaveEvent(QEvent*); void enterEvent(QEvent*); void resetService(); + void clearProgram(); void resizeTable(); QAction *createCheckableItem(QString& text, int idx, bool checked); diff --git a/plugins/channelrx/demoddab/dabdemodgui.ui b/plugins/channelrx/demoddab/dabdemodgui.ui index d37e01596..c59d061bd 100644 --- a/plugins/channelrx/demoddab/dabdemodgui.ui +++ b/plugins/channelrx/demoddab/dabdemodgui.ui @@ -825,6 +825,22 @@ + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + @@ -1006,6 +1022,11 @@
gui/levelmeter.h
1 + + ScaledImage + QLabel +
gui/scaledimage.h
+
programs diff --git a/plugins/channelrx/demoddab/dabdemodsink.cpp b/plugins/channelrx/demoddab/dabdemodsink.cpp index 11d0088f0..79699c1d6 100644 --- a/plugins/channelrx/demoddab/dabdemodsink.cpp +++ b/plugins/channelrx/demoddab/dabdemodsink.cpp @@ -274,11 +274,10 @@ void programQualityHandler(int16_t frames, int16_t rs, int16_t aac, void *ctx) sink->programQuality(frames, rs, aac); } -void motDataHandler(std::string data, int a, void *ctx) +void motDataHandler(std::string filename, int contentsubType, void *ctx) { - (void)data; - (void)a; - (void)ctx; + DABDemodSink *sink = (DABDemodSink *)ctx; + sink->motData(filename.c_str(), contentsubType); } void DABDemodSink::systemData(bool sync, int16_t snr, int32_t freqOffset) @@ -343,6 +342,15 @@ void DABDemodSink::data(const QString& data) } } +void DABDemodSink::motData(const QString& filename, int contentSubType) +{ + if (getMessageQueueToChannel()) + { + DABDemod::MsgDABMOTData *msg = DABDemod::MsgDABMOTData::create(filename, contentSubType); + getMessageQueueToChannel()->push(msg); + } +} + static int16_t scale(int16_t sample, float factor) { int32_t prod = (int32_t)(((int32_t)sample) * factor); diff --git a/plugins/channelrx/demoddab/dabdemodsink.h b/plugins/channelrx/demoddab/dabdemodsink.h index 8c2ab8e0e..fc5a98356 100644 --- a/plugins/channelrx/demoddab/dabdemodsink.h +++ b/plugins/channelrx/demoddab/dabdemodsink.h @@ -89,6 +89,7 @@ public: void programQuality(int16_t frames, int16_t rs, int16_t aac); void fibQuality(int16_t percent); void data(const QString& data); + void motData(const QString& filename, int contentSubType); private: struct MagSqLevelsStore From b72275b1d3fd64c9da5d41757a35563dc8ebd089 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Fri, 23 Apr 2021 14:02:40 +0100 Subject: [PATCH 2/2] Add dependency on pthreads project for DAB project on windows --- external/CMakeLists.txt | 57 ++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 4af95abb4..27ce9d3f9 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -451,27 +451,42 @@ if (ZLIB_FOUND AND FAAD_FOUND) set(DAB_LIBRARIES "${EXTERNAL_BUILD_LIBRARIES}/lib/libdab_lib${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "") endif() if (WIN32) - set(PTHREADS_OPT_FOR_DAB "-DPTHREADS=${PTHREADS4W_LIBRARIES}" CACHE INTERNAL "") - else() - set(PTHREADS_OPT_FOR_DAB "" CACHE INTERNAL "") - endif() - ExternalProject_Add(dab - GIT_REPOSITORY https://github.com/srcejon/dab-cmdline.git - GIT_TAG msvc - PREFIX "${EXTERNAL_BUILD_LIBRARIES}/dab" - SOURCE_SUBDIR "library" - CMAKE_ARGS ${COMMON_CMAKE_ARGS} - -DFFTW3F_INCLUDE_DIRS=${FFTW3F_INCLUDE_DIRS} - -DFFTW3F_LIBRARIES=${FFTW3F_LIBRARIES} - -DFAAD_INCLUDE_DIR=${FAAD_INCLUDE_DIR} - -DFAAD_LIBRARY=${FAAD_LIBRARY} - -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} - -DZLIB_LIBRARY=${ZLIB_LIBRARIES} - ${PTHREADS_OPT_FOR_DAB} - BUILD_BYPRODUCTS "${DAB_LIBRARIES}" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) + ExternalProject_Add(dab + GIT_REPOSITORY https://github.com/srcejon/dab-cmdline.git + GIT_TAG msvc + DEPENDS ${PTHREADS4W_DEPENDS} + PREFIX "${EXTERNAL_BUILD_LIBRARIES}/dab" + SOURCE_SUBDIR "library" + CMAKE_ARGS ${COMMON_CMAKE_ARGS} + -DFFTW3F_INCLUDE_DIRS=${FFTW3F_INCLUDE_DIRS} + -DFFTW3F_LIBRARIES=${FFTW3F_LIBRARIES} + -DFAAD_INCLUDE_DIR=${FAAD_INCLUDE_DIR} + -DFAAD_LIBRARY=${FAAD_LIBRARY} + -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} + -DZLIB_LIBRARY=${ZLIB_LIBRARIES} + -DPTHREADS=${PTHREADS4W_LIBRARIES} + BUILD_BYPRODUCTS "${DAB_LIBRARIES}" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) + else(WIN32) + ExternalProject_Add(dab + GIT_REPOSITORY https://github.com/srcejon/dab-cmdline.git + GIT_TAG msvc + PREFIX "${EXTERNAL_BUILD_LIBRARIES}/dab" + SOURCE_SUBDIR "library" + CMAKE_ARGS ${COMMON_CMAKE_ARGS} + -DFFTW3F_INCLUDE_DIRS=${FFTW3F_INCLUDE_DIRS} + -DFFTW3F_LIBRARIES=${FFTW3F_LIBRARIES} + -DFAAD_INCLUDE_DIR=${FAAD_INCLUDE_DIR} + -DFAAD_LIBRARY=${FAAD_LIBRARY} + -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} + -DZLIB_LIBRARY=${ZLIB_LIBRARIES} + BUILD_BYPRODUCTS "${DAB_LIBRARIES}" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) + endif(WIN32) ExternalProject_Get_Property(dab source_dir binary_dir) set(DAB_FOUND ON CACHE INTERNAL "") set(DAB_EXTERNAL ON CACHE INTERNAL "")