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
58 /* Previously dvdread would assume files only had one AD chain, and since they
59 * are 1GB or less, this is most problably true. However, now we handle chains
60 * for large files. ECMA_167 does not specify the maximum number of chains, is
61 * it as many as can fit in a 2048 block (minus ID 266 size), or some other
62 * limit. For now, I have assumed that;
63 * a 4.4GB file uses 5 AD chains. A BluRay disk can store 50GB of data, so the
64 * largest file should be 50 GB. So the maximum number of chains should be
67 * However, with AD chain extensions there has been examples of chains up to
68 * around 1600 entries.
71 #define UDF_MAX_AD_CHAINS 2000
77 uint32_t Partition_Start;
80 struct AD AD_chain[UDF_MAX_AD_CHAINS];
89 struct extent_ad mvds;
90 struct extent_ad rvds;
94 uint8_t VolumeIdentifier[32];
95 uint8_t VolumeSetIdentifier[128];
101 /* needed for proper freeing */
116 struct Partition partition;
126 PartitionCache, RootICBCache, LBUDFCache, MapCache, AVDPCache, PVDCache
130 * DVDReaddir entry types.
145 * DVDReaddir structure.
146 * Extended a little from POSIX to also return filesize.
149 unsigned char d_name[MAX_UDF_FILE_NAME_LEN];
150 // "Shall not exceed 1023; Ecma-167 page 123"
151 udf_dir_type_t d_type; // DT_REG, DT_DIR
152 unsigned int d_namlen;
158 * DVDOpendir DIR* structure
161 uint32_t dir_location;
163 uint32_t dir_current; // Separate to _location should we one day want to
164 // implement dir_rewind()
165 unsigned int current_p; // Internal implementation specific. UDFScanDirX
171 typedef struct FileAD *UDF_FILE;
173 typedef struct _BD_FILE
176 uint64_t seek_pos; // in bytes
177 uint64_t filesize; // in bytes
189 DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod );
190 int64_t GetFileSize(HANDLE hFile);
191 int64_t GetFilePosition(HANDLE hFile);
192 int64_t Seek(HANDLE hFile, int64_t lOffset, int whence);
193 bool Open(const char *isofile);
194 HANDLE OpenFile( const char* filename );
195 long ReadFile(HANDLE fd, unsigned char *pBuffer, long lSize);
196 void CloseFile(HANDLE hFile);
198 udf_dir_t *OpenDir( const char *subdir );
199 udf_dirent_t *ReadDir( udf_dir_t *dirp );
200 int CloseDir( udf_dir_t *dirp );
207 UDF_FILE UDFFindFile( const char* filename, uint64_t *filesize );
208 int UDFScanDirX( udf_dir_t *dirp );
209 int DVDUDFCacheLevel(int level);
210 void* GetUDFCacheHandle();
211 void SetUDFCacheHandle(void *cache);
212 int GetUDFCache(UDFCacheType type,uint32_t nr, void *data);
213 int UDFFindPartition( int partnum, struct Partition *part );
214 int UDFGetAVDP( struct avdp_t *avdp);
215 int DVDReadLBUDF( uint32_t lb_number, size_t block_count, unsigned char *data, int encrypted );
216 int ReadAt( int64_t pos, size_t len, unsigned char *data );
217 int UDFMapICB( struct AD ICB, struct Partition *partition, struct FileAD *File );
218 int UDFScanDir( struct FileAD Dir, char *FileName, struct Partition *partition, struct AD *FileICB, int cache_file_info);
219 int SetUDFCache(UDFCacheType type, uint32_t nr, void *data);
221 /* Filesystem cache */
222 int m_udfcache_level; /* 0 - turned off, 1 - on */