mirror of
https://github.com/videolan/vlc.git
synced 2024-12-13 11:44:18 +08:00
* Win2000 DVD input by Jon Lech Johansen <jon-vl@nanocrew.net>.
This commit is contained in:
parent
94d3d4d8be
commit
b8ce47bbc7
1
AUTHORS
1
AUTHORS
@ -115,6 +115,7 @@ D: Bug fixes
|
||||
N: Jon Lech Johansen
|
||||
E: jon-vl@nanocrew.net
|
||||
D: PS input fixes
|
||||
D: Win32 port
|
||||
|
||||
N: Michel Kaempf
|
||||
E: maxx@via.ecp.fr
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Collection of useful common types and macros definitions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998, 1999, 2000 VideoLAN
|
||||
* $Id: common.h,v 1.33 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: common.h,v 1.34 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Samuel Hocevar <sam@via.ecp.fr>
|
||||
* Vincent Seguin <seguin@via.ecp.fr>
|
||||
@ -140,7 +140,6 @@ struct es_descriptor_s;
|
||||
/*****************************************************************************
|
||||
* Macros and inline functions
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef NTOHL_IN_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#elif defined(WIN32)
|
||||
@ -157,10 +156,10 @@ struct es_descriptor_s;
|
||||
|
||||
/* MAX and MIN: self explanatory */
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
|
||||
# define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
|
||||
# define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
|
||||
#endif
|
||||
|
||||
/* MSB (big endian)/LSB (little endian) conversions - network order is always
|
||||
@ -171,19 +170,19 @@ struct es_descriptor_s;
|
||||
/* FIXME: hton64 should be declared as an extern inline function to avoid
|
||||
* border effects (see byteorder.h) */
|
||||
#if WORDS_BIGENDIAN
|
||||
#define hton16 htons
|
||||
#define hton32 htonl
|
||||
#define hton64(i) ( i )
|
||||
#define ntoh16 ntohs
|
||||
#define ntoh32 ntohl
|
||||
#define ntoh64(i) ( i )
|
||||
# define hton16 htons
|
||||
# define hton32 htonl
|
||||
# define hton64(i) ( i )
|
||||
# define ntoh16 ntohs
|
||||
# define ntoh32 ntohl
|
||||
# define ntoh64(i) ( i )
|
||||
#else
|
||||
#define hton16 htons
|
||||
#define hton32 htonl
|
||||
#define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
|
||||
#define ntoh16 ntohs
|
||||
#define ntoh32 ntohl
|
||||
#define ntoh64 hton64
|
||||
# define hton16 htons
|
||||
# define hton32 htonl
|
||||
# define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
|
||||
# define ntoh16 ntohs
|
||||
# define ntoh32 ntohl
|
||||
# define ntoh64 hton64
|
||||
#endif
|
||||
|
||||
/* Macros with automatic casts */
|
||||
@ -194,15 +193,16 @@ struct es_descriptor_s;
|
||||
/* win32, cl and icl support */
|
||||
#if defined( _MSC_VER )
|
||||
typedef long off_t;
|
||||
#define __attribute__(x)
|
||||
#define __inline__ __inline
|
||||
#define strncasecmp strnicmp
|
||||
#define strcasecmp stricmp
|
||||
#define S_ISBLK(m) (0)
|
||||
#define S_ISCHR(m) (0)
|
||||
#define S_ISFIFO(m) (((m)&_S_IFMT) == _S_IFIFO)
|
||||
#define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG)
|
||||
#define I64C(x) x
|
||||
# define __attribute__(x)
|
||||
# define __inline__ __inline
|
||||
# define strncasecmp strnicmp
|
||||
# define strcasecmp stricmp
|
||||
# define S_ISBLK(m) (0)
|
||||
# define S_ISCHR(m) (0)
|
||||
# define S_ISFIFO(m) (((m)&_S_IFMT) == _S_IFIFO)
|
||||
# define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG)
|
||||
# define I64C(x) x
|
||||
#else
|
||||
#define I64C(x) x##LL
|
||||
# define I64C(x) x##LL
|
||||
#endif
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* interface, such as message output. See config.h for output configuration.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999, 2000 VideoLAN
|
||||
* $Id: intf_msg.h,v 1.14 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: intf_msg.h,v 1.15 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Vincent Seguin <seguin@via.ecp.fr>
|
||||
*
|
||||
@ -49,11 +49,11 @@ void _intf_DbgMsgImm ( char *psz_file, char *psz_function, int i_line,
|
||||
|
||||
/* Non-TRACE mode */
|
||||
#if defined( _MSC_VER )
|
||||
#define intf_DbgMsg
|
||||
#define intf_DbgMsgImm
|
||||
# define intf_DbgMsg
|
||||
# define intf_DbgMsgImm
|
||||
#else
|
||||
#define intf_DbgMsg( format, args... )
|
||||
#define intf_DbgMsgImm( format, args...)
|
||||
# define intf_DbgMsg( format, args... )
|
||||
# define intf_DbgMsgImm( format, args...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@
|
||||
* dvd_css.c: Functions for DVD authentification and unscrambling
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_css.c,v 1.30 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: dvd_css.c,v 1.31 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -38,9 +38,9 @@
|
||||
#include <stdlib.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>
|
||||
@ -50,9 +50,11 @@
|
||||
#include "intf_msg.h"
|
||||
|
||||
#include "dvd_css.h"
|
||||
|
||||
#ifdef HAVE_CSS
|
||||
#include "dvd_csstables.h"
|
||||
# include "dvd_csstables.h"
|
||||
#endif /* HAVE_CSS */
|
||||
|
||||
#include "dvd_ioctl.h"
|
||||
|
||||
#include "input_dvd.h"
|
||||
@ -333,8 +335,13 @@ int CSSGetKey( int i_fd, css_t * p_css )
|
||||
i_pos = p_css->i_title_pos;
|
||||
|
||||
do {
|
||||
#if !defined( WIN32 )
|
||||
i_pos = lseek( i_fd, i_pos, SEEK_SET );
|
||||
i_bytes_read = read( i_fd, pi_buf, 0x800 );
|
||||
#else
|
||||
i_pos = SetFilePointer( (HANDLE) i_fd, i_pos, 0, FILE_BEGIN );
|
||||
ReadFile( (HANDLE) i_fd, pi_buf, 0x800, &i_bytes_read, NULL );
|
||||
#endif
|
||||
|
||||
/* PES_scrambling_control */
|
||||
if( pi_buf[0x14] & 0x30 )
|
||||
|
@ -2,7 +2,7 @@
|
||||
* dvd_ifo.c: Functions for ifo parsing
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_ifo.c,v 1.28 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: dvd_ifo.c,v 1.29 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -36,9 +36,9 @@
|
||||
#include <stdlib.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>
|
||||
@ -51,9 +51,9 @@
|
||||
#include "dvd_udf.h"
|
||||
#include "input_dvd.h"
|
||||
|
||||
/*
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*/
|
||||
*****************************************************************************/
|
||||
void CommandRead ( command_desc_t );
|
||||
static int ReadTitle ( ifo_t * , title_t *, off_t );
|
||||
static int FreeTitle ( title_t * );
|
||||
@ -72,9 +72,18 @@ static int FreeTitleSet ( vts_t * );
|
||||
*****************************************************************************/
|
||||
static __inline__ u8* FillBuffer( ifo_t* p_ifo, u8* pi_buffer, off_t i_pos )
|
||||
{
|
||||
#if defined( WIN32 )
|
||||
DWORD tmp;
|
||||
#endif
|
||||
|
||||
memset( pi_buffer, 0, DVD_LB_SIZE );
|
||||
#if !defined( WIN32 )
|
||||
p_ifo->i_pos = lseek( p_ifo->i_fd, i_pos, SEEK_SET );
|
||||
read( p_ifo->i_fd, pi_buffer, DVD_LB_SIZE );
|
||||
#else
|
||||
p_ifo->i_pos = SetFilePointer( (HANDLE) p_ifo->i_fd, i_pos, NULL, FILE_BEGIN );
|
||||
ReadFile( (HANDLE) p_ifo->i_fd, pi_buffer, DVD_LB_SIZE, &tmp, NULL );
|
||||
#endif
|
||||
|
||||
return pi_buffer;
|
||||
}
|
||||
@ -1095,9 +1104,15 @@ static int ReadTitle( ifo_t * p_ifo, title_t * p_title, off_t i_pos )
|
||||
/* parsing of chapter_map_t: it gives the entry cell for each chapter */
|
||||
if( p_title->i_chapter_map_start_byte )
|
||||
{
|
||||
#if !defined( WIN32 )
|
||||
p_ifo->i_pos = lseek( p_ifo->i_fd,
|
||||
i_start + p_title->i_chapter_map_start_byte,
|
||||
SEEK_SET );
|
||||
#else
|
||||
p_ifo->i_pos = SetFilePointer( (HANDLE) p_ifo->i_fd,
|
||||
i_start + p_title->i_chapter_map_start_byte,
|
||||
NULL, FILE_BEGIN );
|
||||
#endif
|
||||
|
||||
p_title->chapter_map.pi_start_cell =
|
||||
malloc( p_title->i_chapter_nb *sizeof(chapter_map_t) );
|
||||
|
@ -2,10 +2,11 @@
|
||||
* dvd_ioctl.c: DVD ioctl replacement function
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_ioctl.c,v 1.15 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: dvd_ioctl.c,v 1.16 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
|
||||
* Samuel Hocevar <sam@zoy.org>
|
||||
* Jon Lech Johansen <jon-vl@nanocrew.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -30,9 +31,12 @@
|
||||
#include <string.h> /* memcpy(), memset() */
|
||||
#include <sys/types.h>
|
||||
|
||||
#if !defined( WIN32 )
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#if defined( WIN32 )
|
||||
# include <windows.h>
|
||||
# include <winioctl.h>
|
||||
#else
|
||||
# include <netinet/in.h>
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef DVD_STRUCT_IN_SYS_CDIO_H
|
||||
@ -65,26 +69,6 @@
|
||||
*****************************************************************************/
|
||||
#if defined( SYS_BEOS )
|
||||
static void BeInitRDC ( raw_device_command *, int );
|
||||
#define INIT_RDC( TYPE, SIZE ) \
|
||||
raw_device_command rdc; \
|
||||
u8 p_buffer[ (SIZE) ]; \
|
||||
memset( &rdc, 0, sizeof( raw_device_command ) ); \
|
||||
rdc.data = (char *)p_buffer; \
|
||||
rdc.data_length = (SIZE); \
|
||||
BeInitRDC( &rdc, (TYPE) );
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes, Darwin specific
|
||||
*****************************************************************************/
|
||||
#if defined( SYS_DARWIN1_3 )
|
||||
#define INIT_DVDIOCTL( SIZE ) \
|
||||
dvdioctl_data_t dvdioctl; \
|
||||
u8 p_buffer[ (SIZE) ]; \
|
||||
dvdioctl.p_buffer = p_buffer; \
|
||||
dvdioctl.i_size = (SIZE); \
|
||||
dvdioctl.i_keyclass = kCSS_CSS2_CPRM; \
|
||||
memset( p_buffer, 0, (SIZE) );
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
@ -132,6 +116,49 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
|
||||
|
||||
i_ret = 0;
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
DWORD tmp;
|
||||
u8 p_buffer[ 8 ];
|
||||
SCSI_PASS_THROUGH_DIRECT sptd;
|
||||
|
||||
memset( &sptd, 0, sizeof( sptd ) );
|
||||
memset( &p_buffer, 0, sizeof( p_buffer ) );
|
||||
|
||||
/* When using IOCTL_DVD_READ_STRUCTURE and
|
||||
DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType
|
||||
is always 6. So we send a raw scsi command instead. */
|
||||
|
||||
sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT );
|
||||
sptd.CdbLength = 12;
|
||||
sptd.DataIn = SCSI_IOCTL_DATA_IN;
|
||||
sptd.DataTransferLength = 8;
|
||||
sptd.TimeOutValue = 2;
|
||||
sptd.DataBuffer = p_buffer;
|
||||
sptd.Cdb[ 0 ] = GPCMD_READ_DVD_STRUCTURE;
|
||||
sptd.Cdb[ 6 ] = i_layer;
|
||||
sptd.Cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
||||
sptd.Cdb[ 8 ] = (8 >> 8) & 0xff;
|
||||
sptd.Cdb[ 9 ] = 8 & 0xff;
|
||||
|
||||
i_ret = DeviceIoControl( (HANDLE) i_fd,
|
||||
IOCTL_SCSI_PASS_THROUGH_DIRECT,
|
||||
&sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
|
||||
&sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
|
||||
&tmp, NULL ) ? 0 : -1;
|
||||
|
||||
*pi_copyright = p_buffer[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: add WNASPI support for Win9x */
|
||||
intf_ErrMsg( "css error: DVD ioctls not functional yet" );
|
||||
intf_ErrMsg( "css error: assuming disc is unencrypted" );
|
||||
*pi_copyright = 0;
|
||||
i_ret = 0;
|
||||
}
|
||||
|
||||
#else
|
||||
/* DVD ioctls unavailable - do as if the ioctl failed */
|
||||
i_ret = -1;
|
||||
@ -202,6 +229,35 @@ int ioctl_ReadKey( int i_fd, int *pi_agid, u8 *p_key )
|
||||
|
||||
memset( p_key, 0x00, 2048 );
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
DWORD tmp;
|
||||
u8 buffer[DVD_DISK_KEY_LENGTH];
|
||||
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
||||
|
||||
memset( &buffer, 0, sizeof( buffer ) );
|
||||
|
||||
key->KeyLength = DVD_DISK_KEY_LENGTH;
|
||||
key->SessionId = *pi_agid;
|
||||
key->KeyType = DvdDiskKey;
|
||||
key->KeyFlags = 0;
|
||||
|
||||
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
||||
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
||||
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
memcpy( p_key, key->KeyData, 2048 );
|
||||
}
|
||||
else
|
||||
{
|
||||
i_ret = -1;
|
||||
}
|
||||
|
||||
#else
|
||||
/* DVD ioctls unavailable - do as if the ioctl failed */
|
||||
i_ret = -1;
|
||||
@ -257,6 +313,22 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid )
|
||||
|
||||
*pi_agid = p_buffer[ 7 ] >> 6;
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
ULONG id;
|
||||
DWORD tmp;
|
||||
|
||||
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION,
|
||||
&tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1;
|
||||
|
||||
*pi_agid = id;
|
||||
}
|
||||
else
|
||||
{
|
||||
i_ret = -1;
|
||||
}
|
||||
|
||||
#else
|
||||
/* DVD ioctls unavailable - do as if the ioctl failed */
|
||||
i_ret = -1;
|
||||
@ -312,6 +384,35 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
|
||||
|
||||
memcpy( p_challenge, p_buffer + 4, 12 );
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
DWORD tmp;
|
||||
u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
|
||||
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
||||
|
||||
memset( &buffer, 0, sizeof( buffer ) );
|
||||
|
||||
key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
|
||||
key->SessionId = *pi_agid;
|
||||
key->KeyType = DvdChallengeKey;
|
||||
key->KeyFlags = 0;
|
||||
|
||||
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
||||
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
||||
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
memcpy( p_challenge, key->KeyData, 10 );
|
||||
}
|
||||
else
|
||||
{
|
||||
i_ret = -1;
|
||||
}
|
||||
|
||||
#else
|
||||
/* DVD ioctls unavailable - do as if the ioctl failed */
|
||||
i_ret = -1;
|
||||
@ -369,6 +470,37 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
|
||||
|
||||
*pi_asf = p_buffer[ 7 ] & 1;
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
DWORD tmp;
|
||||
u8 buffer[DVD_ASF_LENGTH];
|
||||
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
||||
|
||||
memset( &buffer, 0, sizeof( buffer ) );
|
||||
|
||||
key->KeyLength = DVD_ASF_LENGTH;
|
||||
key->SessionId = *pi_agid;
|
||||
key->KeyType = DvdAsf;
|
||||
key->KeyFlags = 0;
|
||||
|
||||
((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
|
||||
|
||||
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
||||
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
||||
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
*pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
i_ret = -1;
|
||||
}
|
||||
|
||||
#else
|
||||
/* DVD ioctls unavailable - do as if the ioctl failed */
|
||||
i_ret = -1;
|
||||
@ -423,6 +555,30 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
|
||||
|
||||
memcpy( p_key, p_buffer + 4, 8 );
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
DWORD tmp;
|
||||
u8 buffer[DVD_BUS_KEY_LENGTH];
|
||||
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
||||
|
||||
memset( &buffer, 0, sizeof( buffer ) );
|
||||
|
||||
key->KeyLength = DVD_BUS_KEY_LENGTH;
|
||||
key->SessionId = *pi_agid;
|
||||
key->KeyType = DvdBusKey1;
|
||||
key->KeyFlags = 0;
|
||||
|
||||
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
||||
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
||||
|
||||
memcpy( p_key, key->KeyData, 8 );
|
||||
}
|
||||
else
|
||||
{
|
||||
i_ret = -1;
|
||||
}
|
||||
|
||||
#else
|
||||
/* DVD ioctls unavailable - do as if the ioctl failed */
|
||||
i_ret = -1;
|
||||
@ -473,6 +629,19 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
|
||||
|
||||
i_ret = ioctl( i_fd, IODVD_SEND_KEY, &dvdioctl );
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
DWORD tmp;
|
||||
|
||||
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION,
|
||||
pi_agid, sizeof( *pi_agid ), NULL, 0, &tmp, NULL ) ? 0 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
i_ret = -1;
|
||||
}
|
||||
|
||||
#else
|
||||
/* DVD ioctls unavailable - do as if the ioctl failed */
|
||||
i_ret = -1;
|
||||
@ -527,6 +696,30 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
|
||||
|
||||
return ioctl( i_fd, IODVD_SEND_KEY, &dvdioctl );
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
DWORD tmp;
|
||||
u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
|
||||
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
||||
|
||||
memset( &buffer, 0, sizeof( buffer ) );
|
||||
|
||||
key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
|
||||
key->SessionId = *pi_agid;
|
||||
key->KeyType = DvdChallengeKey;
|
||||
key->KeyFlags = 0;
|
||||
|
||||
memcpy( key->KeyData, p_challenge, 10 );
|
||||
|
||||
return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
|
||||
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else
|
||||
/* DVD ioctls unavailable - do as if the ioctl failed */
|
||||
return -1;
|
||||
@ -569,6 +762,30 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
|
||||
|
||||
return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
||||
|
||||
#elif defined( WIN32 )
|
||||
if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
|
||||
{
|
||||
DWORD tmp;
|
||||
u8 buffer[DVD_BUS_KEY_LENGTH];
|
||||
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
||||
|
||||
memset( &buffer, 0, sizeof( buffer ) );
|
||||
|
||||
key->KeyLength = DVD_BUS_KEY_LENGTH;
|
||||
key->SessionId = *pi_agid;
|
||||
key->KeyType = DvdBusKey2;
|
||||
key->KeyFlags = 0;
|
||||
|
||||
memcpy( key->KeyData, p_key, 8 );
|
||||
|
||||
return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
|
||||
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#elif defined( SYS_DARWIN1_3 )
|
||||
INIT_DVDIOCTL( 12 );
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* dvd_ioctl.h: DVD ioctl replacement function
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_ioctl.h,v 1.8 2001/05/25 04:44:49 sam Exp $
|
||||
* $Id: dvd_ioctl.h,v 1.9 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Samuel Hocevar <sam@zoy.org>
|
||||
*
|
||||
@ -32,7 +32,37 @@ int ioctl_InvalidateAgid ( int, int * );
|
||||
int ioctl_SendChallenge ( int, int *, u8 * );
|
||||
int ioctl_SendKey2 ( int, int *, u8 * );
|
||||
|
||||
#ifdef SYS_BEOS
|
||||
/*****************************************************************************
|
||||
* Common macro, BeOS specific
|
||||
*****************************************************************************/
|
||||
#if defined( SYS_BEOS )
|
||||
#define INIT_RDC( TYPE, SIZE ) \
|
||||
raw_device_command rdc; \
|
||||
u8 p_buffer[ (SIZE) ]; \
|
||||
memset( &rdc, 0, sizeof( raw_device_command ) ); \
|
||||
rdc.data = (char *)p_buffer; \
|
||||
rdc.data_length = (SIZE); \
|
||||
BeInitRDC( &rdc, (TYPE) );
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Common macro, Darwin specific
|
||||
*****************************************************************************/
|
||||
#if defined( SYS_DARWIN1_3 )
|
||||
#define INIT_DVDIOCTL( SIZE ) \
|
||||
dvdioctl_data_t dvdioctl; \
|
||||
u8 p_buffer[ (SIZE) ]; \
|
||||
dvdioctl.p_buffer = p_buffer; \
|
||||
dvdioctl.i_size = (SIZE); \
|
||||
dvdioctl.i_keyclass = kCSS_CSS2_CPRM; \
|
||||
memset( p_buffer, 0, (SIZE) );
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Various DVD I/O tables
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined( SYS_BEOS ) || defined( WIN32 )
|
||||
|
||||
/* The generic packet command opcodes for CD/DVD Logical Units,
|
||||
* From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
|
||||
@ -43,6 +73,81 @@ int ioctl_SendKey2 ( int, int *, u8 * );
|
||||
/* DVD struct types */
|
||||
#define DVD_STRUCT_COPYRIGHT 0x01
|
||||
#define DVD_STRUCT_DISCKEY 0x02
|
||||
#endif
|
||||
|
||||
#if defined( WIN32 )
|
||||
|
||||
#define IOCTL_DVD_START_SESSION CTL_CODE(FILE_DEVICE_DVD, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
#define IOCTL_DVD_READ_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
#define IOCTL_DVD_SEND_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
#define IOCTL_DVD_END_SESSION CTL_CODE(FILE_DEVICE_DVD, 0x0403, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(FILE_DEVICE_CONTROLLER, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define DVD_CHALLENGE_KEY_LENGTH (12 + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_BUS_KEY_LENGTH (8 + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_DISK_KEY_LENGTH (2048 + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_ASF_LENGTH (sizeof(DVD_ASF) + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
|
||||
typedef ULONG DVD_SESSION_ID, *PDVD_SESSION_ID;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DvdChallengeKey = 0x01,
|
||||
DvdBusKey1,
|
||||
DvdBusKey2,
|
||||
DvdTitleKey,
|
||||
DvdAsf,
|
||||
DvdSetRpcKey = 0x6,
|
||||
DvdGetRpcKey = 0x8,
|
||||
DvdDiskKey = 0x80,
|
||||
DvdInvalidateAGID = 0x3f
|
||||
} DVD_KEY_TYPE;
|
||||
|
||||
typedef struct _DVD_COPY_PROTECT_KEY
|
||||
{
|
||||
ULONG KeyLength;
|
||||
DVD_SESSION_ID SessionId;
|
||||
DVD_KEY_TYPE KeyType;
|
||||
ULONG KeyFlags;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
ULONG FileHandle;
|
||||
ULONG Reserved; // used for NT alignment
|
||||
};
|
||||
LARGE_INTEGER TitleOffset;
|
||||
} Parameters;
|
||||
UCHAR KeyData[0];
|
||||
} DVD_COPY_PROTECT_KEY, *PDVD_COPY_PROTECT_KEY;
|
||||
|
||||
typedef struct _DVD_ASF
|
||||
{
|
||||
UCHAR Reserved0[3];
|
||||
UCHAR SuccessFlag:1;
|
||||
UCHAR Reserved1:7;
|
||||
} DVD_ASF, * PDVD_ASF;
|
||||
|
||||
typedef struct _SCSI_PASS_THROUGH_DIRECT
|
||||
{
|
||||
USHORT Length;
|
||||
UCHAR ScsiStatus;
|
||||
UCHAR PathId;
|
||||
UCHAR TargetId;
|
||||
UCHAR Lun;
|
||||
UCHAR CdbLength;
|
||||
UCHAR SenseInfoLength;
|
||||
UCHAR DataIn;
|
||||
ULONG DataTransferLength;
|
||||
ULONG TimeOutValue;
|
||||
PVOID DataBuffer;
|
||||
ULONG SenseInfoOffset;
|
||||
UCHAR Cdb[16];
|
||||
} SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
|
||||
|
||||
#define SCSI_IOCTL_DATA_OUT 0
|
||||
#define SCSI_IOCTL_DATA_IN 1
|
||||
|
||||
/* Key formats */
|
||||
#define DVD_REPORT_AGID 0x00
|
||||
|
@ -7,7 +7,7 @@
|
||||
* will only be given back to netlist when refcount is zero.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
|
||||
* $Id: dvd_netlist.c,v 1.6 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: dvd_netlist.c,v 1.7 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Henri Fallon <henri@videolan.org>
|
||||
* Stéphane Borel <stef@videolan.org>
|
||||
@ -37,14 +37,14 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !defined( WIN32 )
|
||||
#include <sys/uio.h> /* struct iovec */
|
||||
#if defined( WIN32 )
|
||||
# include <io.h>
|
||||
# include "iovec.h"
|
||||
#else
|
||||
#include <io.h>
|
||||
#include "iovec.h"
|
||||
# include <sys/uio.h> /* struct iovec */
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
@ -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.8 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -34,25 +34,26 @@
|
||||
#include "defs.h"
|
||||
|
||||
#ifdef HAVE_CSS
|
||||
#define MODULE_NAME dvd
|
||||
# define MODULE_NAME dvd
|
||||
#else /* HAVE_CSS */
|
||||
#define MODULE_NAME dvdnocss
|
||||
# define MODULE_NAME dvdnocss
|
||||
#endif /* HAVE_CSS */
|
||||
|
||||
#include "modules_inner.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>
|
||||
|
||||
#include "common.h"
|
||||
#include "intf_msg.h"
|
||||
@ -99,18 +100,39 @@ typedef struct ad_s
|
||||
*****************************************************************************/
|
||||
static int UDFReadLB( int i_fd, off_t i_lba, size_t i_block_count, u8 *pi_data )
|
||||
{
|
||||
#if !defined( WIN32 )
|
||||
if( i_fd < 0 )
|
||||
#else
|
||||
DWORD read;
|
||||
|
||||
if( (HANDLE) i_fd == INVALID_HANDLE_VALUE )
|
||||
#endif
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined( WIN32 )
|
||||
if( lseek( i_fd, i_lba * (off_t) DVD_LB_SIZE, SEEK_SET ) < 0 )
|
||||
#else
|
||||
if( SetFilePointer( (HANDLE) i_fd, i_lba * (off_t) DVD_LB_SIZE,
|
||||
NULL, FILE_BEGIN ) == -1 )
|
||||
#endif
|
||||
{
|
||||
intf_ErrMsg( "UDF: Postion not found" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined( WIN32 )
|
||||
return read( i_fd, pi_data, i_block_count *DVD_LB_SIZE);
|
||||
#else
|
||||
if(!ReadFile( (HANDLE) i_fd, pi_data, i_block_count * DVD_LB_SIZE,
|
||||
&read, NULL) || read != i_block_count * DVD_LB_SIZE )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return read;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
* -dvd_udf to find files
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2001 VideoLAN
|
||||
* $Id: input_dvd.c,v 1.63 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: input_dvd.c,v 1.64 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -35,37 +35,38 @@
|
||||
#include "defs.h"
|
||||
|
||||
#ifdef HAVE_CSS
|
||||
#define MODULE_NAME dvd
|
||||
# define MODULE_NAME dvd
|
||||
#else /* HAVE_CSS */
|
||||
#define MODULE_NAME dvdnocss
|
||||
# define MODULE_NAME dvdnocss
|
||||
#endif /* HAVE_CSS */
|
||||
|
||||
#include "modules_inner.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !defined( WIN32 )
|
||||
#include <netinet/in.h>
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef STRNCASECMP_IN_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined( WIN32 )
|
||||
#include <sys/uio.h> /* struct iovec */
|
||||
#if defined( WIN32 )
|
||||
# include <io.h>
|
||||
# include "iovec.h"
|
||||
#else
|
||||
#include <io.h>
|
||||
#include "iovec.h"
|
||||
# include <sys/uio.h> /* struct iovec */
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
@ -151,6 +152,9 @@ static int DVDProbe( probedata_t *p_data )
|
||||
char * psz_name = p_input->p_source;
|
||||
int i_handle;
|
||||
int i_score = 5;
|
||||
#if defined( WIN32 )
|
||||
char buf[7];
|
||||
#endif
|
||||
|
||||
if( TestMethod( INPUT_METHOD_VAR, "dvd" ) )
|
||||
{
|
||||
@ -172,12 +176,25 @@ static int DVDProbe( probedata_t *p_data )
|
||||
psz_name += 4;
|
||||
}
|
||||
|
||||
#if !defined( WIN32 )
|
||||
i_handle = open( psz_name, 0 );
|
||||
if( i_handle == -1 )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
close( i_handle );
|
||||
#else
|
||||
snprintf( buf, 7, "\\\\.\\%c:", psz_name[0] );
|
||||
(HANDLE) i_handle = CreateFile( i_score < 90 ? psz_name : buf,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL );
|
||||
if( (HANDLE) i_handle == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
CloseHandle( (HANDLE) i_handle );
|
||||
#endif
|
||||
|
||||
return( i_score );
|
||||
}
|
||||
@ -224,7 +241,11 @@ static void DVDInit( input_thread_t * p_input )
|
||||
|
||||
p_dvd->b_encrypted = i;
|
||||
|
||||
#if !defined( WIN32 )
|
||||
lseek( p_input->i_handle, 0, SEEK_SET );
|
||||
#else
|
||||
SetFilePointer( (HANDLE) p_input->i_handle, 0, 0, FILE_BEGIN );
|
||||
#endif
|
||||
|
||||
/* Reading structures initialisation */
|
||||
p_input->p_method_data =
|
||||
@ -818,6 +839,14 @@ static int DVDRead( input_thread_t * p_input,
|
||||
return -1;
|
||||
}
|
||||
|
||||
pp_data = (struct data_packet_s **) malloc( p_input->i_read_once *
|
||||
sizeof( struct data_packet_s * ) );
|
||||
if( pp_data == NULL )
|
||||
{
|
||||
intf_ErrMsg( "dvd error: out of memory" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
p_dvd = (thread_dvd_data_t *)p_input->p_plugin_data;
|
||||
p_netlist = (dvd_netlist_t *)p_input->p_method_data;
|
||||
|
||||
@ -897,7 +926,11 @@ static int DVDRead( input_thread_t * p_input,
|
||||
p_netlist->i_read_once = i_block_once;
|
||||
|
||||
/* Reads from DVD */
|
||||
#if !defined( WIN32 )
|
||||
i_read_bytes = readv( p_dvd->i_fd, p_vec, i_block_once );
|
||||
#else
|
||||
i_read_bytes = ReadFileV( p_dvd->i_fd, p_vec, i_block_once );
|
||||
#endif
|
||||
i_read_blocks = ( i_read_bytes + 0x7ff ) >> 11;
|
||||
|
||||
/* Update netlist indexes */
|
||||
@ -922,7 +955,7 @@ static int DVDRead( input_thread_t * p_input,
|
||||
|
||||
while( i_pos < p_netlist->i_buffer_size )
|
||||
{
|
||||
pi_cur = ((u8*)p_vec[i_iovec].iov_base + i_pos);
|
||||
pi_cur = (u8*)p_vec[i_iovec].iov_base + i_pos;
|
||||
|
||||
/*default header */
|
||||
if( U32_AT( pi_cur ) != 0x1BA )
|
||||
@ -987,6 +1020,8 @@ static int DVDRead( input_thread_t * p_input,
|
||||
|
||||
free( pp_data );
|
||||
|
||||
free( pp_data );
|
||||
|
||||
if( b_eof )
|
||||
{
|
||||
return 1;
|
||||
@ -1115,10 +1150,18 @@ static void DVDSeek( input_thread_t * p_input, off_t i_off )
|
||||
p_dvd->i_chapter = i_chapter;
|
||||
p_input->stream.p_selected_area->i_part = p_dvd->i_chapter;
|
||||
|
||||
#if !defined( WIN32 )
|
||||
p_input->stream.p_selected_area->i_tell =
|
||||
lseek( p_dvd->i_fd, p_dvd->i_title_start +
|
||||
(off_t)( p_dvd->i_sector ) *DVD_LB_SIZE, SEEK_SET ) -
|
||||
p_input->stream.p_selected_area->i_start;
|
||||
#else
|
||||
p_input->stream.p_selected_area->i_tell =
|
||||
SetFilePointer( (HANDLE) p_dvd->i_fd, p_dvd->i_title_start +
|
||||
(off_t)( p_dvd->i_sector ) *DVD_LB_SIZE, NULL, FILE_BEGIN) -
|
||||
p_input->stream.p_selected_area->i_start;
|
||||
|
||||
#endif
|
||||
/*
|
||||
intf_WarnMsg( 3, "Program Cell: %d Cell: %d Chapter: %d",
|
||||
p_dvd->i_prg_cell, p_dvd->i_cell, p_dvd->i_chapter );
|
||||
@ -1249,7 +1292,12 @@ static int DVDChapterSelect( thread_dvd_data_t * p_dvd, int i_chapter )
|
||||
DVD_LB_SIZE * (off_t)( p_dvd->i_sector );
|
||||
|
||||
/* Position the fd pointer on the right address */
|
||||
#if !defined( WIN32 )
|
||||
p_dvd->i_start = lseek( p_dvd->i_fd, p_dvd->i_start, SEEK_SET );
|
||||
#else
|
||||
p_dvd->i_start = SetFilePointer( (HANDLE) p_dvd->i_fd,
|
||||
p_dvd->i_start, NULL, FILE_BEGIN );
|
||||
#endif
|
||||
|
||||
p_dvd->i_chapter = i_chapter;
|
||||
return 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* input_es.c: Elementary Stream demux and packet management
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2001 VideoLAN
|
||||
* $Id: input_es.c,v 1.4 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: input_es.c,v 1.5 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors:
|
||||
*
|
||||
@ -37,9 +37,9 @@
|
||||
#include <sys/stat.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 <fcntl.h>
|
||||
|
@ -2,7 +2,7 @@
|
||||
* input_ps.c: PS demux and packet management
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998, 1999, 2000 VideoLAN
|
||||
* $Id: input_ps.c,v 1.26 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: input_ps.c,v 1.27 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Christophe Massiot <massiot@via.ecp.fr>
|
||||
* Cyril Deguet <asmax@via.ecp.fr>
|
||||
@ -32,18 +32,19 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef STRNCASECMP_IN_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.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 <fcntl.h>
|
||||
@ -154,8 +155,8 @@ static void PSInit( input_thread_t * p_input )
|
||||
thread_ps_data_t * p_method;
|
||||
packet_cache_t * p_packet_cache;
|
||||
|
||||
if( (p_method =
|
||||
(thread_ps_data_t *)malloc( sizeof(thread_ps_data_t) )) == NULL )
|
||||
p_method = (thread_ps_data_t *)malloc( sizeof(thread_ps_data_t) );
|
||||
if( p_method == NULL )
|
||||
{
|
||||
intf_ErrMsg( "Out of memory" );
|
||||
p_input->b_error = 1;
|
||||
@ -203,29 +204,31 @@ static void PSInit( input_thread_t * p_input )
|
||||
p_packet_cache->pes.l_index = 0;
|
||||
|
||||
/* allocates the small buffer cache */
|
||||
p_packet_cache->small.p_stack = malloc( SMALL_CACHE_SIZE *
|
||||
p_packet_cache->smallbuffer.p_stack = malloc( SMALL_CACHE_SIZE *
|
||||
sizeof(packet_buffer_t) );
|
||||
if ( p_packet_cache->small.p_stack == NULL )
|
||||
if ( p_packet_cache->smallbuffer.p_stack == NULL )
|
||||
{
|
||||
intf_ErrMsg( "Out of memory" );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
p_packet_cache->small.l_index = 0;
|
||||
p_packet_cache->smallbuffer.l_index = 0;
|
||||
|
||||
/* allocates the large buffer cache */
|
||||
p_packet_cache->large.p_stack = malloc( LARGE_CACHE_SIZE *
|
||||
p_packet_cache->largebuffer.p_stack = malloc( LARGE_CACHE_SIZE *
|
||||
sizeof(packet_buffer_t) );
|
||||
if ( p_packet_cache->large.p_stack == NULL )
|
||||
if ( p_packet_cache->largebuffer.p_stack == NULL )
|
||||
{
|
||||
intf_ErrMsg( "Out of memory" );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
p_packet_cache->large.l_index = 0;
|
||||
p_packet_cache->largebuffer.l_index = 0;
|
||||
|
||||
/* Re-open the socket as a buffered FILE stream */
|
||||
if( (p_method->stream = fdopen( p_input->i_handle, "r" )) == NULL )
|
||||
p_method->stream = fdopen( p_input->i_handle, "r" );
|
||||
|
||||
if( p_method->stream == NULL )
|
||||
{
|
||||
intf_ErrMsg( "Cannot open file (%s)", strerror(errno) );
|
||||
p_input->b_error = 1;
|
||||
@ -504,8 +507,8 @@ static int PSRead( input_thread_t * p_input,
|
||||
}
|
||||
|
||||
/* Fetch a packet of the appropriate size. */
|
||||
if( (p_data = NewPacket( p_input->p_method_data, i_packet_size + 6 ))
|
||||
== NULL )
|
||||
p_data = NewPacket( p_input->p_method_data, i_packet_size + 6 );
|
||||
if( p_data == NULL )
|
||||
{
|
||||
intf_ErrMsg( "Out of memory" );
|
||||
return( -1 );
|
||||
@ -600,7 +603,8 @@ static struct data_packet_s * NewPacket( void * p_packet_cache,
|
||||
if( p_cache->data.l_index == 0 )
|
||||
{
|
||||
/* Allocates a new packet */
|
||||
if ( (p_data = malloc( sizeof(data_packet_t) )) == NULL )
|
||||
p_data = malloc( sizeof(data_packet_t) );
|
||||
if( p_data == NULL )
|
||||
{
|
||||
intf_ErrMsg( "Out of memory" );
|
||||
vlc_mutex_unlock( &p_cache->lock );
|
||||
@ -627,10 +631,11 @@ static struct data_packet_s * NewPacket( void * p_packet_cache,
|
||||
/* Small buffer */
|
||||
|
||||
/* Checks whether the buffer cache is empty */
|
||||
if( p_cache->small.l_index == 0 )
|
||||
if( p_cache->smallbuffer.l_index == 0 )
|
||||
{
|
||||
/* Allocates a new packet */
|
||||
if ( (p_data->p_buffer = malloc( l_size )) == NULL )
|
||||
p_data->p_buffer = malloc( l_size );
|
||||
if( p_data->p_buffer == NULL )
|
||||
{
|
||||
intf_DbgMsg( "Out of memory" );
|
||||
free( p_data );
|
||||
@ -645,8 +650,8 @@ static struct data_packet_s * NewPacket( void * p_packet_cache,
|
||||
else
|
||||
{
|
||||
/* Takes the packet out from the cache */
|
||||
l_index = -- p_cache->small.l_index;
|
||||
if( (p_data->p_buffer = p_cache->small.p_stack[l_index].p_data)
|
||||
l_index = -- p_cache->smallbuffer.l_index;
|
||||
if( (p_data->p_buffer = p_cache->smallbuffer.p_stack[l_index].p_data)
|
||||
== NULL )
|
||||
{
|
||||
intf_ErrMsg( "NULL packet in the small buffer cache" );
|
||||
@ -655,15 +660,15 @@ static struct data_packet_s * NewPacket( void * p_packet_cache,
|
||||
return NULL;
|
||||
}
|
||||
/* Reallocates the packet if it is too small or too large */
|
||||
if( p_cache->small.p_stack[l_index].l_size < l_size ||
|
||||
p_cache->small.p_stack[l_index].l_size > 2*l_size )
|
||||
if( p_cache->smallbuffer.p_stack[l_index].l_size < l_size ||
|
||||
p_cache->smallbuffer.p_stack[l_index].l_size > 2*l_size )
|
||||
{
|
||||
p_data->p_buffer = realloc( p_data->p_buffer, l_size );
|
||||
p_data->l_size = l_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_data->l_size = p_cache->small.p_stack[l_index].l_size;
|
||||
p_data->l_size = p_cache->smallbuffer.p_stack[l_index].l_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -672,10 +677,11 @@ static struct data_packet_s * NewPacket( void * p_packet_cache,
|
||||
/* Large buffer */
|
||||
|
||||
/* Checks whether the buffer cache is empty */
|
||||
if( p_cache->large.l_index == 0 )
|
||||
if( p_cache->largebuffer.l_index == 0 )
|
||||
{
|
||||
/* Allocates a new packet */
|
||||
if ( (p_data->p_buffer = malloc( l_size )) == NULL )
|
||||
p_data->p_buffer = malloc( l_size );
|
||||
if ( p_data->p_buffer == NULL )
|
||||
{
|
||||
intf_ErrMsg( "Out of memory" );
|
||||
free( p_data );
|
||||
@ -690,9 +696,9 @@ static struct data_packet_s * NewPacket( void * p_packet_cache,
|
||||
else
|
||||
{
|
||||
/* Takes the packet out from the cache */
|
||||
l_index = -- p_cache->large.l_index;
|
||||
if( (p_data->p_buffer = p_cache->large.p_stack[l_index].p_data)
|
||||
== NULL )
|
||||
l_index = -- p_cache->largebuffer.l_index;
|
||||
p_data->p_buffer = p_cache->largebuffer.p_stack[l_index].p_data;
|
||||
if( p_data->p_buffer == NULL )
|
||||
{
|
||||
intf_ErrMsg( "NULL packet in the small buffer cache" );
|
||||
free( p_data );
|
||||
@ -700,15 +706,15 @@ static struct data_packet_s * NewPacket( void * p_packet_cache,
|
||||
return NULL;
|
||||
}
|
||||
/* Reallocates the packet if it is too small or too large */
|
||||
if( p_cache->large.p_stack[l_index].l_size < l_size ||
|
||||
p_cache->large.p_stack[l_index].l_size > 2*l_size )
|
||||
if( p_cache->largebuffer.p_stack[l_index].l_size < l_size ||
|
||||
p_cache->largebuffer.p_stack[l_index].l_size > 2*l_size )
|
||||
{
|
||||
p_data->p_buffer = realloc( p_data->p_buffer, l_size );
|
||||
p_data->l_size = l_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_data->l_size = p_cache->large.p_stack[l_index].l_size;
|
||||
p_data->l_size = p_cache->largebuffer.p_stack[l_index].l_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -750,7 +756,8 @@ static pes_packet_t * NewPES( void * p_packet_cache )
|
||||
if( p_cache->pes.l_index == 0 )
|
||||
{
|
||||
/* Allocates a new packet */
|
||||
if ( (p_pes = malloc( sizeof(pes_packet_t) )) == NULL )
|
||||
p_pes = malloc( sizeof(pes_packet_t) );
|
||||
if( p_pes == NULL )
|
||||
{
|
||||
intf_DbgMsg( "Out of memory" );
|
||||
vlc_mutex_unlock( &p_cache->lock );
|
||||
@ -763,8 +770,8 @@ static pes_packet_t * NewPES( void * p_packet_cache )
|
||||
else
|
||||
{
|
||||
/* Takes the packet out from the cache */
|
||||
if( (p_pes = p_cache->pes.p_stack[ -- p_cache->pes.l_index ])
|
||||
== NULL )
|
||||
p_pes = p_cache->pes.p_stack[ -- p_cache->pes.l_index ];
|
||||
if( p_pes == NULL )
|
||||
{
|
||||
intf_ErrMsg( "NULL packet in the data cache" );
|
||||
vlc_mutex_unlock( &p_cache->lock );
|
||||
@ -814,12 +821,12 @@ static void DeletePacket( void * p_packet_cache,
|
||||
if ( p_data->l_size < MAX_SMALL_SIZE )
|
||||
{
|
||||
/* Checks whether the small buffer cache is full */
|
||||
if ( p_cache->small.l_index < SMALL_CACHE_SIZE )
|
||||
if ( p_cache->smallbuffer.l_index < SMALL_CACHE_SIZE )
|
||||
{
|
||||
p_cache->small.p_stack[ p_cache->small.l_index ].l_size =
|
||||
p_data->l_size;
|
||||
p_cache->small.p_stack[ p_cache->small.l_index ++ ].p_data =
|
||||
p_data->p_buffer;
|
||||
p_cache->smallbuffer.p_stack[
|
||||
p_cache->smallbuffer.l_index ].l_size = p_data->l_size;
|
||||
p_cache->smallbuffer.p_stack[
|
||||
p_cache->smallbuffer.l_index++ ].p_data = p_data->p_buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -833,12 +840,12 @@ static void DeletePacket( void * p_packet_cache,
|
||||
else
|
||||
{
|
||||
/* Checks whether the large buffer cache is full */
|
||||
if ( p_cache->large.l_index < LARGE_CACHE_SIZE )
|
||||
if ( p_cache->largebuffer.l_index < LARGE_CACHE_SIZE )
|
||||
{
|
||||
p_cache->large.p_stack[ p_cache->large.l_index ].l_size =
|
||||
p_data->l_size;
|
||||
p_cache->large.p_stack[ p_cache->large.l_index ++ ].p_data =
|
||||
p_data->p_buffer;
|
||||
p_cache->largebuffer.p_stack[
|
||||
p_cache->largebuffer.l_index ].l_size = p_data->l_size;
|
||||
p_cache->largebuffer.p_stack[
|
||||
p_cache->largebuffer.l_index++ ].p_data = p_data->p_buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
* input_ps.h: thread structure of the PS plugin
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999, 2000 VideoLAN
|
||||
* $Id: input_ps.h,v 1.7 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: input_ps.h,v 1.8 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Christophe Massiot <massiot@via.ecp.fr>
|
||||
* Cyril Deguet <asmax@via.ecp.fr>
|
||||
@ -22,10 +22,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
#undef small
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* thread_ps_data_t: extension of input_thread_t
|
||||
*****************************************************************************/
|
||||
@ -82,8 +78,8 @@ typedef struct
|
||||
vlc_mutex_t lock;
|
||||
data_packet_cache_t data;
|
||||
pes_packet_cache_t pes;
|
||||
small_buffer_cache_t small;
|
||||
large_buffer_cache_t large;
|
||||
small_buffer_cache_t smallbuffer;
|
||||
large_buffer_cache_t largebuffer;
|
||||
} packet_cache_t;
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* input_ts.c: TS demux and netlist management
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998, 1999, 2000 VideoLAN
|
||||
* $Id: input_ts.c,v 1.22 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: input_ts.c,v 1.23 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Henri Fallon <henri@videolan.org>
|
||||
*
|
||||
@ -31,34 +31,35 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef STRNCASECMP_IN_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if !defined( _MSC_VER )
|
||||
#include <sys/time.h>
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef SYS_NTO
|
||||
#include <sys/select.h>
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#if !defined( WIN32 )
|
||||
#include <sys/uio.h> /* struct iovec */
|
||||
#if defined( WIN32 )
|
||||
# include <io.h>
|
||||
# include "iovec.h"
|
||||
#else
|
||||
#include <io.h>
|
||||
#include "iovec.h"
|
||||
# include <sys/uio.h> /* struct iovec */
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
* aout_spdif: ac3 passthrough output
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2001 VideoLAN
|
||||
* $Id: aout_spdif.c,v 1.9 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: aout_spdif.c,v 1.10 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Michel Kaempf <maxx@via.ecp.fr>
|
||||
* Stéphane Borel <stef@via.ecp.fr>
|
||||
@ -114,10 +114,10 @@ void aout_SpdifThread( aout_thread_t * p_aout )
|
||||
mlast = mplay;
|
||||
/* play spdif frame to the external decoder */
|
||||
p_aout->pf_play( p_aout,
|
||||
((byte_t*) p_aout->fifo[i_fifo].buffer +
|
||||
p_aout->fifo[i_fifo].l_start_frame*
|
||||
SPDIF_FRAME_SIZE ),
|
||||
p_aout->fifo[i_fifo].l_frame_size );
|
||||
( (byte_t *)p_aout->fifo[i_fifo].buffer
|
||||
+ p_aout->fifo[i_fifo].l_start_frame
|
||||
* SPDIF_FRAME_SIZE ),
|
||||
p_aout->fifo[i_fifo].l_frame_size );
|
||||
|
||||
p_aout->fifo[i_fifo].l_start_frame =
|
||||
(p_aout->fifo[i_fifo].l_start_frame + 1 )
|
||||
|
@ -4,7 +4,7 @@
|
||||
* decoders.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998, 1999, 2000 VideoLAN
|
||||
* $Id: input.c,v 1.115 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: input.c,v 1.116 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Christophe Massiot <massiot@via.ecp.fr>
|
||||
*
|
||||
@ -34,33 +34,27 @@
|
||||
#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>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef STRNCASECMP_IN_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
/* WinSock Includes */
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Network functions */
|
||||
|
||||
#if !defined( SYS_BEOS ) && !defined( SYS_NTO ) && !defined( WIN32 )
|
||||
#include <netdb.h> /* hostent ... */
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
# include <winsock2.h>
|
||||
#elif !defined( SYS_BEOS ) && !defined( SYS_NTO )
|
||||
# include <netdb.h> /* hostent ... */
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef STATS
|
||||
@ -86,7 +80,6 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*****************************************************************************/
|
||||
@ -260,6 +253,7 @@ static void RunThread( input_thread_t *p_input )
|
||||
if( pp_packets == NULL )
|
||||
{
|
||||
intf_ErrMsg( "input error: out of memory" );
|
||||
free( pp_packets );
|
||||
p_input->b_error = 1;
|
||||
}
|
||||
|
||||
@ -504,6 +498,10 @@ static void FileOpen( input_thread_t * p_input )
|
||||
struct stat stat_info;
|
||||
int i_stat;
|
||||
|
||||
#if defined( WIN32 )
|
||||
char buf[7] = { 0 };
|
||||
#endif
|
||||
|
||||
char *psz_name = p_input->p_source;
|
||||
|
||||
/* FIXME: this code ought to be in the plugin so that code can
|
||||
@ -518,6 +516,9 @@ static void FileOpen( input_thread_t * p_input )
|
||||
/* get rid of the 'dvd:' stuff and try again */
|
||||
psz_name += 4;
|
||||
i_stat = stat( psz_name, &stat_info );
|
||||
#if defined( WIN32 )
|
||||
snprintf( buf, 7, "\\\\.\\%c:", psz_name[0] );
|
||||
#endif
|
||||
}
|
||||
else if( ( i_size > 5 )
|
||||
&& !strncasecmp( psz_name, "file:", 5 ) )
|
||||
@ -527,7 +528,11 @@ static void FileOpen( input_thread_t * p_input )
|
||||
i_stat = stat( psz_name, &stat_info );
|
||||
}
|
||||
|
||||
if( i_stat == (-1) )
|
||||
if( i_stat == (-1)
|
||||
#if defined( WIN32 )
|
||||
&& !buf[0]
|
||||
#endif
|
||||
)
|
||||
{
|
||||
intf_ErrMsg( "input error: cannot stat() file `%s' (%s)",
|
||||
psz_name, strerror(errno));
|
||||
@ -542,7 +547,11 @@ static void FileOpen( input_thread_t * p_input )
|
||||
p_input->stream.b_pace_control = 1;
|
||||
|
||||
if( S_ISREG(stat_info.st_mode) || S_ISCHR(stat_info.st_mode)
|
||||
|| S_ISBLK(stat_info.st_mode) )
|
||||
|| S_ISBLK(stat_info.st_mode)
|
||||
#if defined( WIN32 )
|
||||
|| ( buf[0] && ( ( stat_info.st_size = 0 ) == 0 ) )
|
||||
#endif
|
||||
)
|
||||
{
|
||||
p_input->stream.b_seekable = 1;
|
||||
p_input->stream.p_selected_area->i_size = stat_info.st_size;
|
||||
@ -573,8 +582,10 @@ static void FileOpen( input_thread_t * p_input )
|
||||
if( (p_input->i_handle = open( psz_name,
|
||||
/*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) )
|
||||
#else
|
||||
if( (p_input->i_handle = open( psz_name, O_BINARY
|
||||
/*O_NONBLOCK | O_LARGEFILE*/ )) == (-1) )
|
||||
if( ( buf[0] && ( (HANDLE) p_input->i_handle = CreateFile( buf,
|
||||
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL ) ) == INVALID_HANDLE_VALUE ) ||
|
||||
( !buf[0] && (p_input->i_handle = open( psz_name, O_BINARY ) ) == (-1) ) )
|
||||
#endif
|
||||
{
|
||||
intf_ErrMsg( "input error: cannot open file (%s)", strerror(errno) );
|
||||
@ -590,6 +601,14 @@ static void FileOpen( input_thread_t * p_input )
|
||||
static void FileClose( input_thread_t * p_input )
|
||||
{
|
||||
intf_WarnMsg( 1, "input: closing file `%s'", p_input->p_source );
|
||||
#if defined( WIN32 )
|
||||
if( ( strlen( p_input->p_source ) > 4 ) &&
|
||||
!strncasecmp( p_input->p_source, "dvd:", 4 ) )
|
||||
{
|
||||
CloseHandle( (HANDLE) p_input->i_handle );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
close( p_input->i_handle );
|
||||
|
||||
return;
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Functions are prototyped in mtime.h.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998, 1999, 2000 VideoLAN
|
||||
* $Id: mtime.c,v 1.19 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: mtime.c,v 1.20 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Vincent Seguin <seguin@via.ecp.fr>
|
||||
*
|
||||
@ -35,25 +35,55 @@
|
||||
#include <stdio.h> /* sprintf() */
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* select() */
|
||||
#endif
|
||||
|
||||
#if !defined( _MSC_VER )
|
||||
#include <sys/time.h>
|
||||
# include <unistd.h> /* select() */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KERNEL_OS_H
|
||||
#include <kernel/OS.h>
|
||||
# include <kernel/OS.h>
|
||||
#endif
|
||||
|
||||
#if defined( WIN32 )
|
||||
#include <windows.h>
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "mtime.h"
|
||||
|
||||
#if defined( WIN32 )
|
||||
/*****************************************************************************
|
||||
* usleep: microsecond sleep for win32
|
||||
*****************************************************************************
|
||||
* This function uses performance counter if available, and Sleep() if not.
|
||||
*****************************************************************************/
|
||||
static __inline__ void usleep( unsigned int i_useconds )
|
||||
{
|
||||
s64 i_cur, i_freq;
|
||||
s64 i_now, i_then;
|
||||
|
||||
if( i_useconds < 1000
|
||||
&& QueryPerformanceFrequency( (LARGE_INTEGER *) &i_freq ) )
|
||||
{
|
||||
QueryPerformanceCounter( (LARGE_INTEGER *) &i_cur );
|
||||
|
||||
i_now = ( cur * 1000 * 1000 / i_freq );
|
||||
i_then = i_now + i_useconds;
|
||||
|
||||
while( i_now < i_then )
|
||||
{
|
||||
QueryPerformanceCounter( (LARGE_INTEGER *) &i_cur );
|
||||
now = cur * 1000 * 1000 / i_freq;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Sleep( (int) ((i_useconds + 500) / 1000) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* mstrtime: return a date in a readable format
|
||||
*****************************************************************************
|
||||
@ -87,22 +117,19 @@ mtime_t mdate( void )
|
||||
/* We don't get the real date, just the value of a high precision timer.
|
||||
* this is because the usual time functions have at best only a milisecond
|
||||
* resolution */
|
||||
mtime_t freq,usec_time;
|
||||
mtime_t freq, usec_time;
|
||||
|
||||
if( !QueryPerformanceFrequency((LARGE_INTEGER *)&freq) )
|
||||
if( QueryPerformanceFrequency( (LARGE_INTEGER *)&freq ) )
|
||||
{
|
||||
/* Milisecond resolution */
|
||||
FILETIME file_time;
|
||||
GetSystemTimeAsFileTime((FILETIME *)&file_time);
|
||||
usec_time *= 1000;
|
||||
/* Microsecond resolution */
|
||||
QueryPerformanceCounter( (LARGE_INTEGER *)&usec_time );
|
||||
return ( usec_time * 1000000 ) / freq;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Microsecond resolution */
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&usec_time);
|
||||
usec_time /= (freq/1000000);
|
||||
/* Milisecond resolution */
|
||||
return 1000 * GetTickCount();
|
||||
}
|
||||
return( usec_time );
|
||||
|
||||
#else
|
||||
struct timeval tv_date;
|
||||
@ -144,8 +171,8 @@ void mwait( mtime_t date )
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* Sleep only has milisecond resolution */
|
||||
Sleep( (DWORD)(delay/1000) );
|
||||
|
||||
usleep( delay );
|
||||
|
||||
#else
|
||||
|
||||
@ -160,7 +187,10 @@ void mwait( mtime_t date )
|
||||
gettimeofday( &tv_date, NULL );
|
||||
|
||||
/* calculate delay and check if current date is before wished date */
|
||||
delay = date - (mtime_t) tv_date.tv_sec * 1000000 - (mtime_t) tv_date.tv_usec - 10000;
|
||||
delay = date - (mtime_t) tv_date.tv_sec * 1000000
|
||||
- (mtime_t) tv_date.tv_usec
|
||||
- 10000;
|
||||
|
||||
/* Linux/i386 has a granularity of 10 ms. It's better to be in advance
|
||||
* than to be late. */
|
||||
if( delay <= 0 ) /* wished date is now or already passed */
|
||||
@ -191,12 +221,7 @@ void msleep( mtime_t delay )
|
||||
#if defined( HAVE_KERNEL_OS_H )
|
||||
snooze( delay );
|
||||
|
||||
#elif defined( WIN32 )
|
||||
Sleep( delay/1000 ); /* Sleep only has milisecond resolution */
|
||||
/* Maybe we could use the multimedia timer to reach the right resolution, */
|
||||
/* or the old Winsock select() function ?*/
|
||||
|
||||
#elif defined( HAVE_USLEEP )
|
||||
#elif defined( HAVE_USLEEP ) || defined( WIN32 )
|
||||
usleep( delay );
|
||||
|
||||
#else
|
||||
|
@ -2,7 +2,7 @@
|
||||
* video_text.c : text manipulation functions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999, 2000 VideoLAN
|
||||
* $Id: video_text.c,v 1.27 2001/05/31 01:37:08 sam Exp $
|
||||
* $Id: video_text.c,v 1.28 2001/05/31 03:12:49 sam Exp $
|
||||
*
|
||||
* Authors: Vincent Seguin <seguin@via.ecp.fr>
|
||||
* Samuel Hocevar <sam@zoy.org>
|
||||
@ -34,9 +34,9 @@
|
||||
#include <fcntl.h> /* open() */
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* read(), close() */
|
||||
# include <unistd.h> /* read(), close() */
|
||||
#elif defined( _MSC_VER ) && defined( _WIN32 )
|
||||
#include <io.h>
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef SYS_BEOS
|
||||
@ -47,6 +47,10 @@
|
||||
# include "darwin_specific.h"
|
||||
#endif
|
||||
|
||||
#if defined( WIN32 )
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "video_text.h"
|
||||
|
Loading…
Reference in New Issue
Block a user