bluray.c 635 Bytes
Newer Older
cRTrn13's avatar
cRTrn13 committed
1

cRTrn13's avatar
cRTrn13 committed
2 3
#include <dlfcn.h>

cRTrn13's avatar
cRTrn13 committed
4
#include "bluray.h"
cRTrn13's avatar
cRTrn13 committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include "util/macro.h"

BLURAY *bd_open(const char* device_path, const char* keyfile_path)
{
    BLURAY *bd = malloc(sizeof(BLURAY));

    // open aacs decryptor if present
    bd->aacs = NULL;
    if ((bd->libaacs_h = dlopen("libaacs", RTLD_NOW))) {
        typedef AACS_KEYS* (*fptr)();

        fptr fptr_s = dlsym(bd->libaacs_h, "aacs_open");
        bd->aacs = fptr_s(device_path, keyfile_path);
    }

    return bd;
}

void bd_close(BLURAY *bd)
{
    if (bd->libaacs_h) {
        aacs_close(bd->aacs);
    }

    X_FREE(bd);
cRTrn13's avatar
cRTrn13 committed
30

cRTrn13's avatar
cRTrn13 committed
31 32 33
    dlclose(bd->libbdplus_h);
    dlclose(bd->libaacs_h);
}