OSDN Git Service

"If one would give me six lines written by the hand of the most honest man, I would...
authorjbrjake <jbrjake@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 22 Mar 2008 00:16:22 +0000 (00:16 +0000)
committerjbrjake <jbrjake@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 22 Mar 2008 00:16:22 +0000 (00:16 +0000)
- Banishes libdvdcss, removing DVD decryption from HandBrake's binaries.
- For decrypttion, the MacGui and Mac CLI now will load at runtime VLC's dynamic library of dvdcss if the media player's available on the user's system.
- Linux users can build with a statically linked lib of dvdcss by using ./configure --libdvdcss, which will download it from a remote third party (videolan.org).

git-svn-id: svn://localhost/HandBrake/trunk@1354 b64f7644-9d1e-0410-96f1-a4d463321fa5

Jamfile
configure
contrib/Jamfile
contrib/patch-libdvdread-css-vlc-dylib.patch [new file with mode: 0644]
contrib/version_libdvdcss.txt
macosx/Controller.mm
macosx/HandBrake.xcodeproj/project.pbxproj

diff --git a/Jamfile b/Jamfile
index f463bf2..a625217 100644 (file)
--- a/Jamfile
+++ b/Jamfile
@@ -24,7 +24,7 @@ if $(OS) = UNKNOWN
     OS = CYGWIN ;
 }
 
-if $(OS) != CYGWIN
+if $(CSS) = 1
 {
     HANDBRAKE_LIBS = $(HANDBRAKE_LIBS) contrib/lib/libdvdcss.a ;
 }
index b648626..7c02be7 100755 (executable)
--- a/configure
+++ b/configure
@@ -98,13 +98,21 @@ MAKE=make
 fi
 
 # If the user included the --snapshot argument, mark it down.
-if [[ $1 = "--snapshot" ]]
+if [[ $1 = "--snapshot" ]] || [[ $2 = "--snapshot" ]]
 then
     SNAPSHOT=1
 else
     SNAPSHOT=0
 fi
 
+# We fought the law and the law won
+if [[ $1 = "--libdvdcss" ]] || [[ $2 = "--libdvdcss" ]] 
+then
+    CSS=1
+else
+    CSS=0
+fi
+
 # Generating the HB_BUILD and HB_VERSION for snapshots requires
 # the build date, working path, and current SVN revision. 
 BUILD_DATE=$(date +%Y%m%d)
@@ -127,6 +135,7 @@ SNAPSHOT = $SNAPSHOT ;
 BUILD_DATE = $BUILD_DATE ;
 FULL_PATH = $FULL_PATH ;
 SVN_REV = $SVN_REV ;
+CSS      = $CSS ;
 EOF
 
 echo
index 8914831..fd0b981 100644 (file)
@@ -101,8 +101,9 @@ LibAvUtil $(SUBDIR)/lib/libavutil.a : $(SUBDIR)/lib/libavcodec.a ;
 LibAvUtil $(SUBDIR)/lib/libavformat.a : $(SUBDIR)/lib/libavcodec.a ;
 LibAvUtil $(SUBDIR)/lib/libswscale.a : $(SUBDIR)/lib/libavcodec.a ;
 
