[MPlayer-cvslog] r20441 - in trunk: Copyright libmpdvdkit2/common.h libmpdvdkit2/device.c libmpdvdkit2/device.h libmpdvdkit2/libdvdcss.c libmpdvdkit2/libdvdcss.h libmpdvdkit2/libdvdcss_changes.diff

diego subversion at mplayerhq.hu
Wed Oct 25 13:55:07 CEST 2006


Author: diego
Date: Wed Oct 25 13:55:06 2006
New Revision: 20441

Removed:
   trunk/libmpdvdkit2/libdvdcss_changes.diff
Modified:
   trunk/Copyright
   trunk/libmpdvdkit2/common.h
   trunk/libmpdvdkit2/device.c
   trunk/libmpdvdkit2/device.h
   trunk/libmpdvdkit2/libdvdcss.c
   trunk/libmpdvdkit2/libdvdcss.h

Log:
Sync with upstream r201.


Modified: trunk/Copyright
==============================================================================
--- trunk/Copyright	(original)
+++ trunk/Copyright	Wed Oct 25 13:55:06 2006
@@ -39,7 +39,7 @@
 License:    GNU General Public License
 
 Name:       libdvdcss
-Version:    1.2.9 + patches
+Version:    Subversion r201 (post 1.2.9 release)
 Homepage:   http://developers.videolan.org/libdvdcss/
 Directory:  libmpdvdkit2
 License:    GNU General Public License

Modified: trunk/libmpdvdkit2/common.h
==============================================================================
--- trunk/libmpdvdkit2/common.h	(original)
+++ trunk/libmpdvdkit2/common.h	Wed Oct 25 13:55:06 2006
@@ -3,9 +3,6 @@
  * Collection of useful common types and macros definitions
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- *
- * Modified for use with MPlayer, changes contained in libdvdread_changes.diff.
- * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
  * $Id$
  *
  * Authors: Samuel Hocevar <sam at via.ecp.fr>
@@ -79,5 +76,9 @@
 #       define snprintf _snprintf  /* snprintf not defined in mingw32 (bug?) */
 #   endif
 
+#else
+
+#   define lseek64 lseek
+
 #endif
 

Modified: trunk/libmpdvdkit2/device.c
==============================================================================
--- trunk/libmpdvdkit2/device.c	(original)
+++ trunk/libmpdvdkit2/device.c	Wed Oct 25 13:55:06 2006
@@ -1,14 +1,11 @@
 /*****************************************************************************
  * device.h: DVD device access
  *****************************************************************************
- * Copyright (C) 1998-2002 VideoLAN
- *
- * Modified for use with MPlayer, changes contained in libdvdcss_changes.diff.
- * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
+ * Copyright (C) 1998-2006 VideoLAN
  * $Id$
  *
  * Authors: Stéphane Borel <stef at via.ecp.fr>
- *          Samuel Hocevar <sam at zoy.org>
+ *          Sam Hocevar <sam at zoy.org>
  *          Håkan Hjort <d95hjort at dtek.chalmers.se>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -58,6 +55,16 @@
 #   include <sys/uio.h>                                      /* struct iovec */
 #endif
 
+#ifdef DARWIN_DVD_IOCTL
+#   include <paths.h>
+#   include <CoreFoundation/CoreFoundation.h>
+#   include <IOKit/IOKitLib.h>
+#   include <IOKit/IOBSD.h>
+#   include <IOKit/storage/IOMedia.h>
+#   include <IOKit/storage/IOCDMedia.h>
+#   include <IOKit/storage/IODVDMedia.h>
+#endif
+
 #include "dvdcss/dvdcss.h"
 
 #include "common.h"
@@ -139,6 +146,148 @@
 #endif
 }
 
