Commit 165adf97 authored by Tobias Güntner's avatar Tobias Güntner Committed by Jean-Baptiste Kempf

Ignore missing meta data files. Check directory name instead.

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit b4720edf2c54e5514074f50cb336d86b3b7b5ddc)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent f18c7b34
...@@ -31,8 +31,8 @@ VDR recordings have either of two directory layouts: ...@@ -31,8 +31,8 @@ VDR recordings have either of two directory layouts:
001.vdr, 002.vdr, 003.vdr, ... 001.vdr, 002.vdr, 003.vdr, ...
index.vdr, info.vdr, marks.vdr, ... index.vdr, info.vdr, marks.vdr, ...
2) TS format: 2) TS format:
/path/to/0000-00-00.00.00.0.0.rec/ /path/to/0000-00-00.00.00.0-0.rec/
001.ts, 002.ts, 003.ts, ... 00001.ts, 00002.ts, 00003.ts, ...
index, info, marks, ... index, info, marks, ...
See http://www.vdr-wiki.de/ and http://www.tvdr.de/ for more information. See http://www.vdr-wiki.de/ and http://www.tvdr.de/ for more information.
***/ ***/
...@@ -149,14 +149,12 @@ static int Control( access_t *, int, va_list ); ...@@ -149,14 +149,12 @@ static int Control( access_t *, int, va_list );
static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len ); static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len );
static int Seek( access_t *p_access, uint64_t i_pos); static int Seek( access_t *p_access, uint64_t i_pos);
static void FindSeekpoint( access_t *p_access ); static void FindSeekpoint( access_t *p_access );
static bool ScanDirectory( access_t *p_access, bool b_strict ); static bool ScanDirectory( access_t *p_access );
static char *GetFilePath( access_t *p_access, unsigned i_file ); static char *GetFilePath( access_t *p_access, unsigned i_file );
static bool ImportNextFile( access_t *p_access ); static bool ImportNextFile( access_t *p_access );
static bool SwitchFile( access_t *p_access, unsigned i_file ); static bool SwitchFile( access_t *p_access, unsigned i_file );
static void OptimizeForRead( int fd ); static void OptimizeForRead( int fd );
static void UpdateFileSize( access_t *p_access ); static void UpdateFileSize( access_t *p_access );
static int StatRelativeFile( access_t *p_access, const char *psz_file,
struct stat *p_stat );
static FILE *OpenRelativeFile( access_t *p_access, const char *psz_file ); static FILE *OpenRelativeFile( access_t *p_access, const char *psz_file );
static bool ReadLine( char **ppsz_line, size_t *pi_size, FILE *p_file ); static bool ReadLine( char **ppsz_line, size_t *pi_size, FILE *p_file );
static void ImportMeta( access_t *p_access ); static void ImportMeta( access_t *p_access );
...@@ -164,6 +162,7 @@ static void ImportMarks( access_t *p_access ); ...@@ -164,6 +162,7 @@ static void ImportMarks( access_t *p_access );
static bool ReadIndexRecord( FILE *p_file, bool b_ts, int64_t i_frame, static bool ReadIndexRecord( FILE *p_file, bool b_ts, int64_t i_frame,
uint64_t *pi_offset, uint16_t *pi_file_num ); uint64_t *pi_offset, uint16_t *pi_file_num );
static int64_t ParseFrameNumber( const char *psz_line, float fps ); static int64_t ParseFrameNumber( const char *psz_line, float fps );
static const char *BaseName( const char *psz_path );
/***************************************************************************** /*****************************************************************************
* Open a directory * Open a directory
...@@ -180,14 +179,17 @@ static int Open( vlc_object_t *p_this ) ...@@ -180,14 +179,17 @@ static int Open( vlc_object_t *p_this )
* and we can avoid false positives in the general case. */ * and we can avoid false positives in the general case. */
bool b_strict = strcmp( p_access->psz_access, "vdr" ); bool b_strict = strcmp( p_access->psz_access, "vdr" );
/* Do a quick test based on the directory extension to see if this /* Do a quick test based on the directory name to see if this
* directory might contain a VDR recording. We can be reasonably * directory might contain a VDR recording. We can be reasonably
* sure if ScanDirectory() actually finds files. */ * sure if ScanDirectory() actually finds files. */
if( b_strict ) if( b_strict )
{ {
const char *psz_ext = strrchr( p_access->psz_filepath, '.' ); char psz_extension[4];
if( !psz_ext || ( strcasecmp( psz_ext, ".rec" ) int i_length = 0;
&& strcasecmp( psz_ext, ".rec" DIR_SEP ) ) ) const char *psz_name = BaseName( p_access->psz_filepath );
if( sscanf( psz_name, "%*u-%*u-%*u.%*u.%*u.%*u%*[-.]%*u.%3s%n",
psz_extension, &i_length ) != 1 || strcasecmp( psz_extension, "rec" ) ||
( psz_name[i_length] != DIR_SEP_CHAR && psz_name[i_length] != '\0' ) )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -204,7 +206,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -204,7 +206,7 @@ static int Open( vlc_object_t *p_this )
ARRAY_INIT( p_sys->file_sizes ); ARRAY_INIT( p_sys->file_sizes );
/* Import all files and prepare playback. */ /* Import all files and prepare playback. */
if( !ScanDirectory( p_access, b_strict ) || if( !ScanDirectory( p_access ) ||
!SwitchFile( p_access, 0 ) ) !SwitchFile( p_access, 0 ) )
{ {
Close( p_this ); Close( p_this );
...@@ -236,7 +238,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -236,7 +238,7 @@ static void Close( vlc_object_t * p_this )
/***************************************************************************** /*****************************************************************************
* Determine format and import files * Determine format and import files
*****************************************************************************/ *****************************************************************************/
static bool ScanDirectory( access_t *p_access, bool b_strict ) static bool ScanDirectory( access_t *p_access )
{ {
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
...@@ -249,15 +251,6 @@ static bool ScanDirectory( access_t *p_access, bool b_strict ) ...@@ -249,15 +251,6 @@ static bool ScanDirectory( access_t *p_access, bool b_strict )
return false; return false;
} }
/* meta data and index should exist */
if( b_strict )
{
struct stat st;
if( StatRelativeFile( p_access, "info", &st ) ||
StatRelativeFile( p_access, "index", &st ) )
return false;
}
/* get all remaining parts */ /* get all remaining parts */
while( ImportNextFile( p_access ) ) while( ImportNextFile( p_access ) )
continue; continue;
...@@ -607,27 +600,6 @@ static void UpdateFileSize( access_t *p_access ) ...@@ -607,27 +600,6 @@ static void UpdateFileSize( access_t *p_access )
p_access->info.i_update |= INPUT_UPDATE_SIZE; p_access->info.i_update |= INPUT_UPDATE_SIZE;
} }
/*****************************************************************************
* Stat file relative to base directory
*****************************************************************************/
static int StatRelativeFile( access_t *p_access, const char *psz_file,
struct stat *p_stat )
{
/* build path and add extension */
char *psz_path;
if( asprintf( &psz_path, "%s" DIR_SEP "%s%s",
p_access->psz_filepath, psz_file,
p_access->p_sys->b_ts_format ? "" : ".vdr" ) == -1 )
return -1;
int ret = vlc_stat( psz_path, p_stat );
if( ret )
msg_Dbg( p_access, "could not stat %s: %m", psz_path );
free( psz_path );
return ret;
}
/***************************************************************************** /*****************************************************************************
* Open file relative to base directory for reading. * Open file relative to base directory for reading.
*****************************************************************************/ *****************************************************************************/
...@@ -974,3 +946,21 @@ static int64_t ParseFrameNumber( const char *psz_line, float fps ) ...@@ -974,3 +946,21 @@ static int64_t ParseFrameNumber( const char *psz_line, float fps )
int64_t i_frame = strtoll( psz_line, NULL, 10 ); int64_t i_frame = strtoll( psz_line, NULL, 10 );
return __MAX(1, i_frame) - 1; return __MAX(1, i_frame) - 1;
} }
/*****************************************************************************
* Return the last path component (including trailing separators)
*****************************************************************************/
static const char *BaseName( const char *psz_path )
{
const char *psz_name = psz_path + strlen( psz_path );
/* skip superfluous separators at the end */
while( psz_name > psz_path && psz_name[-1] == DIR_SEP_CHAR )
--psz_name;
/* skip last component */
while( psz_name > psz_path && psz_name[-1] != DIR_SEP_CHAR )
--psz_name;
return psz_name;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment