#define HELP_TEXT N_("Support for VDR recordings (http://www.tvdr.de/).")
-#define CACHING_TEXT N_("Caching value in ms")
-#define CACHING_LONGTEXT N_( \
- "Caching value for files. This value should be set in milliseconds." )
-
#define CHAPTER_OFFSET_TEXT N_("Chapter offset in ms")
#define CHAPTER_OFFSET_LONGTEXT N_( \
"Move all chapters. This value should be set in milliseconds." )
set_help( HELP_TEXT )
set_subcategory( SUBCAT_INPUT_ACCESS )
set_description( N_("VDR recordings") )
- add_integer( "vdr-caching", 5 * DEFAULT_PTS_DELAY / 1000,
- CACHING_TEXT, CACHING_LONGTEXT, true )
add_integer( "vdr-chapter-offset", 0,
CHAPTER_OFFSET_TEXT, CHAPTER_OFFSET_LONGTEXT, true )
- add_float_with_range( "vdr-fps", 25, 1, 1000, NULL,
+ add_float_with_range( "vdr-fps", 25, 1, 1000,
FPS_TEXT, FPS_LONGTEXT, true )
set_capability( "access", 60 )
add_shortcut( "vdr" )
* Local prototypes, constants, structures
*****************************************************************************/
+/* minimum chapter size in seconds */
+#define MIN_CHAPTER_SIZE 5
+
TYPEDEF_ARRAY( uint64_t, size_array_t );
struct access_sys_t
case ACCESS_GET_PTS_DELAY:
pi64 = va_arg( args, int64_t * );
- *pi64 = var_InheritInteger( p_access, "vdr-caching" ) * INT64_C(1000);
+ *pi64 = INT64_C(1000)
+ * var_InheritInteger( p_access, "file-caching" );
break;
case ACCESS_SET_PAUSE_STATE:
{
/* abort on read error */
msg_Err( p_access, "failed to read (%m)" );
- dialog_Fatal( p_access, _("File reading failed"), "%s",
+ dialog_Fatal( p_access, _("File reading failed"), "%s (%m)",
_("VLC could not read the file.") );
SwitchFile( p_access, -1 );
return 0;
error:
dialog_Fatal (p_access, _("File reading failed"), _("VLC could not"
- " open the file \"%s\"."), psz_path);
+ " open the file \"%s\". (%m)"), psz_path);
if( p_sys->fd != -1 )
{
close( p_sys->fd );
return;
}
+ /* get the length of this recording (index stores 8 bytes per frame) */
+ struct stat st;
+ if( fstat( fileno( indexfile ), &st ) )
+ {
+ fclose( marksfile );
+ fclose( indexfile );
+ return;
+ }
+ int64_t i_frame_count = st.st_size / 8;
+
/* Put all cut marks in a "dummy" title */
input_title_t *p_marks = vlc_input_title_New();
if( !p_marks )
int i_chapter_offset = p_sys->fps / 1000 *
var_InheritInteger( p_access, "vdr-chapter-offset" );
+ /* minimum chapter size in frames */
+ int i_min_chapter_size = p_sys->fps * MIN_CHAPTER_SIZE;
+
+ /* the last chapter started at this frame (init to 0 so
+ * we skip useless chapters near the beginning as well) */
+ int64_t i_prev_chapter = 0;
+
/* parse lines of the form "0:00:00.00 foobar" */
char *line = NULL;
size_t line_len;
{
int64_t i_frame = ParseFrameNumber( line, p_sys->fps );
+ /* skip chapters which are near the end or too close to each other */
+ if( i_frame - i_prev_chapter < i_min_chapter_size ||
+ i_frame >= i_frame_count - i_min_chapter_size )
+ continue;
+ i_prev_chapter = i_frame;
+
/* move chapters (simple workaround for inaccurate cut marks) */
if( i_frame > -i_chapter_offset )
i_frame += i_chapter_offset;
TAB_APPEND( p_marks->i_seekpoint, p_marks->seekpoint, sp );
}
- if( p_marks->i_seekpoint > 0 )
+ /* add a chapter at the beginning if missing */
+ if( p_marks->i_seekpoint > 0 && p_marks->seekpoint[0]->i_byte_offset > 0 )
{
seekpoint_t *sp = vlc_seekpoint_New();
if( sp )
sp->psz_name = strdup( _("Start") );
TAB_INSERT( p_marks->i_seekpoint, p_marks->seekpoint, sp, 0 );
}
- p_sys->p_marks = p_marks;
}
+
+ if( p_marks->i_seekpoint > 0 )
+ p_sys->p_marks = p_marks;
else
- {
vlc_input_title_Delete( p_marks );
- }
fclose( marksfile );
fclose( indexfile );