mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 12:51:49 -05:00
DATV demod: formatted code
This commit is contained in:
parent
18e20d36bf
commit
7b9cb0e9fe
@ -24,8 +24,7 @@
|
|||||||
#include "leansdr/framework.h"
|
#include "leansdr/framework.h"
|
||||||
#include "gui/tvscreen.h"
|
#include "gui/tvscreen.h"
|
||||||
|
|
||||||
namespace leansdr
|
namespace leansdr {
|
||||||
{
|
|
||||||
|
|
||||||
static const int DEFAULT_GUI_DECIMATION = 64;
|
static const int DEFAULT_GUI_DECIMATION = 64;
|
||||||
|
|
||||||
@ -41,23 +40,28 @@ template<typename T> struct datvconstellation: runnable
|
|||||||
std::vector<int> cstln_rows;
|
std::vector<int> cstln_rows;
|
||||||
std::vector<int> cstln_cols;
|
std::vector<int> cstln_cols;
|
||||||
|
|
||||||
datvconstellation(scheduler *sch, pipebuf<complex<T> > &_in, T _xymin, T _xymax, const char *_name = 0, TVScreen *objDATVScreen = 0) :
|
datvconstellation(
|
||||||
runnable(sch, _name ? _name : _in.name),
|
scheduler *sch,
|
||||||
xymin(_xymin),
|
pipebuf<complex<T> > &_in,
|
||||||
xymax(_xymax),
|
T _xymin,
|
||||||
decimation(DEFAULT_GUI_DECIMATION),
|
T _xymax,
|
||||||
pixels_per_frame(1024),
|
const char *_name = nullptr,
|
||||||
cstln(0),
|
TVScreen *objDATVScreen = nullptr) :
|
||||||
m_objDATVScreen(objDATVScreen),
|
runnable(sch, _name ? _name : _in.name),
|
||||||
in(_in),
|
xymin(_xymin),
|
||||||
phase(0)
|
xymax(_xymax),
|
||||||
|
decimation(DEFAULT_GUI_DECIMATION),
|
||||||
|
pixels_per_frame(1024),
|
||||||
|
cstln(0),
|
||||||
|
m_objDATVScreen(objDATVScreen),
|
||||||
|
in(_in),
|
||||||
|
phase(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
//Symbols
|
//Symbols
|
||||||
|
|
||||||
while (in.readable() >= pixels_per_frame)
|
while (in.readable() >= pixels_per_frame)
|
||||||
{
|
{
|
||||||
if ((!phase) && m_objDATVScreen)
|
if ((!phase) && m_objDATVScreen)
|
||||||
@ -69,17 +73,18 @@ template<typename T> struct datvconstellation: runnable
|
|||||||
for (; p < pend; ++p)
|
for (; p < pend; ++p)
|
||||||
{
|
{
|
||||||
m_objDATVScreen->selectRow(256 * (p->re - xymin) / (xymax - xymin));
|
m_objDATVScreen->selectRow(256 * (p->re - xymin) / (xymax - xymin));
|
||||||
m_objDATVScreen->setDataColor(256 - 256 * ((p->im - xymin) / (xymax - xymin)), 255, 0, 255);
|
m_objDATVScreen->setDataColor(
|
||||||
|
256 - 256 * ((p->im - xymin) / (xymax - xymin)),
|
||||||
|
255, 0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cstln && (*cstln))
|
if (cstln && (*cstln))
|
||||||
{
|
{
|
||||||
// Plot constellation points
|
// Plot constellation points
|
||||||
|
|
||||||
std::vector<int>::const_iterator row_it = cstln_rows.begin();
|
std::vector<int>::const_iterator row_it = cstln_rows.begin();
|
||||||
std::vector<int>::const_iterator col_it = cstln_cols.begin();
|
std::vector<int>::const_iterator col_it = cstln_cols.begin();
|
||||||
|
|
||||||
for (; (row_it != cstln_rows.end()) && (col_it != cstln_cols.end()); ++row_it, ++col_it)
|
for (;(row_it != cstln_rows.end()) && (col_it != cstln_cols.end()); ++row_it, ++col_it)
|
||||||
{
|
{
|
||||||
m_objDATVScreen->selectRow(*row_it);
|
m_objDATVScreen->selectRow(*row_it);
|
||||||
m_objDATVScreen->setDataColor(*col_it, 250, 250, 5);
|
m_objDATVScreen->setDataColor(*col_it, 250, 250, 5);
|
||||||
@ -91,8 +96,7 @@ template<typename T> struct datvconstellation: runnable
|
|||||||
|
|
||||||
in.read(pixels_per_frame);
|
in.read(pixels_per_frame);
|
||||||
|
|
||||||
if (++phase >= decimation)
|
if (++phase >= decimation) {
|
||||||
{
|
|
||||||
phase = 0;
|
phase = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,6 +132,6 @@ template<typename T> struct datvconstellation: runnable
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // leansdr
|
||||||
|
|
||||||
#endif // DATVCONSTELLATION_H
|
#endif // DATVCONSTELLATION_H
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -73,59 +73,59 @@ inline int decimation(float Fin, float Fout) { int d = Fin / Fout; return std::m
|
|||||||
|
|
||||||
struct config
|
struct config
|
||||||
{
|
{
|
||||||
dvb_version standard;
|
dvb_version standard;
|
||||||
dvb_sampler sampler;
|
dvb_sampler sampler;
|
||||||
|
|
||||||
int buf_factor; // Buffer sizing
|
int buf_factor; // Buffer sizing
|
||||||
float Fs; // Sampling frequency (Hz)
|
float Fs; // Sampling frequency (Hz)
|
||||||
float Fderot; // Shift the signal (Hz). Note: Ftune is faster
|
float Fderot; // Shift the signal (Hz). Note: Ftune is faster
|
||||||
int anf; // Number of auto notch filters
|
int anf; // Number of auto notch filters
|
||||||
bool cnr; // Measure CNR
|
bool cnr; // Measure CNR
|
||||||
unsigned int decim; // Decimation, 0=auto
|
unsigned int decim; // Decimation, 0=auto
|
||||||
float Fm; // QPSK symbol rate (Hz)
|
float Fm; // QPSK symbol rate (Hz)
|
||||||
leansdr::cstln_lut<256>::predef constellation;
|
leansdr::cstln_lut<256>::predef constellation;
|
||||||
leansdr::code_rate fec;
|
leansdr::code_rate fec;
|
||||||
float Ftune; // Bias frequency for the QPSK demodulator (Hz)
|
float Ftune; // Bias frequency for the QPSK demodulator (Hz)
|
||||||
bool allow_drift;
|
bool allow_drift;
|
||||||
bool fastlock;
|
bool fastlock;
|
||||||
bool viterbi;
|
bool viterbi;
|
||||||
bool hard_metric;
|
bool hard_metric;
|
||||||
bool resample;
|
bool resample;
|
||||||
float resample_rej; // Approx. filter rejection in dB
|
float resample_rej; // Approx. filter rejection in dB
|
||||||
int rrc_steps; // Discrete steps between symbols, 0=auto
|
int rrc_steps; // Discrete steps between symbols, 0=auto
|
||||||
float rrc_rej; // Approx. RRC filter rejection in dB
|
float rrc_rej; // Approx. RRC filter rejection in dB
|
||||||
float rolloff; // Roll-off 0..1
|
float rolloff; // Roll-off 0..1
|
||||||
bool hdlc; // Expect HDLC frames instead of MPEG packets
|
bool hdlc; // Expect HDLC frames instead of MPEG packets
|
||||||
bool packetized; // Output frames with 16-bit BE length
|
bool packetized; // Output frames with 16-bit BE length
|
||||||
float Finfo; // Desired refresh rate on fd_info (Hz)
|
float Finfo; // Desired refresh rate on fd_info (Hz)
|
||||||
|
|
||||||
config() :
|
config() :
|
||||||
standard(DVB_S),
|
standard(DVB_S),
|
||||||
sampler(SAMP_LINEAR),
|
sampler(SAMP_LINEAR),
|
||||||
buf_factor(4),
|
buf_factor(4),
|
||||||
Fs(2.4e6),
|
Fs(2.4e6),
|
||||||
Fderot(0),
|
Fderot(0),
|
||||||
anf(0),
|
anf(0),
|
||||||
cnr(false),
|
cnr(false),
|
||||||
decim(0),
|
decim(0),
|
||||||
Fm(2e6),
|
Fm(2e6),
|
||||||
constellation(leansdr::cstln_lut<256>::QPSK),
|
constellation(leansdr::cstln_lut<256>::QPSK),
|
||||||
fec(leansdr::FEC12),
|
fec(leansdr::FEC12),
|
||||||
Ftune(0),
|
Ftune(0),
|
||||||
allow_drift(false),
|
allow_drift(false),
|
||||||
fastlock(true),
|
fastlock(true),
|
||||||
viterbi(false),
|
viterbi(false),
|
||||||
hard_metric(false),
|
hard_metric(false),
|
||||||
resample(false),
|
resample(false),
|
||||||
resample_rej(10),
|
resample_rej(10),
|
||||||
rrc_steps(0),
|
rrc_steps(0),
|
||||||
rrc_rej(10),
|
rrc_rej(10),
|
||||||
rolloff(0.35),
|
rolloff(0.35),
|
||||||
hdlc(false),
|
hdlc(false),
|
||||||
packetized(false),
|
packetized(false),
|
||||||
Finfo(5)
|
Finfo(5)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -240,7 +240,6 @@ public:
|
|||||||
static const QString m_channelIdURI;
|
static const QString m_channelIdURI;
|
||||||
static const QString m_channelId;
|
static const QString m_channelId;
|
||||||
|
|
||||||
|
|
||||||
class MsgConfigureChannelizer : public Message
|
class MsgConfigureChannelizer : public Message
|
||||||
{
|
{
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
@ -248,8 +247,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
int getCenterFrequency() const { return m_centerFrequency; }
|
int getCenterFrequency() const { return m_centerFrequency; }
|
||||||
|
|
||||||
static MsgConfigureChannelizer* create(int centerFrequency)
|
static MsgConfigureChannelizer* create(int centerFrequency) {
|
||||||
{
|
|
||||||
return new MsgConfigureChannelizer(centerFrequency);
|
return new MsgConfigureChannelizer(centerFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +257,7 @@ public:
|
|||||||
MsgConfigureChannelizer(int centerFrequency) :
|
MsgConfigureChannelizer(int centerFrequency) :
|
||||||
Message(),
|
Message(),
|
||||||
m_centerFrequency(centerFrequency)
|
m_centerFrequency(centerFrequency)
|
||||||
{ }
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -309,16 +309,13 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
|
|||||||
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
|
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
|
||||||
|
|
||||||
resetToDefaults(); // does applySettings()
|
resetToDefaults(); // does applySettings()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DATVDemodGUI::~DATVDemodGUI()
|
DATVDemodGUI::~DATVDemodGUI()
|
||||||
{
|
{
|
||||||
|
|
||||||
m_deviceUISet->removeRxChannelInstance(this);
|
m_deviceUISet->removeRxChannelInstance(this);
|
||||||
delete m_objDATVDemod;
|
delete m_objDATVDemod;
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DATVDemodGUI::blockApplySettings(bool blnBlock)
|
void DATVDemodGUI::blockApplySettings(bool blnBlock)
|
||||||
@ -350,125 +347,83 @@ void DATVDemodGUI::applySettings()
|
|||||||
|
|
||||||
strStandard = ui->cmbStandard->currentText();
|
strStandard = ui->cmbStandard->currentText();
|
||||||
|
|
||||||
if(strStandard=="DVB-S")
|
if(strStandard=="DVB-S") {
|
||||||
{
|
|
||||||
enmVersion=DVB_S;
|
enmVersion=DVB_S;
|
||||||
}
|
} else if (strStandard=="DVB-S2") {
|
||||||
else if (strStandard=="DVB-S2")
|
|
||||||
{
|
|
||||||
enmVersion=DVB_S2;
|
enmVersion=DVB_S2;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
enmVersion=DVB_S;
|
enmVersion=DVB_S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//BPSK, QPSK, PSK8, APSK16, APSK32, APSK64E, QAM16, QAM64, QAM256
|
//BPSK, QPSK, PSK8, APSK16, APSK32, APSK64E, QAM16, QAM64, QAM256
|
||||||
|
|
||||||
strModulation = ui->cmbModulation->currentText();
|
strModulation = ui->cmbModulation->currentText();
|
||||||
|
|
||||||
if(strModulation=="BPSK")
|
if(strModulation=="BPSK") {
|
||||||
{
|
|
||||||
enmSelectedModulation=BPSK;
|
enmSelectedModulation=BPSK;
|
||||||
}
|
}
|
||||||
else if(strModulation=="QPSK")
|
else if(strModulation=="QPSK") {
|
||||||
{
|
|
||||||
enmSelectedModulation=QPSK;
|
enmSelectedModulation=QPSK;
|
||||||
}
|
}
|
||||||
else if(strModulation=="8PSK")
|
else if(strModulation=="8PSK") {
|
||||||
{
|
|
||||||
enmSelectedModulation=PSK8;
|
enmSelectedModulation=PSK8;
|
||||||
}
|
}
|
||||||
else if(strModulation=="16APSK")
|
else if(strModulation=="16APSK") {
|
||||||
{
|
|
||||||
enmSelectedModulation=APSK16;
|
enmSelectedModulation=APSK16;
|
||||||
}
|
}
|
||||||
else if(strModulation=="32APSK")
|
else if(strModulation=="32APSK") {
|
||||||
{
|
|
||||||
enmSelectedModulation=APSK32;
|
enmSelectedModulation=APSK32;
|
||||||
}
|
}
|
||||||
else if(strModulation=="64APSKE")
|
else if(strModulation=="64APSKE") {
|
||||||
{
|
|
||||||
enmSelectedModulation=APSK64E;
|
enmSelectedModulation=APSK64E;
|
||||||
}
|
}
|
||||||
else if(strModulation=="16QAM")
|
else if(strModulation=="16QAM") {
|
||||||
{
|
|
||||||
enmSelectedModulation=QAM16;
|
enmSelectedModulation=QAM16;
|
||||||
}
|
}
|
||||||
else if(strModulation=="64QAM")
|
else if(strModulation=="64QAM") {
|
||||||
{
|
|
||||||
enmSelectedModulation=QAM64;
|
enmSelectedModulation=QAM64;
|
||||||
}
|
}
|
||||||
else if(strModulation=="256QAM")
|
else if(strModulation=="256QAM") {
|
||||||
{
|
|
||||||
enmSelectedModulation=QAM256;
|
enmSelectedModulation=QAM256;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
enmSelectedModulation=BPSK;
|
enmSelectedModulation=BPSK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Viterbi only for BPSK et QPSK
|
//Viterbi only for BPSK et QPSK
|
||||||
if((enmSelectedModulation!=BPSK) && (enmSelectedModulation!=QPSK))
|
if ((enmSelectedModulation!=BPSK) && (enmSelectedModulation!=QPSK)) {
|
||||||
{
|
|
||||||
ui->chkViterbi->setChecked(false);
|
ui->chkViterbi->setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
strFEC = ui->cmbFEC->currentText();
|
strFEC = ui->cmbFEC->currentText();
|
||||||
|
|
||||||
if(strFEC == "1/2")
|
if (strFEC == "1/2") {
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC12;
|
enmFEC = leansdr::FEC12;
|
||||||
}
|
} else if (strFEC == "2/3") {
|
||||||
else if(strFEC == "2/3")
|
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC23;
|
enmFEC = leansdr::FEC23;
|
||||||
}
|
} else if (strFEC == "3/4") {
|
||||||
else if(strFEC == "3/4")
|
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC34;
|
enmFEC = leansdr::FEC34;
|
||||||
}
|
} else if (strFEC == "5/6") {
|
||||||
else if(strFEC == "5/6")
|
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC56;
|
enmFEC = leansdr::FEC56;
|
||||||
}
|
} else if (strFEC == "7/8") {
|
||||||
else if(strFEC == "7/8")
|
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC78;
|
enmFEC = leansdr::FEC78;
|
||||||
}
|
} else if (strFEC == "4/5") {
|
||||||
else if(strFEC == "4/5")
|
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC45;
|
enmFEC = leansdr::FEC45;
|
||||||
}
|
} else if (strFEC == "8/9") {
|
||||||
else if(strFEC == "8/9")
|
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC89;
|
enmFEC = leansdr::FEC89;
|
||||||
}
|
} else if (strFEC == "9/10") {
|
||||||
else if(strFEC == "9/10")
|
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC910;
|
enmFEC = leansdr::FEC910;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
enmFEC = leansdr::FEC12;
|
enmFEC = leansdr::FEC12;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui->cmbFilter->currentIndex()==0)
|
if (ui->cmbFilter->currentIndex() == 0) {
|
||||||
{
|
|
||||||
enmSampler = SAMP_LINEAR;
|
enmSampler = SAMP_LINEAR;
|
||||||
}
|
} else if (ui->cmbFilter->currentIndex() == 1) {
|
||||||
else if(ui->cmbFilter->currentIndex()==1)
|
|
||||||
{
|
|
||||||
enmSampler = SAMP_NEAREST;
|
enmSampler = SAMP_NEAREST;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
enmSampler = SAMP_RRC;
|
enmSampler = SAMP_RRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_objDATVDemod->configure(
|
m_objDATVDemod->configure(
|
||||||
m_objDATVDemod->getInputMessageQueue(),
|
m_objDATVDemod->getInputMessageQueue(),
|
||||||
m_objChannelMarker.getBandwidth(),
|
m_objChannelMarker.getBandwidth(),
|
||||||
@ -487,8 +442,8 @@ void DATVDemodGUI::applySettings()
|
|||||||
ui->spiExcursion->value());
|
ui->spiExcursion->value());
|
||||||
|
|
||||||
qDebug() << "DATVDemodGUI::applySettings:"
|
qDebug() << "DATVDemodGUI::applySettings:"
|
||||||
<< " m_objDATVDemod->getCenterFrequency: " << m_objDATVDemod->getCenterFrequency()
|
<< " m_objDATVDemod->getCenterFrequency: " << m_objDATVDemod->getCenterFrequency()
|
||||||
<< " m_objDATVDemod->GetSampleRate: " << m_objDATVDemod->GetSampleRate();
|
<< " m_objDATVDemod->GetSampleRate: " << m_objDATVDemod->GetSampleRate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +630,7 @@ void DATVDemodGUI::on_pushButton_3_clicked()
|
|||||||
|
|
||||||
m_blnButtonPlayClicked=true;
|
m_blnButtonPlayClicked=true;
|
||||||
|
|
||||||
if(m_objDATVDemod!=NULL)
|
if(m_objDATVDemod!=nullptr)
|
||||||
{
|
{
|
||||||
m_objDATVDemod->PlayVideo(true);
|
m_objDATVDemod->PlayVideo(true);
|
||||||
}
|
}
|
||||||
@ -695,16 +650,11 @@ void DATVDemodGUI::on_mouseEvent(QMouseEvent* obj)
|
|||||||
|
|
||||||
QString DATVDemodGUI::formatBytes(qint64 intBytes)
|
QString DATVDemodGUI::formatBytes(qint64 intBytes)
|
||||||
{
|
{
|
||||||
if(intBytes<1024)
|
if(intBytes<1024) {
|
||||||
{
|
|
||||||
return QString("%1").arg(intBytes);
|
return QString("%1").arg(intBytes);
|
||||||
}
|
} else if(intBytes<1024*1024) {
|
||||||
else if(intBytes<1024*1024)
|
|
||||||
{
|
|
||||||
return QString("%1 K").arg((float)(10*intBytes/1024)/10.0f);
|
return QString("%1 K").arg((float)(10*intBytes/1024)/10.0f);
|
||||||
}
|
} else if(intBytes<1024*1024*1024) {
|
||||||
else if(intBytes<1024*1024*1024)
|
|
||||||
{
|
|
||||||
return QString("%1 M").arg((float)(10*intBytes/(1024*1024))/10.0f);
|
return QString("%1 M").arg((float)(10*intBytes/(1024*1024))/10.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -718,17 +668,13 @@ void DATVDemodGUI::on_StreamDataAvailable(int *intPackets, int *intBytes, int *i
|
|||||||
ui->lblStatus->setText(QString("Data: %1B").arg(formatBytes(*intTotalReceived)));
|
ui->lblStatus->setText(QString("Data: %1B").arg(formatBytes(*intTotalReceived)));
|
||||||
m_intLastDecodedData = *intTotalReceived;
|
m_intLastDecodedData = *intTotalReceived;
|
||||||
|
|
||||||
if((*intPercent)<100)
|
if((*intPercent)<100) {
|
||||||
{
|
ui->prgSynchro->setValue(*intPercent);
|
||||||
ui->prgSynchro->setValue(*intPercent);
|
} else {
|
||||||
}
|
ui->prgSynchro->setValue(100);
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->prgSynchro->setValue(100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_intReadyDecodedData = *intBytes;
|
m_intReadyDecodedData = *intBytes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DATVDemodGUI::on_spiBandwidth_valueChanged(int arg1)
|
void DATVDemodGUI::on_spiBandwidth_valueChanged(int arg1)
|
||||||
@ -758,37 +704,32 @@ void DATVDemodGUI::on_StreamMetaDataChanged(DataTSMetaData2 *objMetaData)
|
|||||||
{
|
{
|
||||||
QString strMetaData="";
|
QString strMetaData="";
|
||||||
|
|
||||||
if(objMetaData!=NULL)
|
if (objMetaData != nullptr)
|
||||||
{
|
{
|
||||||
|
if (objMetaData->OK_TransportStream == true)
|
||||||
if(objMetaData->OK_TransportStream==true)
|
|
||||||
{
|
{
|
||||||
strMetaData.sprintf("PID: %d - Width: %d - Height: %d\r\n%s%s\r\nCodec: %s\r\n",
|
strMetaData.sprintf("PID: %d - Width: %d - Height: %d\r\n%s%s\r\nCodec: %s\r\n",
|
||||||
objMetaData->PID,
|
objMetaData->PID,
|
||||||
objMetaData->Width,
|
objMetaData->Width,
|
||||||
objMetaData->Height,
|
objMetaData->Height,
|
||||||
objMetaData->Program.toStdString().c_str(),
|
objMetaData->Program.toStdString().c_str(),
|
||||||
objMetaData->Stream.toStdString().c_str(),
|
objMetaData->Stream.toStdString().c_str(),
|
||||||
objMetaData->CodecDescription.toStdString().c_str());
|
objMetaData->CodecDescription.toStdString().c_str());
|
||||||
}
|
}
|
||||||
ui->textEdit->setText(strMetaData);
|
|
||||||
|
|
||||||
|
ui->textEdit->setText(strMetaData);
|
||||||
ui->chkData->setChecked(objMetaData->OK_Data);
|
ui->chkData->setChecked(objMetaData->OK_Data);
|
||||||
ui->chkTS->setChecked(objMetaData->OK_TransportStream);
|
ui->chkTS->setChecked(objMetaData->OK_TransportStream);
|
||||||
ui->chkVS->setChecked(objMetaData->OK_VideoStream);
|
ui->chkVS->setChecked(objMetaData->OK_VideoStream);
|
||||||
ui->chkDecoding->setChecked(objMetaData->OK_Decoding);
|
ui->chkDecoding->setChecked(objMetaData->OK_Decoding);
|
||||||
|
|
||||||
if(objMetaData->OK_Decoding==true)
|
if (objMetaData->OK_Decoding == true) {
|
||||||
{
|
|
||||||
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
|
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
|
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(objMetaData->Height>0)
|
if (objMetaData->Height > 0) {
|
||||||
{
|
|
||||||
ui->screenTV_2->setFixedWidth((int)objMetaData->Width*(270.0f/(float)objMetaData->Height));
|
ui->screenTV_2->setFixedWidth((int)objMetaData->Width*(270.0f/(float)objMetaData->Height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -806,7 +747,6 @@ void DATVDemodGUI::on_cmbFilter_currentIndexChanged(int index)
|
|||||||
{
|
{
|
||||||
(void) index;
|
(void) index;
|
||||||
displayRRCParameters((ui->cmbFilter->currentIndex()==2));
|
displayRRCParameters((ui->cmbFilter->currentIndex()==2));
|
||||||
|
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
const PluginDescriptor DATVDemodPlugin::m_ptrPluginDescriptor =
|
const PluginDescriptor DATVDemodPlugin::m_ptrPluginDescriptor =
|
||||||
{
|
{
|
||||||
QString("DATV Demodulator"),
|
QString("DATV Demodulator"),
|
||||||
QString("4.3.1"),
|
QString("4.5.1"),
|
||||||
QString("(c) F4HKW for SDRAngel using LeanSDR framework (c) F4DAV"),
|
QString("(c) F4HKW for SDRAngel using LeanSDR framework (c) F4DAV"),
|
||||||
QString("https://github.com/f4exb/sdrangel"),
|
QString("https://github.com/f4exb/sdrangel"),
|
||||||
true,
|
true,
|
||||||
@ -36,7 +36,7 @@ const PluginDescriptor DATVDemodPlugin::m_ptrPluginDescriptor =
|
|||||||
|
|
||||||
DATVDemodPlugin::DATVDemodPlugin(QObject* ptrParent) :
|
DATVDemodPlugin::DATVDemodPlugin(QObject* ptrParent) :
|
||||||
QObject(ptrParent),
|
QObject(ptrParent),
|
||||||
m_ptrPluginAPI(NULL)
|
m_ptrPluginAPI(nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class DATVDemodPlugin : public QObject, PluginInterface
|
|||||||
Q_PLUGIN_METADATA(IID "sdrangel.channel.demoddatv")
|
Q_PLUGIN_METADATA(IID "sdrangel.channel.demoddatv")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DATVDemodPlugin(QObject* ptrParent = NULL);
|
explicit DATVDemodPlugin(QObject* ptrParent = nullptr);
|
||||||
|
|
||||||
const PluginDescriptor& getPluginDescriptor() const;
|
const PluginDescriptor& getPluginDescriptor() const;
|
||||||
void initPlugin(PluginAPI* ptrPluginAPI);
|
void initPlugin(PluginAPI* ptrPluginAPI);
|
||||||
|
@ -26,15 +26,15 @@ DATVideoRender::DATVideoRender(QWidget * parent):
|
|||||||
|
|
||||||
m_blnIsFFMPEGInitialized=false;
|
m_blnIsFFMPEGInitialized=false;
|
||||||
m_blnIsOpen=false;
|
m_blnIsOpen=false;
|
||||||
m_objFormatCtx=NULL;
|
m_objFormatCtx=nullptr;
|
||||||
m_objDecoderCtx=NULL;
|
m_objDecoderCtx=nullptr;
|
||||||
m_objSwsCtx=NULL;
|
m_objSwsCtx=nullptr;
|
||||||
m_intVideoStreamIndex=-1;
|
m_intVideoStreamIndex=-1;
|
||||||
|
|
||||||
m_intCurrentRenderWidth=-1;
|
m_intCurrentRenderWidth=-1;
|
||||||
m_intCurrentRenderHeight=-1;
|
m_intCurrentRenderHeight=-1;
|
||||||
|
|
||||||
m_objFrame=NULL;
|
m_objFrame=nullptr;
|
||||||
m_intFrameCount=-1;
|
m_intFrameCount=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,17 +55,15 @@ bool DATVideoRender::eventFilter(QObject *obj, QEvent *event)
|
|||||||
|
|
||||||
void DATVideoRender::SetFullScreen(bool blnFullScreen)
|
void DATVideoRender::SetFullScreen(bool blnFullScreen)
|
||||||
{
|
{
|
||||||
if(m_blnIsFullScreen==blnFullScreen)
|
if (m_blnIsFullScreen == blnFullScreen) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(blnFullScreen==true)
|
if (blnFullScreen == true)
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::Window);
|
setWindowFlags(Qt::Window);
|
||||||
setWindowState(Qt::WindowFullScreen);
|
setWindowState(Qt::WindowFullScreen);
|
||||||
show();
|
show();
|
||||||
|
|
||||||
m_blnIsFullScreen=true;
|
m_blnIsFullScreen=true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -73,7 +71,6 @@ void DATVideoRender::SetFullScreen(bool blnFullScreen)
|
|||||||
setWindowFlags(Qt::Widget);
|
setWindowFlags(Qt::Widget);
|
||||||
setWindowState(Qt::WindowNoState);
|
setWindowState(Qt::WindowNoState);
|
||||||
show();
|
show();
|
||||||
|
|
||||||
m_blnIsFullScreen=false;
|
m_blnIsFullScreen=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,18 +87,15 @@ static int64_t SeekFunction(void* opaque, int64_t offset, int whence)
|
|||||||
{
|
{
|
||||||
QIODevice* objStream = reinterpret_cast<QIODevice*>(opaque);
|
QIODevice* objStream = reinterpret_cast<QIODevice*>(opaque);
|
||||||
|
|
||||||
if (whence == AVSEEK_SIZE)
|
if (whence == AVSEEK_SIZE) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objStream->isSequential())
|
if (objStream->isSequential()) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objStream->seek(offset)==false)
|
if (objStream->seek(offset) == false) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,14 +125,12 @@ bool DATVideoRender::InitializeFFMPEG()
|
|||||||
{
|
{
|
||||||
ResetMetaData();
|
ResetMetaData();
|
||||||
|
|
||||||
if(m_blnIsFFMPEGInitialized)
|
if (m_blnIsFFMPEGInitialized) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
avcodec_register_all();
|
avcodec_register_all();
|
||||||
av_register_all();
|
av_register_all();
|
||||||
|
|
||||||
av_log_set_level(AV_LOG_FATAL);
|
av_log_set_level(AV_LOG_FATAL);
|
||||||
//av_log_set_level(AV_LOG_ERROR);
|
//av_log_set_level(AV_LOG_ERROR);
|
||||||
|
|
||||||
@ -149,25 +141,25 @@ bool DATVideoRender::InitializeFFMPEG()
|
|||||||
|
|
||||||
bool DATVideoRender::PreprocessStream()
|
bool DATVideoRender::PreprocessStream()
|
||||||
{
|
{
|
||||||
AVDictionary *objOpts = NULL;
|
AVDictionary *objOpts = nullptr;
|
||||||
AVCodec *objCodec = NULL;
|
AVCodec *objCodec = nullptr;
|
||||||
|
|
||||||
int intRet=-1;
|
int intRet=-1;
|
||||||
char *objBuffer=NULL;
|
char *objBuffer=nullptr;
|
||||||
|
|
||||||
//Identify stream
|
//Identify stream
|
||||||
|
|
||||||
if (avformat_find_stream_info(m_objFormatCtx, NULL) < 0)
|
if (avformat_find_stream_info(m_objFormatCtx, nullptr) < 0)
|
||||||
{
|
{
|
||||||
avformat_close_input(&m_objFormatCtx);
|
avformat_close_input(&m_objFormatCtx);
|
||||||
m_objFormatCtx=NULL;
|
m_objFormatCtx=nullptr;
|
||||||
|
|
||||||
qDebug() << "DATVideoProcess::PreprocessStream cannot find stream info";
|
qDebug() << "DATVideoProcess::PreprocessStream cannot find stream info";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Find video stream
|
//Find video stream
|
||||||
intRet = av_find_best_stream(m_objFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
|
intRet = av_find_best_stream(m_objFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);
|
||||||
|
|
||||||
if (intRet < 0)
|
if (intRet < 0)
|
||||||
{
|
{
|
||||||
@ -191,28 +183,24 @@ bool DATVideoRender::PreprocessStream()
|
|||||||
MetaData.PID = m_objFormatCtx->streams[m_intVideoStreamIndex]->id;
|
MetaData.PID = m_objFormatCtx->streams[m_intVideoStreamIndex]->id;
|
||||||
MetaData.CodecID = m_objDecoderCtx->codec_id;
|
MetaData.CodecID = m_objDecoderCtx->codec_id;
|
||||||
MetaData.OK_TransportStream = true;
|
MetaData.OK_TransportStream = true;
|
||||||
|
|
||||||
|
|
||||||
MetaData.Program="";
|
MetaData.Program="";
|
||||||
MetaData.Stream="";
|
MetaData.Stream="";
|
||||||
|
|
||||||
if(m_objFormatCtx->programs)
|
if(m_objFormatCtx->programs)
|
||||||
{
|
{
|
||||||
objBuffer=NULL;
|
objBuffer=nullptr;
|
||||||
|
|
||||||
av_dict_get_string(m_objFormatCtx->programs[m_intVideoStreamIndex]->metadata,&objBuffer,':','\n');
|
av_dict_get_string(m_objFormatCtx->programs[m_intVideoStreamIndex]->metadata,&objBuffer,':','\n');
|
||||||
if(objBuffer!=NULL)
|
|
||||||
{
|
if(objBuffer!=nullptr) {
|
||||||
MetaData.Program = QString("%1").arg(objBuffer);
|
MetaData.Program = QString("%1").arg(objBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
objBuffer=NULL;
|
objBuffer=nullptr;
|
||||||
|
|
||||||
av_dict_get_string(m_objFormatCtx->streams[m_intVideoStreamIndex]->metadata,&objBuffer,':','\n');
|
av_dict_get_string(m_objFormatCtx->streams[m_intVideoStreamIndex]->metadata,&objBuffer,':','\n');
|
||||||
|
|
||||||
if(objBuffer!=NULL)
|
if (objBuffer != nullptr) {
|
||||||
{
|
|
||||||
MetaData.Stream = QString("%1").arg(objBuffer);
|
MetaData.Stream = QString("%1").arg(objBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,10 +208,11 @@ bool DATVideoRender::PreprocessStream()
|
|||||||
|
|
||||||
//Decoder
|
//Decoder
|
||||||
objCodec = avcodec_find_decoder(m_objDecoderCtx->codec_id);
|
objCodec = avcodec_find_decoder(m_objDecoderCtx->codec_id);
|
||||||
if(objCodec==NULL)
|
|
||||||
|
if (objCodec == nullptr)
|
||||||
{
|
{
|
||||||
avformat_close_input(&m_objFormatCtx);
|
avformat_close_input(&m_objFormatCtx);
|
||||||
m_objFormatCtx=NULL;
|
m_objFormatCtx=nullptr;
|
||||||
|
|
||||||
qDebug() << "DATVideoProcess::PreprocessStream cannot find associated CODEC";
|
qDebug() << "DATVideoProcess::PreprocessStream cannot find associated CODEC";
|
||||||
return false;
|
return false;
|
||||||
@ -234,7 +223,7 @@ bool DATVideoRender::PreprocessStream()
|
|||||||
if (avcodec_open2(m_objDecoderCtx, objCodec, &objOpts) < 0)
|
if (avcodec_open2(m_objDecoderCtx, objCodec, &objOpts) < 0)
|
||||||
{
|
{
|
||||||
avformat_close_input(&m_objFormatCtx);
|
avformat_close_input(&m_objFormatCtx);
|
||||||
m_objFormatCtx=NULL;
|
m_objFormatCtx=nullptr;
|
||||||
|
|
||||||
qDebug() << "DATVideoProcess::PreprocessStream cannot open associated CODEC";
|
qDebug() << "DATVideoProcess::PreprocessStream cannot open associated CODEC";
|
||||||
return false;
|
return false;
|
||||||
@ -246,21 +235,18 @@ bool DATVideoRender::PreprocessStream()
|
|||||||
if (!m_objFrame)
|
if (!m_objFrame)
|
||||||
{
|
{
|
||||||
avformat_close_input(&m_objFormatCtx);
|
avformat_close_input(&m_objFormatCtx);
|
||||||
m_objFormatCtx=NULL;
|
m_objFormatCtx=nullptr;
|
||||||
|
|
||||||
qDebug() << "DATVideoProcess::PreprocessStream cannot allocate frame";
|
qDebug() << "DATVideoProcess::PreprocessStream cannot allocate frame";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_intFrameCount=0;
|
m_intFrameCount=0;
|
||||||
|
|
||||||
|
|
||||||
MetaData.Width=m_objDecoderCtx->width;
|
MetaData.Width=m_objDecoderCtx->width;
|
||||||
MetaData.Height=m_objDecoderCtx->height;
|
MetaData.Height=m_objDecoderCtx->height;
|
||||||
MetaData.BitRate= m_objDecoderCtx->bit_rate;
|
MetaData.BitRate= m_objDecoderCtx->bit_rate;
|
||||||
MetaData.Channels=m_objDecoderCtx->channels;
|
MetaData.Channels=m_objDecoderCtx->channels;
|
||||||
MetaData.CodecDescription= QString("%1").arg(objCodec->long_name);
|
MetaData.CodecDescription= QString("%1").arg(objCodec->long_name);
|
||||||
|
|
||||||
MetaData.OK_VideoStream = true;
|
MetaData.OK_VideoStream = true;
|
||||||
|
|
||||||
emit onMetaDataChanged(&MetaData);
|
emit onMetaDataChanged(&MetaData);
|
||||||
@ -271,111 +257,93 @@ bool DATVideoRender::PreprocessStream()
|
|||||||
bool DATVideoRender::OpenStream(DATVideostream *objDevice)
|
bool DATVideoRender::OpenStream(DATVideostream *objDevice)
|
||||||
{
|
{
|
||||||
int intIOBufferSize = 32768;
|
int intIOBufferSize = 32768;
|
||||||
unsigned char * ptrIOBuffer = NULL;
|
unsigned char * ptrIOBuffer = nullptr;
|
||||||
AVIOContext * objIOCtx = NULL;
|
AVIOContext * objIOCtx = nullptr;
|
||||||
|
|
||||||
if(m_blnRunning)
|
if(m_blnRunning) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (objDevice == nullptr)
|
||||||
if(objDevice==NULL)
|
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::OpenStream QIODevice is NULL";
|
qDebug() << "DATVideoProcess::OpenStream QIODevice is nullptr";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_blnIsOpen)
|
||||||
if(m_blnIsOpen)
|
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::OpenStream already open";
|
qDebug() << "DATVideoProcess::OpenStream already open";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(objDevice->bytesAvailable()<=0)
|
if (objDevice->bytesAvailable() <= 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
qDebug() << "DATVideoProcess::OpenStream no data available";
|
qDebug() << "DATVideoProcess::OpenStream no data available";
|
||||||
|
MetaData.OK_Data = false;
|
||||||
MetaData.OK_Data=false;
|
|
||||||
emit onMetaDataChanged(&MetaData);
|
emit onMetaDataChanged(&MetaData);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Only once execution
|
//Only once execution
|
||||||
m_blnRunning=true;
|
m_blnRunning = true;
|
||||||
|
|
||||||
MetaData.OK_Data=true;
|
MetaData.OK_Data = true;
|
||||||
emit onMetaDataChanged(&MetaData);
|
emit onMetaDataChanged(&MetaData);
|
||||||
|
|
||||||
|
|
||||||
InitializeFFMPEG();
|
InitializeFFMPEG();
|
||||||
|
|
||||||
|
if (!m_blnIsFFMPEGInitialized)
|
||||||
if(!m_blnIsFFMPEGInitialized)
|
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::OpenStream FFMPEG not initialized";
|
qDebug() << "DATVideoProcess::OpenStream FFMPEG not initialized";
|
||||||
|
m_blnRunning = false;
|
||||||
m_blnRunning=false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!objDevice->open(QIODevice::ReadOnly))
|
if (!objDevice->open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::OpenStream cannot open QIODevice";
|
qDebug() << "DATVideoProcess::OpenStream cannot open QIODevice";
|
||||||
|
m_blnRunning = false;
|
||||||
m_blnRunning=false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Connect QIODevice to FFMPEG Reader
|
//Connect QIODevice to FFMPEG Reader
|
||||||
|
|
||||||
m_objFormatCtx = avformat_alloc_context();
|
m_objFormatCtx = avformat_alloc_context();
|
||||||
|
|
||||||
if(m_objFormatCtx==NULL)
|
if (m_objFormatCtx == nullptr)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::OpenStream cannot alloc format FFMPEG context";
|
qDebug() << "DATVideoProcess::OpenStream cannot alloc format FFMPEG context";
|
||||||
|
m_blnRunning = false;
|
||||||
m_blnRunning=false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptrIOBuffer = (unsigned char *)av_malloc(intIOBufferSize+ AV_INPUT_BUFFER_PADDING_SIZE);
|
ptrIOBuffer = (unsigned char *)av_malloc(intIOBufferSize+ AV_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
objIOCtx = avio_alloc_context( ptrIOBuffer,
|
objIOCtx = avio_alloc_context(ptrIOBuffer,
|
||||||
intIOBufferSize,
|
intIOBufferSize,
|
||||||
0,
|
0,
|
||||||
reinterpret_cast<void *>(objDevice),
|
reinterpret_cast<void *>(objDevice),
|
||||||
&ReadFunction,
|
&ReadFunction,
|
||||||
NULL,
|
nullptr,
|
||||||
&SeekFunction);
|
&SeekFunction);
|
||||||
|
|
||||||
m_objFormatCtx->pb = objIOCtx;
|
m_objFormatCtx->pb = objIOCtx;
|
||||||
m_objFormatCtx->flags |= AVFMT_FLAG_CUSTOM_IO;
|
m_objFormatCtx->flags |= AVFMT_FLAG_CUSTOM_IO;
|
||||||
|
|
||||||
|
if (avformat_open_input(&m_objFormatCtx, nullptr , nullptr, nullptr) < 0)
|
||||||
if (avformat_open_input(&m_objFormatCtx, NULL , NULL, NULL) < 0)
|
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::OpenStream cannot open stream";
|
qDebug() << "DATVideoProcess::OpenStream cannot open stream";
|
||||||
|
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!PreprocessStream())
|
if (!PreprocessStream())
|
||||||
{
|
{
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_blnIsOpen=true;
|
m_blnIsOpen=true;
|
||||||
|
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -390,12 +358,10 @@ bool DATVideoRender::RenderStream()
|
|||||||
if(!m_blnIsOpen)
|
if(!m_blnIsOpen)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::RenderStream Stream not open";
|
qDebug() << "DATVideoProcess::RenderStream Stream not open";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_blnRunning)
|
if(m_blnRunning) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +373,6 @@ bool DATVideoRender::RenderStream()
|
|||||||
if (av_read_frame(m_objFormatCtx, &objPacket) < 0)
|
if (av_read_frame(m_objFormatCtx, &objPacket) < 0)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::RenderStream reading packet error";
|
qDebug() << "DATVideoProcess::RenderStream reading packet error";
|
||||||
|
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -418,34 +383,31 @@ bool DATVideoRender::RenderStream()
|
|||||||
memset(m_objFrame, 0, sizeof(AVFrame));
|
memset(m_objFrame, 0, sizeof(AVFrame));
|
||||||
av_frame_unref(m_objFrame);
|
av_frame_unref(m_objFrame);
|
||||||
|
|
||||||
intGotFrame=0;
|
intGotFrame = 0;
|
||||||
|
|
||||||
if(new_decode( m_objDecoderCtx, m_objFrame, &intGotFrame, &objPacket)<0)
|
if (new_decode( m_objDecoderCtx, m_objFrame, &intGotFrame, &objPacket)<0)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::RenderStream decoding packet error";
|
qDebug() << "DATVideoProcess::RenderStream decoding packet error";
|
||||||
|
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(intGotFrame)
|
if (intGotFrame)
|
||||||
{
|
{
|
||||||
//Rendering and RGB Converter setup
|
//Rendering and RGB Converter setup
|
||||||
|
|
||||||
blnNeedRenderingSetup=(m_intFrameCount==0);
|
blnNeedRenderingSetup=(m_intFrameCount==0);
|
||||||
blnNeedRenderingSetup|=(m_objSwsCtx==NULL);
|
blnNeedRenderingSetup|=(m_objSwsCtx==nullptr);
|
||||||
|
|
||||||
if((m_intCurrentRenderWidth!=m_objFrame->width) || (m_intCurrentRenderHeight!=m_objFrame->height))
|
if ((m_intCurrentRenderWidth!=m_objFrame->width) || (m_intCurrentRenderHeight!=m_objFrame->height)) {
|
||||||
{
|
|
||||||
blnNeedRenderingSetup=true;
|
blnNeedRenderingSetup=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(blnNeedRenderingSetup)
|
if (blnNeedRenderingSetup)
|
||||||
{
|
{
|
||||||
if(m_objSwsCtx!=NULL)
|
if (m_objSwsCtx != nullptr)
|
||||||
{
|
{
|
||||||
sws_freeContext(m_objSwsCtx);
|
sws_freeContext(m_objSwsCtx);
|
||||||
m_objSwsCtx=NULL;
|
m_objSwsCtx=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Convertisseur YUV -> RGB
|
//Convertisseur YUV -> RGB
|
||||||
@ -461,67 +423,57 @@ bool DATVideoRender::RenderStream()
|
|||||||
|
|
||||||
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)
|
if (sws_init_context(m_objSwsCtx, nullptr, nullptr) < 0)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::RenderStream cannont init video data converter";
|
qDebug() << "DATVideoProcess::RenderStream cannont init video data converter";
|
||||||
|
m_objSwsCtx=nullptr;
|
||||||
m_objSwsCtx=NULL;
|
|
||||||
|
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_intCurrentRenderHeight>0) && (m_intCurrentRenderWidth>0))
|
if ((m_intCurrentRenderHeight>0) && (m_intCurrentRenderWidth>0))
|
||||||
{
|
{
|
||||||
//av_freep(&m_pbytDecodedData[0]);
|
//av_freep(&m_pbytDecodedData[0]);
|
||||||
//av_freep(&m_pintDecodedLineSize[0]);
|
//av_freep(&m_pintDecodedLineSize[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(av_image_alloc(m_pbytDecodedData, m_pintDecodedLineSize,m_objFrame->width, m_objFrame->height, AV_PIX_FMT_RGB24, 1)<0)
|
if (av_image_alloc(m_pbytDecodedData, m_pintDecodedLineSize,m_objFrame->width, m_objFrame->height, AV_PIX_FMT_RGB24, 1)<0)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::RenderStream cannont init video image buffer";
|
qDebug() << "DATVideoProcess::RenderStream cannont init video image buffer";
|
||||||
|
|
||||||
sws_freeContext(m_objSwsCtx);
|
sws_freeContext(m_objSwsCtx);
|
||||||
m_objSwsCtx=NULL;
|
m_objSwsCtx=nullptr;
|
||||||
|
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Rendering device setup
|
//Rendering device setup
|
||||||
|
|
||||||
resizeTVScreen(m_objFrame->width,m_objFrame->height);
|
resizeTVScreen(m_objFrame->width,m_objFrame->height);
|
||||||
update();
|
update();
|
||||||
resetImage();
|
resetImage();
|
||||||
|
|
||||||
m_intCurrentRenderWidth=m_objFrame->width;
|
m_intCurrentRenderWidth=m_objFrame->width;
|
||||||
m_intCurrentRenderHeight=m_objFrame->height;
|
m_intCurrentRenderHeight=m_objFrame->height;
|
||||||
|
|
||||||
MetaData.Width = m_objFrame->width;
|
MetaData.Width = m_objFrame->width;
|
||||||
MetaData.Height = m_objFrame->height;
|
MetaData.Height = m_objFrame->height;
|
||||||
MetaData.OK_Decoding = true;
|
MetaData.OK_Decoding = true;
|
||||||
emit onMetaDataChanged(&MetaData);
|
emit onMetaDataChanged(&MetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Frame rendering
|
//Frame rendering
|
||||||
|
|
||||||
if(sws_scale(m_objSwsCtx, m_objFrame->data, m_objFrame->linesize, 0, m_objFrame->height, m_pbytDecodedData, m_pintDecodedLineSize)<0)
|
if (sws_scale(m_objSwsCtx, m_objFrame->data, m_objFrame->linesize, 0, m_objFrame->height, m_pbytDecodedData, m_pintDecodedLineSize)<0)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::RenderStream error converting video frame to RGB";
|
qDebug() << "DATVideoProcess::RenderStream error converting video frame to RGB";
|
||||||
|
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderImage(m_pbytDecodedData[0]);
|
renderImage(m_pbytDecodedData[0]);
|
||||||
|
|
||||||
av_frame_unref(m_objFrame);
|
av_frame_unref(m_objFrame);
|
||||||
|
|
||||||
m_intFrameCount ++;
|
m_intFrameCount ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
av_packet_unref(&objPacket);
|
av_packet_unref(&objPacket);
|
||||||
@ -536,29 +488,25 @@ bool DATVideoRender::RenderStream()
|
|||||||
bool DATVideoRender::CloseStream(QIODevice *objDevice)
|
bool DATVideoRender::CloseStream(QIODevice *objDevice)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(m_blnRunning)
|
if (m_blnRunning) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!objDevice)
|
if (!objDevice)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::CloseStream QIODevice is NULL";
|
qDebug() << "DATVideoProcess::CloseStream QIODevice is nullptr";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!m_blnIsOpen)
|
if (!m_blnIsOpen)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::CloseStream Stream not open";
|
qDebug() << "DATVideoProcess::CloseStream Stream not open";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!m_objFormatCtx)
|
if (!m_objFormatCtx)
|
||||||
{
|
{
|
||||||
qDebug() << "DATVideoProcess::CloseStream FFMEG Context is not initialized";
|
qDebug() << "DATVideoProcess::CloseStream FFMEG Context is not initialized";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,32 +515,29 @@ bool DATVideoRender::CloseStream(QIODevice *objDevice)
|
|||||||
|
|
||||||
// maybe done in the avcodec_close
|
// maybe done in the avcodec_close
|
||||||
// avformat_close_input(&m_objFormatCtx);
|
// avformat_close_input(&m_objFormatCtx);
|
||||||
// m_objFormatCtx=NULL;
|
// m_objFormatCtx=nullptr;
|
||||||
|
|
||||||
if(m_objDecoderCtx)
|
if (m_objDecoderCtx)
|
||||||
{
|
{
|
||||||
avcodec_close(m_objDecoderCtx);
|
avcodec_close(m_objDecoderCtx);
|
||||||
m_objDecoderCtx=NULL;
|
m_objDecoderCtx = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_objFrame)
|
if (m_objFrame)
|
||||||
{
|
{
|
||||||
av_frame_unref(m_objFrame);
|
av_frame_unref(m_objFrame);
|
||||||
av_frame_free(&m_objFrame);
|
av_frame_free(&m_objFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_objSwsCtx!=NULL)
|
if (m_objSwsCtx != nullptr)
|
||||||
{
|
{
|
||||||
sws_freeContext(m_objSwsCtx);
|
sws_freeContext(m_objSwsCtx);
|
||||||
m_objSwsCtx=NULL;
|
m_objSwsCtx = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
objDevice->close();
|
objDevice->close();
|
||||||
|
|
||||||
m_blnIsOpen=false;
|
m_blnIsOpen=false;
|
||||||
|
|
||||||
m_blnRunning=false;
|
m_blnRunning=false;
|
||||||
|
|
||||||
m_intCurrentRenderWidth=-1;
|
m_intCurrentRenderWidth=-1;
|
||||||
m_intCurrentRenderHeight=-1;
|
m_intCurrentRenderHeight=-1;
|
||||||
|
|
||||||
@ -612,19 +557,25 @@ int DATVideoRender::new_decode(AVCodecContext *avctx, AVFrame *frame, int *got_f
|
|||||||
|
|
||||||
*got_frame = 0;
|
*got_frame = 0;
|
||||||
|
|
||||||
if (pkt) {
|
if (pkt)
|
||||||
|
{
|
||||||
ret = avcodec_send_packet(avctx, pkt);
|
ret = avcodec_send_packet(avctx, pkt);
|
||||||
// In particular, we don't expect AVERROR(EAGAIN), because we read all
|
// In particular, we don't expect AVERROR(EAGAIN), because we read all
|
||||||
// decoded frames with avcodec_receive_frame() until done.
|
// decoded frames with avcodec_receive_frame() until done.
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
return ret == AVERROR_EOF ? 0 : ret;
|
return ret == AVERROR_EOF ? 0 : ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = avcodec_receive_frame(avctx, frame);
|
ret = avcodec_receive_frame(avctx, frame);
|
||||||
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
|
|
||||||
|
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
|
||||||
return ret;
|
return ret;
|
||||||
if (ret >= 0)
|
}
|
||||||
|
|
||||||
|
if (ret >= 0) {
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -66,22 +66,17 @@ struct DataTSMetaData2
|
|||||||
{
|
{
|
||||||
PID=-1;
|
PID=-1;
|
||||||
CodecID=-1;
|
CodecID=-1;
|
||||||
|
|
||||||
|
|
||||||
Program="";
|
Program="";
|
||||||
Stream="";
|
Stream="";
|
||||||
|
|
||||||
Width=-1;
|
Width=-1;
|
||||||
Height=-1;
|
Height=-1;
|
||||||
BitRate=-1;
|
BitRate=-1;
|
||||||
Channels=-1;
|
Channels=-1;
|
||||||
CodecDescription="";
|
CodecDescription="";
|
||||||
|
|
||||||
OK_Data=false;
|
OK_Data=false;
|
||||||
OK_Decoding=false;
|
OK_Decoding=false;
|
||||||
OK_TransportStream=false;
|
OK_TransportStream=false;
|
||||||
OK_VideoStream=false;
|
OK_VideoStream=false;
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -131,18 +126,16 @@ protected:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void onMetaDataChanged(DataTSMetaData2 *objMetaData);
|
void onMetaDataChanged(DataTSMetaData2 *objMetaData);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//To run Video Rendering with a dedicated thread
|
//To run Video Rendering with a dedicated thread
|
||||||
class DATVideoRenderThread: public QThread
|
class DATVideoRenderThread: public QThread
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DATVideoRenderThread()
|
DATVideoRenderThread()
|
||||||
{
|
{
|
||||||
m_objRenderer = NULL;
|
m_objRenderer = nullptr;
|
||||||
m_objStream = NULL;
|
m_objStream = nullptr;
|
||||||
m_blnRenderingVideo=false;
|
m_blnRenderingVideo=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,31 +155,25 @@ class DATVideoRenderThread: public QThread
|
|||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
if(m_blnRenderingVideo)
|
if (m_blnRenderingVideo) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_objRenderer==NULL) || (m_objStream==NULL))
|
if ((m_objRenderer==nullptr) || (m_objStream==nullptr)) {
|
||||||
{
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_blnRenderingVideo = m_objRenderer->OpenStream(m_objStream);
|
m_blnRenderingVideo = m_objRenderer->OpenStream(m_objStream);
|
||||||
|
|
||||||
if(!m_blnRenderingVideo)
|
if (!m_blnRenderingVideo) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while((m_objRenderer->RenderStream()) && (m_blnRenderingVideo==true))
|
while ((m_objRenderer->RenderStream()) && (m_blnRenderingVideo == true)) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_objRenderer->CloseStream(m_objStream);
|
m_objRenderer->CloseStream(m_objStream);
|
||||||
|
|
||||||
m_blnRenderingVideo=false;
|
m_blnRenderingVideo=false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopRendering()
|
void stopRendering()
|
||||||
|
@ -22,11 +22,11 @@ DATVideostream::DATVideostream():
|
|||||||
m_objMutex(QMutex::NonRecursive)
|
m_objMutex(QMutex::NonRecursive)
|
||||||
{
|
{
|
||||||
cleanUp();
|
cleanUp();
|
||||||
m_intTotalReceived=0;
|
m_intTotalReceived = 0;
|
||||||
m_intPacketReceived=0;
|
m_intPacketReceived = 0;
|
||||||
m_intMemoryLimit = DefaultMemoryLimit;
|
m_intMemoryLimit = DefaultMemoryLimit;
|
||||||
MultiThreaded=false;
|
MultiThreaded = false;
|
||||||
ThreadTimeOut=-1;
|
ThreadTimeOut = -1;
|
||||||
|
|
||||||
m_objeventLoop.connect(this,SIGNAL(onDataAvailable()), &m_objeventLoop, SLOT(quit()),Qt::QueuedConnection);
|
m_objeventLoop.connect(this,SIGNAL(onDataAvailable()), &m_objeventLoop, SLOT(quit()),Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
@ -39,72 +39,65 @@ DATVideostream::~DATVideostream()
|
|||||||
|
|
||||||
void DATVideostream::cleanUp()
|
void DATVideostream::cleanUp()
|
||||||
{
|
{
|
||||||
if(m_objFIFO.size()>0)
|
if (m_objFIFO.size() > 0) {
|
||||||
{
|
|
||||||
m_objFIFO.clear();
|
m_objFIFO.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_objeventLoop.isRunning())
|
if (m_objeventLoop.isRunning()) {
|
||||||
{
|
|
||||||
m_objeventLoop.exit();
|
m_objeventLoop.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_intBytesAvailable=0;
|
m_intBytesAvailable = 0;
|
||||||
m_intBytesWaiting=0;
|
m_intBytesWaiting = 0;
|
||||||
m_intQueueWaiting=0;
|
m_intQueueWaiting = 0;
|
||||||
m_intPercentBuffer=0;
|
m_intPercentBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DATVideostream::setMemoryLimit(int intMemoryLimit)
|
bool DATVideostream::setMemoryLimit(int intMemoryLimit)
|
||||||
{
|
{
|
||||||
if(intMemoryLimit<=0)
|
if (intMemoryLimit <= 0) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_intMemoryLimit=intMemoryLimit;
|
m_intMemoryLimit = intMemoryLimit;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DATVideostream::pushData(const char * chrData, int intSize)
|
int DATVideostream::pushData(const char * chrData, int intSize)
|
||||||
{
|
{
|
||||||
if(intSize<=0)
|
if (intSize <= 0) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_objMutex.lock();
|
m_objMutex.lock();
|
||||||
|
|
||||||
m_intPacketReceived ++;
|
m_intPacketReceived++;
|
||||||
|
|
||||||
m_intBytesWaiting += intSize;
|
m_intBytesWaiting += intSize;
|
||||||
if(m_intBytesWaiting>m_intMemoryLimit)
|
|
||||||
{
|
if (m_intBytesWaiting > m_intMemoryLimit) {
|
||||||
m_intBytesWaiting -= m_objFIFO.dequeue().size();
|
m_intBytesWaiting -= m_objFIFO.dequeue().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_objFIFO.enqueue(QByteArray(chrData,intSize));
|
m_objFIFO.enqueue(QByteArray(chrData,intSize));
|
||||||
m_intBytesAvailable = m_objFIFO.head().size();
|
m_intBytesAvailable = m_objFIFO.head().size();
|
||||||
m_intTotalReceived += intSize;
|
m_intTotalReceived += intSize;
|
||||||
|
|
||||||
m_intQueueWaiting=m_objFIFO.count();
|
m_intQueueWaiting=m_objFIFO.count();
|
||||||
|
|
||||||
m_objMutex.unlock();
|
m_objMutex.unlock();
|
||||||
|
|
||||||
if((m_objeventLoop.isRunning())
|
if ((m_objeventLoop.isRunning())
|
||||||
&& (m_intQueueWaiting>=MinStackSize))
|
&& (m_intQueueWaiting >= MinStackSize))
|
||||||
{
|
{
|
||||||
emit onDataAvailable();
|
emit onDataAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_intPacketReceived%MinStackSize==1)
|
if (m_intPacketReceived % MinStackSize == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_intPercentBuffer = (100*m_intBytesWaiting)/m_intMemoryLimit;
|
m_intPercentBuffer = (100*m_intBytesWaiting)/m_intMemoryLimit;
|
||||||
if(m_intPercentBuffer>100)
|
|
||||||
{
|
if (m_intPercentBuffer > 100) {
|
||||||
m_intPercentBuffer=100;
|
m_intPercentBuffer = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit onDataPackets(&m_intQueueWaiting, &m_intBytesWaiting, &m_intPercentBuffer, &m_intTotalReceived);
|
emit onDataPackets(&m_intQueueWaiting, &m_intBytesWaiting, &m_intPercentBuffer, &m_intTotalReceived);
|
||||||
@ -140,42 +133,39 @@ bool DATVideostream::open(OpenMode mode)
|
|||||||
qint64 DATVideostream::readData(char *data, qint64 len)
|
qint64 DATVideostream::readData(char *data, qint64 len)
|
||||||
{
|
{
|
||||||
QByteArray objCurrentArray;
|
QByteArray objCurrentArray;
|
||||||
int intEffectiveLen=0;
|
int intEffectiveLen = 0;
|
||||||
int intExpectedLen=0;
|
int intExpectedLen = 0;
|
||||||
int intThreadLoop=0;
|
int intThreadLoop = 0;
|
||||||
|
|
||||||
intExpectedLen = (int) len;
|
intExpectedLen = (int) len;
|
||||||
|
|
||||||
if(intExpectedLen<=0)
|
if (intExpectedLen <= 0) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_objeventLoop.isRunning())
|
if (m_objeventLoop.isRunning()) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_objMutex.lock();
|
m_objMutex.lock();
|
||||||
|
|
||||||
//DATA in FIFO ? -> Waiting for DATA
|
//DATA in FIFO ? -> Waiting for DATA
|
||||||
if((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
|
if ((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
|
||||||
{
|
{
|
||||||
m_objMutex.unlock();
|
m_objMutex.unlock();
|
||||||
|
|
||||||
if(MultiThreaded==true)
|
if (MultiThreaded == true)
|
||||||
{
|
{
|
||||||
|
|
||||||
intThreadLoop=0;
|
intThreadLoop=0;
|
||||||
while((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
|
|
||||||
|
while ((m_objFIFO.isEmpty()) || (m_objFIFO.count() < MinStackSize))
|
||||||
{
|
{
|
||||||
QThread::msleep(5);
|
QThread::msleep(5);
|
||||||
intThreadLoop ++;
|
intThreadLoop++;
|
||||||
|
|
||||||
if(ThreadTimeOut>=0)
|
if (ThreadTimeOut >= 0)
|
||||||
{
|
{
|
||||||
if(intThreadLoop*5>ThreadTimeOut)
|
if (intThreadLoop*5 > ThreadTimeOut) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,13 +182,13 @@ qint64 DATVideostream::readData(char *data, qint64 len)
|
|||||||
//Read DATA
|
//Read DATA
|
||||||
intEffectiveLen=m_objFIFO.head().size();
|
intEffectiveLen=m_objFIFO.head().size();
|
||||||
|
|
||||||
if(intExpectedLen<intEffectiveLen)
|
if (intExpectedLen < intEffectiveLen)
|
||||||
{
|
{
|
||||||
//Partial Read
|
//Partial Read
|
||||||
objCurrentArray = m_objFIFO.head();
|
objCurrentArray = m_objFIFO.head();
|
||||||
memcpy((void *)data,objCurrentArray.constData(),intExpectedLen);
|
memcpy((void *)data,objCurrentArray.constData(),intExpectedLen);
|
||||||
m_objFIFO.head().remove(0,intExpectedLen);
|
m_objFIFO.head().remove(0,intExpectedLen);
|
||||||
intEffectiveLen=intExpectedLen;
|
intEffectiveLen = intExpectedLen;
|
||||||
m_intBytesWaiting -= intExpectedLen;
|
m_intBytesWaiting -= intExpectedLen;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -210,7 +200,7 @@ qint64 DATVideostream::readData(char *data, qint64 len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_intQueueWaiting = m_objFIFO.count();
|
m_intQueueWaiting = m_objFIFO.count();
|
||||||
m_intPercentBuffer = (100*m_intBytesWaiting)/m_intMemoryLimit;
|
m_intPercentBuffer = (100*m_intBytesWaiting) / m_intMemoryLimit;
|
||||||
|
|
||||||
emit onDataPackets(&m_intQueueWaiting, &m_intBytesWaiting, &m_intPercentBuffer, &m_intTotalReceived);
|
emit onDataPackets(&m_intQueueWaiting, &m_intBytesWaiting, &m_intPercentBuffer, &m_intTotalReceived);
|
||||||
|
|
||||||
|
@ -23,18 +23,21 @@
|
|||||||
|
|
||||||
namespace leansdr
|
namespace leansdr
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename T> struct datvvideoplayer: runnable
|
template<typename T> struct datvvideoplayer: runnable
|
||||||
{
|
{
|
||||||
datvvideoplayer(scheduler *sch, pipebuf<T> &_in, DATVideostream * objVideoStream) :
|
datvvideoplayer(scheduler *sch, pipebuf<T> &_in, DATVideostream * objVideoStream) :
|
||||||
runnable(sch, _in.name), in(_in), m_objVideoStream(objVideoStream)
|
runnable(sch, _in.name), in(_in), m_objVideoStream(objVideoStream)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
int size = in.readable() * sizeof(T);
|
int size = in.readable() * sizeof(T);
|
||||||
if (!size)
|
|
||||||
|
if (!size) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int nw = m_objVideoStream->pushData((const char *) in.rd(), size);
|
int nw = m_objVideoStream->pushData((const char *) in.rd(), size);
|
||||||
|
|
||||||
@ -43,18 +46,22 @@ template<typename T> struct datvvideoplayer: runnable
|
|||||||
fatal("leansdr::datvvideoplayer::run: pipe");
|
fatal("leansdr::datvvideoplayer::run: pipe");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nw < 0)
|
if (nw < 0)
|
||||||
{
|
{
|
||||||
fatal("leansdr::datvvideoplayer::run: write");
|
fatal("leansdr::datvvideoplayer::run: write");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nw % sizeof(T))
|
if (nw % sizeof(T))
|
||||||
{
|
{
|
||||||
fatal("leansdr::datvvideoplayer::run: partial write");
|
fatal("leansdr::datvvideoplayer::run: partial write");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
in.read(nw / sizeof(T));
|
in.read(nw / sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pipereader<T> in;
|
pipereader<T> in;
|
||||||
DATVideostream * m_objVideoStream;
|
DATVideostream * m_objVideoStream;
|
||||||
|
Loading…
Reference in New Issue
Block a user