/** * \brief Seek in the disc and change the current key if requested. * * \param dvdcss a \e libdvdcss instance * \param i_blocks an absolute block offset to seek to * \param i_flags #DVDCSS_NOFLAGS, optionally ORed with one of #DVDCSS_SEEK_KEY * or #DVDCSS_SEEK_MPEG * \return the new position in blocks or a negative value in case an error * happened. * * This function seeks to the requested position, in logical blocks. * * You typically set \p i_flags to #DVDCSS_NOFLAGS when seeking in a .IFO. * * If #DVDCSS_SEEK_MPEG is specified in \p i_flags and if \e libdvdcss finds it * reasonable to do so (i.e., if the dvdcss method is not "title"), the current * title key will be checked and a new one will be calculated if necessary. * This flag is typically used when reading data from a .VOB file. * * If #DVDCSS_SEEK_KEY is specified, the title key will always be checked, * even with the "title" method. This flag is typically used when seeking * in a new title. */ LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags ) { /* title cracking method is too slow to be used at each seek */ if( ( ( i_flags & DVDCSS_SEEK_MPEG ) && ( dvdcss->i_method != DVDCSS_METHOD_TITLE ) ) || ( i_flags & DVDCSS_SEEK_KEY ) ) { /* check the title key */ if( dvdcss_title( dvdcss, i_blocks ) ) { return -1; } } return dvdcss->pf_seek( dvdcss, i_blocks ); }
/* Loop over all titles and call dvdcss_title to crack the keys. */ static int initAllCSSKeys( dvd_reader_t *dvd ) { //struct timeval all_s, all_e; //struct timeval t_s, t_e; char filename[ MAX_UDF_FILE_NAME_LEN ]; uint32_t start, len; int title; char *nokeys_str = getenv("DVDREAD_NOKEYS"); if(nokeys_str != NULL) return 0; //fprintf( stderr, "\n" ); //fprintf( stderr, "libdvdread: Attempting to retrieve all CSS keys\n" ); //fprintf( stderr, "libdvdread: This can take a _long_ time, please be patient\n\n" ); //gettimeofday(&all_s, NULL); for( title = 0; title < 100; title++ ) { //gettimeofday( &t_s, NULL ); if( title == 0 ) { sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" ); } else { sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 0 ); } start = UDFFindFile( dvd, filename, &len ); if( start != 0 && len != 0 ) { /* Perform CSS key cracking for this title. */ //fprintf( stderr, "libdvdread: Get key for %s at 0x%08x\n", filename, start ); if( dvdcss_title( dvd->fd, (int)start ) < 0 ) { //fprintf( stderr, "libdvdread: Error cracking CSS key for %s (0x%08x)\n", filename, start); } //gettimeofday( &t_e, NULL ); //fprintf( stderr, "libdvdread: Elapsed time %ld\n", // (long int) t_e.tv_sec - t_s.tv_sec ); } if( !title ) continue; //gettimeofday( &t_s, NULL ); //sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 1 ); start = UDFFindFile( dvd, filename, &len ); if( start == 0 || len == 0 ) break; /* Perform CSS key cracking for this title. */ //fprintf( stderr, "libdvdread: Get key for %s at 0x%08x\n", // filename, start ); if( dvdcss_title( dvd->fd, (int)start ) < 0 ) { //fprintf( stderr, "libdvdread: Error cracking CSS key for %s (0x%08x)!!\n", filename, start); } //gettimeofday( &t_e, NULL ); //fprintf( stderr, "libdvdread: Elapsed time %ld\n", // (long int) t_e.tv_sec - t_s.tv_sec ); } title--; //fprintf( stderr, "libdvdread: Found %d VTS's\n", title ); //gettimeofday(&all_e, NULL); //fprintf( stderr, "libdvdread: Elapsed time %ld\n", // (long int) all_e.tv_sec - all_s.tv_sec ); return 0; }