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);
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;
88 
89  std::atomic<bool> m_run;
90  std::condition_variable m_run_cond;
91  std::mutex m_run_mutex;
92  std::atomic<bool> m_streaming;
93  int m_result;
94 
97 
98  QProcess m_proc;
99  QString m_command;
100 
101  QString m_rec_command;
102  QString m_rec_desc;
103 
104  QMap<QString, QString> m_app_env;
105 
106  QString m_tune_command;
107  QString m_channels_ini;
109 
110  QString m_scan_command;
112 
113  QString m_log_file;
114  QString m_logging;
115  QString m_config_ini;
116  QString m_desc;
117 
118  bool m_tuned;
119 
120  // Channel scanning
121  QSettings *m_chan_settings;
122  QStringList m_channels;
124 
125 };
126 
127 #endif
void ProcReadStandardOutput(void)
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)
void TerminateProcess(void)
std::condition_variable m_run_cond
void SendMessage(const QString &func, const QString &serial, const QString &msg)
QString Desc(void) const
void StartStreaming(const QString &serial)
QSettings * m_chan_settings
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)
std::mutex m_run_mutex
unsigned int uint
Definition: compat.h:140
void ProcFinished(int exitCode, QProcess::ExitStatus exitStatus)
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)
QMap< QString, QString > m_app_env
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)