+void _dvdcss_check ( dvdcss_t dvdcss )
+{
+#if defined( WIN32 )
+    DWORD drives;
+    int i;
+#elif defined( DARWIN_DVD_IOCTL )
+    io_object_t next_media;
+    mach_port_t master_port;
+    kern_return_t kern_result;
+    io_iterator_t media_iterator;
+    CFMutableDictionaryRef classes_to_match;
+#else
+    char *ppsz_devices[] = { "/dev/dvd", "/dev/cdrom", "/dev/hdc", NULL };
+    int i, i_fd;
+#endif
+
+    /* If the device name is non-null, return */
+    if( dvdcss->psz_device[0] )
+    {
+        return;
+    }
+
+#if defined( WIN32 )
+    drives = GetLogicalDrives();
+
+    for( i = 0; drives; i++ )
+    {
+        char psz_device[5];
+        DWORD cur = 1 << i;
+        UINT i_ret;
+
+        if( (drives & cur) == 0 )
+        {
+            continue;
+        }
+        drives &= ~cur;
+
+        sprintf( psz_device, "%c:\\", 'A' + i );
+        i_ret = GetDriveType( psz_device );
+        if( i_ret != DRIVE_CDROM )
+        {
+            continue;
+        }
+
+        /* Remove trailing backslash */
+        psz_device[2] = '\0';
+
+        /* FIXME: we want to differenciate between CD and DVD drives
+         * using DeviceIoControl() */
+        print_debug( dvdcss, "defaulting to drive `%s'", psz_device );
+        free( dvdcss->psz_device );
+        dvdcss->psz_device = strdup( psz_device );
+        return;
+    }
+#elif defined( DARWIN_DVD_IOCTL )
+
+    kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
+    if( kern_result != KERN_SUCCESS )
+    {
+        return;
+    }
+
+    classes_to_match = IOServiceMatching( kIODVDMediaClass );
+    if( classes_to_match == NULL )
+    {
+        return;
+    }
+
+    CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectableKey ),
+                          kCFBooleanTrue );
+
+    kern_result = IOServiceGetMatchingServices( master_port, classes_to_match,
+                                                &media_iterator );
+    if( kern_result != KERN_SUCCESS )
+    {
+        return;
+    }
+
+    next_media = IOIteratorNext( media_iterator );
+    for( ; ; )
+    {
+        char psz_buf[0x32];
+        size_t i_pathlen;
+        CFTypeRef psz_path;
+
+        next_media = IOIteratorNext( media_iterator );
+        if( next_media == 0 )
+        {
+            break;
+        }
+
+        psz_path = IORegistryEntryCreateCFProperty( next_media,
+                                                    CFSTR( kIOBSDNameKey ),
+                                                    kCFAllocatorDefault,
+                                                    0 );
+        if( psz_path == NULL )
+        {
+            IOObjectRelease( next_media );
+            continue;
+        }
+
+        snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
+        i_pathlen = strlen( psz_buf );
+
+        if( CFStringGetCString( psz_path,
+                                (char*)&psz_buf + i_pathlen,
+                                sizeof(psz_buf) - i_pathlen,
+                                kCFStringEncodingASCII ) )
+        {
+            print_debug( dvdcss, "defaulting to drive `%s'", psz_buf );
+            CFRelease( psz_path );
+            IOObjectRelease( next_media );
+            IOObjectRelease( media_iterator );
+            free( dvdcss->psz_device );
+            dvdcss->psz_device = strdup( psz_buf );
+            return;
+        }
+
+        CFRelease( psz_path );
+
+        IOObjectRelease( next_media );
+    }
+
+    IOObjectRelease( media_iterator );
+#else
+    for( i = 0; ppsz_devices[i]; i++ )
+    {
+        i_fd = open( ppsz_devices[i], 0 );
+        if( i_fd != -1 )
+        {
+            print_debug( dvdcss, "defaulting to drive `%s'", ppsz_devices[i] );
+            close( i_fd );
+            free( dvdcss->psz_device );
+            dvdcss->psz_device = strdup( ppsz_devices[i] );
+            return;
+        }
+    }
+#endif
+
+    print_error( dvdcss, "could not find a suitable default drive" );
+}
+
 int _dvdcss_open ( dvdcss_t dvdcss )
 {
     char const *psz_device = dvdcss->psz_device;
@@ -443,7 +592,7 @@
     }
 
     i_seek = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE;
