1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-26 06:46:34 -04:00

DATV demodulator: improvements

This commit is contained in:
f4exb 2018-02-26 01:04:45 +01:00
parent a483b58028
commit 1436844fb3
15 changed files with 1285 additions and 1141 deletions

View File

@ -31,31 +31,24 @@ static const int DEFAULT_GUI_DECIMATION = 64;
template<typename T> struct datvconstellation: runnable
{
T xymin;
T xymax;
T xymin, xymax;
unsigned long decimation;
unsigned long pixels_per_frame;
cstln_lut<256> **cstln; // Optional ptr to optional constellation
DATVScreen *m_objDATVScreen;
pipereader<complex<T> > in;
unsigned long phase;
DATVScreen *m_objDATVScreen;
datvconstellation(
scheduler *sch,
pipebuf<complex<T> > &_in,
T _xymin,
T _xymax,
const char *_name = 0,
DATVScreen * objDATVScreen = 0) :
runnable(sch, _name ? _name : _in.name),
xymin(_xymin),
xymax(_xymax),
decimation(DEFAULT_GUI_DECIMATION),
pixels_per_frame(1024),
cstln(0),
in(_in),
phase(0),
m_objDATVScreen(objDATVScreen)
datvconstellation(scheduler *sch, pipebuf<complex<T> > &_in, T _xymin, T _xymax, const char *_name = NULL, DATVScreen * objDATVScreen = NULL) :
runnable(sch, _name ? _name : _in.name),
xymin(_xymin),
xymax(_xymax),
decimation(DEFAULT_GUI_DECIMATION),
pixels_per_frame(1024),
cstln(NULL),
m_objDATVScreen(objDATVScreen),
in(_in),
phase(0)
{
}
@ -76,11 +69,8 @@ template<typename T> struct datvconstellation: runnable
if (m_objDATVScreen != NULL)
{
m_objDATVScreen->selectRow(
256 * (p->re - xymin) / (xymax - xymin));
m_objDATVScreen->setDataColor(
256 - 256 * ((p->im - xymin) / (xymax - xymin)),
255, 0, 255);
m_objDATVScreen->selectRow(256 * (p->re - xymin) / (xymax - xymin));
m_objDATVScreen->setDataColor(256 - 256 * ((p->im - xymin) / (xymax - xymin)), 255, 0, 255);
}
}
@ -106,7 +96,6 @@ template<typename T> struct datvconstellation: runnable
}
m_objDATVScreen->renderImage(NULL);
}
in.read(pixels_per_frame);
@ -118,15 +107,8 @@ template<typename T> struct datvconstellation: runnable
}
}
//private:
//gfx g;
void draw_begin()
{
//g.clear();
//g.setfg(0, 255, 0);
//g.line(g.w/2,0, g.w/2, g.h);
//g.line(0,g.h/2, g.w,g.h/2);
}
};

File diff suppressed because it is too large Load Diff

View File

