/*****************************************************************************
* bd.c: BluRay Disc support (uncrypted)
*****************************************************************************
- * Copyright (C) 2009 the VideoLAN team
+ * Copyright (C) 2009 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* 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
- * GNU General Public License for more details.
+ * 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 General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
# include "config.h"
#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
#include <limits.h>
+#include <sys/stat.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_input.h>
#include <vlc_access.h>
#include <vlc_demux.h>
-#include <vlc_charset.h>
+#include <vlc_fs.h>
#include <vlc_bits.h>
#include <assert.h>
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-#define CACHING_TEXT N_("Caching value in ms")
-#define CACHING_LONGTEXT N_( \
- "Caching value for BDs. This "\
- "value should be set in milliseconds." )
-
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin ()
set_shortname( N_("BD") )
- set_description( N_("Blu-Ray Disc Input") )
+ set_description( N_("Blu-ray Disc Input") )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_ACCESS )
- add_integer( "bd-caching", DEFAULT_PTS_DELAY / 1000, NULL,
- CACHING_TEXT, CACHING_LONGTEXT, true );
set_capability( "access_demux", 60 )
- add_shortcut( "bd" )
+ add_shortcut( "bd", "file" )
set_callbacks( Open, Close )
vlc_module_end ()
struct demux_sys_t
{
char *psz_base;
+ bool b_shortname;
/* */
int i_mpls;
static int Control( demux_t *, int, va_list );
static int Demux( demux_t * );
-static char *FindPathBase( const char * );
+static char *FindPathBase( const char *, bool *pb_shortname );
static int LoadPlaylist( demux_t * );
static int LoadClip( demux_t * );
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
- if( *p_demux->psz_access && strcmp( p_demux->psz_access, "bd" ) )
+ if( p_demux->psz_file == NULL )
+ return VLC_EGENERIC;
+ if( *p_demux->psz_access &&
+ strcmp( p_demux->psz_access, "bd" ) &&
+ strcmp( p_demux->psz_access, "file" ) )
return VLC_EGENERIC;
/* */
- char *psz_base = FindPathBase( p_demux->psz_path );
+ bool b_shortname;
+ char *psz_base = FindPathBase( p_demux->psz_file, &b_shortname );
if( !psz_base )
return VLC_EGENERIC;
/* Fill p_demux field */
p_demux->p_sys = p_sys = malloc( sizeof(*p_sys) );
if( !p_sys )
+ {
+ free( psz_base );
return VLC_EGENERIC;
+ }
p_sys->psz_base = psz_base;
+ p_sys->b_shortname = b_shortname;
TAB_INIT( p_sys->i_mpls, p_sys->pp_mpls );
TAB_INIT( p_sys->i_clpi, p_sys->pp_clpi );
TAB_INIT( p_sys->i_title, p_sys->pp_title );
/* Duplicate title infos */
*pi_int = p_sys->i_title;
- *ppp_title = calloc( p_sys->i_title, sizeof(input_title_t **) );
+ *ppp_title = calloc( p_sys->i_title, sizeof(input_title_t *) );
for( int i = 0; i < p_sys->i_title; i++ )
(*ppp_title)[i] = vlc_input_title_Duplicate( p_sys->pp_title[i] );
case DEMUX_GET_PTS_DELAY:
{
int64_t *pi_delay = (int64_t*)va_arg( args, int64_t * );
- *pi_delay = var_GetInteger( p_demux, "bd-caching" ) * INT64_C(1000);
+
+ *pi_delay =
+ INT64_C(1000) * var_InheritInteger( p_demux, "disc-caching" );
return VLC_SUCCESS;
}
/* XXX
* we ensure that the TS packet start at the begining of the buffer,
* it ensure proper TS parsing */
- block_t *p_block = block_New( p_demux, i_packets * BD_TS_PACKET_SIZE + BD_TS_PACKET_HEADER );
+ block_t *p_block = block_Alloc( i_packets * BD_TS_PACKET_SIZE + BD_TS_PACKET_HEADER );
if( !p_block )
return -1;
if( p_sys->pp_clpi[i_clpi]->i_id == p_mpls_clpi->i_id )
p_clpi = p_sys->pp_clpi[i_clpi];
}
+ assert(p_clpi);
const bool b_same_clpi = b_same_mpls && p_sys->p_clpi->i_id == p_clpi->i_id;
stream_t *p_m2ts = NULL;
if( !b_same_clpi )
{
char *psz_m2ts;
- if( asprintf( &psz_m2ts, "%s/STREAM/%05d.m2ts", p_sys->psz_base, p_mpls_clpi->i_id ) < 0 )
+ if( asprintf( &psz_m2ts, "%s/STREAM/%05d.%s",
+ p_sys->psz_base, p_mpls_clpi->i_id, p_sys->b_shortname ? "MTS" : "m2ts" ) < 0 )
return VLC_EGENERIC;
p_m2ts = stream_UrlNew( p_demux, psz_m2ts );
/*****************************************************************************
* Helpers:
*****************************************************************************/
+static int CheckFileList( const char *psz_base, const char *ppsz_name[] )
+{
+ for( int i = 0; ppsz_name[i] != NULL ; i++ )
+ {
+ struct stat s;
+ char *psz_tmp;
+
+ if( asprintf( &psz_tmp, "%s/%s", psz_base, ppsz_name[i] ) < 0 )
+ return VLC_EGENERIC;
+
+ bool b_ok = vlc_stat( psz_tmp, &s ) == 0 && S_ISREG( s.st_mode );
+
+ free( psz_tmp );
+ if( !b_ok )
+ return VLC_EGENERIC;
+ }
+ return VLC_SUCCESS;
+}
/* */
-static char *FindPathBase( const char *psz_path )
+static char *FindPathBase( const char *psz_path, bool *pb_shortname )
{
struct stat s;
char *psz_tmp;
psz_base[strlen(psz_base)-1] = '\0';
/* */
- if( utf8_stat( psz_base, &s ) || !S_ISDIR( s.st_mode ) )
+ if( vlc_stat( psz_base, &s ) || !S_ISDIR( s.st_mode ) )
goto error;
/* Check BDMV */
if( asprintf( &psz_tmp, "%s/BDMV", psz_base ) < 0 )
goto error;
- if( !utf8_stat( psz_tmp, &s ) && S_ISDIR( s.st_mode ) )
+ if( !vlc_stat( psz_tmp, &s ) && S_ISDIR( s.st_mode ) )
{
free( psz_base );
psz_base = psz_tmp;
}
/* Check presence of mandatory files */
- for( int i = 0;; i++ )
+ static const char *ppsz_name_long[] = {
+ "index.bdmv",
+ "MovieObject.bdmv",
+ NULL
+ };
+ static const char *ppsz_name_short[] = {
+ "INDEX.BDM",
+ "MOVIEOBJ.BDM",
+ NULL
+ };
+ *pb_shortname = false;
+ if( CheckFileList( psz_base, ppsz_name_long ) )
{
- static const char *ppsz_name[] = {
- "index.bdmv",
- "MovieObject.bdmv",
- NULL
- };
- if( !ppsz_name[i] )
- break;
-
- if( asprintf( &psz_tmp, "%s/%s", psz_base, ppsz_name[i] ) < 0 )
- goto error;
-
- bool b_ok = utf8_stat( psz_tmp, &s ) == 0 && S_ISREG( s.st_mode );
-
- free( psz_tmp );
- if( !b_ok )
+ if( CheckFileList( psz_base, ppsz_name_short ) )
goto error;
+ *pb_shortname = true;
}
-
return psz_base;
error:
}
/* */
-static int FilterMpls( const char *psz_name )
+static int FilterMplsLong( const char *psz_name )
{
return strlen( psz_name ) == strlen( "xxxxx.mpls" ) &&
!strcmp( &psz_name[5], ".mpls" );
}
+static int FilterMplsShort( const char *psz_name )
+{
+ return strlen( psz_name ) == strlen( "xxxxx.MPL" ) &&
+ !strcmp( &psz_name[5], ".MPL" );
+}
static void LoadMpls( demux_t *p_demux, const char *psz_name, int i_id )
{
}
/* */
-static int FilterClpi( const char *psz_name )
+static int FilterClpiLong( const char *psz_name )
{
return strlen( psz_name ) == strlen( "xxxxx.clpi" ) &&
!strcmp( &psz_name[5], ".clpi" );
}
+static int FilterClpiShort( const char *psz_name )
+{
+ return strlen( psz_name ) == strlen( "xxxxx.CPI" ) &&
+ !strcmp( &psz_name[5], ".CPI" );
+}
static void LoadClpi( demux_t *p_demux, const char *psz_name, int i_id )
{
char **ppsz_list;
- int i_list = utf8_scandir( psz_playlist, &ppsz_list, pf_filter, ScanSort );
+ int i_list = vlc_scandir( psz_playlist, &ppsz_list, pf_filter, ScanSort );
for( int i = 0; i < i_list; i++ )
{
static int LoadPlaylist( demux_t *p_demux )
{
- return Load( p_demux, "PLAYLIST", FilterMpls, LoadMpls );
+ return Load( p_demux, "PLAYLIST",
+ p_demux->p_sys->b_shortname ? FilterMplsShort : FilterMplsLong, LoadMpls );
}
static int LoadClip( demux_t *p_demux )
{
- return Load( p_demux, "CLIPINF", FilterClpi, LoadClpi );
+ return Load( p_demux, "CLIPINF",
+ p_demux->p_sys->b_shortname ? FilterClpiShort : FilterClpiLong, LoadClpi );
}
/* */
es_format_t fmt;
es_format_Copy( &fmt, p_fmt );
- fmt.i_priority = -2;
+ fmt.i_priority = ES_PRIORITY_NOT_SELECTABLE;
for( int i = 0; i < p_item->i_stream; i++ )
{
/* TODO improved priority for higher quality stream ?
* if so, extending stream attributes parsing might be a good idea
*/
- fmt.i_priority = 0;
+ fmt.i_priority = ES_PRIORITY_SELECTABLE_MIN;
#if 0
/* Useless, and beside not sure it is the right thing to do */
}
break;
}
- if( fmt.i_priority < 0 )
- msg_Dbg( p_demux, "Hidding one stream (pid=%d)", fmt.i_id );
+ if( fmt.i_priority < ES_PRIORITY_SELECTABLE_MIN )
+ msg_Dbg( p_demux, "Hiding one stream (pid=%d)", fmt.i_id );
/* */
es_out_id_t *p_es = es_out_Add( p_demux->out, &fmt );
p_out->pf_del = EsOutDel;
p_out->pf_control = EsOutControl;
p_out->pf_destroy = EsOutDestroy;
- p_out->b_sout = false;
p_out->p_sys = p_sys = malloc( sizeof(*p_sys) );
if( !p_sys )