[Mplayer-cvslog] CVS: main dvdauth.c,NONE,1.1 dvdauth.h,NONE,1.1 Makefile,1.18,1.19 cfg-mplayer.h,1.25,1.26 configure,1.23,1.24 demux_mpg.c,1.4,1.5 mplayer.c,1.74,1.75 stream.c,1.2,1.3

Gabor Lenart lgb at users.sourceforge.net
Wed Apr 18 00:04:46 CEST 2001


Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv13841/main

Modified Files:
	Makefile cfg-mplayer.h configure demux_mpg.c mplayer.c 
	stream.c 
Added Files:
	dvdauth.c dvdauth.h 
Log Message:
preliminary DVD support using libcss

--- NEW FILE ---
/* (C)2001 by LGB (Gabor Lenart), based on example programs in libcss
   Some TODO: root privilegies really needed??  */

/* don't do anything with this source if css support was not requested */
#include "config.h"
#ifdef HAVE_LIBCSS

#include <stdio.h>
#include <stdlib.h>
#include <linux/cdrom.h>
// FIXME #include <string.h> conflicts with #include <linux/fs.h> (below)
//#include <string.h>  // FIXME this conflicts with #include <linux/fs.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>

#include <css.h>

#include "dvdauth.h"

char *dvd_device=NULL;
unsigned char key_disc[2048];
unsigned char key_title[5];


#include <linux/fs.h>

#ifndef FIBMAP
#define FIBMAP 1
#endif


static int path_to_lba ( int fd )
{
        int lba = 0;
        if (ioctl(fd, FIBMAP, &lba) < 0) {
	        perror ("ioctl FIBMAP");
		fprintf(stderr,"Hint: run mplayer as root!\n");
//	        close(fd);
	        return -1;
	}
	return lba;
}



static void reset_agids ( int fd )
{
        dvd_authinfo ai;
        int i;
        for (i = 0; i < 4; i++) {
	        memset(&ai, 0, sizeof(ai));
	        ai.type = DVD_INVALIDATE_AGID;
	        ai.lsa.agid = i;
	        ioctl(fd, DVD_AUTH, &ai);
	}
}



int dvd_auth ( char *dev , int fd )
{
        int devfd;  /* FD of DVD device */
        int lba;

//	printf("DVD: auth fd=%d on %s.\n",fd,dev);

	if ((devfd=open(dev,O_RDONLY))<0) {
		fprintf(stderr,"DVD: cannot open DVD device \"%s\".\n",dev);
		return 1;
	}

	/* reset AGIDs */
	reset_agids(devfd);

	/* authenticate disc */
	if (CSSAuthDisc(devfd,key_disc)) {
		fprintf(stderr,"DVD: CSSAuthDisc() failed.\n");
		return 1;
	}

	/* authenticate title */
        lba=path_to_lba(fd);
	if (lba==-1) {
		fprintf(stderr,"DVD: path_to_lba() failed.\n");
		return 1;
	}
        if (CSSAuthTitle(devfd,key_title,lba)) {
		fprintf(stderr,"DVD: CSSAuthTitle() failed.\n");
		return 1;
	}

	/* decrypting title */
        if (CSSDecryptTitleKey (key_title, key_disc) < 0) {
                fprintf(stderr,"DVD: CSSDecryptTitleKey() failed.\n");
		return 1;
	}

	close(devfd);
	return 0;
}


#endif

--- NEW FILE ---
#include "config.h"
#ifdef HAVE_LIBCSS
#ifndef _MPLAYER_CSS_H
#define _MPLAYER_CSS_H

extern char *dvd_device;
extern unsigned char key_disc[];
extern unsigned char key_title[];

int dvd_auth ( char *, int );


#endif
#endif
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** Makefile	2001/04/16 00:54:34	1.18
--- Makefile	2001/04/17 22:04:44	1.19
***************
*** 1,9 ****
- # DirectShow support (test code)
- # make -f makefile.DS
- 
  # LINUX Makefile made by A'rpi / Astral
  # Some cleanup by LGB: 	* 'make -C dir' instead of 'cd dir;make;cd..'
  #			* for loops instead of linear sequence of make directories
  #			* some minor problems with make clean and distclean were corrected
  
  include config.mak
