]> git.sesse.net Git - vlc/blobdiff - plugins/dvd/dvd_udf.c
* Added a dummy libdvdcss so that the DVD plugin can be used without
[vlc] / plugins / dvd / dvd_udf.c
index 77c027cf969e5b9f75053ae6d15ecad3e4b06062..9f4f89af57d78cc19d77390955c87fd1ff488935 100644 (file)
@@ -5,7 +5,7 @@
  * contains the basic udf handling functions
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: dvd_udf.c,v 1.7 2001/05/31 01:37:08 sam Exp $
+ * $Id: dvd_udf.c,v 1.13 2001/08/06 13:28:00 sam Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-/*
- * Preamble
- */
-#include "defs.h"
-
-#ifdef HAVE_CSS
 #define MODULE_NAME dvd
-#else /* HAVE_CSS */
-#define MODULE_NAME dvdnocss
-#endif /* HAVE_CSS */
 #include "modules_inner.h"
 
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
 #include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
 
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#   include <unistd.h>
 #elif defined( _MSC_VER ) && defined( _WIN32 )
-#include <io.h>
+#   include <io.h>
 #endif
 
-#include <string.h>
 #ifdef STRNCASECMP_IN_STRINGS_H
 #   include <strings.h>
 #endif
-#include <fcntl.h>
 
+#ifdef GOD_DAMN_DMCA
+#   include "dummy_dvdcss.h"
+#else
+#   include <videolan/dvdcss.h>
+#endif
+
+#include "config.h"
 #include "common.h"
+#include "threads.h"
+#include "mtime.h"
+
 #include "intf_msg.h"
-#include "dvd_css.h"
-#include "dvd_ifo.h"
+
 #include "input_dvd.h"
+#include "dvd_ifo.h"
+
+#include "modules.h"
+#include "modules_export.h"
 
 #define UDFADshort      1
 #define UDFADlong       2
 
 typedef struct partition_s
 {
-    boolean_t   b_valid;
-    u8          pi_volume_desc[128];
-    u16         i_flags;
-    u16         i_number;
-    u8          pi_contents[32];
-    u32         i_access_type;
-    u32         i_start;
-    u32         i_length;
-    int         i_fd;
+    boolean_t     b_valid;
+    u8            pi_volume_desc[128];
+    u16           i_flags;
+    u16           i_number;
+    u8            pi_contents[32];
+    u32           i_access_type;
+    u32           i_start;
+    u32           i_length;
+    dvdcss_handle dvdhandle;
 } partition_t;
 
 typedef struct ad_s
@@ -97,20 +106,16 @@ typedef struct ad_s
  *****************************************************************************
  * Returns number of read bytes on success, 0 on error
  *****************************************************************************/
-static int UDFReadLB( int i_fd, off_t i_lba, size_t i_block_count, u8 *pi_data )
+static int UDFReadLB( dvdcss_handle dvdhandle, off_t i_lba,
+                      size_t i_block_count, u8 *pi_data )
 {
-    if( i_fd < 0 )
-    {
-        return 0;
-    }
-
-    if( lseek( i_fd, i_lba * (off_t) DVD_LB_SIZE, SEEK_SET ) < 0 )
+    if( dvdcss_seek( dvdhandle, i_lba ) < 0 )
     {
         intf_ErrMsg( "UDF: Postion not found" );
         return 0;
     }
 
-    return read( i_fd, pi_data, i_block_count *DVD_LB_SIZE);
+    return dvdcss_read( dvdhandle, pi_data, i_block_count, DVDCSS_NOFLAGS );
 }
 
 
@@ -383,7 +388,7 @@ static int UDFMapICB( struct ad_s icb, u8 * pi_file_type, struct ad_s * p_file,
 
     do
     {
-        if( !UDFReadLB( partition.i_fd, i_lba++, 1, pi_lb ) )
+        if( !UDFReadLB( partition.dvdhandle, i_lba++, 1, pi_lb ) )
         {
             i_tag_id = 0;
         }
@@ -427,7 +432,7 @@ static int UDFScanDir( struct ad_s dir, char * psz_filename,
 #if 0
     do
     {
-        if( !UDFReadLB( partition.i_fd, i_lba++, 1, pi_lb ) )
+        if( !UDFReadLB( partition.dvdhandle, i_lba++, 1, pi_lb ) )
         {
             i_tag_id = 0;
         }
@@ -459,7 +464,7 @@ static int UDFScanDir( struct ad_s dir, char * psz_filename,
 
 #else
 
-    if( UDFReadLB( partition.i_fd, i_lba, 2, pi_lb ) <= 0 ) {
+    if( UDFReadLB( partition.dvdhandle, i_lba, 2, pi_lb ) <= 0 ) {
         return 0;
     }
 
@@ -471,7 +476,7 @@ static int UDFScanDir( struct ad_s dir, char * psz_filename,
             ++i_lba;
             p -= DVD_LB_SIZE;
             dir.i_length -= DVD_LB_SIZE;
-            if( UDFReadLB( partition.i_fd, i_lba, 2, pi_lb ) <= 0 )
+            if( UDFReadLB( partition.dvdhandle, i_lba, 2, pi_lb ) <= 0 )
             {
                 return 0;
             }
@@ -528,7 +533,7 @@ static int UDFFindPartition( int i_part_nb, struct partition_s *p_partition )
     /* Search anchor loop */
     while( 1 )
     {
-        if( UDFReadLB( p_partition->i_fd, i_lba, 1, pi_anchor ) )
+        if( UDFReadLB( p_partition->dvdhandle, i_lba, 1, pi_anchor ) )
         {
             UDFDescriptor( pi_anchor, &i_tag_id );
         }
@@ -592,7 +597,7 @@ static int UDFFindPartition( int i_part_nb, struct partition_s *p_partition )
 
         do
         {
-            if( !UDFReadLB( p_partition->i_fd, i_lba++, 1, pi_lb ) )
+            if( !UDFReadLB( p_partition->dvdhandle, i_lba++, 1, pi_lb ) )
             {
                 i_tag_id = 0;
             }
@@ -649,7 +654,7 @@ static int UDFFindPartition( int i_part_nb, struct partition_s *p_partition )
  * starting with '/'.
  * returns absolute LB number, or 0 on error
  *****************************************************************************/
-u32 UDFFindFile( int i_fd, char * psz_path )
+u32 UDFFindFile( dvdcss_handle dvdhandle, char * psz_path )
 {
     struct partition_s  partition;
     struct ad_s         root_icb;
@@ -666,7 +671,7 @@ u32 UDFFindFile( int i_fd, char * psz_path )
     strcat( psz_tokenline, psz_path );
 
     /* Init file descriptor of UDF filesystem (== DVD) */
-    partition.i_fd = i_fd;
+    partition.dvdhandle = dvdhandle;
 
     /* Find partition 0, standard partition for DVD-Video */
     i_partition = 0;
@@ -681,7 +686,7 @@ u32 UDFFindFile( int i_fd, char * psz_path )
 
     do
     {
-        if( !UDFReadLB( i_fd, i_lba++, 1, pi_lb ) )
+        if( !UDFReadLB( dvdhandle, i_lba++, 1, pi_lb ) )
         {
             i_tag_id = 0;
         }