*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
#include <sys/stat.h>
#endif
+#ifdef __APPLE__
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#endif
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h> /* demux_t */
#include <vlc_atomic.h>
#include <vlc_dialog.h> /* BD+/AACS warnings */
#include <vlc_vout.h> /* vout_PutSubpicture / subpicture_t */
+#include <vlc_url.h> /* vlc_path2uri */
#include <libbluray/bluray.h>
#include <libbluray/keys.h>
* Module descriptor
*****************************************************************************/
-#define BD_MENU_TEXT N_( "Bluray menus" )
-#define BD_MENU_LONGTEXT N_( "Use bluray menus. If disabled, "\
+#define BD_MENU_TEXT N_( "Blu-ray menus" )
+#define BD_MENU_LONGTEXT N_( "Use Blu-ray menus. If disabled, "\
"the movie will start directly" )
+#define BD_REGION_TEXT N_( "Region code" )
+#define BD_REGION_LONGTEXT N_( "Blu-Ray player region code. "\
+ "Some discs can be played only with a correct region code.")
+
+static const char *const ppsz_region_code[] = {
+ "A", "B", "C" };
+static const char *const ppsz_region_code_text[] = {
+ "Region A", "Region B", "Region C" };
+
+#define REGION_DEFAULT 1 /* Index to region list. Actual region code is (1<<REGION_DEFAULT) */
/* Callbacks */
static int blurayOpen ( vlc_object_t * );
static void blurayClose( vlc_object_t * );
vlc_module_begin ()
- set_shortname( N_("BluRay") )
- set_description( N_("Blu-Ray Disc support (libbluray)") )
+ set_shortname( N_("Blu-ray") )
+ set_description( N_("Blu-ray Disc support (libbluray)") )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_ACCESS )
set_capability( "access_demux", 200)
add_bool( "bluray-menu", false, BD_MENU_TEXT, BD_MENU_LONGTEXT, false )
+ add_string( "bluray-region", ppsz_region_code[REGION_DEFAULT], BD_REGION_TEXT, BD_REGION_LONGTEXT, false)
+ change_string_list( ppsz_region_code, ppsz_region_code_text )
add_shortcut( "bluray", "file" )
int i_audio_stream; /* Selected audio stream. -1 if default */
int i_video_stream;
stream_t *p_parser;
+
+ /* Used to store bluray disc path */
+ char *psz_bd_path;
};
struct subpicture_updater_sys_t
demux_t *p_demux = (demux_t*)object;
demux_sys_t *p_sys;
- char bd_path[PATH_MAX] = { '\0' };
const char *error_msg = NULL;
if (strcmp(p_demux->psz_access, "bluray")) {
TAB_INIT( p_sys->i_title, p_sys->pp_title );
- /* store current bd_path */
+ /* store current bd path */
if (p_demux->psz_file) {
- strncpy(bd_path, p_demux->psz_file, sizeof(bd_path));
- bd_path[PATH_MAX - 1] = '\0';
+ p_sys->psz_bd_path = strndup(p_demux->psz_file, strlen(p_demux->psz_file));
}
#if defined (HAVE_MNTENT_H) && defined (HAVE_SYS_STAT_H)
/* If we're passed a block device, try to convert it to the mount point. */
struct stat st;
- if ( !stat (bd_path, &st)) {
+ if ( !stat (p_sys->psz_bd_path, &st)) {
if (S_ISBLK (st.st_mode)) {
FILE* mtab = setmntent ("/proc/self/mounts", "r");
struct mntent* m;
struct mntent mbuf;
char buf [8192];
+ /* bd path may be a symlink (e.g. /dev/dvd -> /dev/sr0), so make
+ * sure we look up the real device */
+ char* bd_device = realpath(p_sys->psz_bd_path, NULL);
while ((m = getmntent_r (mtab, &mbuf, buf, sizeof(buf))) != NULL) {
- if (!strcmp (m->mnt_fsname, bd_path)) {
- strncpy (bd_path, m->mnt_dir, sizeof(bd_path));
- bd_path[sizeof(bd_path) - 1] = '\0';
+ if (!strcmp (m->mnt_fsname, (bd_device == NULL ? p_sys->psz_bd_path : bd_device))) {
+ p_sys->psz_bd_path = strndup(m->mnt_dir, strlen(m->mnt_dir));
break;
}
}
+ free(bd_device);
endmntent (mtab);
}
}
#endif /* HAVE_MNTENT_H && HAVE_SYS_STAT_H */
- p_sys->bluray = bd_open(bd_path, NULL);
+#ifdef __APPLE__
+ /* If we're passed a block device, try to convert it to the mount point. */
+ struct stat st;
+ if ( !stat (p_sys->psz_bd_path, &st)) {
+ if (S_ISBLK (st.st_mode)) {
+ struct statfs mbuf[128];
+ int fs_count;
+
+ if ( (fs_count = getfsstat (NULL, 0, MNT_NOWAIT)) > 0 ) {
+ getfsstat (mbuf, fs_count * sizeof(mbuf[0]), MNT_NOWAIT);
+ for ( int i = 0; i < fs_count; ++i) {
+ if (!strcmp (mbuf[i].f_mntfromname, p_sys->psz_bd_path)) {
+ p_sys->psz_bd_path = strndup(mbuf[i].f_mntonname, strlen(mbuf[i].f_mntonname));
+ }
+ }
+ }
+ }
+ }
+#endif
+ p_sys->bluray = bd_open(p_sys->psz_bd_path, NULL);
if (!p_sys->bluray) {
free(p_sys);
return VLC_EGENERIC;
/* Is it a bluray? */
if (!disc_info->bluray_detected) {
- error_msg = "Path doesn't appear to be a bluray";
+ error_msg = "Path doesn't appear to be a Blu-ray";
goto error;
}
/* AACS */
if (disc_info->aacs_detected) {
if (!disc_info->libaacs_detected) {
- error_msg = _("This Blu-Ray Disc needs a library for AACS decoding, "
+ error_msg = _("This Blu-ray Disc needs a library for AACS decoding, "
"and your system does not have it.");
goto error;
}
if (disc_info->aacs_error_code) {
switch (disc_info->aacs_error_code) {
case BD_AACS_CORRUPTED_DISC:
- error_msg = _("BluRay Disc is corrupted.");
+ error_msg = _("Blu-ray Disc is corrupted.");
break;
case BD_AACS_NO_CONFIG:
error_msg = _("Missing AACS configuration file!");
/* BD+ */
if (disc_info->bdplus_detected) {
if (!disc_info->libbdplus_detected) {
- error_msg = _("This Blu-Ray Disc needs a library for BD+ decoding, "
+ error_msg = _("This Blu-ray Disc needs a library for BD+ decoding, "
"and your system does not have it.");
goto error;
}
}
}
+ /* set player region code */
+ char *psz_region = var_InheritString(p_demux, "bluray-region");
+ unsigned int region = psz_region ? (psz_region[0] - 'A') : REGION_DEFAULT;
+ free(psz_region);
+ bd_set_player_setting(p_sys->bluray, BLURAY_PLAYER_SETTING_REGION_CODE, 1<<region);
+
/* Get titles and chapters */
p_sys->p_meta = bd_get_meta(p_sys->bluray);
if (!p_sys->p_meta)
error:
if (error_msg)
- dialog_Fatal(p_demux, _("Blu-Ray error"), "%s", error_msg);
+ dialog_Fatal(p_demux, _("Blu-ray error"), "%s", error_msg);
blurayClose(object);
return VLC_EGENERIC;
}
vlc_input_title_Delete(p_sys->pp_title[i]);
TAB_CLEAN( p_sys->i_title, p_sys->pp_title );
+ free(p_sys->psz_bd_path);
free(p_sys);
}
if ( likely(p_pair != NULL) ) {
p_pair->i_id = p_fmt->i_id;
p_pair->p_es = p_es;
- msg_Err( p_out->p_sys->p_demux, "Adding ES %d", p_fmt->i_id );
+ msg_Info( p_out->p_sys->p_demux, "Adding ES %d", p_fmt->i_id );
vlc_array_append(&p_sys->es, p_pair);
}
}
subpicture_region_t *p_src = p_overlay->p_regions;
if (!p_src)
+ {
+ vlc_mutex_unlock(&p_overlay->lock);
return;
+ }
subpicture_region_t **p_dst = &(p_subpic->p_region);
while (p_src != NULL) {
return VLC_SUCCESS;
}
+static int sendKeyEvent(demux_sys_t *p_sys, unsigned int key)
+{
+ mtime_t now = mdate();
+ if (bd_user_input(p_sys->bluray, now, key) < 0) {
+ return VLC_EGENERIC;
+ }
+ return VLC_SUCCESS;
+}
+
/*****************************************************************************
* libbluray overlay handling:
*****************************************************************************/
.pf_destroy = subpictureUpdaterDestroy,
.p_sys = p_upd_sys,
};
+ vlc_mutex_init(&p_sys->p_overlays[ov->plane]->lock);
p_sys->p_overlays[ov->plane]->p_pic = subpicture_New(&updater);
p_sys->p_overlays[ov->plane]->p_pic->i_original_picture_width = ov->w;
p_sys->p_overlays[ov->plane]->p_pic->i_original_picture_height = ov->h;
// if (meta->di_set_number > 0) vlc_meta_SetTrackNum(p_meta, meta->di_set_number);
// if (meta->di_num_sets > 0) vlc_meta_AddExtra(p_meta, "Discs numbers in Set", meta->di_num_sets);
- if (meta->thumb_count > 0 && meta->thumbnails) {
- vlc_meta_SetArtURL(p_meta, meta->thumbnails[0].path);
+ if (meta->thumb_count > 0 && meta->thumbnails)
+ {
+ char *psz_thumbpath;
+ if( asprintf( &psz_thumbpath, "%s" DIR_SEP "BDMV" DIR_SEP "META" DIR_SEP "DL" DIR_SEP "%s",
+ p_sys->psz_bd_path, meta->thumbnails[0].path ) > 0 )
+ {
+ char *psz_thumburl = vlc_path2uri( psz_thumbpath, "file" );
+ if( unlikely(psz_thumburl == NULL) )
+ return VLC_ENOMEM;
+
+ vlc_meta_SetArtURL( p_meta, psz_thumburl );
+ free( psz_thumburl );
+ }
+ free( psz_thumbpath );
}
return VLC_SUCCESS;
}
+ case DEMUX_NAV_ACTIVATE:
+ return sendKeyEvent(p_sys, BD_VK_ENTER);
+ case DEMUX_NAV_UP:
+ return sendKeyEvent(p_sys, BD_VK_UP);
+ case DEMUX_NAV_DOWN:
+ return sendKeyEvent(p_sys, BD_VK_DOWN);
+ case DEMUX_NAV_LEFT:
+ return sendKeyEvent(p_sys, BD_VK_LEFT);
+ case DEMUX_NAV_RIGHT:
+ return sendKeyEvent(p_sys, BD_VK_RIGHT);
+
case DEMUX_CAN_RECORD:
case DEMUX_GET_FPS:
case DEMUX_SET_GROUP:
{
demux_sys_t *p_sys = p_demux->p_sys;
- block_t *p_block = block_New(p_demux, NB_TS_PACKETS * (int64_t)BD_TS_PACKET_SIZE);
+ block_t *p_block = block_Alloc(NB_TS_PACKETS * (int64_t)BD_TS_PACKET_SIZE);
if (!p_block) {
return -1;
}