add new code to disable dvdcss caching
This commit is contained in:
parent
ed3801ab02
commit
83d91b6a73
|
@ -268,7 +268,7 @@ namespace Li::Dvd {
|
||||||
this->sectorsReadSoFar = 0;
|
this->sectorsReadSoFar = 0;
|
||||||
this->fileReadSoFar = 0;
|
this->fileReadSoFar = 0;
|
||||||
this->keepRunning = false;
|
this->keepRunning = false;
|
||||||
this->ripinThread->join();
|
this->ripinThread->detach();
|
||||||
|
|
||||||
delete this->driveIoCtl;
|
delete this->driveIoCtl;
|
||||||
delete this->ripinThread;
|
delete this->ripinThread;
|
||||||
|
|
|
@ -36,18 +36,24 @@ namespace Li::Gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
DumpDVD::~DumpDVD() {
|
DumpDVD::~DumpDVD() {
|
||||||
this->keepPolling = false;
|
if (this->imRippinIt) {
|
||||||
this->pollDrives->join();
|
this->endRipNow();
|
||||||
|
std::filesystem::remove(std::string(this->outputFile));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->keepPolling = false;
|
||||||
|
this->pollDrives->detach();
|
||||||
|
delete this->pollDrives;
|
||||||
|
}
|
||||||
|
|
||||||
delete this->lock;
|
delete this->lock;
|
||||||
delete this->pollDrives;
|
|
||||||
freeOldDriveList();
|
freeOldDriveList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpDVD::pollDrivesThread() {
|
void DumpDVD::pollDrivesThread() {
|
||||||
while (this->keepPolling) {
|
while (this->keepPolling) {
|
||||||
if ( (this->counter % (60 * 10)) == 0) {
|
this->refreshDriveList();
|
||||||
this->refreshDriveList();
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +109,7 @@ namespace Li::Gui {
|
||||||
void DumpDVD::startRip() {
|
void DumpDVD::startRip() {
|
||||||
if (this->GetCurrentSelectedDrive()->DiscInDrive()) {
|
if (this->GetCurrentSelectedDrive()->DiscInDrive()) {
|
||||||
this->keepPolling = false;
|
this->keepPolling = false;
|
||||||
this->pollDrives->join();
|
this->pollDrives->detach();
|
||||||
delete this->pollDrives;
|
delete this->pollDrives;
|
||||||
|
|
||||||
std::vector<uint32_t>* speeds = this->GetCurrentSelectedDrive()->SupportedSpeeds();
|
std::vector<uint32_t>* speeds = this->GetCurrentSelectedDrive()->SupportedSpeeds();
|
||||||
|
@ -119,11 +125,15 @@ namespace Li::Gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpDVD::endRipAndGoBackToMenu() {
|
void DumpDVD::endRipNow() {
|
||||||
this->dvdRipper->EndRip();
|
this->dvdRipper->EndRip();
|
||||||
delete this->dvdRipper;
|
delete this->dvdRipper;
|
||||||
|
|
||||||
this->imRippinIt = false;
|
this->imRippinIt = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DumpDVD::endRipAndGoBackToMenu() {
|
||||||
|
this->endRipNow();
|
||||||
|
|
||||||
this->reset();
|
this->reset();
|
||||||
|
|
||||||
this->keepPolling = true;
|
this->keepPolling = true;
|
||||||
|
@ -177,7 +187,7 @@ namespace Li::Gui {
|
||||||
|
|
||||||
if (this->dvdRipper->Done()) {
|
if (this->dvdRipper->Done()) {
|
||||||
if (!this->dvdRipper->Error()) {
|
if (!this->dvdRipper->Error()) {
|
||||||
ImGui::Begin("Complete", &this->imRippinIt, ImGuiWindowFlags_NoCollapse);
|
ImGui::Begin("Complete", &this->imRippinIt, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize);
|
||||||
ImGui::Text("ISO file was created successfully.");
|
ImGui::Text("ISO file was created successfully.");
|
||||||
if (ImGui::Button("OK")) {
|
if (ImGui::Button("OK")) {
|
||||||
this->endRipAndGoBackToMenu();
|
this->endRipAndGoBackToMenu();
|
||||||
|
@ -185,7 +195,7 @@ namespace Li::Gui {
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ImGui::Begin("Error", &this->imRippinIt, ImGuiWindowFlags_NoCollapse);
|
ImGui::Begin("Error", &this->imRippinIt, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize);
|
||||||
ImGui::Text("Error occured when creating an ISO\n\"%s\"", this->dvdRipper->ErrorMessage().c_str());
|
ImGui::Text("Error occured when creating an ISO\n\"%s\"", this->dvdRipper->ErrorMessage().c_str());
|
||||||
if (ImGui::Button("OK")) {
|
if (ImGui::Button("OK")) {
|
||||||
this->endRipAndGoBackToMenu();
|
this->endRipAndGoBackToMenu();
|
||||||
|
@ -284,7 +294,7 @@ namespace Li::Gui {
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||||
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize, ImGuiCond_Always);
|
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize, ImGuiCond_Always);
|
||||||
|
|
||||||
ImGui::Begin("DVD Dumper", NULL, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove |
|
ImGui::Begin("DVD Dumper", NULL, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing);
|
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||||
|
|
||||||
if (this->imRippinIt)
|
if (this->imRippinIt)
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace Li::Gui {
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void startRip();
|
void startRip();
|
||||||
|
void endRipNow();
|
||||||
void endRipAndGoBackToMenu();
|
void endRipAndGoBackToMenu();
|
||||||
|
|
||||||
void showRipMenu();
|
void showRipMenu();
|
||||||
|
|
|
@ -1,38 +1,25 @@
|
||||||
#include "MainWindow.hpp"
|
#include "MainWindow.hpp"
|
||||||
#ifdef _WIN32
|
#include "SDL.hpp"
|
||||||
#include "D3D.hpp"
|
#include "DumpDVD.hpp"
|
||||||
#include <imgui_impl_dx11.cpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <imgui_impl_sdl2.h>
|
|
||||||
#include <imgui.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "SDL.hpp"
|
|
||||||
#include "DumpDVD.hpp"
|
|
||||||
|
|
||||||
namespace Li::Gui {
|
namespace Li::Gui {
|
||||||
MainWindow::MainWindow() {
|
MainWindow::MainWindow() {
|
||||||
this->sdl = new SDL("DumpDVD", 800, 400);
|
this->sdl = new SDL("DumpDVD", 800, 400);
|
||||||
|
this->sdl->SetMaxFPS(24.0);
|
||||||
|
|
||||||
DumpDVD* dumpDvdMenu = new DumpDVD();
|
DumpDVD* dumpDvdMenu = new DumpDVD();
|
||||||
uint32_t lastRenderTime = SDL_GetTicks();
|
|
||||||
while (!this->sdl->IsExiting()) {
|
while (!this->sdl->IsExiting()) {
|
||||||
uint32_t curRenderTime = SDL_GetTicks();
|
this->sdl->PollEvent();
|
||||||
uint32_t delta = curRenderTime - lastRenderTime;
|
this->sdl->NewFrame();
|
||||||
if (delta > 1000 / 60.0)
|
|
||||||
{
|
|
||||||
this->sdl->PollEvent();
|
|
||||||
this->sdl->NewFrame();
|
|
||||||
|
|
||||||
dumpDvdMenu->RenderUI();
|
dumpDvdMenu->RenderUI();
|
||||||
|
|
||||||
this->sdl->Render();
|
this->sdl->Render();
|
||||||
|
|
||||||
lastRenderTime = curRenderTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete dumpDvdMenu;
|
delete dumpDvdMenu;
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
#include <imgui_impl_dx11.h>
|
#include <imgui_impl_dx11.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <imgui_impl_sdl2.h>
|
#include <imgui_impl_sdl2.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
@ -50,7 +53,9 @@ namespace Li::Gui {
|
||||||
#else
|
#else
|
||||||
#error No imgui renderer backend provided for this platform
|
#error No imgui renderer backend provided for this platform
|
||||||
#endif
|
#endif
|
||||||
isExiting = false;
|
this->isExiting = false;
|
||||||
|
this->SetMaxFPS(24.0);
|
||||||
|
this->lastRenderTime = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
bool SDL::IsExiting() {
|
bool SDL::IsExiting() {
|
||||||
return this->isExiting;
|
return this->isExiting;
|
||||||
|
@ -77,16 +82,31 @@ namespace Li::Gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SDL::NewFrame() {
|
void SDL::NewFrame() {
|
||||||
|
this->curRenderTime = SDL_GetTicks();
|
||||||
|
|
||||||
this->renderer->ImGuiNewFrame();
|
this->renderer->ImGuiNewFrame();
|
||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDL::SetMaxFPS(float fpsLimit) {
|
||||||
|
this->maxFps = fpsLimit;
|
||||||
|
this->limit = (1000 / this->maxFps);
|
||||||
|
}
|
||||||
|
|
||||||
void SDL::Render() {
|
void SDL::Render() {
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImVec4 clearColor = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clearColor = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
this->renderer->Render(clearColor);
|
this->renderer->Render(clearColor);
|
||||||
|
|
||||||
|
this->lastRenderTime = this->curRenderTime;
|
||||||
|
this->delta = (this->curRenderTime - this->lastRenderTime);
|
||||||
|
|
||||||
|
if (this->delta < this->limit)
|
||||||
|
{
|
||||||
|
uint32_t remain = (this->limit - this->delta);
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(remain));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL::~SDL() {
|
SDL::~SDL() {
|
||||||
|
|
|
@ -11,12 +11,22 @@ namespace Li::Gui {
|
||||||
SDL_WindowFlags windowFlags;
|
SDL_WindowFlags windowFlags;
|
||||||
SDL_SysWMinfo wmInfo;
|
SDL_SysWMinfo wmInfo;
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
|
|
||||||
|
|
||||||
|
float maxFps;
|
||||||
|
uint32_t limit;
|
||||||
|
|
||||||
|
uint32_t lastRenderTime;
|
||||||
|
uint32_t curRenderTime;
|
||||||
|
uint32_t delta;
|
||||||
|
|
||||||
Renderer* renderer;
|
Renderer* renderer;
|
||||||
bool isExiting;
|
bool isExiting;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool IsExiting();
|
bool IsExiting();
|
||||||
void NewFrame();
|
void NewFrame();
|
||||||
|
void SetMaxFPS(float fpsLimit);
|
||||||
void PollEvent();
|
void PollEvent();
|
||||||
void Render();
|
void Render();
|
||||||
SDL(std::string windowTitle, int windowWidth, int windowHeight);
|
SDL(std::string windowTitle, int windowWidth, int windowHeight);
|
||||||
|
|
Binary file not shown.
|
@ -200,7 +200,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_CACHE
|
||||||
/* Check if we've already cracked this key */
|
/* Check if we've already cracked this key */
|
||||||
p_title = dvdcss->p_titles;
|
p_title = dvdcss->p_titles;
|
||||||
while( p_title != NULL
|
while( p_title != NULL
|
||||||
|
@ -253,7 +253,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
||||||
close( i_fd );
|
close( i_fd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* Crack or decrypt Content Scrambling System (CSS) title key
|
/* Crack or decrypt Content Scrambling System (CSS) title key
|
||||||
* for current Video Title Set (VTS). */
|
* for current Video Title Set (VTS). */
|
||||||
if( i_ret < 0 )
|
if( i_ret < 0 )
|
||||||
|
@ -273,7 +273,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
||||||
/* We cache this anyway, so we don't need to check again. */
|
/* We cache this anyway, so we don't need to check again. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_CACHE
|
||||||
/* Key is valid, we store it on disk. */
|
/* Key is valid, we store it on disk. */
|
||||||
if( dvdcss->psz_cachefile[0] && b_cache )
|
if( dvdcss->psz_cachefile[0] && b_cache )
|
||||||
{
|
{
|
||||||
|
@ -294,7 +294,6 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
||||||
close( i_fd );
|
close( i_fd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find our spot in the list */
|
/* Find our spot in the list */
|
||||||
p_newtitle = NULL;
|
p_newtitle = NULL;
|
||||||
p_title = dvdcss->p_titles;
|
p_title = dvdcss->p_titles;
|
||||||
|
@ -329,6 +328,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
||||||
p_title->p_next = p_newtitle;
|
p_title->p_next = p_newtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
memcpy( dvdcss->css.p_title_key, p_title_key, DVD_KEY_SIZE );
|
memcpy( dvdcss->css.p_title_key, p_title_key, DVD_KEY_SIZE );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
* "C:\Documents and Settings\$USER\Application Data\dvdcss\" under Win32.
|
* "C:\Documents and Settings\$USER\Application Data\dvdcss\" under Win32.
|
||||||
* The special value "off" disables caching.
|
* The special value "off" disables caching.
|
||||||
*/
|
*/
|
||||||
|
//#define ENABLE_CACHE 1
|
||||||
/*
|
/*
|
||||||
* Preamble
|
* Preamble
|
||||||
*/
|
*/
|
||||||
|
@ -204,6 +204,7 @@ static int set_access_method( dvdcss_t dvdcss )
|
||||||
|
|
||||||
static int set_cache_directory( dvdcss_t dvdcss )
|
static int set_cache_directory( dvdcss_t dvdcss )
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_CACHE
|
||||||
char *psz_cache = getenv( "DVDCSS_CACHE" );
|
char *psz_cache = getenv( "DVDCSS_CACHE" );
|
||||||
|
|
||||||
if( psz_cache && !strcmp( psz_cache, "off" ) )
|
if( psz_cache && !strcmp( psz_cache, "off" ) )
|
||||||
|
@ -299,11 +300,13 @@ static int set_cache_directory( dvdcss_t dvdcss )
|
||||||
print_error( dvdcss, "cache directory name is too long" );
|
print_error( dvdcss, "cache directory name is too long" );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_cache_dir( dvdcss_t dvdcss )
|
static int init_cache_dir( dvdcss_t dvdcss )
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_CACHE
|
||||||
static const char psz_tag[] =
|
static const char psz_tag[] =
|
||||||
"Signature: 8a477f597d28d172789f06886806bc55\r\n"
|
"Signature: 8a477f597d28d172789f06886806bc55\r\n"
|
||||||
"# This file is a cache directory tag created by libdvdcss.\r\n"
|
"# This file is a cache directory tag created by libdvdcss.\r\n"
|
||||||
|
@ -344,11 +347,13 @@ static int init_cache_dir( dvdcss_t dvdcss )
|
||||||
}
|
}
|
||||||
close( i_fd );
|
close( i_fd );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_cache_subdir( dvdcss_t dvdcss )
|
static void create_cache_subdir( dvdcss_t dvdcss )
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_CACHE
|
||||||
uint8_t p_sector[DVDCSS_BLOCK_SIZE];
|
uint8_t p_sector[DVDCSS_BLOCK_SIZE];
|
||||||
char psz_key[STRING_KEY_SIZE + 1];
|
char psz_key[STRING_KEY_SIZE + 1];
|
||||||
char *psz_title;
|
char *psz_title;
|
||||||
|
@ -465,10 +470,12 @@ static void create_cache_subdir( dvdcss_t dvdcss )
|
||||||
|
|
||||||
error:
|
error:
|
||||||
dvdcss->psz_cachefile[0] = '\0';
|
dvdcss->psz_cachefile[0] = '\0';
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_cache( dvdcss_t dvdcss )
|
static void init_cache( dvdcss_t dvdcss )
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_CACHE
|
||||||
/* Set CSS key cache directory. */
|
/* Set CSS key cache directory. */
|
||||||
int i_ret = set_cache_directory( dvdcss );
|
int i_ret = set_cache_directory( dvdcss );
|
||||||
if ( i_ret < 0 )
|
if ( i_ret < 0 )
|
||||||
|
@ -485,6 +492,7 @@ static void init_cache( dvdcss_t dvdcss )
|
||||||
|
|
||||||
/* If the cache is enabled, create a DVD-specific subdirectory. */
|
/* If the cache is enabled, create a DVD-specific subdirectory. */
|
||||||
create_cache_subdir( dvdcss );
|
create_cache_subdir( dvdcss );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBDVDCSS_EXPORT char* dvdcss_get_cur_disckey(dvdcss_t dvdcss) {
|
LIBDVDCSS_EXPORT char* dvdcss_get_cur_disckey(dvdcss_t dvdcss) {
|
||||||
|
@ -628,9 +636,9 @@ static dvdcss_t dvdcss_open_common ( const char *psz_target, void *p_stream,
|
||||||
print_debug( dvdcss, "could not get disc key" );
|
print_debug( dvdcss, "could not get disc key" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_CACHE
|
||||||
init_cache( dvdcss );
|
init_cache( dvdcss );
|
||||||
|
#endif
|
||||||
/* Seek to the beginning, just for safety. */
|
/* Seek to the beginning, just for safety. */
|
||||||
dvdcss->pf_seek( dvdcss, 0 );
|
dvdcss->pf_seek( dvdcss, 0 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue