MythTV  master
MythExternRecApp.h
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  *
3  * Copyright (C) John Poet 2018
4  *
5  * This file is part of MythTV
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _MythTVExternRecApp_H_
22 #define _MythTVExternRecApp_H_
23 
24 #include <QObject>
25 #include <QtCore/QtCore>
26 
27 #include <atomic>
28 #include <condition_variable>
29 
30 class MythExternControl;
31 
32 class MythExternRecApp : public QObject
33 {
34  Q_OBJECT
35 
36  public:
37  MythExternRecApp(QString command, QString conf_file,
38  QString log_file, QString logging);
39  ~MythExternRecApp(void) override;
40 
41  bool Open(void);
42  void Run(void);
43 
44  QString Desc(void) const;
45  void MythLog(const QString & msg)
46  { SendMessage("", "0", QString("STATUS:%1").arg(msg)); }
47  void SetErrorMsg(const QString & msg) { emit ErrorMessage(msg); }
48 
49  signals:
50  void SetDescription(const QString & desc);
51  void SendMessage(const QString & func, const QString & serial,
52  const QString & msg);
53  void ErrorMessage(const QString & msg);
54  void Opened(void);
55  void Done(void);
56  void Streaming(bool val);
57  void Fill(const QByteArray & buffer);
58 
59  public slots:
60  void ProcStarted(void);
61  void ProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
62  void ProcStateChanged(QProcess::ProcessState newState);
63  void ProcError(QProcess::ProcessError error);
64  void ProcReadStandardError(void);
65  void ProcReadStandardOutput(void);
66 
67  void Close(void);
68  void StartStreaming(const QString & serial);
69  void StopStreaming(const QString & serial, bool silent);
70  void LockTimeout(const QString & serial);
71  void HasTuner(const QString & serial);
72  void LoadChannels(const QString & serial);
73  void FirstChannel(const QString & serial);
74  void NextChannel(const QString & serial);
75 
76  void TuneChannel(const QString & serial, const QString & channum);
77  void HasPictureAttributes(const QString & serial);
78  void SetBlockSize(const QString & serial, int blksz);
79 
80  protected:
81  void GetChannel(const QString & serial, const QString & func);
82  void TerminateProcess(void);
83 
84  private:
85  bool config(void);
86 
87  bool m_fatal { false };
88 
89  std::atomic<bool> m_run { true };
90  std::condition_variable m_runCond;
91  std::mutex m_runMutex;
92  std::atomic<bool> m_streaming { false };
93  int m_result { 0 };
94 
95  uint m_bufferMax { 188 * 10000 };
97 
98  QProcess m_proc;
99  QString m_command;
100 
101  QString m_recCommand;
102  QString m_recDesc;
103 
104  QMap<QString, QString> m_appEnv;
105 
106  QString m_tuneCommand;
107  QString m_channelsIni;
109 
110  QString m_scanCommand;
111  uint m_scanTimeout { 120000 };
112 
113  QString m_logFile;
114  QString m_logging;
115  QString m_configIni;
116  QString m_desc;
117 
118  bool m_tuned { false };
119 
120  // Channel scanning
121  QSettings *m_chanSettings { nullptr };
122  QStringList m_channels;
123  int m_channelIdx { -1 };
124 
125 };
126 
127 #endif
void ProcReadStandardOutput(void)
QSettings * m_chanSettings
unsigned int slots[4]
Definition: element.c:38
void ErrorMessage(const QString &msg)
void NextChannel(const QString &serial)
static void error(const char *str,...)
Definition: vbi.c:42
void ProcError(QProcess::ProcessError error)
void FirstChannel(const QString &serial)
~MythExternRecApp(void) override
void TerminateProcess(void)
void SendMessage(const QString &func, const QString &serial, const QString &msg)
QString Desc(void) const
QMap< QString, QString > m_appEnv
std::condition_variable m_runCond
void StartStreaming(const QString &serial)
void HasTuner(const QString &serial)
void Fill(const QByteArray &buffer)
void ProcStateChanged(QProcess::ProcessState newState)
void Streaming(bool val)
MythExternRecApp(QString command, QString conf_file, QString log_file, QString logging)
void SetDescription(const QString &desc)
unsigned int uint
Definition: compat.h:140
void ProcFinished(int exitCode, QProcess::ExitStatus exitStatus)
std::mutex m_runMutex
void StopStreaming(const QString &serial, bool silent)
std::atomic< bool > m_run
void Done(void)
QStringList m_channels
void SetBlockSize(const QString &serial, int blksz)
void MythLog(const QString &msg)
void LockTimeout(const QString &serial)
void TuneChannel(const QString &serial, const QString &channum)
void HasPictureAttributes(const QString &serial)
void LoadChannels(const QString &serial)
void Opened(void)
void SetErrorMsg(const QString &msg)
std::atomic< bool > m_streaming
void GetChannel(const QString &serial, const QString &func)
void ProcReadStandardError(void)