00001 #ifndef MTD_H_ 00002 #define MTD_H_ 00003 /* 00004 mtd.h 00005 00006 (c) 2003 Thor Sigvaldason and Isaac Richards 00007 Part of the mythTV project 00008 00009 Headers for the core mtd object 00010 00011 */ 00012 00013 #include <qobject.h> 00014 #include <qptrlist.h> 00015 00016 #include "logging.h" 00017 #include "serversocket.h" 00018 #include "jobthread.h" 00019 #include "dvdprobe.h" 00020 #include "threadevents.h" 00021 00022 class QStringList; 00023 class QTimer; 00024 00025 class DiscCheckingThread : public QThread 00026 { 00027 00028 public: 00029 00030 DiscCheckingThread( MTD *owner, 00031 DVDProbe *probe, 00032 QMutex *drive_access_mutex, 00033 QMutex *mutex_for_titles); 00034 virtual void run(); 00035 bool haveDisc(){return have_disc;} 00036 bool keepGoing(); 00037 void cancelMe(bool yes_or_no){cancel_me = yes_or_no;} 00038 00039 private: 00040 00041 MTD *parent; 00042 DVDProbe *dvd_probe; 00043 bool have_disc; 00044 bool cancel_me; 00045 QMutex *dvd_drive_access; 00046 QMutex *titles_mutex; 00047 }; 00048 00049 00050 00051 class MTD : public QObject 00052 { 00053 00054 Q_OBJECT 00055 00056 // 00057 // Core logic (wait for connections, launch transcoding 00058 // threads) 00059 // 00060 00061 public: 00062 00063 MTD(int port, bool log_stdout); 00064 bool threadsShouldContinue(){return keep_running;} 00065 bool isItOkToStartTranscoding(); 00066 00067 signals: 00068 00069 void writeToLog(const QString &entry); 00070 00071 private slots: 00072 00073 void newConnection(QSocket *); 00074 void endConnection(QSocket *); 00075 void readSocket(); 00076 void parseTokens(const QStringList &tokens, QSocket *socket); 00077 void shutDown(); 00078 void sendMessage(QSocket *where, const QString &what); 00079 void sayHi(QSocket *socket); 00080 void sendStatusReport(QSocket *socket); 00081 void sendMediaReport(QSocket *socket); 00082 void startJob (const QStringList &tokens); 00083 void startAbort(const QStringList &tokens); 00084 void startDVD (const QStringList &tokens); 00085 void useDrive (const QStringList &tokens); 00086 void useDVD (const QStringList &tokens); 00087 void noDrive (const QStringList &tokens); 00088 QString noDVD (const QStringList &tokens); 00089 void forgetDVD(); 00090 void cleanThreads(); 00091 void checkDisc(); 00092 bool checkFinalFile(QFile *final_file, const QString &extension); 00093 00094 private: 00095 00096 void customEvent(QCustomEvent *ce); 00097 00098 MTDLogger *mtd_log; 00099 MTDServerSocket *server_socket; 00100 QPtrList<JobThread> job_threads; 00101 QMutex *dvd_drive_access; 00102 QMutex *titles_mutex; 00103 bool keep_running; 00104 bool have_disc; 00105 QTimer *thread_cleaning_timer; 00106 QTimer *disc_checking_timer; 00107 DVDProbe *dvd_probe; 00108 QString dvd_device; 00109 DiscCheckingThread *disc_checking_thread; 00110 int nice_level; 00111 QMutex *concurrent_transcodings_mutex; 00112 int concurrent_transcodings; 00113 int max_concurrent_transcodings; 00114 }; 00115 00116 #endif // mtd_h_ 00117
1.5.5