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.
datvvideoplayer.h
Go to the documentation of this file.
1 // Copyright (C) 2018 F4HKW //
3 // for F4EXB / SDRAngel //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef DATVVIDEOPLAYER_H
20 #define DATVVIDEOPLAYER_H
21 
22 #include "leansdr/framework.h"
23 #include "datvideostream.h"
24 #include "datvudpstream.h"
25 
26 namespace leansdr
27 {
28 
29 template<typename T> struct datvvideoplayer: runnable
30 {
32  scheduler *sch,
33  pipebuf<T> &_in,
34  DATVideostream *objVideoStream,
35  DATVUDPStream *udpStream) :
36  runnable(sch, _in.name),
37  in(_in),
38  m_objVideoStream(objVideoStream),
39  m_udpStream(udpStream)
40  {
41  }
42 
43  void run()
44  {
45  int size = in.readable() * sizeof(T);
46 
47  if (!size) {
48  return;
49  }
50 
51  m_udpStream->pushData((const char *) in.rd(), in.readable());
52  int nw = m_objVideoStream->pushData((const char *) in.rd(), size);
53 
54  if (!nw)
55  {
56  fatal("leansdr::datvvideoplayer::run: pipe");
57  return;
58  }
59 
60  if (nw < 0)
61  {
62  fatal("leansdr::datvvideoplayer::run: write");
63  return;
64  }
65 
66  if (nw % sizeof(T))
67  {
68  fatal("leansdr::datvvideoplayer::run: partial write");
69  return;
70  }
71 
72  if (nw != size) {
73  fprintf(stderr, "leansdr::datvvideoplayer::run: nw: %d size: %d\n", nw, size);
74  }
75 
76  in.read(nw / sizeof(T));
77  }
78 
79 private:
83 };
84 
85 }
86 
87 #endif // DATVVIDEOPLAYER_H
DATVideostream * m_objVideoStream
DATVUDPStream * m_udpStream
int pushData(const char *chrData, int intSize)
void fatal(const char *s)
Definition: framework.cpp:6
void pushData(const char *chrData, int nbTSBlocks)
scheduler * sch
Definition: framework.h:199
datvvideoplayer(scheduler *sch, pipebuf< T > &_in, DATVideostream *objVideoStream, DATVUDPStream *udpStream)