--- 1,7 ----
  # LINUX Makefile made by A'rpi / Astral
  # Some cleanup by LGB: 	* 'make -C dir' instead of 'cd dir;make;cd..'
  #			* for loops instead of linear sequence of make directories
  #			* some minor problems with make clean and distclean were corrected
+ #			* DVD support
  
  include config.mak
***************
*** 23,29 ****
  BINDIR = ${prefix}/bin
  # BINDIR = /usr/local/bin
! SRCS = codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c
! OBJS = codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o mixer.o
! CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo # -Wall
  A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3
  VO_LIBS = -Llibvo -lvo $(X_LIBS)
--- 21,27 ----
  BINDIR = ${prefix}/bin
  # BINDIR = /usr/local/bin
! SRCS = codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c
! OBJS = codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o mixer.o dvdauth.o
! CFLAGS = $(OPTFLAGS) $(CSS_INC) -Iloader -Ilibvo # -Wall
  A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3
  VO_LIBS = -Llibvo -lvo $(X_LIBS)
***************
*** 66,70 ****
  
  $(PRG):	.depend mplayer.o $(OBJS) loader/libloader.a loader/DirectShow/libDS_Filter.a libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a
! 	$(CC) $(CFLAGS) -o $(PRG) mplayer.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) -Lloader -lloader -Lloader/DirectShow -lDS_Filter -ldl -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore $(VO_LIBS) -Lencore -lencore -lpthread -lstdc++
  
  $(PRG_HQ):	.depend mplayerHQ.o $(OBJS) loader/libloader.a libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a
--- 64,68 ----
  
  $(PRG):	.depend mplayer.o $(OBJS) loader/libloader.a loader/DirectShow/libDS_Filter.a libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a
! 	$(CC) $(CFLAGS) -o $(PRG) mplayer.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) -Lloader -lloader -Lloader/DirectShow -lDS_Filter -ldl -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore $(VO_LIBS) $(CSS_LIB) -Lencore -lencore -lpthread -lstdc++
  
  $(PRG_HQ):	.depend mplayerHQ.o $(OBJS) loader/libloader.a libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a

Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** cfg-mplayer.h	2001/04/16 00:21:00	1.25
--- cfg-mplayer.h	2001/04/17 22:04:44	1.26
***************
*** 21,24 ****
--- 21,31 ----
          {"mixer", &mixer_device, CONF_TYPE_STRING, 0, 0, 0},
          {"master", &mixer_usemaster, CONF_TYPE_FLAG, 0, 0, 1},
+ #ifdef HAVE_LIBCSS
+         {"dvd", &dvd_device, CONF_TYPE_STRING, 0, 0, 0},
+ #else
+         {"dvd", "DVD support was not compiled in. See file DOCS/DVD.\n",
+             CONF_TYPE_PRINT, CONF_NOCFG, 0 , 0},
+ #endif
+ 			    
  #ifdef HAVE_FBDEV
  	{"fb", &fb_dev_name, CONF_TYPE_STRING, 0, 0, 0},

Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** configure	2001/04/16 00:44:29	1.23
--- configure	2001/04/17 22:04:44	1.24
***************
*** 7,10 ****
--- 7,13 ----
  # Changes in reversed order:
  #
+ # 2001/04/16 by LGB
+ #  - added libcss stuffs
+ #
  # 2001/04/15 by Pontscho
  #  - added --disable-select option
***************
*** 18,22 ****
  #
  # 2001/03/08 by LGB:
! #  - DGA detection-o-matic :)
  #  - '--disable-dga' option to force disabling DGA vo driver compiling into mplayer
  #  - line about '--enable-dga' is added to the help message
--- 21,25 ----
  #
  # 2001/03/08 by LGB:
! #  - DGA detect-o-matic :)
  #  - '--disable-dga' option to force disabling DGA vo driver compiling into mplayer
  #  - line about '--enable-dga' is added to the help message
***************
*** 101,104 ****
--- 104,109 ----
          --with-x11libdir=DIR    X library files are in DIR
          --with-win32libdir=DIR  windows codec files
