diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2009-09-03 02:59:36 -0400 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2009-09-03 02:59:36 -0400 |
commit | a787d32f4d7a8de300c2a3c1f8b1c104be5de849 (patch) | |
tree | 10f15b62925fb7f973294ffdb95c145350a1be0c | |
download | AnyRip-a787d32f4d7a8de300c2a3c1f8b1c104be5de849.tar.xz AnyRip-a787d32f4d7a8de300c2a3c1f8b1c104be5de849.zip |
Initial attempt at ripper.
-rw-r--r-- | main.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..1073fa8 --- /dev/null +++ b/main.cpp @@ -0,0 +1,58 @@ +#include "ripper.h" +#include <dvdcss/dvdcss.h> +#include <QDebug> +#include <QFile> +#include <QApplication> + +int main(int argc, char *argv[]) +{ + dvdcss_t dvdcss = dvdcss_open("/dev/dvd"); + if (!dvdcss) + qDebug() << "failed to open dvd"; + else + qDebug() << "opened dvd"; + const int blocksPerRead = 128; + uint8_t p_data[DVDCSS_BLOCK_SIZE * (blocksPerRead + 1)]; + uint8_t *p_buffer = p_data + DVDCSS_BLOCK_SIZE - ((intptr_t)p_data & (DVDCSS_BLOCK_SIZE - 1)); + QFile out("out.iso"); + out.open(QIODevice::WriteOnly); + int blocksOffset = 0; + int blocksRead; + int neededTitleKeys = 0; + while ((blocksRead = dvdcss_read(dvdcss, p_buffer, blocksPerRead, DVDCSS_READ_DECRYPT)) > 0) { + //Check if key retreval is neccessary for this block sector + uint8_t *p_scan = p_buffer; + bool neededAKey = false; + for (int i = 0; i < blocksRead; ++i) { + if(((uint8_t*)p_scan)[0x14] & 0x30) { + dvdcss_seek(dvdcss, blocksOffset + i, DVDCSS_SEEK_KEY); + ++neededTitleKeys; + neededAKey = true; + qDebug() << "getting title key" << neededTitleKeys; + } + p_scan = p_scan + DVDCSS_BLOCK_SIZE; + } + //Reread once we've gotten a key + if (neededAKey) { + dvdcss_seek(dvdcss, blocksOffset, DVDCSS_NOFLAGS); + dvdcss_read(dvdcss, p_buffer, blocksPerRead, DVDCSS_READ_DECRYPT); + } + out.write((char*)p_buffer, (quint64)(DVDCSS_BLOCK_SIZE * blocksRead)); + out.flush(); + blocksOffset += blocksRead; + } + dvdcss_close(dvdcss); + out.close(); + return 0; + + + + + QApplication a(argc, argv); + a.setApplicationName(QLatin1String("AnyRip")); + a.setOrganizationName(QLatin1String("AnyClip")); + a.setOrganizationDomain(QLatin1String("anyclip.com")); + Ripper w; + w.show(); + return a.exec(); +} |