]> git.sesse.net Git - vlc/blobdiff - modules/access/bd/bd.c
BluRay instead of Blu-Ray. Re-using short messages for long ones
[vlc] / modules / access / bd / bd.c
index b1fdb53b91af4908e6ec5720dd4f67a754ac0aab..fd98f2f3f643c07405f215824bcc096e089e95df 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * 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>
 /*****************************************************************************
  * 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_("BluRay 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( "file" )
+    add_shortcut( "bd", "file" )
     set_callbacks( Open, Close )
 vlc_module_end ()
 
@@ -153,6 +143,8 @@ static int Open( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
+    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" ) )
@@ -160,7 +152,7 @@ static int Open( vlc_object_t *p_this )
 
     /* */
     bool b_shortname;
-    char *psz_base = FindPathBase( p_demux->psz_path, &b_shortname );
+    char *psz_base = FindPathBase( p_demux->psz_file, &b_shortname );
     if( !psz_base )
         return VLC_EGENERIC;
 
@@ -353,7 +345,9 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     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;
     }
 
@@ -415,7 +409,7 @@ static int Demux( demux_t *p_demux )
     /* 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;
 
@@ -944,7 +938,7 @@ static int CheckFileList( const char *psz_base, const char *ppsz_name[] )
         if( asprintf( &psz_tmp, "%s/%s", psz_base, ppsz_name[i] ) < 0 )
             return VLC_EGENERIC;
 
-        bool b_ok = utf8_stat( psz_tmp, &s ) == 0 && S_ISREG( s.st_mode );
+        bool b_ok = vlc_stat( psz_tmp, &s ) == 0 && S_ISREG( s.st_mode );
 
         free( psz_tmp );
         if( !b_ok )
@@ -968,13 +962,13 @@ static char *FindPathBase( const char *psz_path, bool *pb_shortname )
         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;
@@ -1212,7 +1206,7 @@ static int Load( demux_t *p_demux,
 
     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++ )
     {
@@ -1304,7 +1298,7 @@ static es_out_id_t *EsOutAdd( es_out_t *p_out, const es_format_t *p_fmt )
         break;
     }
     if( fmt.i_priority < 0 )
-        msg_Dbg( p_demux, "Hidding one stream (pid=%d)", fmt.i_id );
+        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 );