+         --with-csslibdir=DIR    directory contains libcss.so shared library
+         --with-cssincdir=DIR    directory contains libcss header file (css.h)
  
  	--size-x=SIZE		default screen width
***************
*** 180,183 ****
--- 185,189 ----
  pstepping=`cat /proc/cpuinfo | grep 'stepping' | cut -d ':' -f 2 | cut -d ' ' -f 2`
  
+ _css=no
  _mmx=no
  _mmx2=no
***************
*** 461,464 ****
--- 467,473 ----
  do
   case "$ac_option" in
+   --enable-css)
+ 	_css=yes
+ 	;;
    --enable-sse)
          _sse=yes
***************
*** 527,530 ****
--- 536,542 ----
          _select='#define HAVE_AUDIO_SELECT'
  	;;
+   --disable-css)
+ 	_css=no
+ 	;;
    --disable-sse)
          _sse=no
***************
*** 583,586 ****
--- 595,606 ----
  	_win32libdirnotify=no
          ;;
+   --with-csslibdir=*)
+         _csslibdir=`echo $ac_option | cut -d '=' -f 2`
+ 	_css='yes';
+ 	;;
+   --with-cssincdir=*)
+         _cssincdir=`echo $ac_option | cut -d '=' -f 2`
+         _css='yes';
+         ;;
    --size-x=*)
  	_x=`echo $ac_option | cut -d '=' -f 2`
***************
*** 625,628 ****
--- 645,649 ----
  echo "Checking for SVGAlib ... $_svga"
  echo "Checking for FBDev ... $_fbdev"
+ echo "Checking for DeCSS support ... $_css"
  # write conf files.
  
***************
*** 631,634 ****
--- 652,673 ----
  fi
  
+ if [ $_css = yes ]; then
+    if [ ! -z $_csslibdir ]; then
+      _csslib="-L${_csslibdir} -lcss"
+    else
+      _csslib='-lcss'
+    fi
+    _css='#define HAVE_LIBCSS'
+    if [ ! -z $_cssincdir ]; then
+      _cssinc="-I${_cssincdir}"
+    else
+      _cssinc=""
+    fi
+ else
+    _css='#undef HAVE_LIBCSS'
+    _csslib=''
+    _cssinc=''
+ fi
+ 
  if [ $_x11 = yes ]; then
    if [ $_xdpms = yes ]; then
***************
*** 698,701 ****
--- 737,742 ----
  XMM_LIBS = $_xmmplibs
  LIRC_LIBS = $_lirclibs
+ CSS_LIB = $_csslib
+ CSS_INC = $_cssinc
  WIN32_PATH=-DWIN32_PATH=\"$_win32libdir\"
  
***************
*** 869,872 ****
--- 910,916 ----
  /* LIRC (remote control, see www.lirc.org) support: */
  $_lircdefs
+ 
+ /* DeCSS support using libcss */
+ $_css
  
  /* Define this to enable MPEG 1/2 image postprocessing (requires FAST cpu!) */

Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_mpg.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** demux_mpg.c	2001/04/15 03:40:37	1.4
--- demux_mpg.c	2001/04/17 22:04:44	1.5
***************
*** 18,21 ****
--- 18,24 ----
    int d;
    int len;
+ #ifdef HAVE_LIBCSS
+   int css=0;
+ #endif
    unsigned char c=0;
    unsigned int pts=0;
***************
*** 32,36 ****
    len=stream_read_word(demux->stream);
    if(verbose>=3)  printf("PACKET len=%d",len);
