changeset 546:22ed5f5821e2

command line requested DVD key support for Arpi :)
author lgb
date Fri, 20 Apr 2001 14:32:09 +0000
parents 142dd5a2631f
children 3e46eab9f782
files cfg-mplayer.h demux_mpg.c dvdauth.c dvdauth.h mplayer.c
diffstat 5 files changed, 43 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer.h	Fri Apr 20 12:09:32 2001 +0000
+++ b/cfg-mplayer.h	Fri Apr 20 14:32:09 2001 +0000
@@ -25,6 +25,7 @@
         {"master", &mixer_usemaster, CONF_TYPE_FLAG, 0, 0, 1},
 #ifdef HAVE_LIBCSS
         {"dvd", &dvd_device, CONF_TYPE_STRING, 0, 0, 0},
+        {"dvdkey", &dvdimportkey, 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},
--- a/demux_mpg.c	Fri Apr 20 12:09:32 2001 +0000
+++ b/demux_mpg.c	Fri Apr 20 14:32:09 2001 +0000
@@ -180,7 +180,10 @@
     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);
+    if (css) {
+	    if (descrambling) CSSDescramble(demux->stream->buffer,key_title); else
+		    printf("Encrypted stream but authentication was not requested by you!!\n");
+    }
 #endif
     ds_read_packet(ds,demux->stream,len,pts/90000.0f,0);
     return 1;
--- a/dvdauth.c	Fri Apr 20 12:09:32 2001 +0000
+++ b/dvdauth.c	Fri Apr 20 14:32:09 2001 +0000
@@ -23,6 +23,8 @@
 char *dvd_device=NULL;
 unsigned char key_disc[2048];
 unsigned char key_title[5];
+unsigned char *dvdimportkey=NULL;
+int descrambling=0;
 
 
 #include <linux/fs.h>
@@ -59,6 +61,30 @@
 }
 
 
+int dvd_import_key ( unsigned char *hexkey )
+{
+	unsigned char *t=key_title;
+	int digit=4,len;
+	bzero(key_title,sizeof(key_title));
+//	printf("DVD key: %s\n",hexkey);
+	for (len=0;len<10;len++) {
+//		printf("-> %c\n",*hexkey);
+		if (!*hexkey) return 1;
+		if (*hexkey>='A'&&*hexkey<='F') *t|=(*hexkey-'A'+10)<<digit;
+			else if (*hexkey>='0'&&*hexkey<='9') *t|=(*hexkey-'0')<<digit;
+				else return 1;
+		if (digit) digit=0; else {
+			digit=4;
+			t++;
+		}
+		hexkey++;
+	}
+	if (*hexkey) return 1;
+	printf("DVD key (requested): %02X%02X%02X%02X%02X\n",key_title[0],key_title[1],key_title[2],key_title[3],key_title[4]);
+	descrambling=1;
+	return 0;
+}
+
 
 int dvd_auth ( char *dev , int fd )
 {
@@ -99,6 +125,8 @@
 	}
 
 	close(devfd);
+	printf("DVD title key is: %02X%02X%02X%02X%02X\n",key_title[0],key_title[1],key_title[2],key_title[3],key_title[4]);
+	descrambling=1;
 	return 0;
 }
 
--- a/dvdauth.h	Fri Apr 20 12:09:32 2001 +0000
+++ b/dvdauth.h	Fri Apr 20 14:32:09 2001 +0000
@@ -6,9 +6,11 @@
 extern char *dvd_device;
 extern unsigned char key_disc[];
 extern unsigned char key_title[];
+extern unsigned char *dvdimportkey;
+extern int descrambling;
 
 int dvd_auth ( char *, int );
-
+int dvd_import_key ( unsigned char * );
 
 #endif
 #endif
\ No newline at end of file
--- a/mplayer.c	Fri Apr 20 12:09:32 2001 +0000
+++ b/mplayer.c	Fri Apr 20 14:32:09 2001 +0000
@@ -613,6 +613,13 @@
   f=open(filename,O_RDONLY);
   if(f<0){ printf("File not found: '%s'\n",filename);return 1; }
 #ifdef HAVE_LIBCSS
+  if (dvdimportkey) {
+    if (dvd_import_key(dvdimportkey)) {
+	fprintf(stderr,"Error processing DVD KEY.\n");
+	exit(1);
+    }
+    printf("DVD command line requested key is stored for descrambling.\n");
+  }
   if (dvd_device) {
     if (dvd_auth(dvd_device,f)) exit(0);
     printf("DVD auth sequence seems to be OK.\n");