2023-03-16 19:26:43 +00:00
|
|
|
#ifndef _LI_DVDRIPPER
|
|
|
|
#define _LI_DVDRIPPER 1
|
|
|
|
#include <iostream>
|
|
|
|
#include <dvdcss.h>
|
|
|
|
#include <thread>
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
#include "../Scsi/IoCtl.hpp"
|
|
|
|
#include "../Scsi/OpticalDrive.hpp"
|
|
|
|
|
|
|
|
namespace Li::Dvd {
|
|
|
|
class DvdRipper {
|
|
|
|
private:
|
2023-03-21 10:12:28 +00:00
|
|
|
uint32_t retriedReads;
|
|
|
|
uint32_t failedReads;
|
|
|
|
|
2023-03-16 19:26:43 +00:00
|
|
|
bool error;
|
|
|
|
bool done;
|
2023-03-21 10:12:28 +00:00
|
|
|
|
2023-03-26 14:00:19 +00:00
|
|
|
bool lastReadWasErr;
|
2023-03-21 10:12:28 +00:00
|
|
|
bool keepRunning;
|
|
|
|
bool starting;
|
|
|
|
bool decrypt;
|
|
|
|
|
2023-03-16 19:26:43 +00:00
|
|
|
std::string errorMsg;
|
|
|
|
|
|
|
|
bool inFile;
|
|
|
|
uint32_t fileReadSoFar;
|
|
|
|
uint32_t fileRemain;
|
|
|
|
|
2023-03-21 10:12:28 +00:00
|
|
|
|
2023-03-16 19:26:43 +00:00
|
|
|
uint32_t sectorsAtOnce;
|
|
|
|
uint32_t sectorsReadSoFar;
|
|
|
|
|
|
|
|
std::string outputPath;
|
|
|
|
std::thread* ripinThread;
|
|
|
|
|
|
|
|
std::ofstream* iso;
|
2023-03-17 06:45:03 +00:00
|
|
|
std::byte* tmpBuffer;
|
|
|
|
|
|
|
|
std::byte* titleKey;
|
|
|
|
|
2023-03-16 19:26:43 +00:00
|
|
|
Li::Scsi::IoCtl* driveIoCtl;
|
|
|
|
Li::Scsi::OpticalDrive* drive;
|
|
|
|
void ripThread();
|
|
|
|
void readNonFileSectors();
|
|
|
|
void readFileSectors();
|
2023-03-17 06:45:03 +00:00
|
|
|
|
2023-03-17 08:23:19 +00:00
|
|
|
void readUnprotectedSectors();
|
|
|
|
void readCssSectors();
|
|
|
|
|
2023-03-16 19:26:43 +00:00
|
|
|
int read1SectorATimeSkippingBadSectors(int toRead);
|
|
|
|
public:
|
|
|
|
DvdRipper(Li::Scsi::OpticalDrive* opticalDrive, std::string outputISO, uint32_t sectorsAtOnce);
|
|
|
|
~DvdRipper();
|
|
|
|
|
|
|
|
uint32_t SectorsReadSoFar();
|
|
|
|
float PercentDone();
|
|
|
|
std::string OutputPath();
|
|
|
|
|
|
|
|
uint32_t FileSoFar();
|
|
|
|
uint32_t FileLen();
|
|
|
|
|
2023-03-21 10:12:28 +00:00
|
|
|
uint32_t FailedReads();
|
|
|
|
uint32_t RetriedReads();
|
|
|
|
|
2023-03-17 08:23:19 +00:00
|
|
|
bool Decrypt();
|
2023-03-17 06:45:03 +00:00
|
|
|
std::byte* GetTitleKey();
|
|
|
|
std::byte* GetDiscKey();
|
|
|
|
|
2023-03-21 10:12:28 +00:00
|
|
|
bool Starting();
|
2023-03-16 19:26:43 +00:00
|
|
|
bool Done();
|
|
|
|
bool Error();
|
|
|
|
std::string ErrorMessage();
|
|
|
|
|
2023-03-17 08:23:19 +00:00
|
|
|
void StartRip(uint32_t driveSpeed, bool decryptCss);
|
2023-03-16 19:26:43 +00:00
|
|
|
void EndRip();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|