SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Signals | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
DATVideostream Class Reference

#include <datvideostream.h>

Inherits QIODevice.

Signals

void onDataAvailable ()
 
void onDataPackets (int *intDataPackets, int *intDataBytes, int *intPercentBuffer, qint64 *intTotalReceived)
 

Public Member Functions

 DATVideostream ()
 
 ~DATVideostream ()
 
int pushData (const char *chrData, int intSize)
 
bool setMemoryLimit (int intMemoryLimit)
 
virtual bool isSequential () const
 
virtual qint64 bytesAvailable () const
 
virtual void close ()
 
virtual bool open (OpenMode mode)
 

Public Attributes

bool MultiThreaded
 
int ThreadTimeOut
 
QQueue< QByteArray > m_objFIFO
 

Protected Member Functions

virtual qint64 readData (char *data, qint64 len)
 
virtual qint64 writeData (const char *data, qint64 len)
 
virtual qint64 readLineData (char *data, qint64 maxSize)
 

Private Member Functions

void cleanUp ()
 

Private Attributes

QEventLoop m_objeventLoop
 
QMutex m_objMutex
 
int m_intMemoryLimit
 
int m_intBytesAvailable
 
int m_intBytesWaiting
 
int m_intQueueWaiting
 
int m_intPercentBuffer
 
qint64 m_intTotalReceived
 
qint64 m_intPacketReceived
 

Detailed Description

Definition at line 32 of file datvideostream.h.

Constructor & Destructor Documentation

◆ DATVideostream()

DATVideostream::DATVideostream ( )

Definition at line 22 of file datvideostream.cpp.

References cleanUp(), DefaultMemoryLimit, m_intMemoryLimit, m_intPacketReceived, m_intTotalReceived, m_objeventLoop, MultiThreaded, onDataAvailable(), and ThreadTimeOut.

22  :
23  m_objMutex(QMutex::NonRecursive)
24 {
25  cleanUp();
29  MultiThreaded = false;
30  ThreadTimeOut = -1;
31 
32  m_objeventLoop.connect(this,SIGNAL(onDataAvailable()), &m_objeventLoop, SLOT(quit()),Qt::QueuedConnection);
33 }
QEventLoop m_objeventLoop
qint64 m_intTotalReceived
void onDataAvailable()
qint64 m_intPacketReceived
#define DefaultMemoryLimit
+ Here is the call graph for this function:

◆ ~DATVideostream()

DATVideostream::~DATVideostream ( )

Definition at line 35 of file datvideostream.cpp.

References cleanUp(), m_objeventLoop, and onDataAvailable().

36 {
37  m_objeventLoop.disconnect(this,SIGNAL(onDataAvailable()), &m_objeventLoop, SLOT(quit()));
38  cleanUp();
39 }
QEventLoop m_objeventLoop
void onDataAvailable()
+ Here is the call graph for this function:

Member Function Documentation

◆ bytesAvailable()

qint64 DATVideostream::bytesAvailable ( ) const
virtual

Definition at line 115 of file datvideostream.cpp.

References m_intBytesAvailable.

Referenced by DATVideoRender::OpenStream(), and DATVDemod::PlayVideo().

116 {
117  return m_intBytesAvailable;
118 }
+ Here is the caller graph for this function:

◆ cleanUp()

void DATVideostream::cleanUp ( )
private

Definition at line 41 of file datvideostream.cpp.

References m_intBytesAvailable, m_intBytesWaiting, m_intPercentBuffer, m_intQueueWaiting, m_objeventLoop, and m_objFIFO.

Referenced by close(), DATVideostream(), and ~DATVideostream().

42 {
43  if (m_objFIFO.size() > 0) {
44  m_objFIFO.clear();
45  }
46 
47  if (m_objeventLoop.isRunning()) {
48  m_objeventLoop.exit();
49  }
50 
55 }
QEventLoop m_objeventLoop
QQueue< QByteArray > m_objFIFO
+ Here is the caller graph for this function:

◆ close()

void DATVideostream::close ( )
virtual

Definition at line 120 of file datvideostream.cpp.

References cleanUp().

121 {
122  QIODevice::close();
123  cleanUp();
124 }
+ Here is the call graph for this function:

◆ isSequential()

bool DATVideostream::isSequential ( ) const
virtual

Definition at line 110 of file datvideostream.cpp.

111 {
112  return true;
113 }

