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

Merge pull request #880 from srcejon/dab_lib_use_latest_api

Use latest DAB lib API.
This commit is contained in:
Edouard Griffiths 2021-04-30 13:24:47 +02:00 committed by GitHub
commit f2ca0e2a98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 33 deletions

View File

@ -254,20 +254,23 @@ public:
MESSAGE_CLASS_DECLARATION
public:
QByteArray getData() const { return m_data; }
const QString getFilename() const { return m_filename; }
int getContentSubType() const { return m_contentSubType; }
static MsgDABMOTData* create(const QString& filename, int contentSubType)
static MsgDABMOTData* create(QByteArray data, const QString& filename, int contentSubType)
{
return new MsgDABMOTData(filename, contentSubType);
return new MsgDABMOTData(data, filename, contentSubType);
}
private:
QByteArray m_data;
QString m_filename;
int m_contentSubType;
MsgDABMOTData(const QString& filename, int contentSubType) :
MsgDABMOTData(QByteArray data, const QString& filename, int contentSubType) :
Message(),
m_data(data),
m_filename(filename),
m_contentSubType(contentSubType)
{ }

View File

@ -253,7 +253,6 @@ bool DABDemodGUI::handleMessage(const Message& message)
else if (DABDemod::MsgDABSampleRate::match(message))
{
DABDemod::MsgDABSampleRate& report = (DABDemod::MsgDABSampleRate&) message;
qDebug() << "Ssample rate: " << report.getSampleRate();
ui->sampleRate->setText(QString("%1k").arg(report.getSampleRate()/1000.0, 0, 'f', 0));
return true;
}
@ -266,11 +265,16 @@ bool DABDemodGUI::handleMessage(const Message& message)
else if (DABDemod::MsgDABMOTData::match(message))
{
DABDemod::MsgDABMOTData& report = (DABDemod::MsgDABMOTData&) message;
QPixmap pixmap(report.getFilename());
QString filename = report.getFilename();
if (filename.endsWith(".png") || filename.endsWith(".PNG") || filename.endsWith(".jpg") || filename.endsWith(".JPG"))
{
QPixmap pixmap;
pixmap.loadFromData(report.getData());
ui->motImage->resize(ui->motImage->width(), pixmap.height());
ui->motImage->setVisible(true);
ui->motImage->setPixmap(pixmap, pixmap.size());
arrangeRollups();
}
return true;
}

View File

@ -43,16 +43,16 @@ void systemDataHandler(bool sync, int16_t snr, int32_t freqOffset, void *ctx)
sink->systemData(sync, snr, freqOffset);
}
void ensembleNameHandler(std::string name, int32_t id, void *ctx)
void ensembleNameHandler(const char *name, int32_t id, void *ctx)
{
DABDemodSink *sink = (DABDemodSink *)ctx;
sink->ensembleName(QString::fromStdString(name), id);
sink->ensembleName(QString::fromUtf8(name), id);
}
void programNameHandler(std::string name, int32_t id, void *ctx)
void programNameHandler(const char *name, int32_t id, void *ctx)
{
DABDemodSink *sink = (DABDemodSink *)ctx;
sink->programName(QString::fromStdString(name), id);
sink->programName(QString::fromUtf8(name), id);
}
void fibQualityHandler(int16_t percent, void *ctx)
@ -67,10 +67,10 @@ void audioHandler(int16_t *buffer, int size, int samplerate, bool stereo, void *
sink->audio(buffer, size, samplerate, stereo);
}
void dataHandler(std::string data, void *ctx)
void dataHandler(const char *data, void *ctx)
{
DABDemodSink *sink = (DABDemodSink *)ctx;
sink->data(QString::fromStdString(data));
sink->data(QString::fromUtf8(data));
}
void byteHandler(uint8_t *data, int16_t a, uint8_t b, void *ctx)
@ -274,10 +274,10 @@ void programQualityHandler(int16_t frames, int16_t rs, int16_t aac, void *ctx)
sink->programQuality(frames, rs, aac);
}
void motDataHandler(std::string filename, int contentsubType, void *ctx)
void motDataHandler(uint8_t *data, int len, const char *filename, int contentsubType, void *ctx)
{
DABDemodSink *sink = (DABDemodSink *)ctx;
sink->motData(filename.c_str(), contentsubType);
sink->motData(data, len, QString::fromUtf8(filename), contentsubType);
}
void DABDemodSink::systemData(bool sync, int16_t snr, int32_t freqOffset)
@ -342,11 +342,12 @@ void DABDemodSink::data(const QString& data)
}
}
void DABDemodSink::motData(const QString& filename, int contentSubType)
void DABDemodSink::motData(const uint8_t *data, int len, const QString& filename, int contentSubType)
{
if (getMessageQueueToChannel())
{
DABDemod::MsgDABMOTData *msg = DABDemod::MsgDABMOTData::create(filename, contentSubType);
QByteArray byteArray((const char *)data, len);
DABDemod::MsgDABMOTData *msg = DABDemod::MsgDABMOTData::create(byteArray, filename, contentSubType);
getMessageQueueToChannel()->push(msg);
}
}
@ -482,20 +483,22 @@ DABDemodSink::DABDemodSink(DABDemod *packetDemod) :
applySettings(m_settings, true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
int mode = 1; // Latest DAB spec only has mode 1
m_api.dabMode = 1; // Latest DAB spec only has mode 1
m_api.syncsignal_Handler = syncHandler;
m_api.systemdata_Handler = systemDataHandler;
m_api.ensemblename_Handler = ensembleNameHandler;
m_api.programname_Handler = programNameHandler;
m_api.fib_quality_Handler = fibQualityHandler;
m_api.audioOut_Handler = audioHandler;
m_api.dataOut_Handler = dataHandler;
m_api.bytesOut_Handler = byteHandler;
m_api.programdata_Handler = programDataHandler;
m_api.program_quality_Handler = programQualityHandler;
m_api.motdata_Handler = motDataHandler;
m_api.tii_data_Handler = nullptr;
m_api.timeHandler = nullptr;
m_dab = dabInit(&m_device,
mode,
syncHandler,
systemDataHandler,
ensembleNameHandler,
programNameHandler,
fibQualityHandler,
audioHandler,
dataHandler,
byteHandler,
programDataHandler,
programQualityHandler,
motDataHandler,
&m_api,
nullptr,
nullptr,
this);

View File

@ -89,7 +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);
void motData(const uint8_t *data, int len, const QString& filename, int contentSubType);
private:
struct MagSqLevelsStore
@ -114,6 +114,8 @@ private:
void *m_dab;
DABDemodDevice m_device;
audiodata m_ad;
packetdata m_pd;
API_struct m_api;
NCO m_nco;
Interpolator m_interpolator;