[PATCH] Title key cache and minor fixes

adam at yggdrasl.demon.co.uk adam at yggdrasl.demon.co.uk
Mon Jul 1 13:16:41 CEST 2002


d95hjort at dtek.chalmers.se wrote:
> Mon Jul 01 2002, adam at yggdrasl.demon.co.uk wrote:

> > When inserting a key at the start of a non-empty list, the first list
> > item was being lost (but not freed).
> Ok, I rewrote it a bit.  No need to add that extra if.

Right.  I thought there was probably a way, but it just didn't spring to
mind whilst I was writing.

> > Would it be helpful for me to post a better explanation of the cache
> > patch to the list?
> I haven't had time to look at it yet but sure, if it's not to much work.

Okay.  The cache patch is rather longer, but the idea is pretty simple
(although the code is probably a bit naive - this is my first time
 sending patches to a net-based project).

In summary, we're essentially building a database of CSS title keys
keyed by disc serial number and block number.


The patch adds two local routines to libdvdcss.c:
_dvdcss_cache_init() and _dvdcss_get_serial()

It also adds two new members to the dvdcss_handle struct to keep track of
the cache file.

In _dvdcss_open() the environment variable DVDCSS_USE_CACHE is checked.
If true, then the directory $HOME/.dvdcss is created to hold key cache
files (name defined in libdvdcss.h).  If the disc is encrypted, then
_dvdcss_cache_init() is called.

_dvdcss_cache_init() calls _dvdcss_get_serial(), which returns a
serial number string for the disc (the concept for this code came
from libdvdread) - this serial number is used as a unique filename
for the cache file.  (Problem: what happens when playing individual
vob files rather than DVD discs?  Someone with more knowledge of the
format of .vob files please help.)

The cache file is then read, simply populating the cache list in the
dvdcss_handle structure.

Finally, a change is made to dvdcss_title() such that when a key is
cracked (as opposed to read from the memory cache list), it is appended
to the cache file in the form:

block: 0xbyte0, 0xbyte1, 0xbyte2, 0xbyte3, 0xbyte4


I've been using this for a couple of weeks now on a range of discs
and it seems to work fine for me.  However, it will probably need
some work to make it less Linux-specific (one or two calls changing
is all, I think) and just general cleanups.

(Apologies for any iffy coding.  This is a learning experience for me
 as much as anything...)
-- 
Adam Jones


-- 
This is the libdvdcss-devel mailing-list, see http://www.videolan.org/libdvdcss/
To unsubscribe, please read http://www.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>



More information about the libdvdcss-devel mailing list