summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--cfg-mplayer.h7
-rwxr-xr-xconfigure46
-rw-r--r--demux_mpg.c20
-rw-r--r--dvdauth.c106
-rw-r--r--dvdauth.h14
-rw-r--r--mplayer.c11
-rw-r--r--stream.c4
8 files changed, 206 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 5a347bdd68..c66a71ae1b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,8 @@
-# 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
+# * DVD support
include config.mak
@@ -22,9 +20,9 @@ PRG_CFG = codec-cfg
prefix = /usr/local
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
+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)
@@ -65,7 +63,7 @@ encore/libencore.a:
$(MAKE) -C encore
$(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++
+ $(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
$(CC) $(CFLAGS) -o $(PRG_HQ) mplayerHQ.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) -Lloader -lloader -ldl -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore $(VO_LIBS) -Lencore -lencore -lpthread
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 2f0ef07894..fd7307cdda 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -20,6 +20,13 @@ struct config conf[]={
{"dsp", &dsp, CONF_TYPE_STRING, 0, 0, 0},
{"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},
{"fbmode", &fb_mode_name, CONF_TYPE_STRING, 0, 0, 0},
diff --git a/configure b/configure
index 0f2dcd6524..256513e516 100755
--- a/configure
+++ b/configure
@@ -6,6 +6,9 @@
#
# Changes in reversed order:
#
+# 2001/04/16 by LGB
+# - added libcss stuffs
+#
# 2001/04/15 by Pontscho
# - added --disable-select option
# - added X11DIR variable in config.mak and fix syncfb Makefile -L/usr/X11/lib bug
@@ -17,7 +20,7 @@
# - new option: --cc (to specify C compiler path+name)
#
# 2001/03/08 by LGB:
-# - DGA detection-o-matic :)
+# - 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
#
@@ -100,6 +103,8 @@ params:
--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
--size-y=SIZE default screen height
@@ -179,6 +184,7 @@ pfamily=`cat /proc/cpuinfo | grep 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f
pmodel=`cat /proc/cpuinfo | grep "model$TAB" | cut -d ':' -f 2 | cut -d ' ' -f 2`
pstepping=`cat /proc/cpuinfo | grep 'stepping' | cut -d ':' -f 2 | cut -d ' ' -f 2`
+_css=no
_mmx=no
_mmx2=no
_3dnow=no
@@ -460,6 +466,9 @@ rm -f $TMPC $TMPO
for ac_option
do
case "$ac_option" in
+ --enable-css)
+ _css=yes
+ ;;
--enable-sse)
_sse=yes
;;
@@ -526,6 +535,9 @@ do
--enable-select)
_select='#define HAVE_AUDIO_SELECT'
;;
+ --disable-css)
+ _css=no
+ ;;
--disable-sse)
_sse=no
;;
@@ -582,6 +594,14 @@ do
_win32libdir=`echo $ac_option | cut -d '=' -f 2`
_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`
;;
@@ -624,12 +644,31 @@ echo "Checking for DGA 2.0 .. $_dga2"
echo "Checking for Xf86VM ... $_vm"
echo "Checking for SVGAlib ... $_svga"
echo "Checking for FBDev ... $_fbdev"
+echo "Checking for DeCSS support ... $_css"
# write conf files.
if [ $_gl = yes ]; then
_gllib='-lGL'
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
_x11lib='-lX11 -lXext -lXdpms'
@@ -697,6 +736,8 @@ X_LIBS=$_x11libdir $_gllib $_sdllib $_dgalib $_x11lib $_xvlib $_vmlib $_svgalib
TERMCAP_LIB=$_libtermcap
XMM_LIBS = $_xmmplibs
LIRC_LIBS = $_lirclibs
+CSS_LIB = $_csslib
+CSS_INC = $_cssinc
WIN32_PATH=-DWIN32_PATH=\"$_win32libdir\"
EOF
@@ -869,6 +910,9 @@ $_xmmpaudio
/* 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!) */
#define MPEG12_POSTPROC
diff --git a/demux_mpg.c b/demux_mpg.c
index 3b3e5fc804..4c09da6f7b 100644
--- a/demux_mpg.c
+++ b/demux_mpg.c
@@ -17,6 +17,9 @@ static char dvdaudio_table[256];
static int demux_mpg_read_packet(demuxer_t *demux,int id){
int d;
int len;
+#ifdef HAVE_LIBCSS
+ int css=0;
+#endif
unsigned char c=0;
unsigned int pts=0;
unsigned int dts=0;
@@ -31,7 +34,7 @@ static int demux_mpg_read_packet(demuxer_t *demux,int id){
len=stream_read_word(demux->stream);
if(verbose>=3) printf("PACKET len=%d",len);
- if(len==0 || len>4096) return -2; // invalid packet !!!!!!
+ if(len==0 || len>STREAM_BUFFER_SIZE) return -2; // invalid packet !!!!!!
while(len>0){ // Skip stuFFing bytes
c=stream_read_char(demux->stream);--len;
@@ -60,7 +63,13 @@ static int demux_mpg_read_packet(demuxer_t *demux,int id){
int pts_flags;
int hdrlen;
// System-2 (.VOB) stream:
- if((c>>4)&3) printf("Warning! Encrypted VOB file! (DeCSS not (yet) supported)\n");
+ 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;
len-=2;
@@ -121,7 +130,7 @@ static int demux_mpg_read_packet(demuxer_t *demux,int id){
}
if(verbose>=3) printf(" => len=%d\n",len);
- if(len<=0 || len>4096) return -1; // Invalid packet size
+ if(len<=0 || len>STREAM_BUFFER_SIZE) return -1; // Invalid packet size
if(id>=0x1C0 && id<=0x1DF){
// mpeg audio
@@ -148,6 +157,9 @@ static int demux_mpg_read_packet(demuxer_t *demux,int id){
if(ds){
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;
}
@@ -164,7 +176,7 @@ int demux_mpg_es_fill_buffer(demuxer_t *demux){
// Elementary video stream
if(demux->stream->eof) return 0;
demux->filepos=stream_tell(demux->stream);
- ds_read_packet(demux->video,demux->stream,4096,0,0);
+ ds_read_packet(demux->video,demux->stream,STREAM_BUFFER_SIZE,0,0);
return 1;
}
diff --git a/dvdauth.c b/dvdauth.c
new file mode 100644
index 0000000000..da6832c58a
--- /dev/null
+++ b/dvdauth.c
@@ -0,0 +1,106 @@
+/* (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
diff --git a/dvdauth.h b/dvdauth.h
new file mode 100644
index 0000000000..b719bf0caa
--- /dev/null
+++ b/dvdauth.h
@@ -0,0 +1,14 @@
+#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 \ No newline at end of file
diff --git a/mplayer.c b/mplayer.c
index f637157ec9..023c210a54 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -50,6 +50,8 @@
#include "codec-cfg.h"
+#include "dvdauth.h"
+
#ifdef USE_DIRECTSHOW
#include "DirectShow/DS_VideoDec.h"
#include "DirectShow/DS_AudioDec.h"
@@ -605,6 +607,12 @@ if(vcd_track){
//============ Open plain FILE ============
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;
}
@@ -1900,6 +1908,9 @@ switch(file_format){
// picture->bitrate=2324*75*8; // standard VCD bitrate (75 sectors / sec)
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:
videobuf_code_len=0; // reset ES stream buffer
diff --git a/stream.c b/stream.c
index b07af0d3db..fd3ec353fc 100644
--- a/stream.c
+++ b/stream.c
@@ -3,7 +3,7 @@
//=================== STREAMER =========================
-#define STREAM_BUFFER_SIZE 4096
+#define STREAM_BUFFER_SIZE 2048
#define STREAMTYPE_FILE 0
#define STREAMTYPE_VCD 1
@@ -126,7 +126,7 @@ if(verbose>=3){
switch(s->type){
case STREAMTYPE_FILE:
- newpos=pos&(~4095);break;
+ newpos=pos&(~(STREAM_BUFFER_SIZE-1));break;
case STREAMTYPE_VCD:
newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break;
}