00001 #ifndef JOBTHREAD_H_
00002 #define JOBTHREAD_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <qthread.h>
00014 #include <qstringlist.h>
00015
00016 #include "fileobs.h"
00017
00018 class MTD;
00019
00020 class JobThread : public QThread
00021 {
00022
00023
00024
00025
00026
00027 public:
00028
00029 JobThread(MTD *owner, const QString &start_string, int nice_priority);
00030 virtual void run();
00031 bool keepGoing();
00032 virtual bool transcodeSlotUsed(){return false;}
00033
00034 QString getJobName();
00035 QString getSubName();
00036 double getProgress(){return overall_progress;}
00037 double getSubProgress(){return subjob_progress;}
00038
00039 void problem(const QString &a_problem);
00040 QString getProblem();
00041 QString getJobString();
00042 void updateSubjobString( int seconds_elapsed,
00043 const QString &pre_string);
00044 void cancelMe(bool yes_or_no){cancel_me = yes_or_no;}
00045 void setSubProgress(double a_value, uint priority);
00046 void setSubName(const QString &new_name, uint priority);
00047 virtual QString getFinalFileName(){return "";}
00048 void sendLoggingEvent(const QString &event_string);
00049
00050 virtual bool usesDevice(const QString &device)
00051 { return false; (void)device; }
00052
00053 protected:
00054
00055 void setJobName(const QString &jname);
00056 void setProblem(const QString &prob);
00057
00058 private:
00059
00060 QString problem_string;
00061 QString job_name;
00062 QString subjob_name;
00063 QString job_string;
00064
00065 protected:
00066
00067 double overall_progress;
00068 double subjob_progress;
00069 double sub_to_overall_multiple;
00070 MTD *parent;
00071 int nice_level;
00072 bool cancel_me;
00073
00074 QMutex subjob_progress_mutex;
00075 QMutex subjob_name_mutex;
00076 QMutex problem_string_mutex;
00077 QMutex job_name_mutex;
00078 QMutex job_string_mutex;
00079 };
00080
00081
00082 class DVDThread : public JobThread
00083 {
00084
00085
00086
00087
00088
00089
00090 public:
00091
00092 DVDThread(MTD *owner,
00093 QMutex *drive_mutex,
00094 const QString &dvd_device,
00095 int track,
00096 const QString &dest_file,
00097 const QString &name,
00098 const QString &start_string,
00099 int nice_priority);
00100
00101 ~DVDThread();
00102
00103 virtual void run();
00104 QString getFinalFileName(){return destination_file_string;}
00105 bool usesDevice(const QString &device)
00106 { return dvd_device_location.contains(device); };
00107
00108 protected:
00109
00110 bool ripTitle(int title_number,
00111 const QString &to_location,
00112 const QString &extension,
00113 bool multiple_files,
00114 QStringList *output_files = 0);
00115
00116 QMutex *dvd_device_access;
00117 QString dvd_device_location;
00118 QString destination_file_string;
00119 int dvd_title;
00120 QString rip_name;
00121 };
00122
00123 class DVDISOCopyThread : public DVDThread
00124 {
00125
00126
00127
00128
00129
00130 public:
00131
00132 DVDISOCopyThread(MTD *owner,
00133 QMutex *drive_mutex,
00134 const QString &dvd_device,
00135 int track,
00136 const QString &dest_file,
00137 const QString &name,
00138 const QString &start_string,
00139 int nice_priority);
00140
00141 ~DVDISOCopyThread();
00142
00143 virtual void run();
00144
00145 bool copyFullDisc(void);
00146 };
00147
00148 class DVDPerfectThread : public DVDThread
00149 {
00150
00151
00152
00153
00154
00155 public:
00156
00157 DVDPerfectThread(MTD *owner,
00158 QMutex *drive_mutex,
00159 const QString &dvd_device,
00160 int track,
00161 const QString &dest_file,
00162 const QString &name,
00163 const QString &start_string,
00164 int nice_priority);
00165
00166 ~DVDPerfectThread();
00167
00168 virtual void run();
00169
00170
00171 };
00172
00173 class DVDTranscodeThread : public DVDThread
00174 {
00175
00176
00177
00178
00179
00180
00181 public:
00182
00183 DVDTranscodeThread(MTD *owner,
00184 QMutex *drive_mutex,
00185 const QString &dvd_device,
00186 int track,
00187 const QString &dest_file,
00188 const QString &name,
00189 const QString &start_string,
00190 int nice_priority,
00191 int quality_level,
00192 bool do_ac3,
00193 int which_audio,
00194 int numb_seconds,
00195 int subtitle_track_numb);
00196
00197
00198 ~DVDTranscodeThread();
00199
00200 virtual void run();
00201 bool transcodeSlotUsed(){return used_transcode_slot;}
00202
00203 bool makeWorkingDirectory();
00204 bool buildTranscodeCommandLine(int which_run);
00205 bool runTranscode(int run);
00206 void cleanUp();
00207 void wipeClean();
00208 bool used_transcode_slot;
00209
00210 private:
00211
00212 int quality;
00213 QDir *working_directory;
00214 QStringList tc_arguments;
00215 class QProcess *tc_process;
00216 bool two_pass;
00217 int audio_track;
00218 int length_in_seconds;
00219 bool ac3_flag;
00220 int subtitle_track;
00221 };
00222
00223
00224 #endif // jobthread_h_
00225