MythTV  master
v4lrecorder.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 #ifndef V4L_RECORDER_H
3 #define V4L_RECORDER_H
4 
5 #include "libmythbase/mthread.h"
6 
9 #include "libmythtv/tv.h" // for VBIMode
10 
11 class VBI608Extractor;
12 class VBIThread;
13 class TVRec;
14 
17 {
18  friend class VBIThread;
19  public:
20  explicit V4LRecorder(TVRec *rec) : DTVRecorder(rec) {}
21  ~V4LRecorder() override;
22 
23  void StopRecording(void) override; // RecorderBase
24  void SetOption(const QString &name, const QString &value) override; // DTVRecorder
25  void SetOption(const QString &name, int value) override // DTVRecorder
26  { DTVRecorder::SetOption(name, value); }
27 
28  protected:
29  int OpenVBIDevice(void);
30  void CloseVBIDevice(void);
31  void RunVBIDevice(void);
32 
33  virtual bool IsHelperRequested(void) const;
34  virtual void FormatCC(uint /*code1*/, uint /*code2*/) {}
35 
36  protected:
38  QString m_vbiDeviceName;
39  int m_vbiMode {VBIMode::None};
40  uint m_ntscVbiWidth {0};
41  uint m_ntscVbiStartLine {0};
42  uint m_ntscVbiLineCount {0};
43  VBI608Extractor *m_vbi608 {nullptr};
44  VBIThread *m_vbiThread {nullptr};
45  int m_vbiFd {-1};
46  volatile bool m_requestHelper {false};
47 };
48 
49 class VBIThread : public MThread
50 {
51  public:
52  explicit VBIThread(V4LRecorder *_parent) :
53  MThread("VBIThread"), m_parent(_parent)
54  {
55  start();
56  }
57 
58  ~VBIThread() override
59  {
60  while (isRunning())
61  {
63  wait(1s);
64  }
65  }
66 
67  void run(void) override // MThread
68  {
69  RunProlog();
71  RunEpilog();
72  }
73 
74  private:
75  V4LRecorder *m_parent {nullptr};
76 };
77 
78 #endif // V4L_RECORDER_H
VBIThread
Definition: v4lrecorder.h:49
tv.h
MThread::start
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
Definition: mthread.cpp:283
VBIMode::None
@ None
Definition: tv.h:12
dtvrecorder.h
V4LRecorder
Abstract base class for Video4Linux based recorders.
Definition: v4lrecorder.h:16
MThread::wait
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:300
VBIThread::~VBIThread
~VBIThread() override
Definition: v4lrecorder.h:58
VBI608Extractor
Definition: vbi608extractor.h:32
MThread::RunProlog
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
Definition: mthread.cpp:196
V4LRecorder::SetOption
void SetOption(const QString &name, int value) override
handles the "wait_for_seqstart" option.
Definition: v4lrecorder.h:25
cc608decoder.h
V4LRecorder::V4LRecorder
V4LRecorder(TVRec *rec)
Definition: v4lrecorder.h:20
VBIThread::run
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: v4lrecorder.h:67
V4LRecorder::StopRecording
void StopRecording(void) override
StopRecording() signals to the recorder that it should stop recording and exit cleanly.
Definition: v4lrecorder.cpp:42
MThread::RunEpilog
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
Definition: mthread.cpp:209
DTVRecorder::SetOption
void SetOption(const QString &name, const QString &value) override
Set an specific option.
Definition: dtvrecorder.cpp:91
DTVRecorder
This is a specialization of RecorderBase used to handle MPEG-2, MPEG-4, MPEG-4 AVC,...
Definition: dtvrecorder.h:26
VBIThread::m_parent
V4LRecorder * m_parent
Definition: v4lrecorder.h:75
RecorderBase::StopRecording
virtual void StopRecording(void)
StopRecording() signals to the recorder that it should stop recording and exit cleanly.
Definition: recorderbase.cpp:227
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
VBIThread::VBIThread
VBIThread(V4LRecorder *_parent)
Definition: v4lrecorder.h:52
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
mthread.h
MThread::isRunning
bool isRunning(void) const
Definition: mthread.cpp:263
V4LRecorder::FormatCC
virtual void FormatCC(uint, uint)
Definition: v4lrecorder.h:34
V4LRecorder::m_audioDeviceName
QString m_audioDeviceName
Definition: v4lrecorder.h:37
V4LRecorder::RunVBIDevice
void RunVBIDevice(void)
Definition: v4lrecorder.cpp:169
uint
unsigned int uint
Definition: freesurround.h:24
V4LRecorder::m_vbiDeviceName
QString m_vbiDeviceName
Definition: v4lrecorder.h:38