1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-27 02:09:14 -05:00
sdrangel/plugins/channelrx/demoddatv/datvvideoplayer.h

74 lines
2.4 KiB
C
Raw Normal View History

2018-02-22 16:52:49 -05:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 F4HKW //
// for F4EXB / SDRAngel //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
2019-04-11 00:39:30 -04:00
// (at your option) any later version. //
2018-02-22 16:52:49 -05:00
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef DATVVIDEOPLAYER_H
#define DATVVIDEOPLAYER_H
#include "leansdr/framework.h"
#include "datvideostream.h"
namespace leansdr
{
2019-03-16 20:36:44 -04:00
2018-02-25 19:04:45 -05:00
template<typename T> struct datvvideoplayer: runnable
{
datvvideoplayer(scheduler *sch, pipebuf<T> &_in, DATVideostream * objVideoStream) :
2019-03-16 20:36:44 -04:00
runnable(sch, _in.name), in(_in), m_objVideoStream(objVideoStream)
2018-02-22 16:52:49 -05:00
{
2018-02-25 19:04:45 -05:00
}
2018-02-22 16:52:49 -05:00
2018-02-25 19:04:45 -05:00
void run()
{
int size = in.readable() * sizeof(T);
2019-03-16 20:36:44 -04:00
if (!size) {
2018-02-25 19:04:45 -05:00
return;
2019-03-16 20:36:44 -04:00
}
2018-02-22 16:52:49 -05:00
2018-02-25 19:04:45 -05:00
int nw = m_objVideoStream->pushData((const char *) in.rd(), size);
2018-02-22 16:52:49 -05:00
2018-02-25 19:04:45 -05:00
if (!nw)
{
fatal("leansdr::datvvideoplayer::run: pipe");
return;
}
2019-03-16 20:36:44 -04:00
2018-02-25 19:04:45 -05:00
if (nw < 0)
{
fatal("leansdr::datvvideoplayer::run: write");
return;
}
2019-03-16 20:36:44 -04:00
2018-02-25 19:04:45 -05:00
if (nw % sizeof(T))
{
fatal("leansdr::datvvideoplayer::run: partial write");
return;
}
2019-03-16 20:36:44 -04:00
2018-02-25 19:04:45 -05:00
in.read(nw / sizeof(T));
}
2019-03-16 20:36:44 -04:00
2018-02-25 19:04:45 -05:00
private:
pipereader<T> in;
DATVideostream * m_objVideoStream;
};
2018-02-22 16:52:49 -05:00
}
#endif // DATVVIDEOPLAYER_H