summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile15
-rw-r--r--dvdauth.c65
2 files changed, 61 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index f8a8275edd..0fa68bf3d1 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@ include config.mak
PRG = mplayer
PRG_HQ = mplayerHQ
PRG_AVIP = aviparse
+PRG_FIBMAP = fibmap_mplayer
PRG_TV = tvision
PRG_CFG = codec-cfg
@@ -25,7 +26,7 @@ VO_LIBS = -Llibvo -lvo $(X_LIBS)
# .PHONY: all clean
-all: $(PRG)
+all: $(PRG) $(PRG_FIBMAP)
# $(PRG_AVIP)
.c.o:
@@ -66,6 +67,9 @@ mplayerwithoutlink: version.h mplayer.o $(OBJS) loader/libloader.a $(DS_DEP) lib
$(PRG): version.h mplayer.o $(OBJS) loader/libloader.a $(DS_DEP) 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 $(DS_LIB) -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore -Llibao2 -lao2 $(VO_LIBS) $(CSS_LIB) -Lencore -lencore $(ARCH_LIBS)
+$(PRG_FIBMAP): fibmap_mplayer.o
+ $(CC) -o $(PRG_FIBMAP) fibmap_mplayer.o
+
# $(PRG_HQ): depfile 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
@@ -78,16 +82,21 @@ $(PRG): version.h mplayer.o $(OBJS) loader/libloader.a $(DS_DEP) libmpeg2/libmpe
$(PRG_CFG): version.h codec-cfg.c codec-cfg.h
$(CC) $(CFLAGS) -g codec-cfg.c -o $(PRG_CFG) -DCODECS2HTML
-install: $(PRG)
+install: $(PRG) $(PRG_FIBMAP)
install -D -m 755 -s $(PRG) $(BINDIR)/$(PRG)
install -D -m 644 DOCS/mplayer.1 $(prefix)/man/man1/mplayer.1
+ @echo "Following task requires root privs. If it fails don't panic"
+ @echo "however it means you can't use fibmap_mplayer."
+ @echo "Without this (or without running mplayer as root) you won't be"
+ @echo "able to play DVDs."
+ install -D -o root -g root -m 4755 -s $(PRG_FIBMAP) $(BINDIR)/$(PRG_FIBMAP)
clean:
rm -f *.o *~ $(OBJS)
distclean:
@for a in mp3lib libac3 libmpeg2 opendivx encore libvo libao2 loader loader/DirectShow drivers drivers/syncfb ; do $(MAKE) -C $$a distclean ; done
- rm -f *~ $(PRG) $(PRG_HQ) $(PRG_AVIP) $(PRG_TV) $(OBJS) *.o *.a .depend
+ rm -f *~ $(PRG) $(PRG_FIBMAP) $(PRG_HQ) $(PRG_AVIP) $(PRG_TV) $(OBJS) *.o *.a .depend
dep: depend
diff --git a/dvdauth.c b/dvdauth.c
index affab071c7..a117c27e6f 100644
--- a/dvdauth.c
+++ b/dvdauth.c
@@ -13,6 +13,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include <css.h>
#if CSS_MAJOR_VERSION > 0 || (CSS_MAJOR_VERSION == 0 && CSS_MINOR_VERSION > 1)
# include <dvd.h>
@@ -46,8 +47,10 @@
#define DVDCloseDevice(hdl) close(hdl)
#define CSSDVDisEncrypted(hdl) CSSisEncrypted(hdl)
#define CSSDVDAuthDisc CSSAuthDisc
-#define CSSDVDAuthTitlePath(hdl,key_title,path) \
- CSSAuthTitle(hdl,key_title,path_to_lba(path))
+/* Arghhh! Please think before you commit! You forget to check the return
+ value of path_to_lba (-1 for error) in this way ... - LGB */
+//#define CSSDVDAuthTitlePath(hdl,key_title,path) \
+// CSSAuthTitle(hdl,key_title,path_to_lba(path))
#else /*OLD_CSS_API*/
@@ -58,6 +61,8 @@
char *dvd_auth_device=NULL;
+char *dvd_device=NULL;
+char *dvd_raw_device=NULL;
unsigned char key_disc[2048];
unsigned char key_title[5];
unsigned char *dvdimportkey=NULL;
@@ -79,24 +84,52 @@ int descrambling=0;
static int path_to_lba (char *path)
{
- int fd, lba = 0;
-
- if ((fd = open(path, O_RDONLY)) == -1) {
- fprintf(stderr, "Cannot open file %s: %s",
- path ? path : "(NULL)", strerror(errno));
- return -1;
+ int lba = 0;
+ char cmd[100];
+ FILE *fp;
+
+ snprintf(cmd,sizeof(cmd),"fibmap_mplayer %s",path);
+ fp=popen(cmd,"r");
+ if (fp) {
+ int ret;
+ bzero(cmd,sizeof(cmd));
+ fgets(cmd,99,fp);
+ if ((ret=pclose(fp)))
+ fprintf(stderr,"fibmap_mplayer: %s\n",*cmd?cmd:"no error info");
+ if(WIFEXITED(ret) && !WEXITSTATUS(ret))
+ lba=atoi(cmd);
+ else
+ fp=NULL;
}
- if (ioctl(fd, FIBMAP, &lba) != 0) {
- perror ("ioctl FIBMAP");
- fprintf(stderr,"Hint: run mplayer as root!\n");
- close(fd);
- return -1;
+ if (!fp) {
+ int fd;
+ printf("fibmap_mplayer could not run, trying with ioctl() ...\n");
+ if ((fd = open(path, O_RDONLY)) == -1) {
+ fprintf(stderr, "Cannot open file %s: %s",
+ path ? path : "(NULL)", strerror(errno));
+ return -1;
+ }
+ if (ioctl(fd, FIBMAP, &lba) != 0) {
+ perror ("ioctl FIBMAP");
+ fprintf(stderr,"Hint: run mplayer as root (or better to install fibmap_mplayer as suid root)!\n");
+ close(fd);
+ return -1;
+ }
+ close(fd);
}
-
- close(fd);
-
+ printf("LBA: %d\n",lba);
return lba;
}
+
+
+int CSSDVDAuthTitlePath(DVDHandle hdl,unsigned char *key_title,char *path)
+{
+ int lba=path_to_lba(path);
+ if (lba==-1) return -1;
+ return CSSAuthTitle(hdl,key_title,lba);
+}
+
+
#else /*linux*/
static int path_to_lba (char *path)
{