@ -68,82 +68,70 @@ class DownChannelizer;
using namespace leansdr;
enum DATVModulation
{
BPSK, QPSK, PSK8, APSK16, APSK32, APSK64E, QAM16, QAM64, QAM256
};
enum dvb_version
{
DVB_S, DVB_S2
};
enum dvb_sampler
{
SAMP_NEAREST, SAMP_LINEAR, SAMP_RRC
};
enum DATVModulation { BPSK, QPSK, PSK8, APSK16, APSK32, APSK64E, QAM16, QAM64, QAM256 };
enum dvb_version { DVB_S, DVB_S2 };
enum dvb_sampler { SAMP_NEAREST, SAMP_LINEAR, SAMP_RRC };
inline int decimation(float Fin, float Fout)
{
int d = Fin / Fout;
return max(d, 1);
}
inline int decimation(float Fin, float Fout) { int d = Fin / Fout; return max(d, 1); }
struct config
{
dvb_version standard;
dvb_sampler sampler;
dvb_version standard;
dvb_sampler sampler;
int buf_factor; // Buffer sizing
float Fs; // Sampling frequency (Hz)
float Fderot; // Shift the signal (Hz). Note: Ftune is faster
int anf; // Number of auto notch filters
bool cnr; // Measure CNR
unsigned int decim; // Decimation, 0=auto
float Fm; // QPSK symbol rate (Hz)
cstln_lut<256>::predef constellation;
code_rate fec;
float Ftune; // Bias frequency for the QPSK demodulator (Hz)
bool allow_drift;
bool fastlock;
bool viterbi;
bool hard_metric;
bool resample;
float resample_rej; // Approx. filter rejection in dB
int rrc_steps; // Discrete steps between symbols, 0=auto
float rrc_rej; // Approx. RRC filter rejection in dB
float rolloff; // Roll-off 0..1
bool hdlc; // Expect HDLC frames instead of MPEG packets
bool packetized; // Output frames with 16-bit BE length
float Finfo; // Desired refresh rate on fd_info (Hz)
int buf_factor; // Buffer sizing
float Fs; // Sampling frequency (Hz)
float Fderot; // Shift the signal (Hz). Note: Ftune is faster
int anf; // Number of auto notch filters
bool cnr; // Measure CNR
unsigned int decim; // Decimation, 0=auto
float Fm; // QPSK symbol rate (Hz)
cstln_lut<256>::predef constellation;
code_rate fec;
float Ftune; // Bias frequency for the QPSK demodulator (Hz)
bool allow_drift;
bool fastlock;
bool viterbi;
bool hard_metric;
bool resample;
float resample_rej; // Approx. filter rejection in dB
int rrc_steps; // Discrete steps between symbols, 0=auto
float rrc_rej; // Approx. RRC filter rejection in dB
float rolloff; // Roll-off 0..1
bool hdlc; // Expect HDLC frames instead of MPEG packets
bool packetized; // Output frames with 16-bit BE length
float Finfo; // Desired refresh rate on fd_info (Hz)
config() :
standard(DVB_S),
sampler(SAMP_LINEAR),
buf_factor(4),
Fs(2.4e6),
Fderot(0),
anf(1),
cnr(false),
decim(0),
Fm(2e6),
constellation(cstln_lut<256>::QPSK),
fec(FEC12),
Ftune(0),
allow_drift(false),
fastlock(true),
viterbi(false),
hard_metric(false),
resample(false),
resample_rej(10),
rrc_steps(0),
rrc_rej(10),
rolloff(0.35),
hdlc(false),
packetized(false),
Finfo(5)
{
}
config() :
standard(DVB_S),
sampler(SAMP_LINEAR),
buf_factor(4),
Fs(2.4e6),
Fderot(0),
anf(1),
cnr(false),
decim(0),
Fm(2e6),
constellation(cstln_lut<256>::QPSK),
fec(FEC12),
Ftune(0),
allow_drift(false),
fastlock(true),
viterbi(false),
hard_metric(false),
resample(false),
resample_rej(10),
rrc_steps(0),
rrc_rej(10),
rolloff(0.35),
hdlc(false),
packetized(false),
Finfo(5)
{
}
};
struct DATVConfig
{
int intMsps;
@ -157,110 +145,72 @@ struct DATVConfig
int intNotchFilters;
bool blnAllowDrift;
bool blnFastLock;
bool blnHDLC;
dvb_sampler enmFilter;
bool blnHardMetric;
bool blnResample;
float fltRollOff;
bool blnViterbi;
int intExcursion;
DATVConfig() :
intMsps(1024000),
intRFBandwidth(1024000),
intCenterFrequency(0),
enmStandard(DVB_S),
enmModulation(BPSK),
enmFEC(FEC12),
intSampleRate(1024000),
intSymbolRate(250000),
intNotchFilters(1),
blnAllowDrift(false),
blnFastLock(false),
blnHDLC(false),
blnHardMetric(false),
blnResample(false),
blnViterbi(false)
intMsps(1024000),
intRFBandwidth(1024000),
intCenterFrequency(0),
enmStandard(DVB_S),
enmModulation(BPSK),
enmFEC(FEC12),
intSampleRate(1024000),
intSymbolRate(250000),
intNotchFilters(1),
blnAllowDrift(false),
blnFastLock(false),
enmFilter(SAMP_LINEAR),
blnHardMetric(false),
fltRollOff(0.35),
blnViterbi(false),
intExcursion(10)
{
}
};
class DATVDemod: public BasebandSampleSink, public ChannelSinkAPI
class DATVDemod : public BasebandSampleSink, public ChannelSinkAPI
{
Q_OBJECT
Q_OBJECT
public:
class MsgConfigureChannelizer: public Message
{
MESSAGE_CLASS_DECLARATION
public:
int getCenterFrequency() const
{
return m_centerFrequency;
}
static MsgConfigureChannelizer* create(int centerFrequency)
{
return new MsgConfigureChannelizer(centerFrequency);
}
private:
int m_centerFrequency;
MsgConfigureChannelizer(int centerFrequency) :
Message(), m_centerFrequency(centerFrequency)
{
}
};
DATVDemod(DeviceSourceAPI *);
~DATVDemod();
virtual void destroy()
{
delete this;
}
virtual void getIdentifier(QString& id)
{
id = objectName();
}
virtual void getTitle(QString& title)
{
title = objectName();
}
virtual qint64 getCenterFrequency() const
{
return m_objRunning.intCenterFrequency;
}
virtual void destroy() { delete this; }
virtual void getIdentifier(QString& id) { id = objectName(); }
virtual void getTitle(QString& title) { title = objectName(); }
virtual qint64 getCenterFrequency() const { return m_objRunning.intCenterFrequency; }
virtual QByteArray serialize() const
{
return QByteArray();
}
virtual bool deserialize(const QByteArray& data __attribute__((unused)))
{
return false;
}
virtual QByteArray serialize() const { return QByteArray(); }
virtual bool deserialize(const QByteArray& data __attribute__((unused))) { return false; }
void configure(
MessageQueue* objMessageQueue,
int intRFBandwidth,
int intCenterFrequency,
dvb_version enmStandard,
DATVModulation enmModulation,
code_rate enmFEC,
int intSymbolRate,
int intNotchFilters,
bool blnAllowDrift,
bool blnFastLock,
bool blnHDLC,
bool blnHardMetric,
bool blnResample,
bool blnViterbi);
MessageQueue* objMessageQueue,
int intRFBandwidth,
int intCenterFrequency,
dvb_version enmStandard,
DATVModulation enmModulation,
code_rate enmFEC,
int intSymbolRate,
int intNotchFilters,
bool blnAllowDrift,
bool blnFastLock,
dvb_sampler enmFilter,
bool blnHardMetric,
float fltRollOff,
bool blnViterbi,
int intfltExcursion);
virtual void feed(const SampleVector::const_iterator& begin,
const SampleVector::const_iterator& end, bool po);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& cmd);
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& cmd);
bool SetDATVScreen(DATVScreen *objScreen);
DATVideostream * SetVideoRender(DATVideoRender *objScreen);
@ -268,36 +218,62 @@ public:
bool PlayVideo(bool blnStartStop);
void InitDATVParameters(
int intMsps,
int intRFBandwidth,
int intCenterFrequency,
dvb_version enmStandard,
DATVModulation enmModulation,
code_rate enmFEC,
int intSampleRate,
int intSymbolRate,
int intNotchFilters,
bool blnAllowDrift,
bool blnFastLock,
bool blnHDLC,
bool blnHardMetric,
bool blnResample,
bool blnViterbi);
int intMsps,
int intRFBandwidth,
int intCenterFrequency,
dvb_version enmStandard,
DATVModulation enmModulation,
code_rate enmFEC,
int intSampleRate,
int intSymbolRate,
int intNotchFilters,
bool blnAllowDrift,
bool blnFastLock,
dvb_sampler enmFilter,
bool blnHardMetric,
float fltRollOff,
bool blnViterbi,
int intEExcursion);
void CleanUpDATVFramework();
void CleanUpDATVFramework(bool blnRelease);
int GetSampleRate();
void InitDATVFramework();
static const QString m_channelIdURI;
static const QString m_channelId;
private:
class MsgConfigureDATVDemod: public Message
class MsgConfigureChannelizer : public Message
{
MESSAGE_CLASS_DECLARATION
MESSAGE_CLASS_DECLARATION
public:
static MsgConfigureDATVDemod* create(
public:
int getCenterFrequency() const { return m_centerFrequency; }
static MsgConfigureChannelizer* create(int centerFrequency)
{
return new MsgConfigureChannelizer(centerFrequency);
}
private:
int m_centerFrequency;
MsgConfigureChannelizer(int centerFrequency) :
Message(),
m_centerFrequency(centerFrequency)
{ }
};
private slots:
void channelSampleRateChanged();
private:
class MsgConfigureDATVDemod : public Message
{
MESSAGE_CLASS_DECLARATION
public:
static MsgConfigureDATVDemod* create(
int intRFBandwidth,
int intCenterFrequency,
dvb_version enmStandard,
@ -307,60 +283,50 @@ private:
int intNotchFilters,
bool blnAllowDrift,
bool blnFastLock,
bool blnHDLC,
dvb_sampler enmFilter,
bool blnHardMetric,
bool blnResample,
bool blnViterbi)
{
return new MsgConfigureDATVDemod(
intRFBandwidth,
intCenterFrequency,
enmStandard,
enmModulation,
enmFEC,
intSymbolRate,
intNotchFilters,
blnAllowDrift,
blnFastLock,
blnHDLC,
blnHardMetric,
blnResample,
blnViterbi);
}
float fltRollOff,
bool blnViterbi,
int intExcursion)
{
return new MsgConfigureDATVDemod(intRFBandwidth,intCenterFrequency,enmStandard, enmModulation, enmFEC, intSymbolRate, intNotchFilters, blnAllowDrift,blnFastLock,enmFilter,blnHardMetric,fltRollOff, blnViterbi, intExcursion);
}
DATVConfig m_objMsgConfig;
DATVConfig m_objMsgConfig;
private:
MsgConfigureDATVDemod(
int intRFBandwidth,
int intCenterFrequency,
dvb_version enmStandard,
DATVModulation enmModulation,
code_rate enmFEC,
int intSymbolRate,
int intNotchFilters,
bool blnAllowDrift,
bool blnFastLock,
bool blnHDLC,
bool blnHardMetric,
bool blnResample,
bool blnViterbi) :
private:
MsgConfigureDATVDemod(
int intRFBandwidth,
int intCenterFrequency,
dvb_version enmStandard,
DATVModulation enmModulation,
code_rate enmFEC,
int intSymbolRate,
int intNotchFilters,
bool blnAllowDrift,
bool blnFastLock,
dvb_sampler enmFilter,
bool blnHardMetric,
float fltRollOff,
bool blnViterbi,
int intExcursion) :
Message()
{
m_objMsgConfig.intRFBandwidth = intRFBandwidth;
m_objMsgConfig.intCenterFrequency = intCenterFrequency;
m_objMsgConfig.enmStandard = enmStandard;
m_objMsgConfig.enmModulation = enmModulation;
m_objMsgConfig.enmFEC = enmFEC;
m_objMsgConfig.intSymbolRate = intSymbolRate;
m_objMsgConfig.intNotchFilters = intNotchFilters;
m_objMsgConfig.blnAllowDrift = blnAllowDrift;
m_objMsgConfig.blnFastLock = blnFastLock;
m_objMsgConfig.blnHDLC = blnHDLC;
m_objMsgConfig.blnHardMetric = blnHardMetric;
m_objMsgConfig.blnResample = blnResample;
m_objMsgConfig.blnViterbi = blnViterbi;
}
{
m_objMsgConfig.intRFBandwidth = intRFBandwidth;
m_objMsgConfig.intCenterFrequency = intCenterFrequency;
m_objMsgConfig.enmStandard = enmStandard;
m_objMsgConfig.enmModulation = enmModulation;
m_objMsgConfig.enmFEC = enmFEC;
m_objMsgConfig.intSymbolRate = intSymbolRate;
m_objMsgConfig.intNotchFilters = intNotchFilters;
m_objMsgConfig.blnAllowDrift = blnAllowDrift;
m_objMsgConfig.blnFastLock = blnFastLock;
m_objMsgConfig.enmFilter= enmFilter;
m_objMsgConfig.blnHardMetric = blnHardMetric;
m_objMsgConfig.fltRollOff = fltRollOff;
m_objMsgConfig.blnViterbi = blnViterbi;
m_objMsgConfig.intExcursion = intExcursion;
}
};
unsigned long m_lngExpectedReadIQ;
@ -403,7 +369,7 @@ private:
cnr_fft<f32> *r_cnr;
//FILTERING
fir_filter<cf32, float> *r_resample;
fir_filter<cf32,float> *r_resample;
pipebuf<cf32> *p_resampled;
float *coeffs;
int ncoeffs;
@ -442,17 +408,18 @@ private:
pipebuf<u8> *p_mpegbytes;
pipebuf<int> *p_lock;
pipebuf<u32> *p_locktime;
mpeg_sync<u8, 0> *r_sync_mpeg;
mpeg_sync<u8,0> *r_sync_mpeg;
// DEINTERLEAVING
pipebuf<rspacket<u8> > *p_rspackets;
pipebuf< rspacket<u8> > *p_rspackets;
deinterleaver<u8> *r_deinter;
// REED-SOLOMON
pipebuf<int> *p_vbitcount;
pipebuf<int> *p_verrcount;
pipebuf<tspacket> *p_rtspackets;
rs_decoder<u8, 0> *r_rsdec;
rs_decoder<u8,0> *r_rsdec;
// BER ESTIMATION
pipebuf<float> *p_vber;
@ -462,6 +429,7 @@ private:
pipebuf<tspacket> *p_tspackets;
derandomizer *r_derand;
//OUTPUT
file_writer<tspacket> *r_stdout;
datvvideoplayer<tspacket> *r_videoplayer;
@ -485,6 +453,7 @@ private:
bool m_blnInitialized;
bool m_blnRenderingVideo;
bool m_blnStartStopVideo;
DATVModulation m_enmModulation;
@ -495,9 +464,6 @@ private:
QMutex m_objSettingsMutex;
void ApplySettings();
private slots:
void channelSampleRateChanged();
};
#endif // INCLUDE_DATVDEMOD_H

View File

@ -78,14 +78,14 @@ void DATVDemodGUI::resetToDefaults()
ui->chkAllowDrift->setChecked(false);
ui->chkFastlock->setChecked(true);
ui->chkHDLC->setChecked(false);
ui->chkHardMetric->setChecked(false);
ui->chkResample->setChecked(false);
ui->chkViterbi->setChecked(false);
ui->cmbFEC->setCurrentIndex(0);
ui->cmbModulation->setCurrentIndex(0);
ui->cmbStandard->setCurrentIndex(0);
ui->cmbFilter->setCurrentIndex(0);
displayRRCParameters(false);
ui->spiNotchFilters->setValue(1);
ui->prgSynchro->setValue(0);
@ -94,6 +94,9 @@ void DATVDemodGUI::resetToDefaults()
ui->spiBandwidth->setValue(512000);
ui->spiSymbolRate->setValue(250000);
ui->spiRollOff->setValue(35);
ui->spiExcursion->setValue(10);
blockApplySettings(false);
@ -109,9 +112,9 @@ QByteArray DATVDemodGUI::serialize() const
s.writeBool(3, ui->chkAllowDrift->isChecked());
s.writeBool(4, ui->chkFastlock->isChecked());
s.writeBool(5, ui->chkHDLC->isChecked());
s.writeS32(5, ui->cmbFilter->currentIndex());
s.writeBool(6, ui->chkHardMetric->isChecked());
s.writeBool(7, ui->chkResample->isChecked());
s.writeS32(7, ui->spiRollOff->value());
s.writeBool(8, ui->chkViterbi->isChecked());
s.writeS32(9, ui->cmbFEC->currentIndex());
@ -121,6 +124,7 @@ QByteArray DATVDemodGUI::serialize() const
s.writeS32(12, ui->spiNotchFilters->value());
s.writeS32(13, ui->spiBandwidth->value());
s.writeS32(14, ui->spiSymbolRate->value());
s.writeS32(15, ui->spiExcursion->value());
return s.final();
}
@ -163,14 +167,16 @@ bool DATVDemodGUI::deserialize(const QByteArray& arrData)
d.readBool(4, &booltmp, false);
ui->chkFastlock->setChecked(booltmp);
d.readBool(5, &booltmp, false);
ui->chkHDLC->setChecked(booltmp);
d.readS32(5, &tmp, false);
ui->cmbFilter->setCurrentIndex(tmp);
displayRRCParameters((tmp==2));
d.readBool(6, &booltmp, false);
ui->chkHardMetric->setChecked(booltmp);
d.readBool(7, &booltmp, false);
ui->chkResample->setChecked(booltmp);
d.readS32(7, &tmp, false);
ui->spiRollOff->setValue(tmp);
d.readBool(8, &booltmp, false);
ui->chkViterbi->setChecked(booltmp);
@ -194,6 +200,9 @@ bool DATVDemodGUI::deserialize(const QByteArray& arrData)
d.readS32(14, &tmp, 250000);
ui->spiSymbolRate->setValue(tmp);
d.readS32(15, &tmp, false);
ui->spiExcursion->setValue(tmp);
blockApplySettings(false);
m_objChannelMarker.blockSignals(false);
@ -227,11 +236,6 @@ void DATVDemodGUI::channelMarkerHighlightedByCursor()
setHighlighted(m_objChannelMarker.getHighlighted());
}
void DATVDemodGUI::channelSampleRateChanged()
{
qDebug("DATVDemodGUI::channelSampleRateChanged");
applySettings();
}
void DATVDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused)))
{
@ -239,14 +243,6 @@ void DATVDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool
void DATVDemodGUI::onMenuDoubleClicked()
{
/*
if (!m_blnBasicSettingsShown)
{
m_blnBasicSettingsShown = true;
BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_objChannelMarker, this);
bcsw->show();
}
*/
}
//DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceSourceAPI *objDeviceAPI, QWidget* objParent) :
@ -262,9 +258,7 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
//connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
//m_objDATVDemod = new DATVDemod();
m_objDATVDemod = (DATVDemod*) rxChannel;
m_objDATVDemod->setMessageQueueToGUI(getInputMessageQueue());
@ -272,12 +266,7 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
connect(m_objDATVDemod->SetVideoRender(ui->screenTV_2),&DATVideostream::onDataPackets,this,&DATVDemodGUI::on_StreamDataAvailable);
//connect(m_objChannelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
//m_objPluginAPI->addThreadedSink(m_objThreadedChannelizer);
//connect(&m_objPluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
connect(ui->screenTV_2,&DATVideoRender::onMetaDataChanged,this,&DATVDemodGUI::on_StreamMetaDataChanged);
m_intPreviousDecodedData=0;
m_intLastDecodedData=0;
@ -295,7 +284,6 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
m_objChannelMarker.setCenterFrequency(0);
m_objChannelMarker.blockSignals(false);
m_objChannelMarker.setVisible(true);
//connect(&m_objChannelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
connect(&m_objChannelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
connect(&m_objChannelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
@ -304,8 +292,6 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
m_deviceUISet->addChannelMarker(&m_objChannelMarker);
m_deviceUISet->addRollupWidget(this);
//ui->screenTV->connectTimer(m_objPluginAPI->getMainWindow()->getMasterTimer());
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
resetToDefaults(); // does applySettings()
@ -335,22 +321,18 @@ void DATVDemodGUI::applySettings()
DATVModulation enmSelectedModulation;
dvb_version enmVersion;
code_rate enmFEC;
dvb_sampler enmSampler;
if (m_blnDoApplySettings)
{
DATVDemod::MsgConfigureChannelizer *msgChan = DATVDemod::MsgConfigureChannelizer::create(m_objChannelMarker.getCenterFrequency());
m_objDATVDemod->getInputMessageQueue()->push(msgChan);
//Bandwidth and center frequency
m_objChannelMarker.setBandwidth(ui->spiBandwidth->value());
//m_objChannelizer->configure(m_objChannelizer->getInputMessageQueue(), m_objChannelizer->getInputSampleRate(), m_objChannelMarker.getCenterFrequency());
setTitleColor(m_objChannelMarker.getColor());
//DATV parameters: cmbStandard cmbModulation cmbFEC spiBandwidth spiSymbolRate spiNotchFilters chkAllowDrift chkFastlock chkHDLC chkHardMetric chkResample chkViterbi
strStandard = ui->cmbStandard->currentText();
if(strStandard=="DVB-S")
@ -412,6 +394,12 @@ void DATVDemodGUI::applySettings()
enmSelectedModulation=BPSK;
}
//Viterbi only for BPSK et QPSK
if((enmSelectedModulation!=BPSK) && (enmSelectedModulation!=QPSK))
{
ui->chkViterbi->setChecked(false);
}
strFEC = ui->cmbFEC->currentText();
@ -452,21 +440,36 @@ void DATVDemodGUI::applySettings()
enmFEC=FEC12;
}
if (ui->cmbFilter->currentIndex()==0)
{
enmSampler = SAMP_LINEAR;
}
else if(ui->cmbFilter->currentIndex()==1)
{
enmSampler = SAMP_NEAREST;
}
else
{
enmSampler = SAMP_RRC;
}
m_objDATVDemod->configure(m_objDATVDemod->getInputMessageQueue(),
m_objChannelMarker.getBandwidth(),
m_objChannelMarker.getCenterFrequency(),
enmVersion,
enmSelectedModulation,
enmFEC,
ui->spiSymbolRate->value(),
ui->spiNotchFilters->value(),
ui->chkAllowDrift->isChecked(),
ui->chkFastlock->isChecked(),
ui->chkHDLC->isChecked(),
ui->chkHardMetric->isChecked(),
ui->chkResample->isChecked(),
ui->chkViterbi->isChecked());
m_objDATVDemod->configure(
m_objDATVDemod->getInputMessageQueue(),
m_objChannelMarker.getBandwidth(),
m_objChannelMarker.getCenterFrequency(),
enmVersion,
enmSelectedModulation,
enmFEC,
ui->spiSymbolRate->value(),
ui->spiNotchFilters->value(),
ui->chkAllowDrift->isChecked(),
ui->chkFastlock->isChecked(),
enmSampler,
ui->chkHardMetric->isChecked(),
((float)ui->spiRollOff->value())/100.0f,
ui->chkViterbi->isChecked(),
ui->spiExcursion->value());
qDebug() << "DATVDemodGUI::applySettings:"
<< " .inputSampleRate: " << 0 /*m_objChannelizer->getInputSampleRate()*/
@ -622,25 +625,11 @@ void DATVDemodGUI::on_chkHardMetric_clicked()
applySettings();
}
/*
void DATVDemodGUI::on_pushButton_clicked()
{
applySettings();
}
*/
void DATVDemodGUI::on_pushButton_2_clicked()
{
resetToDefaults();
}
/*
void DATVDemodGUI::on_spiSampleRate_valueChanged(int arg1)
{
applySettings();
}
*/
void DATVDemodGUI::on_spiSymbolRate_valueChanged(int arg1 __attribute__((unused)))
{
applySettings();
@ -651,21 +640,11 @@ void DATVDemodGUI::on_spiNotchFilters_valueChanged(int arg1 __attribute__((unuse
applySettings();
}
void DATVDemodGUI::on_chkHDLC_clicked()
{
applySettings();
}
void DATVDemodGUI::on_chkAllowDrift_clicked()
{
applySettings();
}
void DATVDemodGUI::on_chkResample_clicked()
{
applySettings();
}
void DATVDemodGUI::on_pushButton_3_clicked()
{
@ -677,23 +656,6 @@ void DATVDemodGUI::on_pushButton_3_clicked()
}
}
/*
void DATVDemodGUI::on_mediaStateChanged(QMediaPlayer::State state)
{
switch(state)
{
case QMediaPlayer::PlayingState:
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
break;
default:
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
break;
}
ui->lblReadStatus->setText(QString("%1").arg(strLitteralState));
}
*/
void DATVDemodGUI::on_pushButton_4_clicked()
{
@ -726,7 +688,7 @@ QString DATVDemodGUI::formatBytes(qint64 intBytes)
void DATVDemodGUI::on_StreamDataAvailable(int *intPackets __attribute__((unused)), int *intBytes, int *intPercent, qint64 *intTotalReceived)
{
ui->lblStatus->setText(QString("Decod: %1B").arg(formatBytes(*intTotalReceived)));
ui->lblStatus->setText(QString("Data: %1B").arg(formatBytes(*intTotalReceived)));
m_intLastDecodedData = *intTotalReceived;
if((*intPercent)<100)
@ -752,3 +714,68 @@ void DATVDemodGUI::on_chkFastlock_clicked()
{
applySettings();
}
void DATVDemodGUI::on_StreamMetaDataChanged(DataTSMetaData2 *objMetaData)
{
QString strMetaData="";
if(objMetaData!=NULL)
{
if(objMetaData->OK_TransportStream==true)
{
strMetaData.sprintf("PID: %d - Width: %d - Height: %d\r\n%s%s\r\nCodec: %s\r\n",objMetaData->PID
,objMetaData->Width
,objMetaData->Height
,objMetaData->Program.toStdString().c_str()
,objMetaData->Stream.toStdString().c_str()
,objMetaData->CodecDescription.toStdString().c_str());
}
ui->textEdit->setText(strMetaData);
ui->chkData->setChecked(objMetaData->OK_Data);
ui->chkTS->setChecked(objMetaData->OK_TransportStream);
ui->chkVS->setChecked(objMetaData->OK_VideoStream);
ui->chkDecoding->setChecked(objMetaData->OK_Decoding);
if(objMetaData->OK_Decoding==true)
{
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
}
else
{
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
}
if(objMetaData->Height>0)
{
ui->screenTV_2->setFixedWidth((int)objMetaData->Width*(270.0f/(float)objMetaData->Height));
}
}
}
void DATVDemodGUI::displayRRCParameters(bool blnVisible)
{
ui->spiRollOff->setVisible(blnVisible);
ui->spiExcursion->setVisible(blnVisible);
ui->label_5->setVisible(blnVisible);
ui->label_6->setVisible(blnVisible);
}
void DATVDemodGUI::on_cmbFilter_currentIndexChanged(int index __attribute__((unused)))
{
displayRRCParameters((ui->cmbFilter->currentIndex()==2));
applySettings();
}
void DATVDemodGUI::on_spiRollOff_valueChanged(int arg1 __attribute__((unused)))
{
applySettings();
}
void DATVDemodGUI::on_spiExcursion_valueChanged(int arg1 __attribute__((unused)))
{
applySettings();
}

View File

@ -81,40 +81,38 @@ private slots:
void on_cmbFEC_currentIndexChanged(const QString &arg1);
void on_chkViterbi_clicked();
void on_chkHardMetric_clicked();
//void on_pushButton_clicked();
void on_pushButton_2_clicked();
//void on_spiSampleRate_valueChanged(int arg1);
void on_spiSymbolRate_valueChanged(int arg1);
void on_spiNotchFilters_valueChanged(int arg1);
void on_chkHDLC_clicked();
void on_chkAllowDrift_clicked();
void on_chkResample_clicked();
void on_pushButton_3_clicked();
void on_pushButton_4_clicked();
void on_mouseEvent(QMouseEvent* obj);
void on_StreamDataAvailable(int *intPackets, int *intBytes, int *intPercent, qint64 *intTotalReceived);
void on_StreamMetaDataChanged(DataTSMetaData2 *objMetaData);
void on_spiBandwidth_valueChanged(int arg1);
void on_chkFastlock_clicked();
void on_cmbFilter_currentIndexChanged(int index);
void on_spiRollOff_valueChanged(int arg1);
void on_spiExcursion_valueChanged(int arg1);
private:
Ui::DATVDemodGUI* ui;
PluginAPI* m_objPluginAPI;
DeviceUISet* m_deviceUISet;
//DeviceSourceAPI* m_objDeviceAPI;
ChannelMarker m_objChannelMarker;
ThreadedBasebandSampleSink* m_objThreadedChannelizer;
DownChannelizer* m_objChannelizer;
@ -132,7 +130,6 @@ private:
bool m_blnDoApplySettings;
bool m_blnButtonPlayClicked;
//explicit DATVDemodGUI(PluginAPI* objPluginAPI, DeviceSourceAPI *objDeviceAPI, QWidget* objParent = NULL);
explicit DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* objParent = 0);
virtual ~DATVDemodGUI();
@ -140,6 +137,8 @@ private:
void applySettings();
QString formatBytes(qint64 intBytes);
void displayRRCParameters(bool blnVisible);
void leaveEvent(QEvent*);
void enterEvent(QEvent*);
};

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>512</width>
<height>520</height>
<height>640</height>
</rect>
</property>
<property name="sizePolicy">
@ -19,13 +19,13 @@
<property name="minimumSize">
<size>
<width>512</width>
<height>520</height>
<height>640</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>512</width>
<height>520</height>
<height>640</height>
</size>
</property>
<property name="font">
@ -97,6 +97,9 @@
<height>220</height>
</size>
</property>
<property name="toolTip">
<string>Signal constellation</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
@ -128,16 +131,14 @@
<height>21</height>
</rect>
</property>
<property name="toolTip">
<string>DVB Standard</string>
</property>
<item>
<property name="text">
<string>DVB-S</string>
</property>
</item>
<item>
<property name="text">
<string>DVB-S2</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="cmbModulation">
<property name="geometry">
@ -148,6 +149,9 @@
<height>21</height>
</rect>
</property>
<property name="toolTip">
<string>Modulation scheme</string>
</property>
<item>
<property name="text">
<string>BPSK</string>
@ -203,6 +207,9 @@
<height>21</height>
</rect>
</property>
<property name="toolTip">
<string>FEC ratio</string>
</property>
<item>
<property name="text">
<string>1/2</string>
@ -228,21 +235,6 @@
<string>7/8</string>
</property>
</item>
<item>
<property name="text">
<string>4/5</string>
</property>
</item>
<item>
<property name="text">
<string>8/9</string>
</property>
</item>
<item>
<property name="text">
<string>9/10</string>
</property>
</item>
</widget>
<widget class="QCheckBox" name="chkFastlock">
<property name="geometry">
@ -253,6 +245,9 @@
<height>20</height>
</rect>
</property>
<property name="toolTip">
<string>Fast signal decode</string>
</property>
<property name="text">
<string>FAST LOCK</string>
</property>
@ -261,11 +256,14 @@
<property name="geometry">
<rect>
<x>140</x>
<y>140</y>
<y>120</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="toolTip">
<string>Viterbi algorithm (CPU intensive)</string>
</property>
<property name="text">
<string>VITERBI</string>
</property>
@ -279,6 +277,9 @@
<height>20</height>
</rect>
</property>
<property name="toolTip">
<string>Constellation hardening</string>
</property>
<property name="text">
<string>HARD METRIC</string>
</property>
@ -309,19 +310,6 @@
<string>Bandwidth</string>
</property>
</widget>
<widget class="QCheckBox" name="chkHDLC">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>101</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>HDLC</string>
</property>
</widget>
<widget class="QCheckBox" name="chkAllowDrift">
<property name="geometry">
<rect>
@ -331,6 +319,9 @@
<height>20</height>
</rect>
</property>
<property name="toolTip">
<string>Small frequency drift compensation</string>
</property>
<property name="text">
<string>ALLOW DRIFT</string>
</property>
@ -344,6 +335,9 @@
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Number of stray peaks to suppress</string>
</property>
<property name="maximum">
<number>32</number>
</property>
@ -361,28 +355,18 @@
<string>Notch filter</string>
</property>
</widget>
<widget class="QCheckBox" name="chkResample">
<property name="geometry">
<rect>
<x>140</x>
<y>120</y>
<width>85</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>RESAMPLE</string>
</property>
</widget>
<widget class="QProgressBar" name="prgSynchro">
<property name="geometry">
<rect>
<x>70</x>
<y>190</y>
<y>200</y>
<width>181</width>
<height>20</height>
</rect>
</property>
<property name="toolTip">
<string>Video buffer fill</string>
</property>
<property name="value">
<number>0</number>
</property>
@ -391,11 +375,14 @@
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<y>180</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="toolTip">
<string>Total number of bytes decoded</string>
</property>
<property name="text">
<string>-</string>
</property>
@ -404,7 +391,7 @@
<property name="geometry">
<rect>
<x>230</x>
<y>140</y>
<y>120</y>
<width>21</width>
<height>22</height>
</rect>
@ -422,6 +409,9 @@
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Symbol rate</string>
</property>
<property name="minimum">
<number>1</number>
</property>
@ -441,6 +431,9 @@
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>RF filter bandwidth</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
@ -455,11 +448,14 @@
<property name="geometry">
<rect>
<x>130</x>
<y>170</y>
<y>180</y>
<width>121</width>
<height>16</height>
</rect>
</property>
<property name="toolTip">
<string>Stream speed</string>
</property>
<property name="text">
<string>-</string>
</property>
@ -468,7 +464,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>190</y>
<y>200</y>
<width>61</width>
<height>15</height>
</rect>
@ -477,46 +473,189 @@
<string>Buffer:</string>
</property>
</widget>
<widget class="QComboBox" name="cmbFilter">
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<width>91</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string>Filter</string>
</property>
<item>
<property name="text">
<string>FIR LINEAR</string>
</property>
</item>
<item>
<property name="text">
<string>FIR NEAREST</string>
</property>
</item>
<item>
<property name="text">
<string>FIR RRC</string>
</property>
</item>
</widget>
<widget class="QSpinBox" name="spiRollOff">
<property name="geometry">
<rect>
<x>140</x>
<y>150</y>
<width>41</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>RRC filter roll off factor </string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99</number>
</property>
<property name="value">
<number>35</number>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>106</x>
<y>150</y>
<width>28</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>R.off</string>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>180</x>
<y>150</y>
<width>28</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Exc</string>
</property>
</widget>
<widget class="QSpinBox" name="spiExcursion">
<property name="geometry">
<rect>
<x>210</x>
<y>150</y>
<width>41</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Filter excursion (dB)</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>10</x>
<y>260</y>
<y>250</y>
<width>496</width>
<height>240</height>
<height>385</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>496</width>
<height>240</height>
<height>385</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>496</width>
<height>240</height>
<height>385</height>
</size>
</property>
<property name="title">
<string>VIDEO Stream</string>
</property>
<widget class="QWidget" name="layoutWidget_2">
<widget class="QTextEdit" name="textEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>300</y>
<width>281</width>
<height>81</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="pushButton_4">
<property name="geometry">
<rect>
<x>400</x>
<y>350</y>
<width>91</width>
<height>27</height>
</rect>
</property>
<property name="toolTip">
<string>Full screen video (click in the image to return)</string>
</property>
<property name="text">
<string>Full Screen</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>400</x>
<y>300</y>
<width>91</width>
<height>27</height>
</rect>
</property>
<property name="toolTip">
<string>Start/Stop video streaming</string>
</property>
<property name="text">
<string> Video</string>
</property>
</widget>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>20</y>
<width>358</width>
<height>211</height>
<width>488</width>
<height>272</height>
</rect>
</property>
<layout class="QHBoxLayout" name="screenTVLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="DATVideoRender" name="screenTV_2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -526,16 +665,19 @@
</property>
<property name="minimumSize">
<size>
<width>356</width>
<height>200</height>
<width>480</width>
<height>270</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>356</width>
<height>200</height>
<width>355</width>
<height>270</height>
</size>
</property>
<property name="toolTip">
<string>Video</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
@ -543,73 +685,93 @@
</item>
</layout>
</widget>
<widget class="QFrame" name="lblState">
<widget class="QCheckBox" name="chkTS">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>360</x>
<y>20</y>
<width>131</width>
<height>211</height>
<x>300</x>
<y>320</y>
<width>85</width>
<height>20</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<property name="toolTip">
<string>Transport stream detected</string>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<property name="text">
<string>Transport</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="chkVS">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>300</x>
<y>340</y>
<width>85</width>
<height>20</height>
</rect>
</property>
<property name="toolTip">
<string>Video data detected</string>
</property>
<property name="text">
<string>Video </string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="chkDecoding">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>300</x>
<y>360</y>
<width>85</width>
<height>20</height>
</rect>
</property>
<property name="toolTip">
<string>Video being decoded</string>
</property>
<property name="text">
<string>Decoding</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="chkData">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>300</x>
<y>300</y>
<width>85</width>
<height>20</height>
</rect>
</property>
<property name="toolTip">
<string>Data being received</string>
</property>
<property name="text">
<string>Data</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>111</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string> Video</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_4">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>111</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Full Screen</string>
</property>
</widget>
<widget class="QLabel" name="lblRead">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QLabel" name="lblReadStatus">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</widget>
</widget>
</widget>

View File

@ -27,7 +27,7 @@
const PluginDescriptor DATVDemodPlugin::m_ptrPluginDescriptor =
{
QString("DATV Demodulator"),
QString("3.13.0"),
QString("3.2.0"),
QString("(c) F4HKW for SDRAngel using LeanSDR framework (c) F4DAV"),
QString("https://github.com/f4exb/sdrangel"),
true,
@ -52,8 +52,7 @@ void DATVDemodPlugin::initPlugin(PluginAPI* ptrPluginAPI)
m_ptrPluginAPI = ptrPluginAPI;
// register DATV demodulator
m_ptrPluginAPI->registerRxChannel(DATVDemod::m_channelIdURI, DATVDemod::m_channelId, this);
m_ptrPluginAPI->registerRxChannel(DATVDemod::m_channelIdURI, DATVDemod::m_channelId, this);
}
PluginInstanceGUI* DATVDemodPlugin::createRxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)

View File

@ -108,7 +108,7 @@ static int64_t SeekFunction(void* opaque, int64_t offset, int whence)
return objStream->pos();
}
bool DATVideoRender::InitializeFFMPEG()
void DATVideoRender::ResetMetaData()
{
MetaData.CodecID=-1;
MetaData.PID=-1;
@ -120,7 +120,18 @@ bool DATVideoRender::InitializeFFMPEG()
MetaData.Channels=-1;
MetaData.CodecDescription= "";
if(m_blnIsFFMPEGInitialized==true)
MetaData.OK_Decoding=false;
MetaData.OK_TransportStream=false;
MetaData.OK_VideoStream=false;
emit onMetaDataChanged(&MetaData);
}
bool DATVideoRender::InitializeFFMPEG()
{
ResetMetaData();
if(m_blnIsFFMPEGInitialized)
{
return false;
}
@ -175,6 +186,8 @@ bool DATVideoRender::PreprocessStream()
MetaData.PID = m_objFormatCtx->streams[m_intVideoStreamIndex]->id;
MetaData.CodecID = m_objDecoderCtx->codec_id;
MetaData.OK_TransportStream = true;
MetaData.Program="";
MetaData.Stream="";
@ -199,6 +212,8 @@ bool DATVideoRender::PreprocessStream()
MetaData.Stream = QString("%1").arg(objBuffer);
}
emit onMetaDataChanged(&MetaData);
//Decoder
objCodec = avcodec_find_decoder(m_objDecoderCtx->codec_id);
if(objCodec==NULL)
@ -238,10 +253,14 @@ bool DATVideoRender::PreprocessStream()
MetaData.Width=m_objDecoderCtx->width;
MetaData.Height=m_objDecoderCtx->height;
MetaData.BitRate=m_objDecoderCtx->bit_rate;
MetaData.BitRate= m_objDecoderCtx->bit_rate;
MetaData.Channels=m_objDecoderCtx->channels;
MetaData.CodecDescription= QString("%1").arg(objCodec->long_name);
MetaData.OK_VideoStream = true;
emit onMetaDataChanged(&MetaData);
return true;
}
@ -251,13 +270,11 @@ bool DATVideoRender::OpenStream(DATVideostream *objDevice)
unsigned char * ptrIOBuffer = NULL;
AVIOContext * objIOCtx = NULL;
if(m_blnRunning==true)
if(m_blnRunning)
{
return false;
}
//Only once execution
m_blnRunning=true;
if(objDevice==NULL)
{
@ -266,19 +283,40 @@ bool DATVideoRender::OpenStream(DATVideostream *objDevice)
return false;
}
if(m_blnIsOpen==true)
if(m_blnIsOpen)
{
qDebug() << "DATVideoProcess::OpenStream already open";
return false;
}
if(objDevice->bytesAvailable()<=0)
{
qDebug() << "DATVideoProcess::OpenStream no data available";
MetaData.OK_Data=false;
emit onMetaDataChanged(&MetaData);
return false;
}
//Only once execution
m_blnRunning=true;
MetaData.OK_Data=true;
emit onMetaDataChanged(&MetaData);
InitializeFFMPEG();
if(!m_blnIsFFMPEGInitialized)
{
qDebug() << "DATVideoProcess::OpenStream FFMPEG not initialized";
m_blnRunning=false;
return false;
}
@ -286,9 +324,11 @@ bool DATVideoRender::OpenStream(DATVideostream *objDevice)
{
qDebug() << "DATVideoProcess::OpenStream cannot open QIODevice";
m_blnRunning=false;
return false;
}
//Connect QIODevice to FFMPEG Reader
m_objFormatCtx = avformat_alloc_context();
@ -297,6 +337,7 @@ bool DATVideoRender::OpenStream(DATVideostream *objDevice)
{
qDebug() << "DATVideoProcess::OpenStream cannot alloc format FFMPEG context";
m_blnRunning=false;
return false;
}
@ -318,12 +359,13 @@ bool DATVideoRender::OpenStream(DATVideostream *objDevice)
{
qDebug() << "DATVideoProcess::OpenStream cannot open stream";
m_blnRunning=false;
return false;
}
if(!PreprocessStream())
{
m_blnRunning=false;
return false;
}
@ -341,14 +383,14 @@ bool DATVideoRender::RenderStream()
int intGotFrame;
bool blnNeedRenderingSetup;
if (!m_blnIsOpen)
if(!m_blnIsOpen)
{
qDebug() << "DATVideoProcess::RenderStream: Stream not open";
qDebug() << "DATVideoProcess::RenderStream Stream not open";
return false;
}
if (m_blnRunning)
if(m_blnRunning)
{
return false;
}
@ -413,7 +455,7 @@ bool DATVideoRender::RenderStream()
av_opt_set_int(m_objSwsCtx,"dsth",m_objFrame->height,0);
av_opt_set_int(m_objSwsCtx,"dst_format",AV_PIX_FMT_RGB24 ,0);
av_opt_set_int(m_objSwsCtx,"sws_flag",SWS_FAST_BILINEAR /* SWS_BICUBIC*/,0);
av_opt_set_int(m_objSwsCtx,"sws_flag", SWS_FAST_BILINEAR /* SWS_BICUBIC*/,0);
if(sws_init_context(m_objSwsCtx, NULL, NULL)<0)
{
@ -455,6 +497,8 @@ bool DATVideoRender::RenderStream()
MetaData.Width = m_objFrame->width;
MetaData.Height = m_objFrame->height;
MetaData.OK_Decoding = true;
emit onMetaDataChanged(&MetaData);
}
//Frame rendering
@ -482,25 +526,17 @@ bool DATVideoRender::RenderStream()
m_blnRunning=false;
//AVDictionaryEntry *objRslt= av_dict_get(fmt_ctx->programs[video_stream_index]->metadata,"service_provider",NULL,0);
//char objErrBuf[1024];
//memset(objErrBuf,0,1024);
//av_strerror(ret,objErrBuf,1024);
return true;
}
bool DATVideoRender::CloseStream(QIODevice *objDevice)
{
if(m_blnRunning==true)
if(m_blnRunning)
{
return false;
}
//Only once execution
m_blnRunning=true;
if(!objDevice)
{
qDebug() << "DATVideoProcess::CloseStream QIODevice is NULL";
@ -508,9 +544,9 @@ bool DATVideoRender::CloseStream(QIODevice *objDevice)
return false;
}
if (!m_blnIsOpen)
if(!m_blnIsOpen)
{
qDebug() << "DATVideoProcess::CloseStream: Stream not open";
qDebug() << "DATVideoProcess::CloseStream Stream not open";
return false;
}
@ -522,6 +558,9 @@ bool DATVideoRender::CloseStream(QIODevice *objDevice)
return false;
}
//Only once execution
m_blnRunning=true;
avformat_close_input(&m_objFormatCtx);
m_objFormatCtx=NULL;
@ -531,7 +570,6 @@ bool DATVideoRender::CloseStream(QIODevice *objDevice)
m_objDecoderCtx=NULL;
}
if(m_objFrame)
{
av_frame_unref(m_objFrame);
@ -553,5 +591,8 @@ bool DATVideoRender::CloseStream(QIODevice *objDevice)
m_intCurrentRenderWidth=-1;
m_intCurrentRenderHeight=-1;
ResetMetaData();
emit onMetaDataChanged(&MetaData);
return true;
}

