4 * Copyright (C) 2010 Team Boxee
7 * Copyright (C) 2010-2013 Team XBMC
10 * This Program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * This Program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with XBMC; see the file COPYING. If not, see
22 * <http://www.gnu.org/licenses/>.
24 * Note: parts of this code comes from libdvdread.
25 * Jorgen Lundman and team boxee did the necessary modifications to support udf 2.5
31 * The length of one Logical Block of a DVD.
33 #define DVD_VIDEO_LB_LEN 2048
36 * Maximum length of filenames allowed in UDF.
38 #define MAX_UDF_FILE_NAME_LEN 2048
49 uint32_t Start_Correction;
59 /* Previously dvdread would assume files only had one AD chain, and since they
60 * are 1GB or less, this is most problably true. However, now we handle chains
61 * for large files. ECMA_167 does not specify the maximum number of chains, is
62 * it as many as can fit in a 2048 block (minus ID 266 size), or some other
63 * limit. For now, I have assumed that;
64 * a 4.4GB file uses 5 AD chains. A BluRay disk can store 50GB of data, so the
65 * largest file should be 50 GB. So the maximum number of chains should be
68 * However, with AD chain extensions there has been examples of chains up to
69 * around 1600 entries.
72 #define UDF_MAX_AD_CHAINS 2000
78 uint32_t Partition_Start;
79 uint32_t Partition_Start_Correction;
82 struct AD AD_chain[UDF_MAX_AD_CHAINS];
91 struct extent_ad mvds;
92 struct extent_ad rvds;
96 uint8_t VolumeIdentifier[32];
97 uint8_t VolumeSetIdentifier[128];
103 /* needed for proper freeing */
118 struct Partition partition;
128 PartitionCache, RootICBCache, LBUDFCache, MapCache, AVDPCache, PVDCache
132 * DVDReaddir entry types.
147 * DVDReaddir structure.
148 * Extended a little from POSIX to also return filesize.
151 unsigned char d_name[MAX_UDF_FILE_NAME_LEN];
152 // "Shall not exceed 1023; Ecma-167 page 123"
153 udf_dir_type_t d_type; // DT_REG, DT_DIR
154 unsigned int d_namlen;
160 * DVDOpendir DIR* structure
163 uint32_t dir_location;
165 uint32_t dir_current; // Separate to _location should we one day want to
166 // implement dir_rewind()
167 unsigned int current_p; // Internal implementation specific. UDFScanDirX
173 typedef struct FileAD *UDF_FILE;
175 typedef struct _BD_FILE
178 uint64_t seek_pos; // in bytes
179 uint64_t filesize; // in bytes
191 DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod );
192 int64_t GetFileSize(HANDLE hFile);
193 int64_t GetFilePosition(HANDLE hFile);
194 int64_t Seek(HANDLE hFile, int64_t lOffset, int whence);
195 bool Open(const char *isofile);
196 HANDLE OpenFile( const char* filename );
197 long ReadFile(HANDLE fd, unsigned char *pBuffer, long lSize);
198 void CloseFile(HANDLE hFile);
200 udf_dir_t *OpenDir( const char *subdir );
201 udf_dirent_t *ReadDir( udf_dir_t *dirp );
202 int CloseDir( udf_dir_t *dirp );
209 UDF_FILE UDFFindFile( const char* filename, uint64_t *filesize );
210 int UDFScanDirX( udf_dir_t *dirp );
211 int DVDUDFCacheLevel(int level);
212 void* GetUDFCacheHandle();
213 void SetUDFCacheHandle(void *cache);
214 int GetUDFCache(UDFCacheType type,uint32_t nr, void *data);
215 int UDFFindPartition( int partnum, struct Partition *part );
216 int UDFGetAVDP( struct avdp_t *avdp);
217 int DVDReadLBUDF( uint32_t lb_number, size_t block_count, unsigned char *data, int encrypted );
218 int ReadAt( int64_t pos, size_t len, unsigned char *data );
219 int UDFMapICB( struct AD ICB, struct Partition *partition, struct FileAD *File );
220 int UDFScanDir( struct FileAD Dir, char *FileName, struct Partition *partition, struct AD *FileICB, int cache_file_info);
221 int SetUDFCache(UDFCacheType type, uint32_t nr, void *data);
223 /* Filesystem cache */
224 int m_udfcache_level; /* 0 - turned off, 1 - on */