◆ onDataAvailable

void DATVideostream::onDataAvailable ( )
signal

Referenced by DATVideostream(), pushData(), and ~DATVideostream().

+ Here is the caller graph for this function:

◆ onDataPackets

void DATVideostream::onDataPackets ( int *  intDataPackets,
int *  intDataBytes,
int *  intPercentBuffer,
qint64 *  intTotalReceived 
)
signal

Referenced by DATVDemodGUI::DATVDemodGUI(), pushData(), and readData().

+ Here is the caller graph for this function:

◆ open()

bool DATVideostream::open ( OpenMode  mode)
virtual

Definition at line 126 of file datvideostream.cpp.

Referenced by DATVideoRender::OpenStream().

127 {
128  //cleanUp();
129  return QIODevice::open(mode);
130 }
+ Here is the caller graph for this function:

◆ pushData()

int DATVideostream::pushData ( const char *  chrData,
int  intSize 
)

Definition at line 68 of file datvideostream.cpp.

References m_intBytesAvailable, m_intBytesWaiting, m_intMemoryLimit, m_intPacketReceived, m_intPercentBuffer, m_intQueueWaiting, m_intTotalReceived, m_objeventLoop, m_objFIFO, m_objMutex, MinStackSize, onDataAvailable(), and onDataPackets().

Referenced by leansdr::datvvideoplayer< leansdr::tspacket >::run().

69 {
70  if (intSize <= 0) {
71  return 0;
72  }
73 
74  m_objMutex.lock();
75 
77  m_intBytesWaiting += intSize;
78 
80  m_intBytesWaiting -= m_objFIFO.dequeue().size();
81  }
82 
83  m_objFIFO.enqueue(QByteArray(chrData,intSize));
84  m_intBytesAvailable = m_objFIFO.head().size();
85  m_intTotalReceived += intSize;
87 
88  m_objMutex.unlock();
89 
90  if ((m_objeventLoop.isRunning())
92  {
93  emit onDataAvailable();
94  }
95 
97  {
99 
100  if (m_intPercentBuffer > 100) {
101  m_intPercentBuffer = 100;
102  }
103 
105  }
106 
107  return intSize;
108 }
QEventLoop m_objeventLoop
#define MinStackSize
QQueue< QByteArray > m_objFIFO
qint64 m_intTotalReceived
void onDataAvailable()
qint64 m_intPacketReceived
void onDataPackets(int *intDataPackets, int *intDataBytes, int *intPercentBuffer, qint64 *intTotalReceived)
+ Here is the caller graph for this function:

◆ readData()

qint64 DATVideostream::readData ( char *  data,
qint64  len 
)
protectedvirtual

Definition at line 134 of file datvideostream.cpp.

References m_intBytesAvailable, m_intBytesWaiting, m_intMemoryLimit, m_intPercentBuffer, m_intQueueWaiting, m_intTotalReceived, m_objeventLoop, m_objFIFO, m_objMutex, MinStackSize, MultiThreaded, onDataPackets(), and ThreadTimeOut.