!   if(len==0 || len>4096) return -2;  // invalid packet !!!!!!
  
    while(len>0){   // Skip stuFFing bytes
--- 35,39 ----
    len=stream_read_word(demux->stream);
    if(verbose>=3)  printf("PACKET len=%d",len);
!   if(len==0 || len>STREAM_BUFFER_SIZE) return -2;  // invalid packet !!!!!!
  
    while(len>0){   // Skip stuFFing bytes
***************
*** 61,65 ****
      int hdrlen;
      // System-2 (.VOB) stream:
!     if((c>>4)&3) printf("Warning! Encrypted VOB file! (DeCSS not (yet) supported)\n");
      c=stream_read_char(demux->stream); pts_flags=c>>6;
      c=stream_read_char(demux->stream); hdrlen=c;
--- 64,74 ----
      int hdrlen;
      // System-2 (.VOB) stream:
!     if((c>>4)&3) {
! #ifdef HAVE_LIBCSS
!         css=1;
! #else
!         printf("Encrypted VOB file (not compiled with libcss support)! Read file DOCS/DVD\n");
! #endif
!     }
      c=stream_read_char(demux->stream); pts_flags=c>>6;
      c=stream_read_char(demux->stream); hdrlen=c;
***************
*** 122,126 ****
    if(verbose>=3) printf(" => len=%d\n",len);
  
!   if(len<=0 || len>4096) return -1;  // Invalid packet size
    
    if(id>=0x1C0 && id<=0x1DF){
--- 131,135 ----
    if(verbose>=3) printf(" => len=%d\n",len);
  
!   if(len<=0 || len>STREAM_BUFFER_SIZE) return -1;  // Invalid packet size
    
    if(id>=0x1C0 && id<=0x1DF){
***************
*** 149,152 ****
--- 158,164 ----
      if(verbose>=2) printf("DEMUX_MPG: Read %d data bytes from packet %04X\n",len,id);
  //    printf("packet start = 0x%X  \n",stream_tell(demux->stream)-packet_start_pos);
+ #ifdef HAVE_LIBCSS
+     if (css) CSSDescramble(demux->stream->buffer,key_title);
+ #endif
      ds_read_packet(ds,demux->stream,len,pts/90000.0f,0);
      return 1;
***************
*** 165,169 ****
    if(demux->stream->eof) return 0;
    demux->filepos=stream_tell(demux->stream);
!   ds_read_packet(demux->video,demux->stream,4096,0,0);
    return 1;
  }
--- 177,181 ----
    if(demux->stream->eof) return 0;
    demux->filepos=stream_tell(demux->stream);
!   ds_read_packet(demux->video,demux->stream,STREAM_BUFFER_SIZE,0,0);
    return 1;
  }

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -r1.74 -r1.75
*** mplayer.c	2001/04/17 18:37:15	1.74
--- mplayer.c	2001/04/17 22:04:44	1.75
***************
*** 51,54 ****
--- 51,56 ----
  #include "codec-cfg.h"
  
+ #include "dvdauth.h"
+ 
  #ifdef USE_DIRECTSHOW
  #include "DirectShow/DS_VideoDec.h"
***************
*** 606,609 ****
--- 608,617 ----
    f=open(filename,O_RDONLY);
    if(f<0){ printf("File not found: '%s'\n",filename);return 1; }
+ #ifdef HAVE_LIBCSS
+   if (dvd_device) {
+     if (dvd_auth(dvd_device,f)) exit(0);
+     printf("DVD auth sequence seems to be OK.\n");
+   }
+ #endif
    stream_type=STREAMTYPE_FILE;
  }
***************
*** 1901,1904 ****
--- 1909,1915 ----
  
          if(newpos<seek_to_byte) newpos=seek_to_byte;
+ #ifdef HAVE_LIBCSS
+         if (dvd_device) newpos&=~(STREAM_BUFFER_SIZE-1);  /* sector boundary */
+ #endif
          stream_seek(demuxer->stream,newpos);
          // re-sync video:

Index: stream.c
===================================================================
RCS file: /cvsroot/mplayer/main/stream.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** stream.c	2001/03/21 03:20:17	1.2
--- stream.c	2001/04/17 22:04:44	1.3
***************
*** 4,8 ****
  //=================== STREAMER =========================
  
! #define STREAM_BUFFER_SIZE 4096
  
  #define STREAMTYPE_FILE 0
--- 4,8 ----
  //=================== STREAMER =========================
  
! #define STREAM_BUFFER_SIZE 2048
  
  #define STREAMTYPE_FILE 0
***************
*** 127,131 ****
    switch(s->type){
    case STREAMTYPE_FILE:
!     newpos=pos&(~4095);break;
    case STREAMTYPE_VCD:
      newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break;
--- 127,131 ----
    switch(s->type){
    case STREAMTYPE_FILE:
!     newpos=pos&(~(STREAM_BUFFER_SIZE-1));break;
    case STREAMTYPE_VCD:
      newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break;


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list