summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/dvd.c11
-rw-r--r--libhb/dvdnav.c11
-rw-r--r--libhb/ports.c37
-rw-r--r--libhb/ports.h5
4 files changed, 64 insertions, 0 deletions
diff --git a/libhb/dvd.c b/libhb/dvd.c
index 29ed04fd4..39b519d4c 100644
--- a/libhb/dvd.c
+++ b/libhb/dvd.c
@@ -87,10 +87,21 @@ hb_dvd_t * hb_dvdread_init( char * path )
{
hb_dvd_t * e;
hb_dvdread_t * d;
+ int region_mask;
e = calloc( sizeof( hb_dvd_t ), 1 );
d = &(e->dvdread);
+ /* Log DVD drive region code */
+ if ( hb_dvd_region( path, &region_mask ) == 0 )
+ {
+ hb_log( "dvd: Region mask 0x%02x", region_mask );
+ if ( region_mask == 0xFF )
+ {
+ hb_log( "dvd: Warning, DVD device has no region set" );
+ }
+ }
+
/* Open device */
if( !( d->reader = DVDOpen( path ) ) )
{
diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c
index 378c1334b..40587b7ed 100644
--- a/libhb/dvdnav.c
+++ b/libhb/dvdnav.c
@@ -142,10 +142,21 @@ static hb_dvd_t * hb_dvdnav_init( char * path )
{
hb_dvd_t * e;
hb_dvdnav_t * d;
+ int region_mask;
e = calloc( sizeof( hb_dvd_t ), 1 );
d = &(e->dvdnav);
+ /* Log DVD drive region code */
+ if ( hb_dvd_region( path, &region_mask ) == 0 )
+ {
+ hb_log( "dvd: Region mask 0x%02x", region_mask );
+ if ( region_mask == 0xFF )
+ {
+ hb_log( "dvd: Warning, DVD device has no region set" );
+ }
+ }
+
/* Open device */
if( dvdnav_open(&d->dvdnav, path) != DVDNAV_STATUS_OK )
{
diff --git a/libhb/ports.c b/libhb/ports.c
index 6c6960633..7b18ce896 100644
--- a/libhb/ports.c
+++ b/libhb/ports.c
@@ -54,6 +54,16 @@
#include <netinet/in.h>
#endif
+#if defined( SYS_LINUX )
+#include <linux/cdrom.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#elif defined( SYS_OPENBSD )
+#include <sys/dvdio.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#endif
+
#include <stddef.h>
#include "hb.h"
@@ -82,6 +92,33 @@ int gettimeofday( struct timeval * tv, struct timezone * tz )
#endif
*/
+int hb_dvd_region(char *device, int *region_mask)
+{
+#if defined( DVD_LU_SEND_RPC_STATE ) && defined( DVD_AUTH )
+ struct stat st;
+ dvd_authinfo ai;
+ int fd, ret;
+
+ fd = open( device, O_RDONLY );
+ if ( fd < 0 )
+ return -1;
+ if ( fstat( fd, &st ) < 0 )
+ return -1;
+ if ( !( S_ISBLK( st.st_mode ) || S_ISCHR( st.st_mode ) ) )
+ return -1;
+
+ ai.type = DVD_LU_SEND_RPC_STATE;
+ ret = ioctl(fd, DVD_AUTH, &ai);
+ if ( ret < 0 )
+ return ret;
+
+ *region_mask = ai.lrpcs.region_mask;
+ return 0;
+#else
+ return -1;
+#endif
+}
+
uint64_t hb_get_date()
{
struct timeval tv;
diff --git a/libhb/ports.h b/libhb/ports.h
index c544f19a6..0f3697f0d 100644
--- a/libhb/ports.h
+++ b/libhb/ports.h
@@ -19,6 +19,11 @@ int hb_get_cpu_count();
/* Everything from now is only used internally and hidden to the UI */
/************************************************************************
+ * DVD utils
+ ***********************************************************************/
+int hb_dvd_region(char *device, int *region_mask);
+
+/************************************************************************
* Files utils
***********************************************************************/
void hb_get_tempory_directory( hb_handle_t * h, char path[512] );