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

Merge pull request #866 from srcejon/dab_images

Add support for displaying images broadcast in the DAB demodulator GUI
This commit is contained in:
Edouard Griffiths 2021-04-23 15:40:54 +02:00 committed by GitHub
commit 8b5ebbd1b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 131 additions and 29 deletions

View File

@ -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 "") set(DAB_LIBRARIES "${EXTERNAL_BUILD_LIBRARIES}/lib/libdab_lib${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
endif() endif()
if (WIN32) if (WIN32)
set(PTHREADS_OPT_FOR_DAB "-DPTHREADS=${PTHREADS4W_LIBRARIES}" CACHE INTERNAL "") ExternalProject_Add(dab
else() GIT_REPOSITORY https://github.com/srcejon/dab-cmdline.git
set(PTHREADS_OPT_FOR_DAB "" CACHE INTERNAL "") GIT_TAG msvc
endif() DEPENDS ${PTHREADS4W_DEPENDS}
ExternalProject_Add(dab PREFIX "${EXTERNAL_BUILD_LIBRARIES}/dab"
GIT_REPOSITORY https://github.com/srcejon/dab-cmdline.git SOURCE_SUBDIR "library"
GIT_TAG msvc CMAKE_ARGS ${COMMON_CMAKE_ARGS}
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/dab" -DFFTW3F_INCLUDE_DIRS=${FFTW3F_INCLUDE_DIRS}
SOURCE_SUBDIR "library" -DFFTW3F_LIBRARIES=${FFTW3F_LIBRARIES}
CMAKE_ARGS ${COMMON_CMAKE_ARGS} -DFAAD_INCLUDE_DIR=${FAAD_INCLUDE_DIR}
-DFFTW3F_INCLUDE_DIRS=${FFTW3F_INCLUDE_DIRS} -DFAAD_LIBRARY=${FAAD_LIBRARY}
-DFFTW3F_LIBRARIES=${FFTW3F_LIBRARIES} -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS}
-DFAAD_INCLUDE_DIR=${FAAD_INCLUDE_DIR} -DZLIB_LIBRARY=${ZLIB_LIBRARIES}
-DFAAD_LIBRARY=${FAAD_LIBRARY} -DPTHREADS=${PTHREADS4W_LIBRARIES}
-DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} BUILD_BYPRODUCTS "${DAB_LIBRARIES}"
-DZLIB_LIBRARY=${ZLIB_LIBRARIES} INSTALL_COMMAND ""
${PTHREADS_OPT_FOR_DAB} TEST_COMMAND ""
BUILD_BYPRODUCTS "${DAB_LIBRARIES}" )
INSTALL_COMMAND "" else(WIN32)
TEST_COMMAND "" 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) ExternalProject_Get_Property(dab source_dir binary_dir)
set(DAB_FOUND ON CACHE INTERNAL "") set(DAB_FOUND ON CACHE INTERNAL "")
set(DAB_EXTERNAL ON CACHE INTERNAL "") set(DAB_EXTERNAL ON CACHE INTERNAL "")

View File

@ -48,6 +48,7 @@ MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABProgramQuality, Message)
MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABFIBQuality, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABFIBQuality, Message)
MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABSampleRate, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABSampleRate, Message)
MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABData, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABData, Message)
MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABMOTData, Message)
MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABReset, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABReset, Message)
MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABResetService, Message) MESSAGE_CLASS_DEFINITION(DABDemod::MsgDABResetService, Message)
@ -232,6 +233,16 @@ bool DABDemod::handleMessage(const Message& cmd)
return true; 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)) else if (MsgDABReset::match(cmd))
{ {
MsgDABReset& report = (MsgDABReset&)cmd; MsgDABReset& report = (MsgDABReset&)cmd;

View File

@ -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 { class MsgDABReset : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION

View File

@ -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(); double frequencyInHz = ui->programs->item(row, PROGRAMS_COL_FREQUENCY)->data(Qt::UserRole).toDouble();
ChannelWebAPIUtils::setCenterFrequency(m_dabDemod->getDeviceSetIndex(), frequencyInHz-m_settings.m_inputFrequencyOffset); ChannelWebAPIUtils::setCenterFrequency(m_dabDemod->getDeviceSetIndex(), frequencyInHz-m_settings.m_inputFrequencyOffset);
clearProgram();
applySettings(); applySettings();
} }
@ -261,6 +263,16 @@ bool DABDemodGUI::handleMessage(const Message& message)
ui->data->setText(report.getData()); ui->data->setText(report.getData());
return true; 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; return false;
} }
@ -452,6 +464,8 @@ DABDemodGUI::DABDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor())); connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
ui->motImage->setVisible(false);
// Resize the table using dummy data // Resize the table using dummy data
resizeTable(); resizeTable();
// Allow user to reorder columns // Allow user to reorder columns
@ -557,11 +571,8 @@ void DABDemodGUI::enterEvent(QEvent*)
m_channelMarker.setHighlighted(true); 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 // Clear current program
ui->program->setText("-"); ui->program->setText("-");
ui->ensemble->setText("-"); ui->ensemble->setText("-");
@ -571,6 +582,17 @@ void DABDemodGUI::resetService()
ui->bitrate->setText("-"); ui->bitrate->setText("-");
ui->sampleRate->setText("-"); ui->sampleRate->setText("-");
ui->data->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) void DABDemodGUI::on_channel_currentIndexChanged(int index)

View File

@ -85,6 +85,7 @@ private:
void leaveEvent(QEvent*); void leaveEvent(QEvent*);
void enterEvent(QEvent*); void enterEvent(QEvent*);
void resetService(); void resetService();
void clearProgram();
void resizeTable(); void resizeTable();
QAction *createCheckableItem(QString& text, int idx, bool checked); QAction *createCheckableItem(QString& text, int idx, bool checked);

View File

@ -825,6 +825,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="ScaledImage" name="motImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="statistics" native="true"> <widget class="QWidget" name="statistics" native="true">
@ -1006,6 +1022,11 @@
<header>gui/levelmeter.h</header> <header>gui/levelmeter.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>ScaledImage</class>
<extends>QLabel</extends>
<header>gui/scaledimage.h</header>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>programs</tabstop> <tabstop>programs</tabstop>

View File

@ -274,11 +274,10 @@ void programQualityHandler(int16_t frames, int16_t rs, int16_t aac, void *ctx)
sink->programQuality(frames, rs, aac); 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; DABDemodSink *sink = (DABDemodSink *)ctx;
(void)a; sink->motData(filename.c_str(), contentsubType);
(void)ctx;
} }
void DABDemodSink::systemData(bool sync, int16_t snr, int32_t freqOffset) 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) static int16_t scale(int16_t sample, float factor)
{ {
int32_t prod = (int32_t)(((int32_t)sample) * factor); int32_t prod = (int32_t)(((int32_t)sample) * factor);

View File

@ -89,6 +89,7 @@ public:
void programQuality(int16_t frames, int16_t rs, int16_t aac); void programQuality(int16_t frames, int16_t rs, int16_t aac);
void fibQuality(int16_t percent); void fibQuality(int16_t percent);
void data(const QString& data); void data(const QString& data);
void motData(const QString& filename, int contentSubType);
private: private:
struct MagSqLevelsStore struct MagSqLevelsStore