135 {
136  QByteArray objCurrentArray;
137  int intEffectiveLen = 0;
138  int intExpectedLen = 0;
139  int intThreadLoop = 0;
140 
141  intExpectedLen = (int) len;
142 
143  if (intExpectedLen <= 0) {
144  return 0;
145  }
146 
147  if (m_objeventLoop.isRunning()) {
148  return 0;
149  }
150 
151  m_objMutex.lock();
152 
153  //DATA in FIFO ? -> Waiting for DATA
154  if ((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
155  {
156  m_objMutex.unlock();
157 
158  if (MultiThreaded == true)
159  {
160  intThreadLoop=0;
161 
162  while ((m_objFIFO.isEmpty()) || (m_objFIFO.count() < MinStackSize))
163  {
164  QThread::msleep(5);
165  intThreadLoop++;
166 
167  if (ThreadTimeOut >= 0)
168  {
169  if (intThreadLoop*5 > ThreadTimeOut) {
170  return -1;
171  }
172  }
173  }
174  }
175  else
176  {
177  m_objeventLoop.exec();
178  }
179 
180  m_objMutex.lock();
181  }
182 
183  //Read DATA
184  intEffectiveLen=m_objFIFO.head().size();
185 
186  if (intExpectedLen < intEffectiveLen)
187  {
188  //Partial Read
189  objCurrentArray = m_objFIFO.head();
190  memcpy((void *)data,objCurrentArray.constData(),intExpectedLen);
191  m_objFIFO.head().remove(0,intExpectedLen);
192  intEffectiveLen = intExpectedLen;
193  m_intBytesWaiting -= intExpectedLen;
194  }
195  else
196  {
197  //Complete Read
198  objCurrentArray = m_objFIFO.dequeue();
199  memcpy((void *)data,objCurrentArray.constData(),intEffectiveLen);
200  m_intBytesWaiting -= intEffectiveLen;
201  }
202 
203  m_intQueueWaiting = m_objFIFO.count();
205 
207 
208  //Next available DATA
209  m_intBytesAvailable = m_objFIFO.head().size();
210 
211  m_objMutex.unlock();
212 
213  return (qint64)intEffectiveLen;
214 }
QEventLoop m_objeventLoop
#define MinStackSize
QQueue< QByteArray > m_objFIFO
qint64 m_intTotalReceived
void onDataPackets(int *intDataPackets, int *intDataBytes, int *intPercentBuffer, qint64 *intTotalReceived)

◆ readLineData()

qint64 DATVideostream::readLineData ( char *  data,
qint64  maxSize 
)
protectedvirtual

Definition at line 223 of file datvideostream.cpp.

224 {
225  (void) data;
226  (void) maxSize;
227  return 0;
228 }

◆ setMemoryLimit()

bool DATVideostream::setMemoryLimit ( int  intMemoryLimit)

Definition at line 57 of file datvideostream.cpp.

References m_intMemoryLimit.

58 {
59  if (intMemoryLimit <= 0) {
60  return false;
61  }
62 
63  m_intMemoryLimit = intMemoryLimit;
64 
65  return true;
66 }

◆ writeData()

qint64 DATVideostream::writeData ( const char *  data,
qint64  len 
)
protectedvirtual

Definition at line 216 of file datvideostream.cpp.

217 {
218  (void) data;
219  (void) len;
220  return 0;
221 }

Member Data Documentation

◆ m_intBytesAvailable

int DATVideostream::m_intBytesAvailable
private

Definition at line 69 of file datvideostream.h.

Referenced by bytesAvailable(), cleanUp(), pushData(), and readData().

◆ m_intBytesWaiting

int DATVideostream::m_intBytesWaiting
private

Definition at line 70 of file datvideostream.h.

Referenced by cleanUp(), pushData(), and readData().

◆ m_intMemoryLimit

int DATVideostream::m_intMemoryLimit
private

Definition at line 68 of file datvideostream.h.

Referenced by DATVideostream(), pushData(), readData(), and setMemoryLimit().

◆ m_intPacketReceived

qint64 DATVideostream::m_intPacketReceived
private

Definition at line 74 of file datvideostream.h.

Referenced by DATVideostream(), and pushData().

◆ m_intPercentBuffer

int DATVideostream::m_intPercentBuffer
private

Definition at line 72 of file datvideostream.h.

Referenced by cleanUp(), pushData(), and readData().

◆ m_intQueueWaiting

int DATVideostream::m_intQueueWaiting
private

Definition at line 71 of file datvideostream.h.

Referenced by cleanUp(), pushData(), and readData().

◆ m_intTotalReceived

qint64 DATVideostream::m_intTotalReceived
private

Definition at line 73 of file datvideostream.h.

Referenced by DATVideostream(), pushData(), and readData().

◆ m_objeventLoop

QEventLoop DATVideostream::m_objeventLoop
private

Definition at line 66 of file datvideostream.h.

Referenced by cleanUp(), DATVideostream(), pushData(), readData(), and ~DATVideostream().

◆ m_objFIFO

QQueue<QByteArray> DATVideostream::m_objFIFO

Definition at line 51 of file datvideostream.h.

Referenced by cleanUp(), pushData(), and readData().

◆ m_objMutex

QMutex DATVideostream::m_objMutex
private

Definition at line 67 of file datvideostream.h.

Referenced by pushData(), and readData().

◆ MultiThreaded

bool DATVideostream::MultiThreaded

Definition at line 40 of file datvideostream.h.

Referenced by DATVideostream(), DATVDemod::PlayVideo(), and readData().

◆ ThreadTimeOut

int DATVideostream::ThreadTimeOut

The documentation for this class was generated from the following files: