wok diff libdvdread/stuff/DVDFileStat.patch @ rev 15936

UP: soprano (2.8.0) and fix build depends
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 22 11:27:57 2014 +0100 (2014-02-22)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libdvdread/stuff/DVDFileStat.patch	Sat Feb 22 11:27:57 2014 +0100
     1.3 @@ -0,0 +1,237 @@
     1.4 +diff -pruN libdvdread-4.1.3/src/dvd_reader.c libdvdread-4.1.3.new/src/dvd_reader.c
     1.5 +--- libdvdread-4.1.3/src/dvd_reader.c	2008-09-06 23:55:51.000000000 +0200
     1.6 ++++ libdvdread-4.1.3.new/src/dvd_reader.c	2009-02-28 01:36:20.000000000 +0100
     1.7 +@@ -889,6 +889,187 @@ void DVDCloseFile( dvd_file_t *dvd_file 
     1.8 +     }
     1.9 + }
    1.10 + 
    1.11 ++static int DVDFileStatVOBUDF(dvd_reader_t *dvd, int title, 
    1.12 ++                             int menu, dvd_stat_t *statbuf)
    1.13 ++{
    1.14 ++  char filename[ MAX_UDF_FILE_NAME_LEN ];
    1.15 ++  uint32_t size;
    1.16 ++  off_t tot_size;
    1.17 ++  off_t parts_size[9];
    1.18 ++  int nr_parts = 0;
    1.19 ++  int n;
    1.20 ++ 
    1.21 ++  if( title == 0 ) {
    1.22 ++    sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
    1.23 ++  } else {
    1.24 ++    sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
    1.25 ++  }
    1.26 ++  if(!UDFFindFile( dvd, filename, &size )) {
    1.27 ++    return -1;
    1.28 ++  }
    1.29 ++  tot_size = size;
    1.30 ++  nr_parts = 1;
    1.31 ++  parts_size[0] = size;
    1.32 ++
    1.33 ++  if( !menu ) {
    1.34 ++    int cur;
    1.35 ++
    1.36 ++    for( cur = 2; cur < 10; cur++ ) {
    1.37 ++      sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur );
    1.38 ++      if( !UDFFindFile( dvd, filename, &size ) ) {
    1.39 ++        break;
    1.40 ++      }
    1.41 ++      parts_size[nr_parts] = size;
    1.42 ++      tot_size += size;
    1.43 ++      nr_parts++;
    1.44 ++    }
    1.45 ++  }
    1.46 ++  
    1.47 ++  statbuf->size = tot_size;
    1.48 ++  statbuf->nr_parts = nr_parts;
    1.49 ++  for(n = 0; n < nr_parts; n++) {
    1.50 ++    statbuf->parts_size[n] = parts_size[n];
    1.51 ++  }
    1.52 ++  return 0;
    1.53 ++}
    1.54 ++
    1.55 ++
    1.56 ++static int DVDFileStatVOBPath( dvd_reader_t *dvd, int title,
    1.57 ++                                       int menu, dvd_stat_t *statbuf )
    1.58 ++{
    1.59 ++  char filename[ MAX_UDF_FILE_NAME_LEN ];
    1.60 ++  char full_path[ PATH_MAX + 1 ];
    1.61 ++  struct stat fileinfo;
    1.62 ++  off_t tot_size;
    1.63 ++  off_t parts_size[9];
    1.64 ++  int nr_parts = 0;
    1.65 ++  int n;
    1.66 ++
    1.67 ++ 
    1.68 ++    
    1.69 ++  if( title == 0 ) {
    1.70 ++    sprintf( filename, "VIDEO_TS.VOB" );
    1.71 ++  } else {
    1.72 ++    sprintf( filename, "VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
    1.73 ++  }
    1.74 ++  if( !findDVDFile( dvd, filename, full_path ) ) {
    1.75 ++    return -1;
    1.76 ++  }
    1.77 ++  
    1.78 ++  if( stat( full_path, &fileinfo ) < 0 ) {
    1.79 ++    fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
    1.80 ++    return -1;
    1.81 ++  }
    1.82 ++  
    1.83 ++
    1.84 ++  tot_size = fileinfo.st_size;
    1.85 ++  nr_parts = 1;
    1.86 ++  parts_size[0] = fileinfo.st_size;
    1.87 ++
    1.88 ++  if( !menu ) {
    1.89 ++    int cur;
    1.90 ++    
    1.91 ++    for( cur = 2; cur < 10; cur++ ) {
    1.92 ++
    1.93 ++      sprintf( filename, "VTS_%02d_%d.VOB", title, cur );
    1.94 ++      if( !findDVDFile( dvd, filename, full_path ) ) {
    1.95 ++        break;
    1.96 ++      }
    1.97 ++
    1.98 ++      if( stat( full_path, &fileinfo ) < 0 ) {
    1.99 ++        fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
   1.100 ++        break;
   1.101 ++      }
   1.102 ++      
   1.103 ++      parts_size[nr_parts] = fileinfo.st_size;
   1.104 ++      tot_size += parts_size[nr_parts];
   1.105 ++      nr_parts++;
   1.106 ++    }
   1.107 ++  }
   1.108 ++
   1.109 ++  statbuf->size = tot_size;
   1.110 ++  statbuf->nr_parts = nr_parts;
   1.111 ++  for(n = 0; n < nr_parts; n++) {
   1.112 ++    statbuf->parts_size[n] = parts_size[n];
   1.113 ++  }
   1.114 ++  return 0;
   1.115 ++}
   1.116 ++
   1.117 ++
   1.118 ++int DVDFileStat(dvd_reader_t *dvd, int titlenum, 
   1.119 ++                dvd_read_domain_t domain, dvd_stat_t *statbuf)
   1.120 ++{
   1.121 ++  char filename[ MAX_UDF_FILE_NAME_LEN ];
   1.122 ++  char full_path[ PATH_MAX + 1 ];
   1.123 ++  struct stat fileinfo;
   1.124 ++  uint32_t size;
   1.125 ++
   1.126 ++  /* Check arguments. */
   1.127 ++  if( dvd == NULL || titlenum < 0 ) {
   1.128 ++    errno = EINVAL;
   1.129 ++    return -1;
   1.130 ++  }
   1.131 ++
   1.132 ++  switch( domain ) {
   1.133 ++  case DVD_READ_INFO_FILE:
   1.134 ++    if( titlenum == 0 ) {
   1.135 ++      sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" );
   1.136 ++    } else {
   1.137 ++      sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum );
   1.138 ++    }
   1.139 ++    break;
   1.140 ++  case DVD_READ_INFO_BACKUP_FILE:
   1.141 ++    if( titlenum == 0 ) {
   1.142 ++      sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" );
   1.143 ++    } else {
   1.144 ++      sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum );
   1.145 ++    }
   1.146 ++    break;
   1.147 ++  case DVD_READ_MENU_VOBS:
   1.148 ++    if( dvd->isImageFile ) {
   1.149 ++      return DVDFileStatVOBUDF( dvd, titlenum, 1, statbuf );
   1.150 ++    } else {
   1.151 ++      return DVDFileStatVOBPath( dvd, titlenum, 1, statbuf );
   1.152 ++    }
   1.153 ++    break;
   1.154 ++  case DVD_READ_TITLE_VOBS:
   1.155 ++    if( titlenum == 0 ) {
   1.156 ++      return -1;
   1.157 ++    }
   1.158 ++    if( dvd->isImageFile ) {
   1.159 ++      return DVDFileStatVOBUDF( dvd, titlenum, 0, statbuf );
   1.160 ++    } else {
   1.161 ++      return DVDFileStatVOBPath( dvd, titlenum, 0, statbuf );
   1.162 ++    }
   1.163 ++    break;
   1.164 ++  default:
   1.165 ++    fprintf( stderr, "libdvdread: Invalid domain for file stat.\n" );
   1.166 ++    errno = EINVAL;
   1.167 ++    return -1;
   1.168 ++  }
   1.169 ++  
   1.170 ++  if( dvd->isImageFile ) {
   1.171 ++    if( UDFFindFile( dvd, filename, &size ) ) {
   1.172 ++      statbuf->size = size;
   1.173 ++      statbuf->nr_parts = 1;
   1.174 ++      statbuf->parts_size[0] = size;
   1.175 ++      return 0;
   1.176 ++    }
   1.177 ++  } else {
   1.178 ++    if( findDVDFile( dvd, filename, full_path ) )  {
   1.179 ++      if( stat( full_path, &fileinfo ) < 0 ) {
   1.180 ++        fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
   1.181 ++      } else {
   1.182 ++        statbuf->size = fileinfo.st_size;
   1.183 ++        statbuf->nr_parts = 1;
   1.184 ++        statbuf->parts_size[0] = statbuf->size;
   1.185 ++        return 0;
   1.186 ++      }
   1.187 ++    }
   1.188 ++  }
   1.189 ++  return -1;
   1.190 ++}
   1.191 ++
   1.192 + /* Internal, but used from dvd_udf.c */
   1.193 + int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number,
   1.194 + 			 size_t block_count, unsigned char *data,
   1.195 +diff -pruN libdvdread-4.1.3/src/dvd_reader.h libdvdread-4.1.3.new/src/dvd_reader.h
   1.196 +--- libdvdread-4.1.3/src/dvd_reader.h	2008-09-06 23:55:51.000000000 +0200
   1.197 ++++ libdvdread-4.1.3.new/src/dvd_reader.h	2009-02-28 01:36:49.000000000 +0100
   1.198 +@@ -115,6 +115,42 @@ typedef enum {
   1.199 + } dvd_read_domain_t;
   1.200 + 
   1.201 + /**
   1.202 ++ *
   1.203 ++ */
   1.204 ++typedef struct {
   1.205 ++  off_t size;          /**< Total size of file in bytes */
   1.206 ++  int nr_parts;        /**< Number of file parts */
   1.207 ++  off_t parts_size[9]; /**< Size of each part in bytes */
   1.208 ++} dvd_stat_t;
   1.209 ++
   1.210 ++/**
   1.211 ++ * Stats a file on the DVD given the title number and domain.
   1.212 ++ * The information about the file is stored in a dvd_stat_t
   1.213 ++ * which contains information about the size of the file and
   1.214 ++ * the number of parts in case of a multipart file and the respective
   1.215 ++ * sizes of the parts.
   1.216 ++ * A multipart file is for instance VTS_02_1.VOB, VTS_02_2.VOB, VTS_02_3.VOB
   1.217 ++ * The size of VTS_02_1.VOB will be stored in stat->parts_size[0],
   1.218 ++ * VTS_02_2.VOB in stat->parts_size[1], ...
   1.219 ++ * The total size (sum of all parts) is stored in stat->size and
   1.220 ++ * stat->nr_parts will hold the number of parts.
   1.221 ++ * Only DVD_READ_TITLE_VOBS (VTS_??_[1-9].VOB) can be multipart files.
   1.222 ++ * 
   1.223 ++ * This function is only of use if you want to get the size of each file
   1.224 ++ * in the filesystem. These sizes are not needed to use any other
   1.225 ++ * functions in libdvdread. 
   1.226 ++ *
   1.227 ++ * @param dvd  A dvd read handle.
   1.228 ++ * @param titlenum Which Video Title Set should be used, VIDEO_TS is 0.
   1.229 ++ * @param domain Which domain. 
   1.230 ++ * @param stat Pointer to where the result is stored.
   1.231 ++ * @return If successful 0, otherwise -1.
   1.232 ++ *
   1.233 ++ * int DVDFileStat(dvd, titlenum, domain, stat);
   1.234 ++ */
   1.235 ++int DVDFileStat(dvd_reader_t *, int, dvd_read_domain_t, dvd_stat_t *);
   1.236 ++  
   1.237 ++/**
   1.238 +  * Opens a file on the DVD given the title number and domain.
   1.239 +  *
   1.240 +  * If the title number is 0, the video manager information is opened