View File

@ -39,13 +39,18 @@ extern "C"
#include <libavutil/samplefmt.h>
#include "libswscale/swscale.h"
}
struct DataTSMetaData2
{
int PID;
int CodecID;
bool OK_Data;
bool OK_Decoding;
bool OK_TransportStream;
bool OK_VideoStream;
QString Program;
QString Stream;
@ -53,12 +58,16 @@ struct DataTSMetaData2
int Height;
int BitRate;
int Channels;
QString CodecDescription;
DataTSMetaData2()
{
PID=-1;
CodecID=-1;
Program="";
Stream="";
@ -67,12 +76,19 @@ struct DataTSMetaData2
BitRate=-1;
Channels=-1;
CodecDescription="";
OK_Data=false;
OK_Decoding=false;
OK_TransportStream=false;
OK_VideoStream=false;
}
};
class DATVideoRender : public DATVScreen
{
Q_OBJECT
public:
explicit DATVideoRender(QWidget * parent);
void SetFullScreen(bool blnFullScreen);
@ -106,18 +122,17 @@ private:
bool InitializeFFMPEG();
bool PreprocessStream();
void ResetMetaData();
protected:
virtual bool eventFilter(QObject *obj, QEvent *event);
signals:
public slots:
void onMetaDataChanged(DataTSMetaData2 *objMetaData);
};
//To run Video Rendering with a dedicated thread
class DATVideoRenderThread: public QThread
{
@ -141,12 +156,11 @@ class DATVideoRenderThread: public QThread
m_objRenderer = objRenderer;
m_objStream = objStream;
m_blnRenderingVideo=false;
}
void run()
{
if(m_blnRenderingVideo==true)
if(m_blnRenderingVideo)
{
return;
}
@ -156,19 +170,11 @@ class DATVideoRenderThread: public QThread
return ;
}
m_blnRenderingVideo=false;
m_blnRenderingVideo = m_objRenderer->OpenStream(m_objStream);
if(m_objRenderer->OpenStream(m_objStream))
if(!m_blnRenderingVideo)
{
qInfo("DATVideoRenderThread::run: PID: %d W: %d H: %d Codec: %s Data: %s Service: %s",
m_objRenderer->MetaData.PID,
m_objRenderer->MetaData.Width,
m_objRenderer->MetaData.Height,
m_objRenderer->MetaData.CodecDescription.toStdString().c_str(),
m_objRenderer->MetaData.Program.toStdString().c_str(),
m_objRenderer->MetaData.Stream.toStdString().c_str());
m_blnRenderingVideo=true;
return;
}
while((m_objRenderer->RenderStream()) && (m_blnRenderingVideo==true))
@ -177,6 +183,8 @@ class DATVideoRenderThread: public QThread
m_objRenderer->CloseStream(m_objStream);
m_blnRenderingVideo=false;
}
void stopRendering()
@ -186,7 +194,6 @@ class DATVideoRenderThread: public QThread
private:
DATVideoRender *m_objRenderer;
DATVideostream *m_objStream;
bool m_blnRenderingVideo;

