Mercurial > mplayer.hg
changeset 20425:f59726d0761e
Sync with upstream r201.
author | diego |
---|---|
date | Wed, 25 Oct 2006 11:55:06 +0000 |
parents | 945fa0eb37c0 |
children | 192efe61abaa |
files | Copyright libmpdvdkit2/common.h libmpdvdkit2/device.c libmpdvdkit2/device.h libmpdvdkit2/libdvdcss.c libmpdvdkit2/libdvdcss.h libmpdvdkit2/libdvdcss_changes.diff |
diffstat | 7 files changed, 184 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/Copyright Wed Oct 25 00:05:14 2006 +0000 +++ b/Copyright Wed Oct 25 11:55:06 2006 +0000 @@ -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
--- a/libmpdvdkit2/common.h Wed Oct 25 00:05:14 2006 +0000 +++ b/libmpdvdkit2/common.h Wed Oct 25 11:55:06 2006 +0000 @@ -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@via.ecp.fr> @@ -79,5 +76,9 @@ # define snprintf _snprintf /* snprintf not defined in mingw32 (bug?) */ # endif +#else + +# define lseek64 lseek + #endif
--- a/libmpdvdkit2/device.c Wed Oct 25 00:05:14 2006 +0000 +++ b/libmpdvdkit2/device.c Wed Oct 25 11:55:06 2006 +0000 @@ -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@via.ecp.fr> - * Samuel Hocevar <sam@zoy.org> + * Sam Hocevar <sam@zoy.org> * Håkan Hjort <d95hjort@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 ) {
--- a/libmpdvdkit2/device.h Wed Oct 25 00:05:14 2006 +0000 +++ b/libmpdvdkit2/device.h Wed Oct 25 11:55:06 2006 +0000 @@ -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 );
--- a/libmpdvdkit2/libdvdcss.c Wed Oct 25 00:05:14 2006 +0000 +++ b/libmpdvdkit2/libdvdcss.c Wed Oct 25 11:55:06 2006 +0000 @@ -5,9 +5,6 @@ * Håkan Hjort <d95hjort@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 ); }
--- a/libmpdvdkit2/libdvdcss.h Wed Oct 25 00:05:14 2006 +0000 +++ b/libmpdvdkit2/libdvdcss.h Wed Oct 25 11:55:06 2006 +0000 @@ -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 * );
--- a/libmpdvdkit2/libdvdcss_changes.diff Wed Oct 25 00:05:14 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ ---- common.h 2005-10-11 10:55:45.000000000 +0200 -+++ common.h 2005-10-11 14:07:42.000000000 +0200 -@@ -50,10 +53,9 @@ - # define PATH_MAX MAX_PATH - #endif - --#define lseek _lseeki64 -- - /* several type definitions */ - # if defined( __MINGW32__ ) -+#define lseek _lseeki64 - # if !defined( _OFF_T_ ) - typedef long long _off_t; - typedef _off_t off_t; ---- device.c 2005-07-11 13:33:34.000000000 +0200 -+++ device.c 2005-10-01 19:08:07.000000000 +0200 -@@ -143,8 +132,11 @@ - print_debug( dvdcss, "opening target `%s'", psz_device ); - - #if defined( WIN32 ) -- /* If device is not "X:", we are actually opening a file. */ -- dvdcss->b_file = !psz_device[0] || psz_device[1] != ':' || psz_device[2]; -+ dvdcss->b_file = 1; -+ /* If device is "X:" or "X:\", we are not actually opening a file. */ -+ if (psz_device[0] && psz_device[1] == ':' && -+ (!psz_device[2] || (psz_device[2] == '\\' && !psz_device[3]))) -+ dvdcss->b_file = 0; - - /* Initialize readv temporary buffer */ - dvdcss->p_readv_buffer = NULL; ---- libdvdcss.c 2004-08-13 15:40:18.000000000 +0200 -+++ libdvdcss.c 2005-10-01 19:11:27.000000000 +0200 -@@ -301,6 +301,10 @@ - { - psz_home = getenv( "HOME" ); - } -+ if( psz_home == NULL ) -+ { -+ psz_home = getenv( "USERPROFILE" ); -+ } - - /* Cache our keys in ${HOME}/.dvdcss/ */ - if( psz_home )