1. Index: mythvideo/mtd/jobthread.cpp
  2. ===================================================================
  3. --- mythvideo/mtd/jobthread.cpp (revision 24265)
  4. +++ mythvideo/mtd/jobthread.cpp (working copy)
  5. @@ -847,22 +847,40 @@
  6. secs_mult = 1.0f / length_in_seconds;
  7. }
  8.  
  9. +
  10. +
  11. void DVDTranscodeThread::run(void)
  12. {
  13. myth_nice(nice_level);
  14.  
  15. - // Make working directory
  16. - if (IsCancelled() || !makeWorkingDirectory())
  17. + // Make working directory, errors -4 and -5 are files / direcotires
  18. + // already exist
  19. + int makedirecoryresult = makeWorkingDirectory();
  20. + if (IsCancelled() ||
  21. + ((makedirecoryresult < 0) && (makedirecoryresult >= -3)) )
  22. + {
  23. + SendProblemEvent("abandoned job cos of error "
  24. + "between 0 an -3");
  25. + cleanUp();
  26. return;
  27. + }
  28.  
  29. - if (IsCancelled())
  30. + if (IsCancelled())
  31. + {
  32. + cleanUp();
  33. return;
  34. + }
  35.  
  36. - // Build the transcode command line. We do this early
  37. - // (before ripping) so we can figure out if this is
  38. - // a two pass job or not (for the progress display)
  39. - if (!buildTranscodeCommandLine(1))
  40. + // Build the transcode command line. We do this early (before ripping) so
  41. + // we can figure out if this is a two pass job or not
  42. + // (for the progress display)
  43. + int transcodejobno;
  44. +
  45. + transcodejobno = buildTranscodeCommandLine(1);
  46. +
  47. + if (transcodejobno < 0)
  48. {
  49. + // building the transcode command line failed
  50. cleanUp();
  51. return;
  52. }
  53. @@ -878,17 +896,38 @@
  54. sub_to_overall_multiple = 0.50;
  55. }
  56.  
  57. - if (IsCancelled())
  58. + if (IsCancelled())
  59. + {
  60. + cleanUp();
  61. return;
  62. + }
  63.  
  64. // Rip VOB to working directory
  65. QStringList output_files;
  66. QString rip_file_string = QString("%1/vob/%2")
  67. .arg(working_directory->path()).arg(rip_name);
  68. - if (!ripTitle(dvd_title, rip_file_string, ".vob", true, &output_files))
  69. - {
  70. - cleanUp();
  71. - return;
  72. +
  73. + if (makedirecoryresult == 0)
  74. + {
  75. + if (!ripTitle(dvd_title, rip_file_string, ".vob", true, &output_files))
  76. + {
  77. + cleanUp();
  78. + return;
  79. + }
  80. + else
  81. + {
  82. + MSqlQuery sayweveripped_query(MSqlQuery::InitCon());
  83. +
  84. + sayweveripped_query.prepare(
  85. + "UPDATE dvdtranscodejobs SET state=1 WHERE final_dir_and_file "
  86. + "LIKE :RIPNAME;");
  87. + sayweveripped_query.bindValue(":RIPNAME", '%' + rip_name);
  88. +
  89. + if(!sayweveripped_query.exec())
  90. + {
  91. + SendProblemEvent("Couldnt update the job as ripped in the database");
  92. + }
  93. + }
  94. }
  95.  
  96. // Get permission to start transcoding from MTD instance.
  97. @@ -919,20 +958,30 @@
  98. // Run the first (only?) crack at transcoding
  99. if (!IsCancelled() && !runTranscode(1))
  100. {
  101. + SendProblemEvent("Failed single pass transcode");
  102. +
  103. wipeClean();
  104. return;
  105. }
  106.  
  107. // Second pass, if enabled
  108. if (two_pass && !IsCancelled() && !runTranscode(2))
  109. + {
  110. + SendProblemEvent("Failed 2nd pass transcode");
  111. +
  112. wipeClean();
  113. -
  114. + }
  115. +
  116. #ifndef DEBUG_STAGE_2
  117. if (!gContext->GetNumSetting("mythdvd.mtd.SaveTranscodeIntermediates", 0))
  118. {
  119. // remove any temporary titles that are now transcoded
  120. std::for_each(output_files.begin(), output_files.end(), delete_file());
  121. }
  122. + else
  123. + {
  124. + SendProblemEvent("failed to tidy up");
  125. + }
  126. #endif
  127.  
  128. cleanUp();
  129. @@ -949,13 +998,21 @@
  130. }
  131. }
  132.  
  133. -bool DVDTranscodeThread::makeWorkingDirectory(void)
  134. +// int DVDTranscodeThread::makeWorkingDirectory(void)
  135. +//
  136. +// changed by m bennett 10/04/10
  137. +
  138. +// I have changed this to be more verbose about the error condition (if any)
  139. +// This is so there can be a difference made between a failed condition
  140. +// and mearly a previos attempt to transcode
  141. +
  142. +int DVDTranscodeThread::makeWorkingDirectory(void)
  143. {
  144. QString dir_name = gContext->GetSetting("DVDRipLocation");
  145. if (dir_name.isEmpty())
  146. {
  147. SendProblemEvent("could not find rip directory in settings");
  148. - return false;
  149. + return -1;
  150. }
  151.  
  152. working_directory = new QDir(dir_name);
  153. @@ -963,7 +1020,7 @@
  154. {
  155. SendProblemEvent(QString("rip directory '%1' does not seem to exist")
  156. .arg(dir_name));
  157. - return false;
  158. + return -2;
  159. }
  160.  
  161. #ifndef DEBUG_STAGE_2
  162. @@ -971,7 +1028,8 @@
  163. {
  164. SendProblemEvent(QString("Could not create directory called '%1/%2' ")
  165. .arg(dir_name).arg(rip_name));
  166. - return false;
  167. + //return -4;
  168. + // we dont want to quit out just to tell the system that the dir is there
  169. }
  170. #endif
  171.  
  172. @@ -979,7 +1037,7 @@
  173. {
  174. SendProblemEvent(QString("Could not cd into '%1/%2'")
  175. .arg(dir_name).arg(rip_name));
  176. - return false;
  177. + return -3;
  178. }
  179.  
  180. #ifndef DEBUG_STAGE_2
  181. @@ -988,22 +1046,54 @@
  182. SendProblemEvent(QString("could not create a vob subdirectory "
  183. "in the working directory '%1/%2'")
  184. .arg(dir_name).arg(rip_name));
  185. - return false;
  186. + return -5;
  187. }
  188. #endif
  189.  
  190. - return true;
  191. + return 0;
  192. }
  193.  
  194. -bool DVDTranscodeThread::buildTranscodeCommandLine(int which_run)
  195. +// int DVDTranscodeThread::buildTranscodeCommandLine(int which_run)
  196. +//
  197. +// changed by m bennett 10/04/10
  198. +
  199. +// I am changing this to return the job number if sucessful
  200. +// or a -1 if fail. This is so that when the DVDTranscodeThread::run
  201. +// calls this routine, the job data in dvdtranscode can be updated
  202. +// as sucessfully ripped, and therfore can be skipped if mtd
  203. +// bails for some reason
  204. +
  205. +// error conditions are less than 0
  206. +// -1 destination file already exists
  207. +// -2 no TranscodeCommand setting
  208. +// -3 buildTranscodeCommandLine query failed
  209. +// -4 buildTranscodeCommandLine query null return 1
  210. +// -5 buildTranscodeCommandLine query failed 2
  211. +// -6 buildTranscodeCommandLine query null return 2
  212. +// -7 Can't transcode without a codec
  213. +
  214. +// suggested improvemnets
  215. +// it would be nice - if the ripped files were held cenrally, if
  216. +// any backend configured to transcode would pick up the job
  217. +// using the standard backends job running mechanisim and adhearing to the
  218. +// run job on same backend option
  219. +
  220. +// originally this
  221. +//bool DVDTranscodeThread::buildTranscodeCommandLine(int which_run)
  222. +int DVDTranscodeThread::buildTranscodeCommandLine(int which_run)
  223. {
  224. // If our destination file already exists, bail out
  225. + // It seems strange to test for the destination file here
  226. + // all things being good, this error condition should not arise
  227. + // and even if it does should the routine that build the command line
  228. + // have power of vito over its creation, should we not pass this back up
  229. + // for the calling - high level routines to deal with?
  230. QFile a_file(QString("%1.avi").arg(destination_file_string));
  231. if (a_file.exists())
  232. {
  233. SendProblemEvent("Transcode cannot run, "
  234. "destination file already exists");
  235. - return false;
  236. + return(-1);
  237. }
  238.  
  239. tc_command = gContext->GetSetting("TranscodeCommand");
  240. @@ -1011,7 +1101,7 @@
  241. {
  242. SendProblemEvent(
  243. "There is no TranscodeCommand setting for this system");
  244. - return false;
  245. + return(-2);
  246. }
  247.  
  248. tc_arguments.clear();
  249. @@ -1033,13 +1123,13 @@
  250. if (!a_query.exec())
  251. {
  252. SendProblemEvent("buildTranscodeCommandLine query failed 1");
  253. - return false;
  254. + return(-3);
  255. }
  256.  
  257. if (!a_query.next())
  258. {
  259. SendProblemEvent("buildTranscodeCommandLine query null return 1");
  260. - return false;
  261. + return(-4);
  262. }
  263.  
  264. // Convert query results to named variables
  265. @@ -1079,13 +1169,13 @@
  266. if (!a_query.exec())
  267. {
  268. SendProblemEvent("buildTranscodeCommandLine query failed 2");
  269. - return false;
  270. + return(-5);
  271. }
  272.  
  273. if (!a_query.next())
  274. {
  275. SendProblemEvent("buildTranscodeCommandLine query null return 2");
  276. - return false;
  277. + return(-6);
  278. }
  279.  
  280. int input_hsize = a_query.value(0).toInt();
  281. @@ -1176,7 +1266,7 @@
  282. if (codec.isEmpty())
  283. {
  284. SendProblemEvent("Yo! Kaka-brain! Can't transcode without a codec");
  285. - return false;
  286. + return(-7);
  287. }
  288.  
  289. if (codec.contains("divx") && gContext->GetNumSetting("MTDxvidFlag"))
  290. @@ -1264,24 +1354,25 @@
  291. for (int i = 0; i < tc_arguments.size(); i++)
  292. args.push_back(shell_escape(tc_arguments[i]));
  293. QString transcode_command_string =
  294. - QString("transcode command will be: '%1 %2'")
  295. + QString("'%1 %2'")
  296. .arg(tc_command).arg(args.join(" "));
  297.  
  298. + SendLoggingEvent("transcode command will be: ");
  299. SendLoggingEvent(transcode_command_string);
  300.  
  301. - return true;
  302. + return(0);
  303. }
  304.  
  305. bool DVDTranscodeThread::runTranscode(int which_run)
  306. {
  307. // Set description strings to let the user
  308. // know what is going on.
  309. -
  310. SetSubName(QObject::tr("Transcode is thinking..."), 1);
  311. SetSubProgress(0.0, 1);
  312.  
  313. // Second pass?
  314. - if ((which_run > 1) && !buildTranscodeCommandLine(which_run))
  315. + // This builds the final transcode line
  316. + if ((which_run > 1) && (buildTranscodeCommandLine(which_run) < 0))
  317. {
  318. SendProblemEvent("Problem building second pass command line.");
  319. return false;
  320. @@ -1491,6 +1582,21 @@
  321. working_directory->rmdir("vob");
  322. working_directory->cd("..");
  323. working_directory->rmdir(rip_name);
  324. +
  325. + // remove the database entry
  326. + MSqlQuery removedonejob_query(MSqlQuery::InitCon());
  327. + // and the one before (buildtrancodeCommandLine is called twice
  328. + // change this to search for like filnames
  329. + removedonejob_query.prepare(
  330. + "DELETE FROM dvdtranscodejobs WHERE `final_dir_and_file` LIKE "
  331. + ":RIPNAME;");
  332. + removedonejob_query.bindValue(":RIPNAME", '%' + rip_name);
  333. +
  334. + if(!removedonejob_query.exec())
  335. + {
  336. + SendProblemEvent("Couldnt remove the finished job from the database");
  337. + }
  338. +
  339. delete working_directory;
  340. working_directory = NULL;
  341. SetSubProgress(1, 1);
  342. Index: mythvideo/mtd/mtd.cpp
  343. ===================================================================
  344. --- mythvideo/mtd/mtd.cpp (revision 24265)
  345. +++ mythvideo/mtd/mtd.cpp (working copy)
  346. @@ -794,12 +794,18 @@
  347. DVDTitle which_title = dvd_probe->GetTitle(dvd_title);
  348. titles_mutex->unlock();
  349.  
  350. + // this is a senible check to do, unfortnatley since I changed mtd
  351. + // to pick up on previous jobs it is likely to fial when adding a job
  352. + // when there is no disk in the drive
  353. if (!which_title.IsValid())
  354. {
  355. VERBOSE(VB_IMPORTANT, LOC_ERR + "Title number not valid?");
  356. - return;
  357. + // so we will try anyway after logging this error just to
  358. + // the flip side of this is is could now go wrong when adding a job
  359. + //return;
  360. }
  361.  
  362. + // Why do we not need to record this in the database?
  363. uint numb_seconds = which_title.GetPlayLength();
  364.  
  365. emit writeToLog(QString("launching job: %1").arg(flat));
  366. Index: mythvideo/mtd/logging.cpp
  367. ===================================================================
  368. --- mythvideo/mtd/logging.cpp (revision 24265)
  369. +++ mythvideo/mtd/logging.cpp (working copy)
  370. @@ -26,6 +26,11 @@
  371. {
  372. }
  373.  
  374. +// changed by m bennett 06/04/10
  375. +//
  376. +// Appends the mtd log file rather than rewrites it every time, this is for
  377. +// debug
  378. +//
  379. bool MTDLogger::Init(void)
  380. {
  381. QString logfile_name = gContext->GetSetting("DVDRipLocation");
  382. @@ -41,7 +46,7 @@
  383. if (!log_to_stdout)
  384. {
  385. logging_file.setFileName(logfile_name);
  386. - if (!logging_file.open(QIODevice::WriteOnly))
  387. + if (!logging_file.open(QIODevice::Append))
  388. {
  389. VERBOSE(VB_IMPORTANT, LOC_ERR + "\n\t\t\t" +
  390. QString("Could not open logfile '%1' for writing")
  391. Index: mythvideo/mtd/jobthread.h
  392. ===================================================================
  393. --- mythvideo/mtd/jobthread.h (revision 24265)
  394. +++ mythvideo/mtd/jobthread.h (working copy)
  395. @@ -206,8 +206,8 @@
  396.  
  397. virtual bool transcodeSlotUsed(void) const { return used_transcode_slot; }
  398.  
  399. - bool makeWorkingDirectory(void);
  400. - bool buildTranscodeCommandLine(int which_run);
  401. + int makeWorkingDirectory(void);
  402. + int buildTranscodeCommandLine(int which_run);
  403. bool runTranscode(int run);
  404. void cleanUp(void);
  405. void wipeClean(void);
  406. Index: mythvideo/mythvideo/dvdripbox.cpp
  407. ===================================================================
  408. --- mythvideo/mythvideo/dvdripbox.cpp (revision 24265)
  409. +++ mythvideo/mythvideo/dvdripbox.cpp (working copy)
  410. @@ -188,10 +188,155 @@
  411. return true;
  412. }
  413.  
  414. +// DVDRipBox::Init
  415. +//
  416. +// changed by m bennett 26/04/10
  417. +
  418. +// I have changed this to check for jobs not yet fully ripped and delete then
  419. +// from the db, then place any jobs (in dvdtranscodejobs) that were fully
  420. +// copied (state = 1) back into mtd
  421. +
  422. +// suggested improvemnets
  423. +// The frontend would reprompt for the unripped jobs rather than delete them
  424. +
  425. void DVDRipBox::Init()
  426. {
  427. ConnectToMTD();
  428.  
  429. + // here i would like to check for jobs stashed in the database
  430. + // and kick em off
  431. + // get the jobs out of the db
  432. + // Ideally Id like to repropmt the user for dvds that failed to be ripped
  433. + // the first time, but well just bin em for now
  434. + MSqlQuery getnoofnonrippedjobs_query(MSqlQuery::InitCon());
  435. + getnoofnonrippedjobs_query.prepare(
  436. + "SELECT COUNT(*) FROM dvdtranscodejobs WHERE state=0;");
  437. +
  438. + if(!getnoofnonrippedjobs_query.exec())
  439. + {
  440. + VERBOSE(VB_IMPORTANT, "DIDNT get no of unrippedjobs");
  441. + }
  442. +
  443. + if (!getnoofnonrippedjobs_query.next())
  444. + {
  445. + VERBOSE(VB_IMPORTANT, "get no of unrippedjobs query null return 1");
  446. + }
  447. +
  448. + // this currently gets only the unripped first job - need to fix this
  449. + int noofunrippedjobs = getnoofnonrippedjobs_query.value(0).toInt();
  450. +
  451. + if (noofunrippedjobs > 0)
  452. + {
  453. + // delete the jobs that havent been ripped both off the disk and the db
  454. + // it would be nice if the frontend demanded for these items after
  455. + // purging them
  456. +
  457. + // remove any temporary titles that are now transcoded
  458. + MSqlQuery getunrippedjobs_query(MSqlQuery::InitCon());
  459. + getunrippedjobs_query.prepare(
  460. + "SELECT * FROM dvdtranscodejobs WHERE state=0;");
  461. +
  462. + if(!getunrippedjobs_query.exec())
  463. + {
  464. + VERBOSE(VB_IMPORTANT, "DIDNT get unrippedjobs");
  465. + }
  466. +
  467. + QString unused_final_dir_and_file;
  468. +
  469. + MSqlQuery removenotdonejob_query(MSqlQuery::InitCon());
  470. +
  471. + while(getunrippedjobs_query.next())
  472. + {
  473. +// std::for_each(output_files.begin(), output_files.end(), delete_file());
  474. +
  475. + unused_final_dir_and_file = getunrippedjobs_query.value(1).toString();
  476. +
  477. + // remove the database entry
  478. + // and the one before (buildtrancodeCommandLine is called twice
  479. + // change this to search for like filnames
  480. + removenotdonejob_query.prepare(
  481. + "DELETE FROM dvdtranscodejobs WHERE `final_dir_and_file`"
  482. + " LIKE :RIPNAME;");
  483. + removenotdonejob_query.bindValue(":RIPNAME",
  484. + '%' + unused_final_dir_and_file);
  485. +
  486. + if(!removenotdonejob_query.exec())
  487. + {
  488. + VERBOSE(VB_IMPORTANT, "Couldnt remove the unfinished job from"
  489. + "the database");
  490. + }
  491. +
  492. + } // end while loop
  493. + }
  494. +
  495. + VERBOSE(VB_IMPORTANT, "Got rid of blank entries");
  496. +
  497. + // Now get the much more intresting ripped but not yet transcoded jobs
  498. + MSqlQuery getnoofrippedjobs_query(MSqlQuery::InitCon());
  499. + getnoofrippedjobs_query.prepare(
  500. + "SELECT COUNT(*) FROM dvdtranscodejobs WHERE state=1;");
  501. +
  502. + if(!getnoofrippedjobs_query.exec())
  503. + {
  504. + VERBOSE(VB_IMPORTANT, "DIDNT get rippedjobs");
  505. + }
  506. +
  507. + if (!getnoofrippedjobs_query.next())
  508. + {
  509. + VERBOSE(VB_IMPORTANT, "get noofrippedjobs query null return 1");
  510. + }
  511. +
  512. + // this currently gets only the unripped first job - need to fix this
  513. + int noofrippedjobs = getnoofrippedjobs_query.value(0).toInt();
  514. +
  515. + if (noofrippedjobs > 0)
  516. + {
  517. + // I dont know how clever the compiler is but im better we probablly
  518. + // have enough ram for an extra struct
  519. + MSqlQuery getrippedjobs_query(MSqlQuery::InitCon());
  520. + getrippedjobs_query.prepare(
  521. + "SELECT * FROM dvdtranscodejobs WHERE state=1;");
  522. +
  523. + if(!getrippedjobs_query.exec())
  524. + {
  525. + VERBOSE(VB_IMPORTANT, "DIDNT get rippedjobs");
  526. + }
  527. +
  528. + int rippedjobsindex;
  529. + QString final_dir_and_file;
  530. + int Track;
  531. + int Audio;
  532. + int Quality;
  533. + int AC3;
  534. + int SubTitle;
  535. +
  536. + while(getrippedjobs_query.next())
  537. + {
  538. + rippedjobsindex = getrippedjobs_query.value(0).toInt();
  539. + final_dir_and_file = getrippedjobs_query.value(1).toString();
  540. + Track = getrippedjobs_query.value(2).toInt();
  541. + Audio = getrippedjobs_query.value(3).toInt();
  542. + Quality = getrippedjobs_query.value(4).toInt();
  543. + AC3 = getrippedjobs_query.value(5).toInt();
  544. + SubTitle = getrippedjobs_query.value(6).toInt();
  545. +
  546. + // pipe them into mtd
  547. +
  548. + QString job_string = QString("job dvd %1 %2 %3 %4 %5 %6")
  549. + .arg(Track)
  550. + .arg(Audio)
  551. + .arg(Quality)
  552. + .arg(AC3)
  553. + .arg(SubTitle)
  554. + .arg(final_dir_and_file);
  555. +
  556. + QTextStream os(&m_clientSocket);
  557. + os << job_string << "\n" ;
  558. + } // end while loop
  559. + }
  560. +
  561. + VERBOSE(VB_IMPORTANT, "put in job entries");
  562. +
  563. // Create (but do not open) the DVD probing object
  564. // and then ask a thread to check it for us. Make a
  565. // timer to query whether the thread is done or not
  566. @@ -827,7 +972,7 @@
  567. &m_clientSocket,
  568. m_dvdInfo->getName(),
  569. m_dvdInfo->getTitles());
  570. -
  571. +
  572. if (title_dialog->Create())
  573. screenStack->AddScreen(title_dialog);
  574.  
  575. Index: mythvideo/mythvideo/titledialog.cpp
  576. ===================================================================
  577. --- mythvideo/mythvideo/titledialog.cpp (revision 24265)
  578. +++ mythvideo/mythvideo/titledialog.cpp (working copy)
  579. @@ -190,7 +190,8 @@
  580. else
  581. m_ripacthreeCheck->SetCheckState(MythUIStateType::Off);
  582.  
  583. - m_numbtitlesText->SetText(QString(tr("Title %1 of %2")).arg(m_currentTitle->getTrack()).arg(m_dvdTitles->size()));
  584. + m_numbtitlesText->SetText(QString(tr("Title %1 of %2"))
  585. + .arg(m_currentTitle->getTrack()).arg(m_dvdTitles->size()));
  586.  
  587. }
  588. }
  589. @@ -302,7 +303,8 @@
  590. if(m_currentTitle)
  591. {
  592. audio_track = m_currentTitle->getAudio();
  593. - DVDAudioInfo *audio_in_question = m_currentTitle->getAudioTrack(audio_track - 1);
  594. + DVDAudioInfo *audio_in_question =
  595. + m_currentTitle->getAudioTrack(audio_track - 1);
  596. if(audio_in_question)
  597. {
  598. channels = audio_in_question->getChannels();
  599. @@ -318,16 +320,20 @@
  600. }
  601.  
  602. player_string = player_string.replace(QRegExp("%d"), dvd_device);
  603. - player_string = player_string.replace(QRegExp("%t"), QString("%1").arg(m_currentTitle->getTrack()));
  604. - player_string = player_string.replace(QRegExp("%a"), QString("%1").arg(audio_track));
  605. - player_string = player_string.replace(QRegExp("%c"), QString("%1").arg(channels));
  606. + player_string = player_string.replace(QRegExp("%t"),
  607. + QString("%1").arg(m_currentTitle->getTrack()));
  608. + player_string = player_string.replace(QRegExp("%a"),
  609. + QString("%1").arg(audio_track));
  610. + player_string = player_string.replace(QRegExp("%c"),
  611. + QString("%1").arg(channels));
  612.  
  613. if(m_currentTitle->getSubTitle() > -1)
  614. {
  615. QString player_append = gContext->GetSetting("SubTitleCommand");
  616. if(player_append.length() > 1)
  617. {
  618. - player_append = player_append.replace(QRegExp("%s"), QString("%1").arg(m_currentTitle->getSubTitle()));
  619. + player_append = player_append.replace(QRegExp("%s"),
  620. + QString("%1").arg(m_currentTitle->getSubTitle()));
  621. player_string += " ";
  622. player_string += player_append;
  623. }
  624. @@ -337,6 +343,13 @@
  625. myth_system(player_string);
  626. }
  627.  
  628. +// void TitleDialog::ripTitles()
  629. +//
  630. +// changed by m bennett 18/04/10
  631. +
  632. +// I have changed this to insert a copy of the job string details into
  633. +// dvdtranscodejobs with a state of 0
  634. +
  635. void TitleDialog::ripTitles()
  636. {
  637. //
  638. @@ -388,11 +401,13 @@
  639.  
  640. if(destination_directory.length() < 1)
  641. {
  642. - VERBOSE(VB_IMPORTANT, "titledialog.o: I can't rip, as I have nowhere to put finished files. MythVideo installed?");
  643. + VERBOSE(VB_IMPORTANT, "titledialog.o: I can't rip, as I have "
  644. + "nowhere to put finished files. MythVideo installed?");
  645. return;
  646. }
  647.  
  648. - QString final_dir_and_file = destination_directory + "/" + m_dvdTitles->at(i)->getName();
  649. + QString final_dir_and_file = destination_directory + "/"
  650. + + m_dvdTitles->at(i)->getName();
  651.  
  652. QString job_string = QString("job dvd %1 %2 %3 %4 %5 %6")
  653. .arg(m_dvdTitles->at(i)->getTrack())
  654. @@ -401,7 +416,80 @@
  655. .arg(m_dvdTitles->at(i)->getAC3())
  656. .arg(m_dvdTitles->at(i)->getSubTitle())
  657. .arg(final_dir_and_file);
  658. +
  659. + // read back the data
  660. + QString q_string = QString("SELECT getTrack,getAudio,getQuality, "
  661. + "getAC3,getSubTitle,getSubTitle "
  662. + "FROM dvdtranscode ;");
  663.  
  664. + MSqlQuery a_query(MSqlQuery::InitCon());
  665. +
  666. + if(a_query.exec(q_string))
  667. + {
  668. + while(a_query.next())
  669. + {
  670. + new MythUIButtonListItem(m_qualityList,
  671. + a_query.value(0).toString(), a_query.value(1).toInt());
  672. + }
  673. + } // end make job string
  674. +
  675. + VERBOSE(VB_IMPORTANT, job_string);
  676. +
  677. + // here is the magic place, we need to put this data into the db
  678. + // so that if mtd or the box it is on dies, that mtd can pick up
  679. + // this data on restart
  680. +
  681. + MSqlQuery getjobindex_query(MSqlQuery::InitCon());
  682. + getjobindex_query.prepare(
  683. + "SELECT max(jobindex) from dvdtranscodejobs;");
  684. +
  685. + if(!getjobindex_query.exec())
  686. + {
  687. + VERBOSE(VB_IMPORTANT, "DIDNT get max result");
  688. + }
  689. +
  690. + if (!getjobindex_query.next())
  691. + {
  692. + VERBOSE(VB_IMPORTANT, "get next jobs query null return");
  693. + }
  694. +
  695. + int current_dvdtranscode_job_index =
  696. + getjobindex_query.value(0).toInt();
  697. +
  698. + QString op_string = QString("max result is: %1")
  699. + .arg(current_dvdtranscode_job_index);
  700. +
  701. + VERBOSE(VB_IMPORTANT, op_string);
  702. +
  703. + int new_dvdtranscode_job_index = current_dvdtranscode_job_index + 1;
  704. +
  705. + MSqlQuery dvdtranscodejob_query(MSqlQuery::InitCon());
  706. +
  707. + dvdtranscodejob_query.prepare(
  708. + "INSERT INTO dvdtranscodejobs VALUES (:JOBID, :FINALDIRANDFILE"
  709. + ", :TRACK, :AUDIO, :QUALITY, :AC3, :SUBTITLE, 0, :BACKEND);");
  710. + dvdtranscodejob_query.bindValue(":JOBID",
  711. + new_dvdtranscode_job_index);
  712. + dvdtranscodejob_query.bindValue(":FINALDIRANDFILE",
  713. + final_dir_and_file);
  714. + dvdtranscodejob_query.bindValue(":TRACK",
  715. + m_dvdTitles->at(i)->getTrack());
  716. + dvdtranscodejob_query.bindValue(":AUDIO",
  717. + m_dvdTitles->at(i)->getAudio());
  718. + dvdtranscodejob_query.bindValue(":QUALITY",
  719. + m_dvdTitles->at(i)->getQuality());
  720. + dvdtranscodejob_query.bindValue(":AC3",
  721. + m_dvdTitles->at(i)->getAC3());
  722. + dvdtranscodejob_query.bindValue(":SUBTITLE",
  723. + m_dvdTitles->at(i)->getSubTitle());
  724. + dvdtranscodejob_query.bindValue(":BACKEND", "");
  725. +
  726. + if(!dvdtranscodejob_query.exec())
  727. + {
  728. + VERBOSE(VB_IMPORTANT,
  729. + "DIDNT insert into transcode values into db");
  730. + }
  731. +
  732. QTextStream os(m_socketToMtd);
  733. os << job_string << "\n" ;
  734. }
  735.