View File

@ -26,6 +26,7 @@ DATVideostream::DATVideostream():
m_intPacketReceived=0;
m_intMemoryLimit = DefaultMemoryLimit;
MultiThreaded=false;
ThreadTimeOut=-1;
m_objeventLoop.connect(this,SIGNAL(onDataAvailable()), &m_objeventLoop, SLOT(quit()),Qt::QueuedConnection);
}
@ -115,7 +116,7 @@ int DATVideostream::pushData(const char * chrData, int intSize)
}
bool DATVideostream::isSequential() const
{
{
return true;
}
@ -139,10 +140,11 @@ bool DATVideostream::open(OpenMode mode)
//PROTECTED
qint64 DATVideostream::readData(char *data, qint64 len)
{
{
QByteArray objCurrentArray;
int intEffectiveLen=0;
int intExpectedLen=0;
int intThreadLoop=0;
intExpectedLen = (int) len;
@ -160,15 +162,25 @@ qint64 DATVideostream::readData(char *data, qint64 len)
//DATA in FIFO ? -> Waiting for DATA
if((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
//|| (m_intBytesWaiting<10*len))
{
m_objMutex.unlock();
if(MultiThreaded==true)
{
intThreadLoop=0;
while((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
{
QThread::msleep(5);
intThreadLoop ++;
if(ThreadTimeOut>=0)
{
if(intThreadLoop*5>ThreadTimeOut)
{
return -1;
}
}
}
}
else
@ -212,12 +224,12 @@ qint64 DATVideostream::readData(char *data, qint64 len)
return (qint64)intEffectiveLen;
}
qint64 DATVideostream::writeData(const char *data, qint64 len)
qint64 DATVideostream::writeData(const char *data __attribute__((unused)), qint64 len __attribute__((unused)))
{
return 0;
}
qint64 DATVideostream::readLineData(char *data, qint64 maxSize)
{
qint64 DATVideostream::readLineData(char *data __attribute__((unused)), qint64 maxSize __attribute__((unused)))
{
return 0;
}

View File

@ -37,6 +37,7 @@ public:
~DATVideostream();
bool MultiThreaded;
int ThreadTimeOut;
int pushData(const char * chrData, int intSize);
bool setMemoryLimit(int intMemoryLimit);

View File

@ -52,7 +52,7 @@ DATVScreen::~DATVScreen()
QRgb* DATVScreen::getRowBuffer(int intRow)
{
if (m_blnGLContextInitialized == false)
if (!m_blnGLContextInitialized)
{
return NULL;
}
@ -161,7 +161,7 @@ void DATVScreen::paintGL()
m_objMutex.unlock();
}
void DATVScreen::mousePressEvent(QMouseEvent* event)
void DATVScreen::mousePressEvent(QMouseEvent* event __attribute__((unused)))
{
}
@ -194,13 +194,20 @@ bool DATVScreen::selectRow(int intLine)
{
return m_objGLShaderArray.SelectRow(intLine);
}
else
{
return false;
}
}
bool DATVScreen::setDataColor(int intCol, int intRed, int intGreen, int intBlue)
{
if (m_blnGLContextInitialized)
{
return m_objGLShaderArray.SetDataColor(intCol,
qRgb(intRed, intGreen, intBlue));
}
{
return m_objGLShaderArray.SetDataColor(intCol, qRgb(intRed, intGreen, intBlue));
}
else
{
return false;
}
}

View File

@ -33,12 +33,8 @@
#include "util/export.h"
#include "util/bitfieldindex.h"
class QPainter;
class SDRANGEL_API DATVScreen: public QGLWidget
{
Q_OBJECT

View File

@ -23,32 +23,42 @@
namespace leansdr
{
template<typename T> struct datvvideoplayer : runnable
template<typename T> struct datvvideoplayer: runnable
{
datvvideoplayer(scheduler *sch, pipebuf<T> &_in, DATVideostream * objVideoStream) :
runnable(sch, _in.name), in(_in), m_objVideoStream(objVideoStream)
{
datvvideoplayer(scheduler *sch, pipebuf<T> &_in, DATVideostream * objVideoStream) :
runnable(sch, _in.name),
in(_in),
m_objVideoStream(objVideoStream)
{
}
}
void run()
{
void run()
{
int size = in.readable() * sizeof(T);
if ( ! size ) return;
if (!size)
return;
int nw = m_objVideoStream->pushData((const char *)in.rd(),size);
int nw = m_objVideoStream->pushData((const char *) in.rd(), size);
if ( ! nw ) fatal("pipe");
if ( nw < 0 ) fatal("write");
if ( nw % sizeof(T) ) fatal("partial write");
in.read(nw/sizeof(T));
}
private:
pipereader<T> in;
DATVideostream * m_objVideoStream;
};
if (!nw)
{
fatal("leansdr::datvvideoplayer::run: pipe");
return;
}
if (nw < 0)
{
fatal("leansdr::datvvideoplayer::run: write");
return;
}
if (nw % sizeof(T))
{
fatal("leansdr::datvvideoplayer::run: partial write");
return;
}
in.read(nw / sizeof(T));
}
private:
pipereader<T> in;
DATVideostream * m_objVideoStream;
};
}

View File

@ -126,7 +126,7 @@ void GLShaderArray::InitializeGL(int intCols, int intRows)
QRgb * GLShaderArray::GetRowBuffer(int intRow)
{
if (m_blnInitialized == false)
if (!m_blnInitialized)
{
return 0;
}
@ -167,7 +167,7 @@ void GLShaderArray::RenderPixels(unsigned char *chrData)
QRgb *ptrLine;
if (m_blnInitialized == false)
if (!m_blnInitialized)
{
return;
}