-# CSS doesn't work on Cygwin/Windows as of now, so don't use it.
-if $(OS) != CYGWIN
+# HandBrake does not include a DVD decrypting library,
+# so if a user requests it, let them download and compile it from a 3rd party
+if $(CSS) = 1
 {
     # libdvdcss
     # We need libdvdcss.so for libdvdread's configure to work...
@@ -114,8 +115,8 @@ if $(OS) != CYGWIN
     actions LibDvdCss
     {
         cd `dirname $(>)` && CONTRIB=`pwd` &&
-        rm -rf libdvdcss && (gzip -dc libdvdcss.tar.gz | tar xf - ) && 
-        cd libdvdcss &&
+        rm -rf libdvdcss-1.2.9 && (gzip -dc libdvdcss.tar.gz | tar xf - ) && 
+        cd libdvdcss-1.2.9 &&
         ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache && $(MAKE) && $(MAKE) install &&
         $(STRIP) $CONTRIB/lib/libdvdcss.a
     }
@@ -145,8 +146,14 @@ rule LibDvdRead
 {
     Depends $(<) : $(>) ;
     Depends lib  : $(<) ;
+    
+    if $(OS) = MACOSX
+    {
+        DVDREAD_PATCH = "$(PATCH) -p0 < ../patch-libdvdread-css-vlc-dylib.patch &&" ;
+    }
+    
 }
-if $(OS) != CYGWIN
+if $(CSS) = 1 # Include CSS support in libdvdread if requested
 {
     actions LibDvdRead
     {
@@ -161,11 +168,12 @@ if $(OS) != CYGWIN
 else {
     # Cygwin/Windows doesn't use CSS as of now, so don't include it on the
     # configure line.
+    # MacOSX uses a dylib for CSS, so it doesn't need including there either.
     actions LibDvdRead
     {
         cd `dirname $(>)` && CONTRIB=`pwd` &&
-        rm -rf libdvdread && (gzip -dc libdvdread.tar.gz | tar xf - ) && 
-        cd libdvdread &&
+        rm -rf libdvdread && (gzip -dc libdvdread.tar.gz | tar xf - ) &&
+        cd libdvdread && $(DVDREAD_PATCH)
         ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared &&
         $(MAKE) && $(MAKE) install &&
         $(STRIP) $CONTRIB/lib/libdvdread.a
diff --git a/contrib/patch-libdvdread-css-vlc-dylib.patch b/contrib/patch-libdvdread-css-vlc-dylib.patch
new file mode 100644 (file)
index 0000000..6d61cfa
--- /dev/null
@@ -0,0 +1,11 @@
+--- dvdread/dvd_input.c        2005-09-19 09:43:08.000000000 -0400
++++ dvdread/patched-dvd_input.c        2008-03-19 12:47:16.000000000 -0400
+@@ -332,7 +332,7 @@
+ #else
+-  dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY);
++  dvdcss_library = dlopen("/Applications/VLC.app/Contents/MacOS/lib/vlc_libdvdcss.dylib", RTLD_LAZY);
+   if(dvdcss_library != NULL) {
+ #if defined(__OpenBSD__) && !defined(__ELF__)
index 81d1ef1..4821730 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/libdvdcss-1.2.9.tar.gz
+http://download.videolan.org/pub/libdvdcss/1.2.9/libdvdcss-1.2.9.tar.gz
\ No newline at end of file
index 207f1f1..2534994 100644 (file)
@@ -1229,6 +1229,8 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 /* Here we actually tell hb_scan to perform the source scan, using the path to source and title number*/
 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum
 {
+    /* use a bool to determine whether or not we can decrypt using vlc */
+    BOOL cancelScanDecrypt = 0;
     NSString *path = scanPath;
     HBDVDDetector *detector = [HBDVDDetector detectorForPath:path];
     if( [detector isVideoDVD] )
@@ -1237,21 +1239,74 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
         // device path instead.
         path = [detector devicePath];
         [self writeToActivityLog: "trying to open a physical dvd at: %s", [scanPath UTF8String]];
+        
+        /* lets check for vlc here to make sure we have a dylib available to use for decrypting */
+        NSString *vlcPath = @"/Applications/VLC.app";
+        NSFileManager * fileManager = [NSFileManager defaultManager];
+           if ([fileManager fileExistsAtPath:vlcPath] == 0) 
+           {
+            /*vlc not found in /Applications so we set the bool to cancel scanning to 1 */
+            cancelScanDecrypt = 1;
+            [self writeToActivityLog: "VLC app not found for decrypting physical dvd"];
+            int status;
+            status = NSRunAlertPanel(@"HandBrake could not find VLC.",@"Please download and install VLC media player in your /Applications folder if you wish to read encrypted DVDs.", @"Get VLC", @"Cancel Scan", @"Attempt Scan Anyway");
+            [NSApp requestUserAttention:NSCriticalRequest];
+            
+            if (status == NSAlertDefaultReturn)
+            {
+                /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */
+                [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/"]];
+            }
+            else if (status == NSAlertAlternateReturn)
+            {
+            /* User chose to cancel the scan */
+            [self writeToActivityLog: "cannot open physical dvd , scan cancelled"];
+            }
+            else
+            {
+            /* User chose to override our warning and scan the physical dvd anyway, at their own peril. on an encrypted dvd this produces massive log files and fails */
+            cancelScanDecrypt = 0;
+            [self writeToActivityLog: "user overrode vlc warning -trying to open physical dvd without decryption"];
+            }
+            
+        }
+        else
+        {
+            /* VLC was found in /Applications so all is well, we can carry on using vlc's libdvdcss.dylib for decrypting if needed */
+            [self writeToActivityLog: "VLC app found for decrypting physical dvd"];
+        }
+        
     }
-    /* If there is no title number passed to scan, we use "0"
-        * which causes the default behavior of a full source scan
-    */
-    if (!scanTitleNum)
+    
+    
+    
+    if (cancelScanDecrypt == 0)
     {
-        scanTitleNum = 0;
+        
+        /* we actually pass the scan off to libhb here */
+        /* If there is no title number passed to scan, we use "0"
+         * which causes the default behavior of a full source scan
+         */
+        if (!scanTitleNum)
+        {
+            scanTitleNum = 0;
+        }
+        if (scanTitleNum > 0)
+        {
+            [self writeToActivityLog: "scanning specifically for title: %d", scanTitleNum];
+        }
+        hb_scan( fHandle, [path UTF8String], scanTitleNum );
+        [fSrcDVD2Field setStringValue: [NSString stringWithFormat: @"Scanning new source ..."]];
     }
-    if (scanTitleNum > 0)
+    else
     {
-    [self writeToActivityLog: "scanning specifically for title: %d", scanTitleNum];
+            /* if we have a title loaded up */
+        if ([[fSrcDVD2Field stringValue] length] > 0)
+        {
+            [self enableUI: YES];
+        }
     }
-    [fSrcDVD2Field setStringValue: [NSString stringWithFormat: @"Scanning new source ..."]];
-    /* we actually pass the scan off to libhb here */
-    hb_scan( fHandle, [path UTF8String], scanTitleNum );
+
     
 }
 
index 7cc5b52..d8973ae 100644 (file)
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,
                                        ../contrib/lib/libavcodec.a,
                                        ../contrib/lib/libavutil.a,
                                        ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libdvdcss.a,
                                        ../contrib/lib/libfaac.a,
                                        ../contrib/lib/libmp3lame.a,
                                        ../contrib/lib/libmpeg2.a,