-    i_seek = lseek( dvdcss->i_read_fd, i_seek, SEEK_SET );
+    i_seek = lseek64( dvdcss->i_read_fd, i_seek, SEEK_SET );
 
     if( i_seek < 0 )
     {

Modified: trunk/libmpdvdkit2/device.h
==============================================================================
--- trunk/libmpdvdkit2/device.h	(original)
+++ trunk/libmpdvdkit2/device.h	Wed Oct 25 13:55:06 2006
@@ -45,6 +45,7 @@
  * Device reading prototypes
  *****************************************************************************/
 int  _dvdcss_use_ioctls ( dvdcss_t );
+void _dvdcss_check      ( dvdcss_t );
 int  _dvdcss_open       ( dvdcss_t );
 int  _dvdcss_close      ( dvdcss_t );
 

Modified: trunk/libmpdvdkit2/libdvdcss.c
==============================================================================
--- trunk/libmpdvdkit2/libdvdcss.c	(original)
+++ trunk/libmpdvdkit2/libdvdcss.c	Wed Oct 25 13:55:06 2006
@@ -5,9 +5,6 @@
  *          Håkan Hjort <d95hjort at dtek.chalmers.se>
  *
  * Copyright (C) 1998-2002 VideoLAN
- *
- * Modified for use with MPlayer, changes contained in libdvdcss_changes.diff.
- * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
  * $Id$
  *
  * This program is free software; you can redistribute it and/or modify
@@ -145,6 +142,7 @@
  * The variable itself contains the exact version number of the library,
  * which can be useful for specific feature needs.
  */
+LIBDVDCSS_EXPORT char * dvdcss_interface_2;
 char * dvdcss_interface_2 = VERSION;
 
 /**
@@ -161,7 +159,7 @@
  * dvdcss_open() returns a handle to be used for all subsequent \e libdvdcss
  * calls. If an error occurred, NULL is returned.
  */
-extern dvdcss_t dvdcss_open ( char *psz_target )
+LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
 {
     char psz_buffer[PATH_MAX];
     int i_ret;
@@ -337,6 +335,7 @@
     /*
      *  Open device
      */
+    _dvdcss_check( dvdcss );
     i_ret = _dvdcss_open( dvdcss );
     if( i_ret < 0 )
     {
@@ -560,7 +559,7 @@
  * occurred in \e libdvdcss. It can be used to format error messages at your
  * convenience in your application.
  */
-extern char * dvdcss_error ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t dvdcss )
 {
     return dvdcss->psz_error;
 }
@@ -589,7 +588,7 @@
  * deprecated dvdcss_title() call. This flag is typically used when seeking
  * in a new title.
  */
-extern int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags )
+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 )
@@ -629,7 +628,7 @@
  * \warning dvdcss_read() expects to be able to write \p i_blocks *
  *          #DVDCSS_BLOCK_SIZE bytes in \p p_buffer.
  */
-extern int dvdcss_read ( dvdcss_t dvdcss, void *p_buffer,
+LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t dvdcss, void *p_buffer,
                                           int i_blocks,
                                           int i_flags )
 {
@@ -702,7 +701,7 @@
  *          Moreover, all iov_len members of the iovec structures should be
  *          multiples of #DVDCSS_BLOCK_SIZE.
  */
-extern int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
+LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
                                            int i_blocks,
                                            int i_flags )
 {
@@ -760,7 +759,7 @@
  * by \e libdvdcss. On return, the #dvdcss_t is invalidated and may not be
  * used again.
  */
-extern int dvdcss_close ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss )
 {
     dvd_title_t *p_title;
     int i_ret;
@@ -791,7 +790,7 @@
  *  Deprecated. See dvdcss_seek().
  */
 #undef dvdcss_title
-extern int dvdcss_title ( dvdcss_t dvdcss, int i_block )
+LIBDVDCSS_EXPORT int dvdcss_title ( dvdcss_t dvdcss, int i_block )
 {
     return _dvdcss_title( dvdcss, i_block );
 }

Modified: trunk/libmpdvdkit2/libdvdcss.h
==============================================================================
--- trunk/libmpdvdkit2/libdvdcss.h	(original)
+++ trunk/libmpdvdkit2/libdvdcss.h	Wed Oct 25 13:55:06 2006
@@ -78,6 +78,19 @@
  * Functions used across the library
  *****************************************************************************/
 #define print_error(dvdcss,msg) _print_error(dvdcss,msg)
+#if defined( _MSC_VER )
+#include <stdarg.h>
+__forceinline void print_debug(dvdcss_t dvdcss, const char *msg,...)
+{
+	va_list args;
+
+    fprintf( stderr, "libdvdcss debug: " );
+	va_start( args, msg );
+    vfprintf( stderr, msg, args );
+	va_end( args );
+    fprintf( stderr, "\n" );
+}
+#else
 #define print_debug(dvdcss,msg,args...) \
     if( dvdcss->b_debug ) \
     { \
@@ -85,6 +98,7 @@
         fprintf( stderr, msg, ##args ); \
         fprintf( stderr, "\n" ); \
     }
+#endif
 
 void _print_error ( dvdcss_t, char * );
 



More information about the MPlayer-cvslog mailing list